diff options
author | Iuliana Prodan <iuliana.prodan@nxp.com> | 2019-07-31 15:05:55 +0200 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2019-08-09 07:11:43 +0200 |
commit | bc67d04e75260942fb534fb91673103dcad7ca96 (patch) | |
tree | 7a32f21ca3a91c5eddf22fa8a06ac13f1ecad681 /lib/crypto | |
parent | crypto: gcm - helper functions for assoclen/authsize check (diff) | |
download | linux-bc67d04e75260942fb534fb91673103dcad7ca96.tar.xz linux-bc67d04e75260942fb534fb91673103dcad7ca96.zip |
crypto: aes - helper function to validate key length for AES algorithms
Add inline helper function to check key length for AES algorithms.
The key can be 128, 192 or 256 bits size.
This function is used in the generic aes implementation.
Signed-off-by: Iuliana Prodan <iuliana.prodan@nxp.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'lib/crypto')
-rw-r--r-- | lib/crypto/aes.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/crypto/aes.c b/lib/crypto/aes.c index 4e100af38c51..827fe89922ff 100644 --- a/lib/crypto/aes.c +++ b/lib/crypto/aes.c @@ -187,11 +187,11 @@ int aes_expandkey(struct crypto_aes_ctx *ctx, const u8 *in_key, { u32 kwords = key_len / sizeof(u32); u32 rc, i, j; + int err; - if (key_len != AES_KEYSIZE_128 && - key_len != AES_KEYSIZE_192 && - key_len != AES_KEYSIZE_256) - return -EINVAL; + err = aes_check_keylen(key_len); + if (err) + return err; ctx->key_length = key_len; |