diff options
Diffstat (limited to 'src/lib/libcrypto/rsa')
-rw-r--r-- | src/lib/libcrypto/rsa/rsa.h | 4 | ||||
-rw-r--r-- | src/lib/libcrypto/rsa/rsa_lib.c | 29 |
2 files changed, 31 insertions, 2 deletions
diff --git a/src/lib/libcrypto/rsa/rsa.h b/src/lib/libcrypto/rsa/rsa.h index 7e28a8766c..51b06ba6aa 100644 --- a/src/lib/libcrypto/rsa/rsa.h +++ b/src/lib/libcrypto/rsa/rsa.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: rsa.h,v 1.33 2018/02/18 12:52:13 tb Exp $ */ | 1 | /* $OpenBSD: rsa.h,v 1.34 2018/02/18 12:53:46 tb 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 | * |
@@ -399,6 +399,8 @@ void *RSA_get_ex_data(const RSA *r, int idx); | |||
399 | int RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d); | 399 | int RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d); |
400 | void RSA_get0_key(const RSA *r, const BIGNUM **n, const BIGNUM **e, | 400 | void RSA_get0_key(const RSA *r, const BIGNUM **n, const BIGNUM **e, |
401 | const BIGNUM **d); | 401 | const BIGNUM **d); |
402 | void RSA_get0_factors(const RSA *r, const BIGNUM **p, const BIGNUM **q); | ||
403 | int RSA_set0_factors(RSA *r, BIGNUM *p, BIGNUM *q); | ||
402 | 404 | ||
403 | RSA *RSAPublicKey_dup(RSA *rsa); | 405 | RSA *RSAPublicKey_dup(RSA *rsa); |
404 | RSA *RSAPrivateKey_dup(RSA *rsa); | 406 | RSA *RSAPrivateKey_dup(RSA *rsa); |
diff --git a/src/lib/libcrypto/rsa/rsa_lib.c b/src/lib/libcrypto/rsa/rsa_lib.c index 2a73364e70..c31aa935b7 100644 --- a/src/lib/libcrypto/rsa/rsa_lib.c +++ b/src/lib/libcrypto/rsa/rsa_lib.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: rsa_lib.c,v 1.32 2018/02/17 13:47:36 tb Exp $ */ | 1 | /* $OpenBSD: rsa_lib.c,v 1.33 2018/02/18 12:53:46 tb 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 | * |
@@ -289,3 +289,30 @@ RSA_get0_key(const RSA *r, const BIGNUM **n, const BIGNUM **e, const BIGNUM **d) | |||
289 | if (d != NULL) | 289 | if (d != NULL) |
290 | *d = r->d; | 290 | *d = r->d; |
291 | } | 291 | } |
292 | |||
293 | void | ||
294 | RSA_get0_factors(const RSA *r, const BIGNUM **p, const BIGNUM **q) | ||
295 | { | ||
296 | if (p != NULL) | ||
297 | *p = r->p; | ||
298 | if (q != NULL) | ||
299 | *q = r->q; | ||
300 | } | ||
301 | |||
302 | int | ||
303 | RSA_set0_factors(RSA *r, BIGNUM *p, BIGNUM *q) | ||
304 | { | ||
305 | if ((r->p == NULL && p == NULL) || (r->q == NULL && q == NULL)) | ||
306 | return 0; | ||
307 | |||
308 | if (p != NULL) { | ||
309 | BN_free(r->p); | ||
310 | r->p = p; | ||
311 | } | ||
312 | if (q != NULL) { | ||
313 | BN_free(r->q); | ||
314 | r->q = q; | ||
315 | } | ||
316 | |||
317 | return 1; | ||
318 | } | ||