diff options
author | Tudor-Dan Ambarus <tudor.ambarus@microchip.com> | 2017-05-25 03:18:16 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2017-06-10 00:04:31 -0400 |
commit | 543de102e3316983119462c2821b76648ac3e744 (patch) | |
tree | 5a81dfedc5bfb787e90bf9b2d7ec15284aab40cf /crypto/rsa-pkcs1pad.c | |
parent | 515c4d27d69acf0473157abeb21a2ae9f9328bac (diff) |
crypto: pkcs1pad - comply with crypto_akcipher_maxsize()
crypto_akcipher_maxsize() asks for the output buffer size without
caring for errors. It allways assume that will be called after
a valid setkey. Comply with it and return what he wants.
crypto_akcipher_maxsize() now returns an unsigned int.
Remove the unnecessary check.
Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/rsa-pkcs1pad.c')
-rw-r--r-- | crypto/rsa-pkcs1pad.c | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/crypto/rsa-pkcs1pad.c b/crypto/rsa-pkcs1pad.c index 8baab4307f7b..044bcfa69cba 100644 --- a/crypto/rsa-pkcs1pad.c +++ b/crypto/rsa-pkcs1pad.c | |||
@@ -120,9 +120,6 @@ static int pkcs1pad_set_pub_key(struct crypto_akcipher *tfm, const void *key, | |||
120 | 120 | ||
121 | /* Find out new modulus size from rsa implementation */ | 121 | /* Find out new modulus size from rsa implementation */ |
122 | err = crypto_akcipher_maxsize(ctx->child); | 122 | err = crypto_akcipher_maxsize(ctx->child); |
123 | if (err < 0) | ||
124 | return err; | ||
125 | |||
126 | if (err > PAGE_SIZE) | 123 | if (err > PAGE_SIZE) |
127 | return -ENOTSUPP; | 124 | return -ENOTSUPP; |
128 | 125 | ||
@@ -144,9 +141,6 @@ static int pkcs1pad_set_priv_key(struct crypto_akcipher *tfm, const void *key, | |||
144 | 141 | ||
145 | /* Find out new modulus size from rsa implementation */ | 142 | /* Find out new modulus size from rsa implementation */ |
146 | err = crypto_akcipher_maxsize(ctx->child); | 143 | err = crypto_akcipher_maxsize(ctx->child); |
147 | if (err < 0) | ||
148 | return err; | ||
149 | |||
150 | if (err > PAGE_SIZE) | 144 | if (err > PAGE_SIZE) |
151 | return -ENOTSUPP; | 145 | return -ENOTSUPP; |
152 | 146 | ||
@@ -154,7 +148,7 @@ static int pkcs1pad_set_priv_key(struct crypto_akcipher *tfm, const void *key, | |||
154 | return 0; | 148 | return 0; |
155 | } | 149 | } |
156 | 150 | ||
157 | static int pkcs1pad_get_max_size(struct crypto_akcipher *tfm) | 151 | static unsigned int pkcs1pad_get_max_size(struct crypto_akcipher *tfm) |
158 | { | 152 | { |
159 | struct pkcs1pad_ctx *ctx = akcipher_tfm_ctx(tfm); | 153 | struct pkcs1pad_ctx *ctx = akcipher_tfm_ctx(tfm); |
160 | 154 | ||
@@ -164,7 +158,7 @@ static int pkcs1pad_get_max_size(struct crypto_akcipher *tfm) | |||
164 | * decrypt/verify. | 158 | * decrypt/verify. |
165 | */ | 159 | */ |
166 | 160 | ||
167 | return ctx->key_size ?: -EINVAL; | 161 | return ctx->key_size; |
168 | } | 162 | } |
169 | 163 | ||
170 | static void pkcs1pad_sg_set_buf(struct scatterlist *sg, void *buf, size_t len, | 164 | static void pkcs1pad_sg_set_buf(struct scatterlist *sg, void *buf, size_t len, |