diff options
author | tb <> | 2018-02-18 12:53:46 +0000 |
---|---|---|
committer | tb <> | 2018-02-18 12:53:46 +0000 |
commit | 57e413e44047c6de5afd81409c4917b1071cb777 (patch) | |
tree | 2eea48ceda5c1ecb2eab68df4708270f46b1a6fd | |
parent | d7ec2573e9647e327eb8fddb8465b70fc269f8be (diff) | |
download | openbsd-57e413e44047c6de5afd81409c4917b1071cb777.tar.gz openbsd-57e413e44047c6de5afd81409c4917b1071cb777.tar.bz2 openbsd-57e413e44047c6de5afd81409c4917b1071cb777.zip |
Provide RSA_{g,s}et0_factors()
ok jsing
-rw-r--r-- | src/lib/libcrypto/Symbols.list | 2 | ||||
-rw-r--r-- | src/lib/libcrypto/rsa/rsa.h | 4 | ||||
-rw-r--r-- | src/lib/libcrypto/rsa/rsa_lib.c | 29 |
3 files changed, 33 insertions, 2 deletions
diff --git a/src/lib/libcrypto/Symbols.list b/src/lib/libcrypto/Symbols.list index 8f18580b55..79d82d49bc 100644 --- a/src/lib/libcrypto/Symbols.list +++ b/src/lib/libcrypto/Symbols.list | |||
@@ -2211,6 +2211,7 @@ RSA_flags | |||
2211 | RSA_free | 2211 | RSA_free |
2212 | RSA_generate_key | 2212 | RSA_generate_key |
2213 | RSA_generate_key_ex | 2213 | RSA_generate_key_ex |
2214 | RSA_get0_factors | ||
2214 | RSA_get0_key | 2215 | RSA_get0_key |
2215 | RSA_get_default_method | 2216 | RSA_get_default_method |
2216 | RSA_get_ex_data | 2217 | RSA_get_ex_data |
@@ -2236,6 +2237,7 @@ RSA_private_decrypt | |||
2236 | RSA_private_encrypt | 2237 | RSA_private_encrypt |
2237 | RSA_public_decrypt | 2238 | RSA_public_decrypt |
2238 | RSA_public_encrypt | 2239 | RSA_public_encrypt |
2240 | RSA_set0_factors | ||
2239 | RSA_set0_key | 2241 | RSA_set0_key |
2240 | RSA_set_default_method | 2242 | RSA_set_default_method |
2241 | RSA_set_ex_data | 2243 | RSA_set_ex_data |
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 | } | ||