Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/boringssl.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Smith <brian@briansmith.org>2016-03-26 02:24:46 +0300
committerDavid Benjamin <davidben@google.com>2016-03-30 01:20:48 +0300
commitf08c1c68957024ced93d35d757daeb373de8f073 (patch)
treeb4423c91d5100d492401f2d09b4e50b388313f48 /crypto/rsa
parent3426d1011946b26ff1bb2fd98a081ba4753c9cc8 (diff)
Drop support for custom |mod_exp| hooks in |RSA_METHOD|.
The documentation in |RSA_METHOD| says that the |ctx| parameter to |mod_exp| can be NULL, however the default implementation doesn't handle that case. That wouldn't matter since internally it is always called with a non-NULL |ctx| and it is static, but an external application could get a pointer to |mod_exp| by extracting it from the default |RSA_METHOD|. That's unlikely, but making that impossible reduces the chances that future refactorings will cause unexpected trouble. Change-Id: Ie0e35e9f107551a16b49c1eb91d0d3386604e594 Reviewed-on: https://boringssl-review.googlesource.com/7580 Reviewed-by: David Benjamin <davidben@google.com>
Diffstat (limited to 'crypto/rsa')
-rw-r--r--crypto/rsa/rsa_impl.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/crypto/rsa/rsa_impl.c b/crypto/rsa/rsa_impl.c
index 8d0899a1..af55c1da 100644
--- a/crypto/rsa/rsa_impl.c
+++ b/crypto/rsa/rsa_impl.c
@@ -424,6 +424,8 @@ err:
return ret;
}
+static int mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx);
+
int rsa_default_verify_raw(RSA *rsa, size_t *out_len, uint8_t *out,
size_t max_out, const uint8_t *in, size_t in_len,
int padding) {
@@ -568,10 +570,9 @@ int rsa_default_private_transform(RSA *rsa, uint8_t *out, const uint8_t *in,
}
}
- if ((rsa->flags & RSA_FLAG_EXT_PKEY) ||
- ((rsa->p != NULL) && (rsa->q != NULL) && (rsa->dmp1 != NULL) &&
+ if (((rsa->p != NULL) && (rsa->q != NULL) && (rsa->dmp1 != NULL) &&
(rsa->dmq1 != NULL) && (rsa->iqmp != NULL))) {
- if (!rsa->meth->mod_exp(result, f, rsa, ctx)) {
+ if (!mod_exp(result, f, rsa, ctx)) {
goto err;
}
} else {
@@ -614,6 +615,8 @@ err:
}
static int mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx) {
+ assert(ctx != NULL);
+
BIGNUM *r1, *m1, *vrfy;
BIGNUM local_dmp1, local_dmq1, local_c, local_r1;
BIGNUM *dmp1, *dmq1, *c, *pr1;
@@ -1094,9 +1097,9 @@ int rsa_default_keygen(RSA *rsa, int bits, BIGNUM *e_value, BN_GENCB *cb) {
cb);
}
-/* Many of these methods are NULL to more easily drop unused functions. The
- * wrapper functions will select the appropriate |rsa_default_*| for all
- * methods. */
+/* All of the methods are NULL to make it easier for the compiler/linker to drop
+ * unused functions. The wrapper functions will select the appropriate
+ * |rsa_default_*| implementation. */
const RSA_METHOD RSA_default_method = {
{
0 /* references */,
@@ -1119,8 +1122,8 @@ const RSA_METHOD RSA_default_method = {
NULL /* private_transform (defaults to rsa_default_private_transform) */,
- mod_exp,
- NULL /* bn_mod_exp */,
+ NULL /* mod_exp (ignored) */,
+ NULL /* bn_mod_exp (ignored) */,
RSA_FLAG_CACHE_PUBLIC | RSA_FLAG_CACHE_PRIVATE,