From 256836fe6fbdcca91646733b8d7c0118b12e2197 Mon Sep 17 00:00:00 2001 From: gojimmypi Date: Thu, 7 Aug 2025 11:23:34 -0700 Subject: [PATCH] Force WOLFSSL_OLD_OID_SUM for WC_16BIT_CPU --- .wolfssl_known_macro_extras | 1 + wolfssl/wolfcrypt/oid_sum.h | 4 ++++ wolfssl/wolfcrypt/settings.h | 9 +++++++++ 3 files changed, 14 insertions(+) diff --git a/.wolfssl_known_macro_extras b/.wolfssl_known_macro_extras index fafab6e0e..b6c240d2a 100644 --- a/.wolfssl_known_macro_extras +++ b/.wolfssl_known_macro_extras @@ -560,6 +560,7 @@ USE_STSAFE_VERBOSE USE_TLSV13 USE_WOLF_STRNSTR USS_API +WC_16BIT_CPU WC_AESXTS_STREAM_NO_REQUEST_ACCOUNTING WC_AES_BS_WORD_SIZE WC_AES_GCM_DEC_AUTH_EARLY diff --git a/wolfssl/wolfcrypt/oid_sum.h b/wolfssl/wolfcrypt/oid_sum.h index 2c6eadc02..d2663c00c 100644 --- a/wolfssl/wolfcrypt/oid_sum.h +++ b/wolfssl/wolfcrypt/oid_sum.h @@ -26,6 +26,10 @@ #ifndef WOLF_CRYPT_OID_SUM_H #define WOLF_CRYPT_OID_SUM_H +/* Note for some CPUs smaller than 32 bit, the upper 16 bits of new OID + * values may be ignored. If collisions are encountered, consider WC_16BIT_CPU + * and/or WOLFSSL_OLD_OID_SUM to force smaller, old OID values. */ + enum Hash_Sum { #ifdef WOLFSSL_OLD_OID_SUM /* 0x2a,0x86,0x48,0x86,0xf7,0x0d,0x02,0x02 */ diff --git a/wolfssl/wolfcrypt/settings.h b/wolfssl/wolfcrypt/settings.h index 50aa25df4..82925f14e 100644 --- a/wolfssl/wolfcrypt/settings.h +++ b/wolfssl/wolfcrypt/settings.h @@ -4389,6 +4389,15 @@ extern void uITRON4_free(void *p) ; #undef XREALLOC #endif +/* There's currently no 100% reliable "smaller than 32 bit" detection. + * The user can specify: WC_16BIT_CPU + * Lower 16 bits of new OID values may collide on some 16 bit platforms. + * e.g Arduino Mega, fqbn=arduino:avr:mega */ +#if defined(WC_16BIT_CPU) + /* Force the old, 16 bit OIDs to be used in wolfcrypt/oid_sum.h */ + #undef WOLFSSL_OLD_OID_SUM + #define WOLFSSL_OLD_OID_SUM +#endif /* --------------------------------------------------------------------------- * Deprecated Algorithm Handling