diff options
| author | beck <> | 2017-01-21 11:00:47 +0000 |
|---|---|---|
| committer | beck <> | 2017-01-21 11:00:47 +0000 |
| commit | 48df727a3547375dae8622c34fb55bdf5ef2c44c (patch) | |
| tree | 7ad0f2808a2ac42a510bf2f280dba63a3dfc83e3 /src/lib/libcrypto/rsa | |
| parent | 55a172a1ed5b0cd8f7de3628fcc2e56df6716d59 (diff) | |
| download | openbsd-48df727a3547375dae8622c34fb55bdf5ef2c44c.tar.gz openbsd-48df727a3547375dae8622c34fb55bdf5ef2c44c.tar.bz2 openbsd-48df727a3547375dae8622c34fb55bdf5ef2c44c.zip | |
Add ct and nonct versions of BN_mod_inverse for internal use
ok jsing@
Diffstat (limited to 'src/lib/libcrypto/rsa')
| -rw-r--r-- | src/lib/libcrypto/rsa/rsa_chk.c | 4 | ||||
| -rw-r--r-- | src/lib/libcrypto/rsa/rsa_crpt.c | 6 | ||||
| -rw-r--r-- | src/lib/libcrypto/rsa/rsa_gen.c | 6 |
3 files changed, 9 insertions, 7 deletions
diff --git a/src/lib/libcrypto/rsa/rsa_chk.c b/src/lib/libcrypto/rsa/rsa_chk.c index efe9431f2d..91616d17cb 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.10 2017/01/21 10:38:29 beck Exp $ */ | 1 | /* $OpenBSD: rsa_chk.c,v 1.11 2017/01/21 11:00:47 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 | * |
| @@ -191,7 +191,7 @@ RSA_check_key(const RSA *key) | |||
| 191 | } | 191 | } |
| 192 | 192 | ||
| 193 | /* iqmp = q^-1 mod p? */ | 193 | /* iqmp = q^-1 mod p? */ |
| 194 | if (!BN_mod_inverse(i, key->q, key->p, ctx)) { | 194 | if (!BN_mod_inverse_ct(i, key->q, key->p, ctx)) { |
| 195 | ret = -1; | 195 | ret = -1; |
| 196 | goto err; | 196 | goto err; |
| 197 | } | 197 | } |
diff --git a/src/lib/libcrypto/rsa/rsa_crpt.c b/src/lib/libcrypto/rsa/rsa_crpt.c index ccb677c12b..8063a83263 100644 --- a/src/lib/libcrypto/rsa/rsa_crpt.c +++ b/src/lib/libcrypto/rsa/rsa_crpt.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: rsa_crpt.c,v 1.16 2016/07/07 11:53:12 bcook Exp $ */ | 1 | /* $OpenBSD: rsa_crpt.c,v 1.17 2017/01/21 11:00:47 beck Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -66,6 +66,8 @@ | |||
| 66 | #include <openssl/lhash.h> | 66 | #include <openssl/lhash.h> |
| 67 | #include <openssl/rsa.h> | 67 | #include <openssl/rsa.h> |
| 68 | 68 | ||
| 69 | #include "bn_lcl.h" | ||
| 70 | |||
| 69 | #ifndef OPENSSL_NO_ENGINE | 71 | #ifndef OPENSSL_NO_ENGINE |
| 70 | #include <openssl/engine.h> | 72 | #include <openssl/engine.h> |
| 71 | #endif | 73 | #endif |
| @@ -160,7 +162,7 @@ rsa_get_public_exp(const BIGNUM *d, const BIGNUM *p, const BIGNUM *q, | |||
| 160 | if (!BN_mul(r0, r1, r2, ctx)) | 162 | if (!BN_mul(r0, r1, r2, ctx)) |
| 161 | goto err; | 163 | goto err; |
| 162 | 164 | ||
| 163 | ret = BN_mod_inverse(NULL, d, r0, ctx); | 165 | ret = BN_mod_inverse_ct(NULL, d, r0, ctx); |
| 164 | err: | 166 | err: |
| 165 | BN_CTX_end(ctx); | 167 | BN_CTX_end(ctx); |
| 166 | return ret; | 168 | return ret; |
diff --git a/src/lib/libcrypto/rsa/rsa_gen.c b/src/lib/libcrypto/rsa/rsa_gen.c index 817f177e96..300b292b7b 100644 --- a/src/lib/libcrypto/rsa/rsa_gen.c +++ b/src/lib/libcrypto/rsa/rsa_gen.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: rsa_gen.c,v 1.19 2017/01/21 10:38:29 beck Exp $ */ | 1 | /* $OpenBSD: rsa_gen.c,v 1.20 2017/01/21 11:00:47 beck Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -197,7 +197,7 @@ rsa_builtin_keygen(RSA *rsa, int bits, BIGNUM *e_value, BN_GENCB *cb) | |||
| 197 | 197 | ||
| 198 | BN_with_flags(&pr0, r0, BN_FLG_CONSTTIME); | 198 | BN_with_flags(&pr0, r0, BN_FLG_CONSTTIME); |
| 199 | 199 | ||
| 200 | if (!BN_mod_inverse(rsa->d, rsa->e, &pr0, ctx)) /* d */ | 200 | if (!BN_mod_inverse_ct(rsa->d, rsa->e, &pr0, ctx)) /* d */ |
| 201 | goto err; | 201 | goto err; |
| 202 | 202 | ||
| 203 | /* set up d for correct BN_FLG_CONSTTIME flag */ | 203 | /* set up d for correct BN_FLG_CONSTTIME flag */ |
| @@ -213,7 +213,7 @@ rsa_builtin_keygen(RSA *rsa, int bits, BIGNUM *e_value, BN_GENCB *cb) | |||
| 213 | 213 | ||
| 214 | /* calculate inverse of q mod p */ | 214 | /* calculate inverse of q mod p */ |
| 215 | BN_with_flags(&p, rsa->p, BN_FLG_CONSTTIME); | 215 | BN_with_flags(&p, rsa->p, BN_FLG_CONSTTIME); |
| 216 | if (!BN_mod_inverse(rsa->iqmp, rsa->q, &p, ctx)) | 216 | if (!BN_mod_inverse_ct(rsa->iqmp, rsa->q, &p, ctx)) |
| 217 | goto err; | 217 | goto err; |
| 218 | 218 | ||
| 219 | ok = 1; | 219 | ok = 1; |
