diff options
Diffstat (limited to 'crypto')
| -rw-r--r-- | crypto/asymmetric_keys/public_key.c | 2 | ||||
| -rw-r--r-- | crypto/asymmetric_keys/verify_pefile.c | 4 | ||||
| -rw-r--r-- | crypto/asymmetric_keys/x509_cert_parser.c | 1 | ||||
| -rw-r--r-- | crypto/drbg.c | 5 | ||||
| -rw-r--r-- | crypto/gcm.c | 6 | ||||
| -rw-r--r-- | crypto/skcipher.c | 40 |
6 files changed, 47 insertions, 11 deletions
diff --git a/crypto/asymmetric_keys/public_key.c b/crypto/asymmetric_keys/public_key.c index d3a989e718f5..3cd6e12cfc46 100644 --- a/crypto/asymmetric_keys/public_key.c +++ b/crypto/asymmetric_keys/public_key.c | |||
| @@ -141,7 +141,7 @@ int public_key_verify_signature(const struct public_key *pkey, | |||
| 141 | * signature and returns that to us. | 141 | * signature and returns that to us. |
| 142 | */ | 142 | */ |
| 143 | ret = crypto_akcipher_verify(req); | 143 | ret = crypto_akcipher_verify(req); |
| 144 | if (ret == -EINPROGRESS) { | 144 | if ((ret == -EINPROGRESS) || (ret == -EBUSY)) { |
| 145 | wait_for_completion(&compl.completion); | 145 | wait_for_completion(&compl.completion); |
| 146 | ret = compl.err; | 146 | ret = compl.err; |
| 147 | } | 147 | } |
diff --git a/crypto/asymmetric_keys/verify_pefile.c b/crypto/asymmetric_keys/verify_pefile.c index 672a94c2c3ff..d178650fd524 100644 --- a/crypto/asymmetric_keys/verify_pefile.c +++ b/crypto/asymmetric_keys/verify_pefile.c | |||
| @@ -381,7 +381,7 @@ static int pefile_digest_pe(const void *pebuf, unsigned int pelen, | |||
| 381 | } | 381 | } |
| 382 | 382 | ||
| 383 | error: | 383 | error: |
| 384 | kfree(desc); | 384 | kzfree(desc); |
| 385 | error_no_desc: | 385 | error_no_desc: |
| 386 | crypto_free_shash(tfm); | 386 | crypto_free_shash(tfm); |
| 387 | kleave(" = %d", ret); | 387 | kleave(" = %d", ret); |
| @@ -450,6 +450,6 @@ int verify_pefile_signature(const void *pebuf, unsigned pelen, | |||
| 450 | ret = pefile_digest_pe(pebuf, pelen, &ctx); | 450 | ret = pefile_digest_pe(pebuf, pelen, &ctx); |
| 451 | 451 | ||
| 452 | error: | 452 | error: |
| 453 | kfree(ctx.digest); | 453 | kzfree(ctx.digest); |
| 454 | return ret; | 454 | return ret; |
| 455 | } | 455 | } |
diff --git a/crypto/asymmetric_keys/x509_cert_parser.c b/crypto/asymmetric_keys/x509_cert_parser.c index c80765b211cf..dd03fead1ca3 100644 --- a/crypto/asymmetric_keys/x509_cert_parser.c +++ b/crypto/asymmetric_keys/x509_cert_parser.c | |||
| @@ -102,6 +102,7 @@ struct x509_certificate *x509_cert_parse(const void *data, size_t datalen) | |||
| 102 | } | 102 | } |
| 103 | } | 103 | } |
| 104 | 104 | ||
| 105 | ret = -ENOMEM; | ||
| 105 | cert->pub->key = kmemdup(ctx->key, ctx->key_size, GFP_KERNEL); | 106 | cert->pub->key = kmemdup(ctx->key, ctx->key_size, GFP_KERNEL); |
| 106 | if (!cert->pub->key) | 107 | if (!cert->pub->key) |
| 107 | goto error_decode; | 108 | goto error_decode; |
diff --git a/crypto/drbg.c b/crypto/drbg.c index fa749f470135..cdb27ac4b226 100644 --- a/crypto/drbg.c +++ b/crypto/drbg.c | |||
| @@ -1767,9 +1767,8 @@ static int drbg_kcapi_sym_ctr(struct drbg_state *drbg, | |||
| 1767 | break; | 1767 | break; |
| 1768 | case -EINPROGRESS: | 1768 | case -EINPROGRESS: |
| 1769 | case -EBUSY: | 1769 | case -EBUSY: |
| 1770 | ret = wait_for_completion_interruptible( | 1770 | wait_for_completion(&drbg->ctr_completion); |
| 1771 | &drbg->ctr_completion); | 1771 | if (!drbg->ctr_async_err) { |
| 1772 | if (!ret && !drbg->ctr_async_err) { | ||
| 1773 | reinit_completion(&drbg->ctr_completion); | 1772 | reinit_completion(&drbg->ctr_completion); |
| 1774 | break; | 1773 | break; |
| 1775 | } | 1774 | } |
diff --git a/crypto/gcm.c b/crypto/gcm.c index b7ad808be3d4..3841b5eafa7e 100644 --- a/crypto/gcm.c +++ b/crypto/gcm.c | |||
| @@ -152,10 +152,8 @@ static int crypto_gcm_setkey(struct crypto_aead *aead, const u8 *key, | |||
| 152 | 152 | ||
| 153 | err = crypto_skcipher_encrypt(&data->req); | 153 | err = crypto_skcipher_encrypt(&data->req); |
| 154 | if (err == -EINPROGRESS || err == -EBUSY) { | 154 | if (err == -EINPROGRESS || err == -EBUSY) { |
| 155 | err = wait_for_completion_interruptible( | 155 | wait_for_completion(&data->result.completion); |
| 156 | &data->result.completion); | 156 | err = data->result.err; |
| 157 | if (!err) | ||
| 158 | err = data->result.err; | ||
| 159 | } | 157 | } |
| 160 | 158 | ||
| 161 | if (err) | 159 | if (err) |
diff --git a/crypto/skcipher.c b/crypto/skcipher.c index 014af741fc6a..4faa0fd53b0c 100644 --- a/crypto/skcipher.c +++ b/crypto/skcipher.c | |||
| @@ -764,6 +764,44 @@ static int crypto_init_skcipher_ops_ablkcipher(struct crypto_tfm *tfm) | |||
| 764 | return 0; | 764 | return 0; |
| 765 | } | 765 | } |
| 766 | 766 | ||
| 767 | static int skcipher_setkey_unaligned(struct crypto_skcipher *tfm, | ||
| 768 | const u8 *key, unsigned int keylen) | ||
| 769 | { | ||
| 770 | unsigned long alignmask = crypto_skcipher_alignmask(tfm); | ||
| 771 | struct skcipher_alg *cipher = crypto_skcipher_alg(tfm); | ||
| 772 | u8 *buffer, *alignbuffer; | ||
| 773 | unsigned long absize; | ||
| 774 | int ret; | ||
| 775 | |||
| 776 | absize = keylen + alignmask; | ||
| 777 | buffer = kmalloc(absize, GFP_ATOMIC); | ||
| 778 | if (!buffer) | ||
| 779 | return -ENOMEM; | ||
| 780 | |||
| 781 | alignbuffer = (u8 *)ALIGN((unsigned long)buffer, alignmask + 1); | ||
| 782 | memcpy(alignbuffer, key, keylen); | ||
| 783 | ret = cipher->setkey(tfm, alignbuffer, keylen); | ||
| 784 | kzfree(buffer); | ||
| 785 | return ret; | ||
| 786 | } | ||
| 787 | |||
| 788 | static int skcipher_setkey(struct crypto_skcipher *tfm, const u8 *key, | ||
| 789 | unsigned int keylen) | ||
| 790 | { | ||
| 791 | struct skcipher_alg *cipher = crypto_skcipher_alg(tfm); | ||
| 792 | unsigned long alignmask = crypto_skcipher_alignmask(tfm); | ||
| 793 | |||
| 794 | if (keylen < cipher->min_keysize || keylen > cipher->max_keysize) { | ||
| 795 | crypto_skcipher_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN); | ||
| 796 | return -EINVAL; | ||
| 797 | } | ||
| 798 | |||
| 799 | if ((unsigned long)key & alignmask) | ||
| 800 | return skcipher_setkey_unaligned(tfm, key, keylen); | ||
| 801 | |||
| 802 | return cipher->setkey(tfm, key, keylen); | ||
| 803 | } | ||
| 804 | |||
| 767 | static void crypto_skcipher_exit_tfm(struct crypto_tfm *tfm) | 805 | static void crypto_skcipher_exit_tfm(struct crypto_tfm *tfm) |
| 768 | { | 806 | { |
| 769 | struct crypto_skcipher *skcipher = __crypto_skcipher_cast(tfm); | 807 | struct crypto_skcipher *skcipher = __crypto_skcipher_cast(tfm); |
| @@ -784,7 +822,7 @@ static int crypto_skcipher_init_tfm(struct crypto_tfm *tfm) | |||
| 784 | tfm->__crt_alg->cra_type == &crypto_givcipher_type) | 822 | tfm->__crt_alg->cra_type == &crypto_givcipher_type) |
| 785 | return crypto_init_skcipher_ops_ablkcipher(tfm); | 823 | return crypto_init_skcipher_ops_ablkcipher(tfm); |
| 786 | 824 | ||
| 787 | skcipher->setkey = alg->setkey; | 825 | skcipher->setkey = skcipher_setkey; |
| 788 | skcipher->encrypt = alg->encrypt; | 826 | skcipher->encrypt = alg->encrypt; |
| 789 | skcipher->decrypt = alg->decrypt; | 827 | skcipher->decrypt = alg->decrypt; |
| 790 | skcipher->ivsize = alg->ivsize; | 828 | skcipher->ivsize = alg->ivsize; |
