engine-corner / engine-chil

The CHIL engine from OpenSSL
3 stars 7 forks source link

Added endianess check #2

Closed urcheon closed 6 years ago

urcheon commented 6 years ago

When converting to and from MPI to BN, we need to have L_ENDIAN defined on little-endian machines. So added AC_C_BIGENDIAN to configure.ac

Also, autoconf is creating a config.h which we weren't using.

levitte commented 6 years ago

I'm à bit confused by this change. I mean, yes, it's good that L_ENDIAN and B_ENDIAN get defined, but I fail to see where those macros are used...

urcheon commented 6 years ago

e_chil.c line 844 and 866

In hwcrhk_mpi_bn2mpi

ifdef L_ENDIAN

if (BN_bn2lebinpad(bn, mpi->buf, mpi_size) != mpi_size) {

else

if (BN_bn2binpad(bn, mpi->buf, mpi_size) != mpi_size) {

endif

In hwcrhk_mpi_mpi2bn

ifdef L_ENDIAN

return BN_lebin2bn(mpi->buf, mpi->size, ret);

else

return BN_bin2bn(mpi->buf, mpi->size, ret);

endif

levitte commented 6 years ago

Ahhh, the code was already there! Makes sense, since this was an internal part of OpenSSL and got those macros served on the compiling command line. Good catch!