diff options
author | Doug Ledford <dledford@redhat.com> | 2015-09-25 10:46:07 -0400 |
---|---|---|
committer | Doug Ledford <dledford@redhat.com> | 2015-09-25 10:46:07 -0400 |
commit | a99c59c0accea388f83ea651e90c814aeac04785 (patch) | |
tree | 1d102927807aa7c12a8a66cbb59d6560c6520645 /crypto/rsa.c | |
parent | c16e43ca0904ac1f8c20a2c007801d4d69bdb6f7 (diff) | |
parent | 733601f243cfd24755f2c120fb9f9ec284fa5ca1 (diff) | |
download | linux-crypto-a99c59c0accea388f83ea651e90c814aeac04785.tar.gz linux-crypto-a99c59c0accea388f83ea651e90c814aeac04785.zip |
Merge tag 'v4.3-rc2' into k.o/for-4.3-v1
Linux 4.3-rc2
Diffstat (limited to 'crypto/rsa.c')
-rw-r--r-- | crypto/rsa.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/crypto/rsa.c b/crypto/rsa.c index 752af065..466003e1 100644 --- a/crypto/rsa.c +++ b/crypto/rsa.c @@ -267,12 +267,36 @@ err_free_m: return ret; } +static int rsa_check_key_length(unsigned int len) +{ + switch (len) { + case 512: + case 1024: + case 1536: + case 2048: + case 3072: + case 4096: + return 0; + } + + return -EINVAL; +} + static int rsa_setkey(struct crypto_akcipher *tfm, const void *key, unsigned int keylen) { struct rsa_key *pkey = akcipher_tfm_ctx(tfm); + int ret; - return rsa_parse_key(pkey, key, keylen); + ret = rsa_parse_key(pkey, key, keylen); + if (ret) + return ret; + + if (rsa_check_key_length(mpi_get_size(pkey->n) << 3)) { + rsa_free_key(pkey); + ret = -EINVAL; + } + return ret; } static void rsa_exit_tfm(struct crypto_akcipher *tfm) |