hc
2024-01-04 1543e317f1da31b75942316931e8f491a8920811
kernel/drivers/crypto/ccp/ccp-crypto-rsa.c
....@@ -1,13 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * AMD Cryptographic Coprocessor (CCP) RSA crypto API support
34 *
45 * Copyright (C) 2017 Advanced Micro Devices, Inc.
56 *
67 * 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.
118 */
129
1310 #include <linux/module.h>
....@@ -37,10 +34,9 @@
3734 if (buf[nskip])
3835 break;
3936 *kplen = sz - nskip;
40
- *kpbuf = kzalloc(*kplen, GFP_KERNEL);
37
+ *kpbuf = kmemdup(buf + nskip, *kplen, GFP_KERNEL);
4138 if (!*kpbuf)
4239 return -ENOMEM;
43
- memcpy(*kpbuf, buf + nskip, *kplen);
4440
4541 return 0;
4642 }
....@@ -116,13 +112,13 @@
116112 static void ccp_rsa_free_key_bufs(struct ccp_ctx *ctx)
117113 {
118114 /* Clean up old key data */
119
- kzfree(ctx->u.rsa.e_buf);
115
+ kfree_sensitive(ctx->u.rsa.e_buf);
120116 ctx->u.rsa.e_buf = NULL;
121117 ctx->u.rsa.e_len = 0;
122
- kzfree(ctx->u.rsa.n_buf);
118
+ kfree_sensitive(ctx->u.rsa.n_buf);
123119 ctx->u.rsa.n_buf = NULL;
124120 ctx->u.rsa.n_len = 0;
125
- kzfree(ctx->u.rsa.d_buf);
121
+ kfree_sensitive(ctx->u.rsa.d_buf);
126122 ctx->u.rsa.d_buf = NULL;
127123 ctx->u.rsa.d_len = 0;
128124 }
....@@ -214,8 +210,6 @@
214210 static struct akcipher_alg ccp_rsa_defaults = {
215211 .encrypt = ccp_rsa_encrypt,
216212 .decrypt = ccp_rsa_decrypt,
217
- .sign = ccp_rsa_decrypt,
218
- .verify = ccp_rsa_encrypt,
219213 .set_pub_key = ccp_rsa_setpubkey,
220214 .set_priv_key = ccp_rsa_setprivkey,
221215 .max_size = ccp_rsa_maxsize,
....@@ -248,7 +242,8 @@
248242 }
249243 };
250244
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)
252247 {
253248 struct ccp_crypto_akcipher_alg *ccp_alg;
254249 struct akcipher_alg *alg;