.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * AMD Cryptographic Coprocessor (CCP) RSA crypto API support |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (C) 2017 Advanced Micro Devices, Inc. |
---|
5 | 6 | * |
---|
6 | 7 | * Author: Gary R Hook <gary.hook@amd.com> |
---|
7 | | - * |
---|
8 | | - * This program is free software; you can redistribute it and/or modify |
---|
9 | | - * it under the terms of the GNU General Public License version 2 as |
---|
10 | | - * published by the Free Software Foundation. |
---|
11 | 8 | */ |
---|
12 | 9 | |
---|
13 | 10 | #include <linux/module.h> |
---|
.. | .. |
---|
37 | 34 | if (buf[nskip]) |
---|
38 | 35 | break; |
---|
39 | 36 | *kplen = sz - nskip; |
---|
40 | | - *kpbuf = kzalloc(*kplen, GFP_KERNEL); |
---|
| 37 | + *kpbuf = kmemdup(buf + nskip, *kplen, GFP_KERNEL); |
---|
41 | 38 | if (!*kpbuf) |
---|
42 | 39 | return -ENOMEM; |
---|
43 | | - memcpy(*kpbuf, buf + nskip, *kplen); |
---|
44 | 40 | |
---|
45 | 41 | return 0; |
---|
46 | 42 | } |
---|
.. | .. |
---|
116 | 112 | static void ccp_rsa_free_key_bufs(struct ccp_ctx *ctx) |
---|
117 | 113 | { |
---|
118 | 114 | /* Clean up old key data */ |
---|
119 | | - kzfree(ctx->u.rsa.e_buf); |
---|
| 115 | + kfree_sensitive(ctx->u.rsa.e_buf); |
---|
120 | 116 | ctx->u.rsa.e_buf = NULL; |
---|
121 | 117 | ctx->u.rsa.e_len = 0; |
---|
122 | | - kzfree(ctx->u.rsa.n_buf); |
---|
| 118 | + kfree_sensitive(ctx->u.rsa.n_buf); |
---|
123 | 119 | ctx->u.rsa.n_buf = NULL; |
---|
124 | 120 | ctx->u.rsa.n_len = 0; |
---|
125 | | - kzfree(ctx->u.rsa.d_buf); |
---|
| 121 | + kfree_sensitive(ctx->u.rsa.d_buf); |
---|
126 | 122 | ctx->u.rsa.d_buf = NULL; |
---|
127 | 123 | ctx->u.rsa.d_len = 0; |
---|
128 | 124 | } |
---|
.. | .. |
---|
214 | 210 | static struct akcipher_alg ccp_rsa_defaults = { |
---|
215 | 211 | .encrypt = ccp_rsa_encrypt, |
---|
216 | 212 | .decrypt = ccp_rsa_decrypt, |
---|
217 | | - .sign = ccp_rsa_decrypt, |
---|
218 | | - .verify = ccp_rsa_encrypt, |
---|
219 | 213 | .set_pub_key = ccp_rsa_setpubkey, |
---|
220 | 214 | .set_priv_key = ccp_rsa_setprivkey, |
---|
221 | 215 | .max_size = ccp_rsa_maxsize, |
---|
.. | .. |
---|
248 | 242 | } |
---|
249 | 243 | }; |
---|
250 | 244 | |
---|
251 | | -int ccp_register_rsa_alg(struct list_head *head, const struct ccp_rsa_def *def) |
---|
| 245 | +static int ccp_register_rsa_alg(struct list_head *head, |
---|
| 246 | + const struct ccp_rsa_def *def) |
---|
252 | 247 | { |
---|
253 | 248 | struct ccp_crypto_akcipher_alg *ccp_alg; |
---|
254 | 249 | struct akcipher_alg *alg; |
---|