Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are OpenSSL byte sequences in little endian or big endian order?

I'm trying to use openssl dsa implementation, but I'm very confused with the following details:

  • Option '-text' of the command openssl dsa ....: the hexadecimal numbers in the output, am I correct to assume that those are the bytes, and thus they are in little-Endian order?

  • Functions BN_bn2hex and BN_hex2bn, what Endianess they use?

Thanks in advance for the help.

like image 379
dsign Avatar asked Dec 22 '22 01:12

dsign


1 Answers

OpenSSL treats all series of bytes (unsigned char arrays) as big endian.

The functions BN_bn2hex and BN_hex2bn are for converting to and from a printable format. Printable formats are always in natural reading order, which is big endian.

For non-printable format conversions like bn2bin, the documentation explicitly states that the conversion is big endian. But like I said before, the convention in OpenSSL is big endian for all series of bytes.

like image 195
indiv Avatar answered Apr 15 '23 09:04

indiv