diff options
| author | beck <> | 2017-01-29 17:49:23 +0000 |
|---|---|---|
| committer | beck <> | 2017-01-29 17:49:23 +0000 |
| commit | d1f47bd292f36094480caa49ada36b99a69c59b0 (patch) | |
| tree | 1a54abba678898ee5270ae4f3404a50ee9a92eea /src/lib/libcrypto/rsa/rsa_chk.c | |
| parent | f8c627888330b75c2eea8a3c27d0efe947a4f9da (diff) | |
| download | openbsd-d1f47bd292f36094480caa49ada36b99a69c59b0.tar.gz openbsd-d1f47bd292f36094480caa49ada36b99a69c59b0.tar.bz2 openbsd-d1f47bd292f36094480caa49ada36b99a69c59b0.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_chk.c')
| -rw-r--r-- | src/lib/libcrypto/rsa/rsa_chk.c | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/src/lib/libcrypto/rsa/rsa_chk.c b/src/lib/libcrypto/rsa/rsa_chk.c index dd9104f304..5345d31df9 100644 --- a/src/lib/libcrypto/rsa/rsa_chk.c +++ b/src/lib/libcrypto/rsa/rsa_chk.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: rsa_chk.c,v 1.12 2017/01/25 06:15:44 beck Exp $ */ | 1 | /* $OpenBSD: rsa_chk.c,v 1.13 2017/01/29 17:49:23 beck Exp $ */ |
| 2 | /* ==================================================================== | 2 | /* ==================================================================== |
| 3 | * Copyright (c) 1999 The OpenSSL Project. All rights reserved. | 3 | * Copyright (c) 1999 The OpenSSL Project. All rights reserved. |
| 4 | * | 4 | * |
| @@ -63,7 +63,7 @@ RSA_check_key(const RSA *key) | |||
| 63 | int ret = 1; | 63 | int ret = 1; |
| 64 | 64 | ||
| 65 | if (!key->p || !key->q || !key->n || !key->e || !key->d) { | 65 | if (!key->p || !key->q || !key->n || !key->e || !key->d) { |
| 66 | RSAerr(RSA_F_RSA_CHECK_KEY, RSA_R_VALUE_MISSING); | 66 | RSAerror(RSA_R_VALUE_MISSING); |
| 67 | return 0; | 67 | return 0; |
| 68 | } | 68 | } |
| 69 | 69 | ||
| @@ -76,7 +76,7 @@ RSA_check_key(const RSA *key) | |||
| 76 | if (i == NULL || j == NULL || k == NULL || l == NULL || m == NULL || | 76 | if (i == NULL || j == NULL || k == NULL || l == NULL || m == NULL || |
| 77 | ctx == NULL) { | 77 | ctx == NULL) { |
| 78 | ret = -1; | 78 | ret = -1; |
| 79 | RSAerr(RSA_F_RSA_CHECK_KEY, ERR_R_MALLOC_FAILURE); | 79 | RSAerror(ERR_R_MALLOC_FAILURE); |
| 80 | goto err; | 80 | goto err; |
| 81 | } | 81 | } |
| 82 | 82 | ||
| @@ -86,7 +86,7 @@ RSA_check_key(const RSA *key) | |||
| 86 | ret = r; | 86 | ret = r; |
| 87 | if (r != 0) | 87 | if (r != 0) |
| 88 | goto err; | 88 | goto err; |
| 89 | RSAerr(RSA_F_RSA_CHECK_KEY, RSA_R_P_NOT_PRIME); | 89 | RSAerror(RSA_R_P_NOT_PRIME); |
| 90 | } | 90 | } |
| 91 | 91 | ||
| 92 | /* q prime? */ | 92 | /* q prime? */ |
| @@ -95,7 +95,7 @@ RSA_check_key(const RSA *key) | |||
| 95 | ret = r; | 95 | ret = r; |
| 96 | if (r != 0) | 96 | if (r != 0) |
| 97 | goto err; | 97 | goto err; |
| 98 | RSAerr(RSA_F_RSA_CHECK_KEY, RSA_R_Q_NOT_PRIME); | 98 | RSAerror(RSA_R_Q_NOT_PRIME); |
| 99 | } | 99 | } |
| 100 | 100 | ||
| 101 | /* n = p*q? */ | 101 | /* n = p*q? */ |
| @@ -107,7 +107,7 @@ RSA_check_key(const RSA *key) | |||
| 107 | 107 | ||
| 108 | if (BN_cmp(i, key->n) != 0) { | 108 | if (BN_cmp(i, key->n) != 0) { |
| 109 | ret = 0; | 109 | ret = 0; |
| 110 | RSAerr(RSA_F_RSA_CHECK_KEY, RSA_R_N_DOES_NOT_EQUAL_P_Q); | 110 | RSAerror(RSA_R_N_DOES_NOT_EQUAL_P_Q); |
| 111 | } | 111 | } |
| 112 | 112 | ||
| 113 | /* d*e = 1 mod lcm(p-1,q-1)? */ | 113 | /* d*e = 1 mod lcm(p-1,q-1)? */ |
| @@ -148,7 +148,7 @@ RSA_check_key(const RSA *key) | |||
| 148 | 148 | ||
| 149 | if (!BN_is_one(i)) { | 149 | if (!BN_is_one(i)) { |
| 150 | ret = 0; | 150 | ret = 0; |
| 151 | RSAerr(RSA_F_RSA_CHECK_KEY, RSA_R_D_E_NOT_CONGRUENT_TO_1); | 151 | RSAerror(RSA_R_D_E_NOT_CONGRUENT_TO_1); |
| 152 | } | 152 | } |
| 153 | 153 | ||
| 154 | if (key->dmp1 != NULL && key->dmq1 != NULL && key->iqmp != NULL) { | 154 | if (key->dmp1 != NULL && key->dmq1 != NULL && key->iqmp != NULL) { |
| @@ -167,8 +167,7 @@ RSA_check_key(const RSA *key) | |||
| 167 | 167 | ||
| 168 | if (BN_cmp(j, key->dmp1) != 0) { | 168 | if (BN_cmp(j, key->dmp1) != 0) { |
| 169 | ret = 0; | 169 | ret = 0; |
| 170 | RSAerr(RSA_F_RSA_CHECK_KEY, | 170 | RSAerror(RSA_R_DMP1_NOT_CONGRUENT_TO_D); |
| 171 | RSA_R_DMP1_NOT_CONGRUENT_TO_D); | ||
| 172 | } | 171 | } |
| 173 | 172 | ||
| 174 | /* dmq1 = d mod (q-1)? */ | 173 | /* dmq1 = d mod (q-1)? */ |
| @@ -186,8 +185,7 @@ RSA_check_key(const RSA *key) | |||
| 186 | 185 | ||
| 187 | if (BN_cmp(j, key->dmq1) != 0) { | 186 | if (BN_cmp(j, key->dmq1) != 0) { |
| 188 | ret = 0; | 187 | ret = 0; |
| 189 | RSAerr(RSA_F_RSA_CHECK_KEY, | 188 | RSAerror(RSA_R_DMQ1_NOT_CONGRUENT_TO_D); |
| 190 | RSA_R_DMQ1_NOT_CONGRUENT_TO_D); | ||
| 191 | } | 189 | } |
| 192 | 190 | ||
| 193 | /* iqmp = q^-1 mod p? */ | 191 | /* iqmp = q^-1 mod p? */ |
| @@ -198,8 +196,7 @@ RSA_check_key(const RSA *key) | |||
| 198 | 196 | ||
| 199 | if (BN_cmp(i, key->iqmp) != 0) { | 197 | if (BN_cmp(i, key->iqmp) != 0) { |
| 200 | ret = 0; | 198 | ret = 0; |
| 201 | RSAerr(RSA_F_RSA_CHECK_KEY, | 199 | RSAerror(RSA_R_IQMP_NOT_INVERSE_OF_Q); |
| 202 | RSA_R_IQMP_NOT_INVERSE_OF_Q); | ||
| 203 | } | 200 | } |
| 204 | } | 201 | } |
| 205 | 202 | ||
