BN_bn2bin(3) OpenSSL BN_bn2bin(3) NNAAMMEE BN_bn2bin, BN_bin2bn, BN_bn2hex, BN_bn2dec, BN_hex2bn, BN_dec2bn, BN_print, BN_print_fp, BN_bn2mpi, BN_mpi2bn - format conversions SSYYNNOOPPSSIISS #include int BN_bn2bin(const BIGNUM *a, unsigned char *to); BIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret); char *BN_bn2hex(const BIGNUM *a); char *BN_bn2dec(const BIGNUM *a); int BN_hex2bn(BIGNUM **a, const char *str); int BN_dec2bn(BIGNUM **a, const char *str); int BN_print(BIO *fp, const BIGNUM *a); int BN_print_fp(FILE *fp, const BIGNUM *a); int BN_bn2mpi(const BIGNUM *a, unsigned char *to); BIGNUM *BN_mpi2bn(unsigned char *s, int len, BIGNUM *ret); DDEESSCCRRIIPPTTIIOONN _B_N___b_n_2_b_i_n_(_) converts the absolute value of aa into big-endian form and stores it at ttoo. ttoo must point to BN_num_bytes(aa) bytes of memory. _B_N___b_i_n_2_b_n_(_) 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. _B_N___b_n_2_h_e_x_(_) and _B_N___b_n_2_d_e_c_(_) return printable strings containing the hexadecimal and decimal encoding of aa respectively. For negative num- bers, the string is prefaced with a leading '-'. The string must be freed later using _O_P_E_N_S_S_L___f_r_e_e_(_). _B_N___h_e_x_2_b_n_(_) converts the string ssttrr containing a hexadecimal number to a BBIIGGNNUUMM and stores it in **bbnn. If *bbnn is NULL, a new BBIIGGNNUUMM is cre- ated. If bbnn is NULL, it only computes the number's length in hexadeci- mal digits. If the string starts with '-', the number is negative. _B_N___d_e_c_2_b_n_(_) is the same using the decimal system. _B_N___p_r_i_n_t_(_) and _B_N___p_r_i_n_t___f_p_(_) write the hexadecimal encoding of aa, with a leading '-' for negative numbers, to the BBIIOO or FFIILLEE ffpp. _B_N___b_n_2_m_p_i_(_) and _B_N___m_p_i_2_b_n_(_) convert BBIIGGNNUUMMs from and to a format that consists 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). _B_N___b_n_2_m_p_i_(_) stores the representation of aa at ttoo, where ttoo must be large enough to hold the result. The size can be determined by calling BN_bn2mpi(aa, NULL). _B_N___m_p_i_2_b_n_(_) 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. RREETTUURRNN VVAALLUUEESS _B_N___b_n_2_b_i_n_(_) returns the length of the big-endian number placed at ttoo. _B_N___b_i_n_2_b_n_(_) returns the BBIIGGNNUUMM, NULL on error. _B_N___b_n_2_h_e_x_(_) and _B_N___b_n_2_d_e_c_(_) return a null-terminated string, or NULL on error. _B_N___h_e_x_2_b_n_(_) and _B_N___d_e_c_2_b_n_(_) return the number's length in hexa- decimal or decimal digits, and 0 on error. _B_N___p_r_i_n_t___f_p_(_) and _B_N___p_r_i_n_t_(_) return 1 on success, 0 on write errors. _B_N___b_n_2_m_p_i_(_) returns the length of the representation. _B_N___m_p_i_2_b_n_(_) returns the BBIIGGNNUUMM, and NULL on error. The error codes can be obtained by _E_R_R___g_e_t___e_r_r_o_r(3). SSEEEE AALLSSOO _b_n(3), _E_R_R___g_e_t___e_r_r_o_r(3), _B_N___z_e_r_o(3), _A_S_N_1___I_N_T_E_G_E_R___t_o___B_N(3), _B_N___n_u_m___b_y_t_e_s(3) HHIISSTTOORRYY _B_N___b_n_2_b_i_n_(_), _B_N___b_i_n_2_b_n_(_), _B_N___p_r_i_n_t___f_p_(_) and _B_N___p_r_i_n_t_(_) are available in all versions of SSLeay and OpenSSL. _B_N___b_n_2_h_e_x_(_), _B_N___b_n_2_d_e_c_(_), _B_N___h_e_x_2_b_n_(_), _B_N___d_e_c_2_b_n_(_), _B_N___b_n_2_m_p_i_(_) and _B_N___m_p_i_2_b_n_(_) were added in SSLeay 0.9.0. 1.0.1u 2016-09-22 BN_bn2bin(3)