hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/crypto/sm4_generic.c
....@@ -143,29 +143,23 @@
143143 EXPORT_SYMBOL_GPL(crypto_sm4_expand_key);
144144
145145 /**
146
- * crypto_sm4_set_key - Set the AES key.
146
+ * crypto_sm4_set_key - Set the SM4 key.
147147 * @tfm: The %crypto_tfm that is used in the context.
148148 * @in_key: The input key.
149149 * @key_len: The size of the key.
150150 *
151
- * Returns 0 on success, on failure the %CRYPTO_TFM_RES_BAD_KEY_LEN flag in tfm
152
- * is set. The function uses crypto_sm4_expand_key() to expand the key.
151
+ * This function uses crypto_sm4_expand_key() to expand the key.
153152 * &crypto_sm4_ctx _must_ be the private data embedded in @tfm which is
154153 * retrieved with crypto_tfm_ctx().
154
+ *
155
+ * Return: 0 on success; -EINVAL on failure (only happens for bad key lengths)
155156 */
156157 int crypto_sm4_set_key(struct crypto_tfm *tfm, const u8 *in_key,
157158 unsigned int key_len)
158159 {
159160 struct crypto_sm4_ctx *ctx = crypto_tfm_ctx(tfm);
160
- u32 *flags = &tfm->crt_flags;
161
- int ret;
162161
163
- ret = crypto_sm4_expand_key(ctx, in_key, key_len);
164
- if (!ret)
165
- return 0;
166
-
167
- *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
168
- return -EINVAL;
162
+ return crypto_sm4_expand_key(ctx, in_key, key_len);
169163 }
170164 EXPORT_SYMBOL_GPL(crypto_sm4_set_key);
171165
....@@ -237,7 +231,7 @@
237231 crypto_unregister_alg(&sm4_alg);
238232 }
239233
240
-module_init(sm4_init);
234
+subsys_initcall(sm4_init);
241235 module_exit(sm4_fini);
242236
243237 MODULE_DESCRIPTION("SM4 Cipher Algorithm");