summaryrefslogtreecommitdiff
path: root/lib/libcrypto/bn
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2018-02-20 17:13:15 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2018-02-20 17:13:15 +0000
commit01911631a594b7f6bda520f706ff0bcf45d68eb2 (patch)
tree833958a5ca6ffd0d406cf1f89ff58ec6296a54d7 /lib/libcrypto/bn
parent30ff4963c9321d7d748a57e79aca5e7d8c16c241 (diff)
Provide BN_GENCB_new(), BN_GENCB_free() and BN_GENCB_get_arg()
Diffstat (limited to 'lib/libcrypto/bn')
-rw-r--r--lib/libcrypto/bn/bn.h7
-rw-r--r--lib/libcrypto/bn/bn_lib.c27
2 files changed, 32 insertions, 2 deletions
diff --git a/lib/libcrypto/bn/bn.h b/lib/libcrypto/bn/bn.h
index cca9def20b3..cd94e393459 100644
--- a/lib/libcrypto/bn/bn.h
+++ b/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/lib/libcrypto/bn/bn_lib.c b/lib/libcrypto/bn/bn_lib.c
index 8aeeb5304fa..ffb5ee7c2eb 100644
--- a/lib/libcrypto/bn/bn_lib.c
+++ b/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;
+}