diff options
author | beck <> | 2017-01-29 17:49:23 +0000 |
---|---|---|
committer | beck <> | 2017-01-29 17:49:23 +0000 |
commit | 957b11334a7afb14537322f0e4795b2e368b3f59 (patch) | |
tree | 1a54abba678898ee5270ae4f3404a50ee9a92eea /src/lib/libcrypto/rsa/rsa_oaep.c | |
parent | df96e020e729c6c37a8c7fe311fdd1fe6a8718c5 (diff) | |
download | openbsd-957b11334a7afb14537322f0e4795b2e368b3f59.tar.gz openbsd-957b11334a7afb14537322f0e4795b2e368b3f59.tar.bz2 openbsd-957b11334a7afb14537322f0e4795b2e368b3f59.zip |
Send the function codes from the error functions to the bit bucket,
as was done earlier in libssl. Thanks inoguchi@ for noticing
libssl had more reacharounds into this.
ok jsing@ inoguchi@
Diffstat (limited to 'src/lib/libcrypto/rsa/rsa_oaep.c')
-rw-r--r-- | src/lib/libcrypto/rsa/rsa_oaep.c | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/src/lib/libcrypto/rsa/rsa_oaep.c b/src/lib/libcrypto/rsa/rsa_oaep.c index 86e2bfc34f..cd7af203b7 100644 --- a/src/lib/libcrypto/rsa/rsa_oaep.c +++ b/src/lib/libcrypto/rsa/rsa_oaep.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: rsa_oaep.c,v 1.25 2015/06/20 12:01:14 jsing Exp $ */ | 1 | /* $OpenBSD: rsa_oaep.c,v 1.26 2017/01/29 17:49:23 beck Exp $ */ |
2 | /* Written by Ulf Moeller. This software is distributed on an "AS IS" | 2 | /* Written by Ulf Moeller. This software is distributed on an "AS IS" |
3 | basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. */ | 3 | basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. */ |
4 | 4 | ||
@@ -44,14 +44,12 @@ RSA_padding_add_PKCS1_OAEP(unsigned char *to, int tlen, | |||
44 | unsigned char *dbmask, seedmask[SHA_DIGEST_LENGTH]; | 44 | unsigned char *dbmask, seedmask[SHA_DIGEST_LENGTH]; |
45 | 45 | ||
46 | if (flen > emlen - 2 * SHA_DIGEST_LENGTH - 1) { | 46 | if (flen > emlen - 2 * SHA_DIGEST_LENGTH - 1) { |
47 | RSAerr(RSA_F_RSA_PADDING_ADD_PKCS1_OAEP, | 47 | RSAerror(RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE); |
48 | RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE); | ||
49 | return 0; | 48 | return 0; |
50 | } | 49 | } |
51 | 50 | ||
52 | if (emlen < 2 * SHA_DIGEST_LENGTH + 1) { | 51 | if (emlen < 2 * SHA_DIGEST_LENGTH + 1) { |
53 | RSAerr(RSA_F_RSA_PADDING_ADD_PKCS1_OAEP, | 52 | RSAerror(RSA_R_KEY_SIZE_TOO_SMALL); |
54 | RSA_R_KEY_SIZE_TOO_SMALL); | ||
55 | return 0; | 53 | return 0; |
56 | } | 54 | } |
57 | 55 | ||
@@ -69,7 +67,7 @@ RSA_padding_add_PKCS1_OAEP(unsigned char *to, int tlen, | |||
69 | 67 | ||
70 | dbmask = malloc(emlen - SHA_DIGEST_LENGTH); | 68 | dbmask = malloc(emlen - SHA_DIGEST_LENGTH); |
71 | if (dbmask == NULL) { | 69 | if (dbmask == NULL) { |
72 | RSAerr(RSA_F_RSA_PADDING_ADD_PKCS1_OAEP, ERR_R_MALLOC_FAILURE); | 70 | RSAerror(ERR_R_MALLOC_FAILURE); |
73 | return 0; | 71 | return 0; |
74 | } | 72 | } |
75 | 73 | ||
@@ -126,8 +124,7 @@ RSA_padding_check_PKCS1_OAEP(unsigned char *to, int tlen, | |||
126 | dblen = num - SHA_DIGEST_LENGTH; | 124 | dblen = num - SHA_DIGEST_LENGTH; |
127 | db = malloc(dblen + num); | 125 | db = malloc(dblen + num); |
128 | if (db == NULL) { | 126 | if (db == NULL) { |
129 | RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP, | 127 | RSAerror(ERR_R_MALLOC_FAILURE); |
130 | ERR_R_MALLOC_FAILURE); | ||
131 | return -1; | 128 | return -1; |
132 | } | 129 | } |
133 | 130 | ||
@@ -167,8 +164,7 @@ RSA_padding_check_PKCS1_OAEP(unsigned char *to, int tlen, | |||
167 | 164 | ||
168 | mlen = dblen - ++i; | 165 | mlen = dblen - ++i; |
169 | if (tlen < mlen) { | 166 | if (tlen < mlen) { |
170 | RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP, | 167 | RSAerror(RSA_R_DATA_TOO_LARGE); |
171 | RSA_R_DATA_TOO_LARGE); | ||
172 | mlen = -1; | 168 | mlen = -1; |
173 | } else | 169 | } else |
174 | memcpy(to, db + i, mlen); | 170 | memcpy(to, db + i, mlen); |
@@ -182,7 +178,7 @@ decoding_err: | |||
182 | * To avoid chosen ciphertext attacks, the error message should not | 178 | * To avoid chosen ciphertext attacks, the error message should not |
183 | * reveal which kind of decoding error happened | 179 | * reveal which kind of decoding error happened |
184 | */ | 180 | */ |
185 | RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP, RSA_R_OAEP_DECODING_ERROR); | 181 | RSAerror(RSA_R_OAEP_DECODING_ERROR); |
186 | free(db); | 182 | free(db); |
187 | return -1; | 183 | return -1; |
188 | } | 184 | } |