diff options
-rw-r--r-- | lib/libcrypto/Symbols.list | 2 | ||||
-rw-r--r-- | lib/libcrypto/rsa/rsa.h | 5 | ||||
-rw-r--r-- | lib/libcrypto/rsa/rsa_lib.c | 37 |
3 files changed, 42 insertions, 2 deletions
diff --git a/lib/libcrypto/Symbols.list b/lib/libcrypto/Symbols.list index 79d82d49bcf..e5997cc76d9 100644 --- a/lib/libcrypto/Symbols.list +++ b/lib/libcrypto/Symbols.list @@ -2211,6 +2211,7 @@ RSA_flags RSA_free RSA_generate_key RSA_generate_key_ex +RSA_get0_crt_params RSA_get0_factors RSA_get0_key RSA_get_default_method @@ -2237,6 +2238,7 @@ RSA_private_decrypt RSA_private_encrypt RSA_public_decrypt RSA_public_encrypt +RSA_set0_crt_params RSA_set0_factors RSA_set0_key RSA_set_default_method diff --git a/lib/libcrypto/rsa/rsa.h b/lib/libcrypto/rsa/rsa.h index 6cce38d35c3..b131359e8c0 100644 --- a/lib/libcrypto/rsa/rsa.h +++ b/lib/libcrypto/rsa/rsa.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rsa.h,v 1.35 2018/02/18 12:55:32 tb Exp $ */ +/* $OpenBSD: rsa.h,v 1.36 2018/02/18 12:57:14 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -399,6 +399,9 @@ void *RSA_get_ex_data(const RSA *r, int idx); void RSA_get0_key(const RSA *r, const BIGNUM **n, const BIGNUM **e, const BIGNUM **d); int RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d); +void RSA_get0_crt_params(const RSA *r, const BIGNUM **dmp1, const BIGNUM **dmq1, + const BIGNUM **iqmp); +int RSA_set0_crt_params(RSA *r, BIGNUM *dmp1, BIGNUM *dmq1, BIGNUM *iqmp); void RSA_get0_factors(const RSA *r, const BIGNUM **p, const BIGNUM **q); int RSA_set0_factors(RSA *r, BIGNUM *p, BIGNUM *q); diff --git a/lib/libcrypto/rsa/rsa_lib.c b/lib/libcrypto/rsa/rsa_lib.c index 379f4cbe347..426c52f24af 100644 --- a/lib/libcrypto/rsa/rsa_lib.c +++ b/lib/libcrypto/rsa/rsa_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rsa_lib.c,v 1.34 2018/02/18 12:55:32 tb Exp $ */ +/* $OpenBSD: rsa_lib.c,v 1.35 2018/02/18 12:57:14 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -290,6 +290,41 @@ RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d) return 1; } +void +RSA_get0_crt_params(const RSA *r, const BIGNUM **dmp1, const BIGNUM **dmq1, + const BIGNUM **iqmp) +{ + if (dmp1 != NULL) + *dmp1 = r->dmp1; + if (dmq1 != NULL) + *dmq1 = r->dmq1; + if (iqmp != NULL) + *iqmp = r->iqmp; +} + +int +RSA_set0_crt_params(RSA *r, BIGNUM *dmp1, BIGNUM *dmq1, BIGNUM *iqmp) +{ + if ((r->dmp1 == NULL && dmp1 == NULL) || + (r->dmq1 == NULL && dmq1 == NULL) || + (r->iqmp == NULL && iqmp == NULL)) + return 0; + + if (dmp1 != NULL) { + BN_free(r->dmp1); + r->dmp1 = dmp1; + } + if (dmq1 != NULL) { + BN_free(r->dmq1); + r->dmq1 = dmq1; + } + if (iqmp != NULL) { + BN_free(r->iqmp); + r->iqmp = iqmp; + } + + return 1; +} void RSA_get0_factors(const RSA *r, const BIGNUM **p, const BIGNUM **q) |