diff options
author | Richard Levitte <levitte@openssl.org> | 2019-02-26 13:08:31 +0100 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2019-02-26 22:44:48 +0100 |
commit | fa4d419c25c07b49789df96b32c4a1a85a984fa1 (patch) | |
tree | 5a45dcc13dc9b3aad538f7a809a31631dbd69282 /crypto/bn/bn_lib.c | |
parent | 1a31d8017ee7e8df0eca76fee601b826699c9ac1 (diff) | |
download | openssl-fa4d419c25c07b49789df96b32c4a1a85a984fa1.tar.gz |
Add BN_native2bn and BN_bn2nativepad, for native BIGNUM import/export
These are a couple of utility functions, to make import and export of
BIGNUMs to byte strings in platform native for (little-endian or
big-endian) easier.
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8346)
Diffstat (limited to 'crypto/bn/bn_lib.c')
-rw-r--r-- | crypto/bn/bn_lib.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/crypto/bn/bn_lib.c b/crypto/bn/bn_lib.c index e624caf9b4..6de17c3b7a 100644 --- a/crypto/bn/bn_lib.c +++ b/crypto/bn/bn_lib.c @@ -536,6 +536,24 @@ int BN_bn2lebinpad(const BIGNUM *a, unsigned char *to, int tolen) return tolen; } +BIGNUM *BN_native2bn(const unsigned char *s, int len, BIGNUM *ret) +{ +#ifdef B_ENDIAN + return BN_bin2bn(s, len, ret); +#else + return BN_lebin2bn(s, len, ret); +#endif +} + +int BN_bn2nativepad(const BIGNUM *a, unsigned char *to, int tolen) +{ +#ifdef B_ENDIAN + return BN_bn2binpad(a, to, tolen); +#else + return BN_bn2lebinpad(a, to, tolen); +#endif +} + int BN_ucmp(const BIGNUM *a, const BIGNUM *b) { int i; |