From: jsing Date: Tue, 20 Feb 2018 17:13:14 +0000 (+0000) Subject: Provide BN_GENCB_new(), BN_GENCB_free() and BN_GENCB_get_arg() X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=34b1aa359e02bba2170844ed852d5afa08af5c1e;p=openbsd Provide BN_GENCB_new(), BN_GENCB_free() and BN_GENCB_get_arg() --- diff --git a/lib/libcrypto/Symbols.list b/lib/libcrypto/Symbols.list index 022176264e1..23030bdb155 100644 --- a/lib/libcrypto/Symbols.list +++ b/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/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; +}