summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib/libcrypto/bn/bn.h16
-rw-r--r--src/lib/libcrypto/bn/bn_lib.c20
2 files changed, 33 insertions, 3 deletions
diff --git a/src/lib/libcrypto/bn/bn.h b/src/lib/libcrypto/bn/bn.h
index 319cfd67ca..cfdf46906b 100644
--- a/src/lib/libcrypto/bn/bn.h
+++ b/src/lib/libcrypto/bn/bn.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn.h,v 1.44 2021/11/18 18:01:08 tb Exp $ */ 1/* $OpenBSD: bn.h,v 1.45 2021/12/04 15:48:23 tb Exp $ */
2/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -297,10 +297,19 @@ struct bn_gencb_st {
297 297
298BN_GENCB *BN_GENCB_new(void); 298BN_GENCB *BN_GENCB_new(void);
299void BN_GENCB_free(BN_GENCB *cb); 299void BN_GENCB_free(BN_GENCB *cb);
300void *BN_GENCB_get_arg(BN_GENCB *cb);
301 300
302/* Wrapper function to make using BN_GENCB easier, */ 301/* Wrapper function to make using BN_GENCB easier, */
303int BN_GENCB_call(BN_GENCB *cb, int a, int b); 302int BN_GENCB_call(BN_GENCB *cb, int a, int b);
303
304#if defined(LIBRESSL_OPAQUE_BN) || defined(LIBRESSL_CRYPTO_INTERNAL)
305/* Populate a BN_GENCB structure with an "old"-style callback */
306void BN_GENCB_set_old(BN_GENCB *gencb, void (*callback)(int, int, void *),
307 void *cb_arg);
308
309/* Populate a BN_GENCB structure with a "new"-style callback */
310void BN_GENCB_set(BN_GENCB *gencb, int (*callback)(int, int, BN_GENCB *),
311 void *cb_arg);
312#else
304/* Macro to populate a BN_GENCB structure with an "old"-style callback */ 313/* Macro to populate a BN_GENCB structure with an "old"-style callback */
305#define BN_GENCB_set_old(gencb, callback, cb_arg) { \ 314#define BN_GENCB_set_old(gencb, callback, cb_arg) { \
306 BN_GENCB *tmp_gencb = (gencb); \ 315 BN_GENCB *tmp_gencb = (gencb); \
@@ -313,6 +322,9 @@ int BN_GENCB_call(BN_GENCB *cb, int a, int b);
313 tmp_gencb->ver = 2; \ 322 tmp_gencb->ver = 2; \
314 tmp_gencb->arg = (cb_arg); \ 323 tmp_gencb->arg = (cb_arg); \
315 tmp_gencb->cb.cb_2 = (callback); } 324 tmp_gencb->cb.cb_2 = (callback); }
325#endif /* !LIBRESSL_CRYPTO_INTERNAL */
326
327void *BN_GENCB_get_arg(BN_GENCB *cb);
316 328
317#define BN_prime_checks 0 /* default: select number of iterations 329#define BN_prime_checks 0 /* default: select number of iterations
318 based on the size of the number */ 330 based on the size of the number */
diff --git a/src/lib/libcrypto/bn/bn_lib.c b/src/lib/libcrypto/bn/bn_lib.c
index af837eed01..14817629aa 100644
--- a/src/lib/libcrypto/bn/bn_lib.c
+++ b/src/lib/libcrypto/bn/bn_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_lib.c,v 1.48 2021/09/08 12:19:17 tb Exp $ */ 1/* $OpenBSD: bn_lib.c,v 1.49 2021/12/04 15:48:23 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 *
@@ -1056,6 +1056,24 @@ BN_GENCB_free(BN_GENCB *cb)
1056 free(cb); 1056 free(cb);
1057} 1057}
1058 1058
1059/* Populate a BN_GENCB structure with an "old"-style callback */
1060void
1061BN_GENCB_set_old(BN_GENCB *gencb, void (*cb)(int, int, void *), void *cb_arg)
1062{
1063 gencb->ver = 1;
1064 gencb->cb.cb_1 = cb;
1065 gencb->arg = cb_arg;
1066}
1067
1068/* Populate a BN_GENCB structure with a "new"-style callback */
1069void
1070BN_GENCB_set(BN_GENCB *gencb, int (*cb)(int, int, BN_GENCB *), void *cb_arg)
1071{
1072 gencb->ver = 2;
1073 gencb->cb.cb_2 = cb;
1074 gencb->arg = cb_arg;
1075}
1076
1059void * 1077void *
1060BN_GENCB_get_arg(BN_GENCB *cb) 1078BN_GENCB_get_arg(BN_GENCB *cb)
1061{ 1079{