Hi All:
I am using mbedtls 2.16.1. I am attempting to migrate from using openssl to using mbedtls.
I am using a test key which has a public exponent (??) of 0x10001. I am using the same pem data in 2 tests. Really it is the same test run on both x86 and ppc. The pem data is stored in memory before calling mbedtls.
I am compiling mbedtls in Linux (gcc) for both x86 and ppc architectures. I have multiple other executables compiled for both platforms. I know my flags are good as far as ppc are concerned (at least in realtion to everything pother than mbedtls). I am not certain about mbedtls flags. I used this same test with openssl way-back-when without issue: i.e. also same pem data.
-
The x86 test works fine.
-
The ppc test fails while attempting to validate the public key. Specifically, it fails while valdiating the public exponent. The failure is detected in mbedtls_rsa_check_pubkey.
The calling function “mbedtls_rsa_check_pubkey” is making this call (line 651 of rsa.c):
if( mbedtls_mpi_get_bit( &ctx->E, 0 ) == 0 ||
I did validate the other calls/values in same if statement: they looked good.
On x86 I am getting a public exponent of 0x10001
where the memory footprint looks like: 01000100
On x86, mbedtls_mpi_get_bit returns 1. This is good.
But on ppc I am getting a public exponent of 16777472 (01000100)
where the memory footprint looks like: 01000100
On ppc, mbedtls_mpi_get_bit returns 0: The least significant bit is 0, so no wonder.
This looks like an endianness issue to me, and I have no idea how to handle this.
Am I suppoosed to let mbedtls read in the data? Thoughts?
Cheers.
Solar.