diff options
author | Richard Levitte <levitte@openssl.org> | 2021-11-25 17:55:41 +0100 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2022-01-20 17:58:08 +0100 |
commit | f5e8050fdcf2083825ef450d51bfacac21d2730e (patch) | |
tree | 0fd8e023bf28dd60713f843c03db4893a2503191 /doc/man3 | |
parent | c30de601850f367e4c16ad91c0168a2e0dc647c0 (diff) |
Add signed bn2bin and bin2bn functions
This adds the functions BN_signed_bin2bn(), BN_signed_bn2bin(),
BN_signed_lebin2bn(), BN_signed_bn2lebin(), BN_signed_native2bn(),
and BN_signed_bn2native(), all essentially doing the same job as
BN_bin2bn(), BN_bn2binpad(), BN_lebin2bn(), BN_bn2lebinpad(),
BN_native2bn(), and BN_bn2nativepad(), except that the 'signed'
ones operate on signed number bins in 2's complement form.
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17139)
Diffstat (limited to 'doc/man3')
-rw-r--r-- | doc/man3/BN_bn2bin.pod | 42 |
1 files changed, 31 insertions, 11 deletions
diff --git a/doc/man3/BN_bn2bin.pod b/doc/man3/BN_bn2bin.pod index e75b9fffb5..3e5f2deeca 100644 --- a/doc/man3/BN_bn2bin.pod +++ b/doc/man3/BN_bn2bin.pod @@ -2,9 +2,10 @@ =head1 NAME -BN_bn2binpad, -BN_bn2bin, BN_bin2bn, BN_bn2lebinpad, BN_lebin2bn, -BN_bn2nativepad, BN_native2bn, BN_bn2hex, BN_bn2dec, BN_hex2bn, BN_dec2bn, +BN_bn2binpad, BN_signed_bn2bin, BN_bn2bin, BN_bin2bn, BN_signed_bin2bn, +BN_bn2lebinpad, BN_signed_bn2lebin, BN_lebin2bn, BN_signed_lebin2bn, +BN_bn2nativepad, BN_signed_bn2native, BN_native2bn, BN_signed_native2bn, +BN_bn2hex, BN_bn2dec, BN_hex2bn, BN_dec2bn, BN_print, BN_print_fp, BN_bn2mpi, BN_mpi2bn - format conversions =head1 SYNOPSIS @@ -13,13 +14,19 @@ BN_print, BN_print_fp, BN_bn2mpi, BN_mpi2bn - format conversions int BN_bn2bin(const BIGNUM *a, unsigned char *to); int BN_bn2binpad(const BIGNUM *a, unsigned char *to, int tolen); + int BN_signed_bn2bin(const BIGNUM *a, unsigned char *to, int tolen); BIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret); + BIGNUM *BN_signed_bin2bn(const unsigned char *s, int len, BIGNUM *ret); int BN_bn2lebinpad(const BIGNUM *a, unsigned char *to, int tolen); + int BN_signed_bn2lebin(const BIGNUM *a, unsigned char *to, int tolen); BIGNUM *BN_lebin2bn(const unsigned char *s, int len, BIGNUM *ret); + BIGNUM *BN_signed_lebin2bn(const unsigned char *s, int len, BIGNUM *ret); int BN_bn2nativepad(const BIGNUM *a, unsigned char *to, int tolen); + int BN_signed_bn2native(const BIGNUM *a, unsigned char *to, int tolen); BIGNUM *BN_native2bn(const unsigned char *s, int len, BIGNUM *ret); + BIGNUM *BN_signed_native2bn(const unsigned char *s, int len, BIGNUM *ret); char *BN_bn2hex(const BIGNUM *a); char *BN_bn2dec(const BIGNUM *a); @@ -43,17 +50,29 @@ and stores it at B<to>. B<tolen> indicates the length of the output buffer B<to>. The result is padded with zeros if necessary. If B<tolen> is less than BN_num_bytes(B<a>) an error is returned. +BN_signed_bn2bin() converts the value of B<a> into big-endian signed 2's +complements form and stores it at B<to>. B<tolen> indicates the length of +the output buffer B<to>. The result is signed extended (padded with 0x00 +for positive numbers or with 0xff for negative numbers) if necessary. +If B<tolen> is smaller than the necessary size (which may be +C<<BN_num_bytes(B<a>) + 1>>), an error is returned. + BN_bin2bn() converts the positive integer in big-endian form of length B<len> at B<s> into a B<BIGNUM> and places it in B<ret>. If B<ret> is NULL, a new B<BIGNUM> is created. -BN_bn2lebinpad() and BN_lebin2bn() are identical to BN_bn2binpad() and -BN_bin2bn() except the buffer is in little-endian format. +BN_signed_bin2bn() converts the integer in big-endian signed 2's complement +form of length B<len> at B<s> into a B<BIGNUM> and places it in B<ret>. If +B<ret> is NULL, a new B<BIGNUM> is created. + +BN_bn2lebinpad(), BN_signed_bn2lebin() and BN_lebin2bn() are identical to +BN_bn2binpad(), BN_signed_bn2bin() and BN_bin2bn() except the buffer is in +little-endian format. -BN_bn2nativepad() and BN_native2bn() are identical to BN_bn2binpad() and -BN_bin2bn() except the buffer is in native format, i.e. most significant -byte first on big-endian platforms, and least significant byte first on -little-endian platforms. +BN_bn2nativepad(), BN_signed_bn2native() and BN_native2bn() are identical +to BN_bn2binpad(), BN_signed_bn2bin() and BN_bin2bn() except the buffer is +in native format, i.e. most significant byte first on big-endian platforms, +and least significant byte first on little-endian platforms. BN_bn2hex() and BN_bn2dec() return printable strings containing the hexadecimal and decimal encoding of B<a> respectively. For negative @@ -91,8 +110,9 @@ if B<ret> is NULL. BN_bn2bin() returns the length of the big-endian number placed at B<to>. BN_bin2bn() returns the B<BIGNUM>, NULL on error. -BN_bn2binpad(), BN_bn2lebinpad(), and BN_bn2nativepad() return the number of bytes written or -1 if the supplied -buffer is too small. +BN_bn2binpad(), BN_signed_bn2bin(), BN_bn2lebinpad(), BN_signed_bn2lebin(), +BN_bn2nativepad(), and_signed BN_bn2native() return the number of bytes +written or -1 if the supplied buffer is too small. BN_bn2hex() and BN_bn2dec() return a NUL-terminated string, or NULL on error. BN_hex2bn() and BN_dec2bn() return the number of characters |