summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortb <>2018-02-18 12:57:14 +0000
committertb <>2018-02-18 12:57:14 +0000
commit08088224c26400ca4e52e683e20d87c097025de9 (patch)
tree20539a532b21fc8bc7d31895c8d6d2491b26f98a
parent751bc66947637a9abd1a17c25842d5ac30445e33 (diff)
downloadopenbsd-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.list2
-rw-r--r--src/lib/libcrypto/rsa/rsa.h5
-rw-r--r--src/lib/libcrypto/rsa/rsa_lib.c37
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
2211RSA_free 2211RSA_free
2212RSA_generate_key 2212RSA_generate_key
2213RSA_generate_key_ex 2213RSA_generate_key_ex
2214RSA_get0_crt_params
2214RSA_get0_factors 2215RSA_get0_factors
2215RSA_get0_key 2216RSA_get0_key
2216RSA_get_default_method 2217RSA_get_default_method
@@ -2237,6 +2238,7 @@ RSA_private_decrypt
2237RSA_private_encrypt 2238RSA_private_encrypt
2238RSA_public_decrypt 2239RSA_public_decrypt
2239RSA_public_encrypt 2240RSA_public_encrypt
2241RSA_set0_crt_params
2240RSA_set0_factors 2242RSA_set0_factors
2241RSA_set0_key 2243RSA_set0_key
2242RSA_set_default_method 2244RSA_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);
399void RSA_get0_key(const RSA *r, const BIGNUM **n, const BIGNUM **e, 399void RSA_get0_key(const RSA *r, const BIGNUM **n, const BIGNUM **e,
400 const BIGNUM **d); 400 const BIGNUM **d);
401int RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d); 401int RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d);
402void RSA_get0_crt_params(const RSA *r, const BIGNUM **dmp1, const BIGNUM **dmq1,
403 const BIGNUM **iqmp);
404int RSA_set0_crt_params(RSA *r, BIGNUM *dmp1, BIGNUM *dmq1, BIGNUM *iqmp);
402void RSA_get0_factors(const RSA *r, const BIGNUM **p, const BIGNUM **q); 405void RSA_get0_factors(const RSA *r, const BIGNUM **p, const BIGNUM **q);
403int RSA_set0_factors(RSA *r, BIGNUM *p, BIGNUM *q); 406int 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
293void
294RSA_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
305int
306RSA_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
294void 329void
295RSA_get0_factors(const RSA *r, const BIGNUM **p, const BIGNUM **q) 330RSA_get0_factors(const RSA *r, const BIGNUM **p, const BIGNUM **q)