NAME
BNbn2bin, BNbin2bn, BNbn2hex, BNbn2dec, BNhex2bn, BNdec2bn,BNprint, BNprintfp, BNbn2mpi, BNmpi2bn - format conversions
SYNOPSIS
#include
int BNbn2bin(const BIGNUM *a, unsigned char *to); BIGNUM *BNbin2bn(const unsigned char *s, int len, BIGNUM *ret); char *BNbn2hex(const BIGNUM *a); char *BNbn2dec(const BIGNUM *a); int BNhex2bn(BIGNUM **a, const char *str); int BNdec2bn(BIGNUM **a, const char *str); int BNprint(BIO *fp, const BIGNUM *a); int BNprintfp(FILE *fp, const BIGNUM *a); int BNbn2mpi(const BIGNUM *a, unsigned char *to); BIGNUM *BNmpi2bn(unsigned char *s, int len, BIGNUM *ret);DESCRIPTION
BNbn2bin() converts the absolute value of aa into big-endian form and
stores it at ttoo. ttoo must point to BNnumbytes(aa) bytes of memory.BNbin2bn() converts the positive integer in big-endian form of length
lleenn at ss into a BBIIGGNNUUMM and places it in rreett. If rreett is NULL, a new BBIIGGNNUUMM is created. BNbn2hex() and BNbn2dec() return printable strings containing the hexadecimal and decimal encoding of aa respectively. For negativenumbers, the string is prefaced with a leading '-'. The string must be
freed later using OPENSSLfree(). BNhex2bn() converts the string ssttrr containing a hexadecimal number to a BBIIGGNNUUMM and stores it in **bbnn. If *bbnn is NULL, a new BBIIGGNNUUMM is created. If bbnn is NULL, it only computes the number's length inhexadecimal digits. If the string starts with '-', the number is
negative. BNdec2bn() is the same using the decimal system. BNprint() and BNprintfp() write the hexadecimal encoding of aa, witha leading '-' for negative numbers, to the BBIIOO or FFIILLEE ffpp.
BNbn2mpi() and BNmpi2bn() convert BBIIGGNNUUMMs from and to a format thatconsists of the number's length in bytes represented as a 4-byte big-
endian number, and the number itself in big-endian format, where the
most significant bit signals a negative number (the representation of numbers with the MSB set is prefixed with null byte). BNbn2mpi() stores the representation of aa at ttoo, where ttoo must be large enough to hold the result. The size can be determined by calling BNbn2mpi(aa, NULL). BNmpi2bn() converts the lleenn bytes long representation at ss to a BBIIGGNNUUMM and stores it at rreett, or in a newly allocated BBIIGGNNUUMM if rreett is NULL.RETURN VALUES
BNbn2bin() returns the length of the big-endian number placed at ttoo.
BNbin2bn() returns the BBIIGGNNUUMM, NULL on error.BNbn2hex() and BNbn2dec() return a null-terminated string, or NULL on
error. BNhex2bn() and BNdec2bn() return the number's length in hexadecimal or decimal digits, and 0 on error. BNprintfp() and BNprint() return 1 on success, 0 on write errors. BNbn2mpi() returns the length of the representation. BNmpi2bn() returns the BBIIGGNNUUMM, and NULL on error. The error codes can be obtained by ERRgeterror(3).SEE ALSO
bn(3), ERRgeterror(3), BNzero(3), ASN1INTEGERtoBN(3), BNnumbytes(3) HISTORY BNbn2bin(), BNbin2bn(), BNprintfp() and BNprint() are available in all versions of SSLeay and OpenSSL. BNbn2hex(), BNbn2dec(), BNhex2bn(), BNdec2bn(), BNbn2mpi() and BNmpi2bn() were added in SSLeay 0.9.0.0.9.7l 2002-09-25 BNbn2bin(3)