From ca59bc2d162fa80d4f5f3325be6da158f3d1b183 Mon Sep 17 00:00:00 2001 From: JacobBarthelmeh Date: Mon, 23 Dec 2019 12:33:59 -0700 Subject: [PATCH 1/2] big endian changes --- src/ssl.c | 6 ++++++ wolfcrypt/test/test.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/ssl.c b/src/ssl.c index fc2aa63bf..6c30d2dab 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -21201,6 +21201,9 @@ int wolfSSL_X509_cmp(const WOLFSSL_X509 *a, const WOLFSSL_X509 *b) mp_to_unsigned_bin(&rsa.e, rawKey); if ((word32)rawLen <= sizeof(word32)) { idx = *(word32*)rawKey; + #ifdef BIG_ENDIAN_ORDER + idx = ByteReverseWord32(idx); + #endif } XSNPRINTF(tmp, sizeof(tmp) - 1, "\n Exponent: %d\n", idx); @@ -33316,6 +33319,9 @@ int wolfSSL_RSA_print(WOLFSSL_BIO* bio, WOLFSSL_RSA* rsa, int offset) mp_to_unsigned_bin(rsaElem, rawKey); if ((word32)rawLen <= sizeof(word32)) { idx = *(word32*)rawKey; + #ifdef BIG_ENDIAN_ORDER + idx = ByteReverseWord32(idx); + #endif } XSNPRINTF(tmp, sizeof(tmp) - 1, "\nExponent: %d (0x%x)", idx, idx); if (wolfSSL_BIO_write(bio, tmp, (int)XSTRLEN(tmp)) <= 0) { diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c index ce9e7f443..08902d535 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -21328,7 +21328,13 @@ static int myDecryptionFunc(PKCS7* pkcs7, int encryptOID, byte* iv, int ivSz, /* keyIdRaw[0] OCTET TAG */ /* keyIdRaw[1] Length */ +#ifdef BIG_ENDIAN_ORDER + if (keyIdRaw[1] == 0x01) { + keyId = 1; + } +#else keyId = *(int*)(keyIdRaw + 2); +#endif } From ac0acb3c37aafc228678a380be08d0582c00b5b0 Mon Sep 17 00:00:00 2001 From: JacobBarthelmeh Date: Thu, 26 Dec 2019 05:57:26 -0700 Subject: [PATCH 2/2] fix for test case with big endian --- tests/api.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/api.c b/tests/api.c index 6d23cac3e..256a99895 100644 --- a/tests/api.c +++ b/tests/api.c @@ -25273,7 +25273,11 @@ static void test_wolfSSL_X509V3_EXT_d2i(void) { AssertNotNull(asn1str = (WOLFSSL_ASN1_STRING*)wolfSSL_X509V3_EXT_d2i(ext)); AssertNotNull(data = wolfSSL_ASN1_STRING_data(asn1str)); expected = KEYUSE_KEY_CERT_SIGN | KEYUSE_CRL_SIGN; +#ifdef BIG_ENDIAN_ORDER + actual = data[1]; +#else actual = data[0]; +#endif AssertIntEQ(actual, expected); wolfSSL_ASN1_STRING_free(asn1str); #if 0