Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:24
erlang
2542-crypto-3.0-API-param-fetcher-helper-in-bn....
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 2542-crypto-3.0-API-param-fetcher-helper-in-bn.c.patch of Package erlang
From ce9161fa9cb7876949630e761a94a9ea92629bfb Mon Sep 17 00:00:00 2001 From: Hans Nilsson <hans@erlang.org> Date: Tue, 1 Mar 2022 13:11:59 +0100 Subject: [PATCH 2/3] crypto: 3.0 API param fetcher helper in bn.c --- lib/crypto/c_src/bn.c | 39 +++++++++++++++++++++++++++++++++++++++ lib/crypto/c_src/bn.h | 6 ++++++ 2 files changed, 45 insertions(+) diff --git a/lib/crypto/c_src/bn.c b/lib/crypto/c_src/bn.c index 4c2167703a..ce9fa45dfd 100644 --- a/lib/crypto/c_src/bn.c +++ b/lib/crypto/c_src/bn.c @@ -192,3 +192,42 @@ ERL_NIF_TERM bn2term(ErlNifEnv* env, size_t size, const BIGNUM *bn) return enif_make_badarg(env); } #endif + + +#ifdef HAS_3_0_API + +int get_ossl_param_from_bin(ErlNifEnv* env, char* key, ERL_NIF_TERM bin, OSSL_PARAM *dest) +{ + BIGNUM *bn = NULL; + ErlNifBinary tmp; + + if (!get_bn_from_bin(env, bin, &bn) || + !enif_inspect_binary(env, bin_from_bn(env,bn), &tmp) || // Allocate buf + BN_bn2nativepad(bn, tmp.data, tmp.size) < 0) {// Fill with BN in right endianity + if (bn) BN_free(bn); + return 0; + } + + *dest = OSSL_PARAM_construct_BN(key, tmp.data, tmp.size); + if (bn) BN_free(bn); + return 1; +} + +int get_ossl_param_from_bin_in_list(ErlNifEnv* env, char* key, ERL_NIF_TERM *listcell, OSSL_PARAM *dest) +{ + ERL_NIF_TERM head; + + return + enif_get_list_cell(env, *listcell, &head, listcell) && + get_ossl_param_from_bin(env, key, head, dest); +} + +#endif + + + + + + + + diff --git a/lib/crypto/c_src/bn.h b/lib/crypto/c_src/bn.h index 8b309db089..95c74f51bb 100644 --- a/lib/crypto/c_src/bn.h +++ b/lib/crypto/c_src/bn.h @@ -34,4 +34,10 @@ int get_bn_from_mpint(ErlNifEnv* env, ERL_NIF_TERM term, BIGNUM** bnp); int get_bn_from_bin(ErlNifEnv* env, ERL_NIF_TERM term, BIGNUM** bnp); int get_bn_from_bin_sz(ErlNifEnv* env, ERL_NIF_TERM term, BIGNUM** bnp, size_t* binsize); +#ifdef HAS_3_0_API +int get_ossl_param_from_bin(ErlNifEnv* env, char* key, ERL_NIF_TERM bin, OSSL_PARAM *dest); +int get_ossl_param_from_bin_in_list(ErlNifEnv* env, char* key, ERL_NIF_TERM *listcell, OSSL_PARAM *dest); +#endif + #endif /* E_BN_H__ */ + -- 2.34.1
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor