diff options
author | tb <> | 2018-02-18 12:57:14 +0000 |
---|---|---|
committer | tb <> | 2018-02-18 12:57:14 +0000 |
commit | 08088224c26400ca4e52e683e20d87c097025de9 (patch) | |
tree | 20539a532b21fc8bc7d31895c8d6d2491b26f98a | |
parent | 751bc66947637a9abd1a17c25842d5ac30445e33 (diff) | |
download | openbsd-08088224c26400ca4e52e683e20d87c097025de9.tar.gz openbsd-08088224c26400ca4e52e683e20d87c097025de9.tar.bz2 openbsd-08088224c26400ca4e52e683e20d87c097025de9.zip |
Provide RSA_{g,s}et0_crt_params()
ok jsing
-rw-r--r-- | src/lib/libcrypto/Symbols.list | 2 | ||||
-rw-r--r-- | src/lib/libcrypto/rsa/rsa.h | 5 | ||||
-rw-r--r-- | src/lib/libcrypto/rsa/rsa_lib.c | 37 |
3 files changed, 42 insertions, 2 deletions
diff --git a/src/lib/libcrypto/Symbols.list b/src/lib/libcrypto/Symbols.list index 79d82d49bc..e5997cc76d 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_crt_params | ||
2214 | RSA_get0_factors | 2215 | RSA_get0_factors |
2215 | RSA_get0_key | 2216 | RSA_get0_key |
2216 | RSA_get_default_method | 2217 | RSA_get_default_method |
@@ -2237,6 +2238,7 @@ RSA_private_decrypt | |||
2237 | RSA_private_encrypt | 2238 | RSA_private_encrypt |
2238 | RSA_public_decrypt | 2239 | RSA_public_decrypt |
2239 | RSA_public_encrypt | 2240 | RSA_public_encrypt |
2241 | RSA_set0_crt_params | ||
2240 | RSA_set0_factors | 2242 | RSA_set0_factors |
2241 | RSA_set0_key | 2243 | RSA_set0_key |
2242 | RSA_set_default_method | 2244 | RSA_set_default_method |
diff --git a/src/lib/libcrypto/rsa/rsa.h b/src/lib/libcrypto/rsa/rsa.h index 6cce38d35c..b131359e8c 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.35 2018/02/18 12:55:32 tb Exp $ */ | 1 | /* $OpenBSD: rsa.h,v 1.36 2018/02/18 12:57:14 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,9 @@ void *RSA_get_ex_data(const RSA *r, int idx); | |||
399 | void RSA_get0_key(const RSA *r, const BIGNUM **n, const BIGNUM **e, | 399 | void RSA_get0_key(const RSA *r, const BIGNUM **n, const BIGNUM **e, |
400 | const BIGNUM **d); | 400 | const BIGNUM **d); |
401 | int RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d); | 401 | int RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d); |
402 | void RSA_get0_crt_params(const RSA *r, const BIGNUM **dmp1, const BIGNUM **dmq1, | ||
403 | const BIGNUM **iqmp); | ||
404 | int RSA_set0_crt_params(RSA *r, BIGNUM *dmp1, BIGNUM *dmq1, BIGNUM *iqmp); | ||
402 | void RSA_get0_factors(const RSA *r, const BIGNUM **p, const BIGNUM **q); | 405 | void RSA_get0_factors(const RSA *r, const BIGNUM **p, const BIGNUM **q); |
403 | int RSA_set0_factors(RSA *r, BIGNUM *p, BIGNUM *q); | 406 | int RSA_set0_factors(RSA *r, BIGNUM *p, BIGNUM *q); |
404 | 407 | ||
diff --git a/src/lib/libcrypto/rsa/rsa_lib.c b/src/lib/libcrypto/rsa/rsa_lib.c index 379f4cbe34..426c52f24a 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.34 2018/02/18 12:55:32 tb Exp $ */ | 1 | /* $OpenBSD: rsa_lib.c,v 1.35 2018/02/18 12:57:14 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 | * |
@@ -290,6 +290,41 @@ RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d) | |||
290 | return 1; | 290 | return 1; |
291 | } | 291 | } |
292 | 292 | ||
293 | void | ||
294 | RSA_get0_crt_params(const RSA *r, const BIGNUM **dmp1, const BIGNUM **dmq1, | ||
295 | const BIGNUM **iqmp) | ||
296 | { | ||
297 | if (dmp1 != NULL) | ||
298 | *dmp1 = r->dmp1; | ||
299 | if (dmq1 != NULL) | ||
300 | *dmq1 = r->dmq1; | ||
301 | if (iqmp != NULL) | ||
302 | *iqmp = r->iqmp; | ||
303 | } | ||
304 | |||
305 | int | ||
306 | RSA_set0_crt_params(RSA *r, BIGNUM *dmp1, BIGNUM *dmq1, BIGNUM *iqmp) | ||
307 | { | ||
308 | if ((r->dmp1 == NULL && dmp1 == NULL) || | ||
309 | (r->dmq1 == NULL && dmq1 == NULL) || | ||
310 | (r->iqmp == NULL && iqmp == NULL)) | ||
311 | return 0; | ||
312 | |||
313 | if (dmp1 != NULL) { | ||
314 | BN_free(r->dmp1); | ||
315 | r->dmp1 = dmp1; | ||
316 | } | ||
317 | if (dmq1 != NULL) { | ||
318 | BN_free(r->dmq1); | ||
319 | r->dmq1 = dmq1; | ||
320 | } | ||
321 | if (iqmp != NULL) { | ||
322 | BN_free(r->iqmp); | ||
323 | r->iqmp = iqmp; | ||
324 | } | ||
325 | |||
326 | return 1; | ||
327 | } | ||
293 | 328 | ||
294 | void | 329 | void |
295 | RSA_get0_factors(const RSA *r, const BIGNUM **p, const BIGNUM **q) | 330 | RSA_get0_factors(const RSA *r, const BIGNUM **p, const BIGNUM **q) |