hc
2024-01-31 f9004dbfff8a3fbbd7e2a88c8a4327c7f2f8e5b2
kernel/drivers/crypto/geode-aes.c
....@@ -1,9 +1,5 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /* Copyright (C) 2004-2006, Advanced Micro Devices, Inc.
2
- *
3
- * This program is free software; you can redistribute it and/or modify
4
- * it under the terms of the GNU General Public License as published by
5
- * the Free Software Foundation; either version 2 of the License, or
6
- * (at your option) any later version.
73 */
84
95 #include <linux/module.h>
....@@ -14,6 +10,7 @@
1410 #include <linux/spinlock.h>
1511 #include <crypto/algapi.h>
1612 #include <crypto/aes.h>
13
+#include <crypto/internal/cipher.h>
1714 #include <crypto/internal/skcipher.h>
1815
1916 #include <linux/io.h>
....@@ -114,7 +111,6 @@
114111 unsigned int len)
115112 {
116113 struct geode_aes_tfm_ctx *tctx = crypto_tfm_ctx(tfm);
117
- unsigned int ret;
118114
119115 tctx->keylen = len;
120116
....@@ -123,11 +119,9 @@
123119 return 0;
124120 }
125121
126
- if (len != AES_KEYSIZE_192 && len != AES_KEYSIZE_256) {
122
+ if (len != AES_KEYSIZE_192 && len != AES_KEYSIZE_256)
127123 /* not supported at all */
128
- tfm->crt_flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
129124 return -EINVAL;
130
- }
131125
132126 /*
133127 * The requested key size is not supported by HW, do a fallback
....@@ -136,20 +130,13 @@
136130 tctx->fallback.cip->base.crt_flags |=
137131 (tfm->crt_flags & CRYPTO_TFM_REQ_MASK);
138132
139
- ret = crypto_cipher_setkey(tctx->fallback.cip, key, len);
140
- if (ret) {
141
- tfm->crt_flags &= ~CRYPTO_TFM_RES_MASK;
142
- tfm->crt_flags |= (tctx->fallback.cip->base.crt_flags &
143
- CRYPTO_TFM_RES_MASK);
144
- }
145
- return ret;
133
+ return crypto_cipher_setkey(tctx->fallback.cip, key, len);
146134 }
147135
148136 static int geode_setkey_skcipher(struct crypto_skcipher *tfm, const u8 *key,
149137 unsigned int len)
150138 {
151139 struct geode_aes_tfm_ctx *tctx = crypto_skcipher_ctx(tfm);
152
- unsigned int ret;
153140
154141 tctx->keylen = len;
155142
....@@ -158,11 +145,9 @@
158145 return 0;
159146 }
160147
161
- if (len != AES_KEYSIZE_192 && len != AES_KEYSIZE_256) {
148
+ if (len != AES_KEYSIZE_192 && len != AES_KEYSIZE_256)
162149 /* not supported at all */
163
- crypto_skcipher_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN);
164150 return -EINVAL;
165
- }
166151
167152 /*
168153 * The requested key size is not supported by HW, do a fallback
....@@ -172,11 +157,7 @@
172157 crypto_skcipher_set_flags(tctx->fallback.skcipher,
173158 crypto_skcipher_get_flags(tfm) &
174159 CRYPTO_TFM_REQ_MASK);
175
- ret = crypto_skcipher_setkey(tctx->fallback.skcipher, key, len);
176
- crypto_skcipher_set_flags(tfm,
177
- crypto_skcipher_get_flags(tctx->fallback.skcipher) &
178
- CRYPTO_TFM_RES_MASK);
179
- return ret;
160
+ return crypto_skcipher_setkey(tctx->fallback.skcipher, key, len);
180161 }
181162
182163 static void
....@@ -454,3 +435,4 @@
454435 MODULE_AUTHOR("Advanced Micro Devices, Inc.");
455436 MODULE_DESCRIPTION("Geode LX Hardware AES driver");
456437 MODULE_LICENSE("GPL");
438
+MODULE_IMPORT_NS(CRYPTO_INTERNAL);