.. | .. |
---|
143 | 143 | EXPORT_SYMBOL_GPL(crypto_sm4_expand_key); |
---|
144 | 144 | |
---|
145 | 145 | /** |
---|
146 | | - * crypto_sm4_set_key - Set the AES key. |
---|
| 146 | + * crypto_sm4_set_key - Set the SM4 key. |
---|
147 | 147 | * @tfm: The %crypto_tfm that is used in the context. |
---|
148 | 148 | * @in_key: The input key. |
---|
149 | 149 | * @key_len: The size of the key. |
---|
150 | 150 | * |
---|
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. |
---|
153 | 152 | * &crypto_sm4_ctx _must_ be the private data embedded in @tfm which is |
---|
154 | 153 | * retrieved with crypto_tfm_ctx(). |
---|
| 154 | + * |
---|
| 155 | + * Return: 0 on success; -EINVAL on failure (only happens for bad key lengths) |
---|
155 | 156 | */ |
---|
156 | 157 | int crypto_sm4_set_key(struct crypto_tfm *tfm, const u8 *in_key, |
---|
157 | 158 | unsigned int key_len) |
---|
158 | 159 | { |
---|
159 | 160 | struct crypto_sm4_ctx *ctx = crypto_tfm_ctx(tfm); |
---|
160 | | - u32 *flags = &tfm->crt_flags; |
---|
161 | | - int ret; |
---|
162 | 161 | |
---|
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); |
---|
169 | 163 | } |
---|
170 | 164 | EXPORT_SYMBOL_GPL(crypto_sm4_set_key); |
---|
171 | 165 | |
---|
.. | .. |
---|
237 | 231 | crypto_unregister_alg(&sm4_alg); |
---|
238 | 232 | } |
---|
239 | 233 | |
---|
240 | | -module_init(sm4_init); |
---|
| 234 | +subsys_initcall(sm4_init); |
---|
241 | 235 | module_exit(sm4_fini); |
---|
242 | 236 | |
---|
243 | 237 | MODULE_DESCRIPTION("SM4 Cipher Algorithm"); |
---|