diff options
author | Theo Buehler <tb@cvs.openbsd.org> | 2018-02-18 12:53:47 +0000 |
---|---|---|
committer | Theo Buehler <tb@cvs.openbsd.org> | 2018-02-18 12:53:47 +0000 |
commit | 132bb13a3574b2ba7f5461684248daf021448f94 (patch) | |
tree | 91b3812fac37d3c935a4f9163c5d8096b884b453 | |
parent | 2787ecbd158905f983fd0e36f271186fbe5c4cc0 (diff) |
Provide RSA_{g,s}et0_factors()
ok jsing
-rw-r--r-- | lib/libcrypto/Symbols.list | 2 | ||||
-rw-r--r-- | lib/libcrypto/rsa/rsa.h | 4 | ||||
-rw-r--r-- | lib/libcrypto/rsa/rsa_lib.c | 29 |
3 files changed, 33 insertions, 2 deletions
diff --git a/lib/libcrypto/Symbols.list b/lib/libcrypto/Symbols.list index 8f18580b559..79d82d49bcf 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_factors RSA_get0_key RSA_get_default_method RSA_get_ex_data @@ -2236,6 +2237,7 @@ RSA_private_decrypt RSA_private_encrypt RSA_public_decrypt RSA_public_encrypt +RSA_set0_factors RSA_set0_key RSA_set_default_method RSA_set_ex_data diff --git a/lib/libcrypto/rsa/rsa.h b/lib/libcrypto/rsa/rsa.h index 7e28a8766c6..51b06ba6aa5 100644 --- a/lib/libcrypto/rsa/rsa.h +++ b/lib/libcrypto/rsa/rsa.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rsa.h,v 1.33 2018/02/18 12:52:13 tb Exp $ */ +/* $OpenBSD: rsa.h,v 1.34 2018/02/18 12:53:46 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -399,6 +399,8 @@ void *RSA_get_ex_data(const RSA *r, int idx); int RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d); void RSA_get0_key(const RSA *r, const BIGNUM **n, const BIGNUM **e, const BIGNUM **d); +void RSA_get0_factors(const RSA *r, const BIGNUM **p, const BIGNUM **q); +int RSA_set0_factors(RSA *r, BIGNUM *p, BIGNUM *q); RSA *RSAPublicKey_dup(RSA *rsa); RSA *RSAPrivateKey_dup(RSA *rsa); diff --git a/lib/libcrypto/rsa/rsa_lib.c b/lib/libcrypto/rsa/rsa_lib.c index 2a73364e702..c31aa935b75 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.32 2018/02/17 13:47:36 tb Exp $ */ +/* $OpenBSD: rsa_lib.c,v 1.33 2018/02/18 12:53:46 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -289,3 +289,30 @@ RSA_get0_key(const RSA *r, const BIGNUM **n, const BIGNUM **e, const BIGNUM **d) if (d != NULL) *d = r->d; } + +void +RSA_get0_factors(const RSA *r, const BIGNUM **p, const BIGNUM **q) +{ + if (p != NULL) + *p = r->p; + if (q != NULL) + *q = r->q; +} + +int +RSA_set0_factors(RSA *r, BIGNUM *p, BIGNUM *q) +{ + if ((r->p == NULL && p == NULL) || (r->q == NULL && q == NULL)) + return 0; + + if (p != NULL) { + BN_free(r->p); + r->p = p; + } + if (q != NULL) { + BN_free(r->q); + r->q = q; + } + + return 1; +} |