From 2f0d52b8a3e3ce63552d3125a01f70077b6e6b1a Mon Sep 17 00:00:00 2001
From: jsing <>
Date: Tue, 20 Feb 2018 17:13:14 +0000
Subject: Provide BN_GENCB_new(), BN_GENCB_free() and BN_GENCB_get_arg()

---
 src/lib/libcrypto/Symbols.list |  3 +++
 src/lib/libcrypto/bn/bn.h      |  7 ++++++-
 src/lib/libcrypto/bn/bn_lib.c  | 27 ++++++++++++++++++++++++++-
 3 files changed, 35 insertions(+), 2 deletions(-)

(limited to 'src/lib')

diff --git a/src/lib/libcrypto/Symbols.list b/src/lib/libcrypto/Symbols.list
index 022176264e..23030bdb15 100644
--- a/src/lib/libcrypto/Symbols.list
+++ b/src/lib/libcrypto/Symbols.list
@@ -375,6 +375,9 @@ BN_CTX_init
 BN_CTX_new
 BN_CTX_start
 BN_GENCB_call
+BN_GENCB_free
+BN_GENCB_get_arg
+BN_GENCB_new
 BN_GF2m_add
 BN_GF2m_arr2poly
 BN_GF2m_mod
diff --git a/src/lib/libcrypto/bn/bn.h b/src/lib/libcrypto/bn/bn.h
index cca9def20b..cd94e39345 100644
--- a/src/lib/libcrypto/bn/bn.h
+++ b/src/lib/libcrypto/bn/bn.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: bn.h,v 1.37 2018/02/20 17:02:30 jsing Exp $ */
+/* $OpenBSD: bn.h,v 1.38 2018/02/20 17:13:14 jsing Exp $ */
 /* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
  * All rights reserved.
  *
@@ -285,6 +285,11 @@ struct bn_gencb_st {
 		int (*cb_2)(int, int, BN_GENCB *);
 	} cb;
 };
+
+BN_GENCB *BN_GENCB_new(void);
+void BN_GENCB_free(BN_GENCB *cb);
+void *BN_GENCB_get_arg(BN_GENCB *cb);
+
 /* Wrapper function to make using BN_GENCB easier,  */
 int BN_GENCB_call(BN_GENCB *cb, int a, int b);
 /* Macro to populate a BN_GENCB structure with an "old"-style callback */
diff --git a/src/lib/libcrypto/bn/bn_lib.c b/src/lib/libcrypto/bn/bn_lib.c
index 8aeeb5304f..ffb5ee7c2e 100644
--- a/src/lib/libcrypto/bn/bn_lib.c
+++ b/src/lib/libcrypto/bn/bn_lib.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bn_lib.c,v 1.38 2017/05/02 03:59:44 deraadt Exp $ */
+/* $OpenBSD: bn_lib.c,v 1.39 2018/02/20 17:13:14 jsing Exp $ */
 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  * All rights reserved.
  *
@@ -888,3 +888,28 @@ BN_consttime_swap(BN_ULONG condition, BIGNUM *a, BIGNUM *b, int nwords)
 	}
 #undef BN_CONSTTIME_SWAP
 }
+
+BN_GENCB *
+BN_GENCB_new(void)
+{
+	BN_GENCB *cb;
+
+	if ((cb = calloc(1, sizeof(*cb))) == NULL)
+		return NULL;
+
+	return cb;
+}
+
+void
+BN_GENCB_free(BN_GENCB *cb)
+{
+	if (cb == NULL)
+		return;
+	free(cb);
+}
+
+void *
+BN_GENCB_get_arg(BN_GENCB *cb)
+{
+	return cb->arg;
+}
-- 
cgit v1.2.3-55-g6feb