Skip to contentSkip to conversation

wolfssl: patch CVE-2025-13912

PATCH In review [email protected] 2 participants 5 messages Feb 24 – Mar 6

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 wolfssl: patch CVE-2025-13912

From: Ankur Tyagi <[email protected]>

Backport changes from PR[1] mentioned in nvd[2]

[1] https://github.com/wolfSSL/wolfssl/pull/9148
[2] https://nvd.nist.gov/vuln/detail/CVE-2025-13912

---
 .../wolfssl/files/CVE-2025-13912.patch        | 439 ++++++++++++++++++
 .../wolfssl/wolfssl_5.8.0.bb                  |   1 +
 2 files changed, 440 insertions(+)
 create mode 100644 meta-networking/recipes-connectivity/wolfssl/files/CVE-2025-13912.patch
meta-networking/recipes-connectivity/wolfssl/files/CVE-2025-13912.patch new file +439 -0
new file mode 100644
index 0000000000..32252058f7
@@ -0,0 +1,439 @@
+From 797e0e7abf5830d515ca838201c03a47f83356b0 Mon Sep 17 00:00:00 2001
+From: Daniel Pouzzner <[email protected]>
+Date: Tue, 30 Sep 2025 20:35:52 -0500
+Subject: [PATCH] Merge pull request #9148 from SparkiDev/ct_volatile
+
+Mark variables as volatile
+
+CVE: CVE-2025-13912
+Upstream-Status: Backport [https://github.com/wolfSSL/wolfssl/commit/234ba7780ad3b7c8c1509973accdc43ed6c328b3]
+Signed-off-by: Ankur Tyagi <[email protected]>
+---
+ src/internal.c         | 25 ++++++++++++---------
+ src/tls.c              |  8 +++++--
+ wolfcrypt/src/aes.c    |  4 ++--
+ wolfcrypt/src/ecc.c    |  8 +++----
+ wolfcrypt/src/misc.c   |  4 ++--
+ wolfcrypt/src/rsa.c    | 18 +++++++++------
+ wolfcrypt/src/sp_int.c | 51 ++++++++++++++++++++++--------------------
+ 7 files changed, 67 insertions(+), 51 deletions(-)
+
+diff --git a/src/internal.c b/src/internal.c
+index eb2f16d63..6b3a227bc 100644
+--- a/src/internal.c
++++ b/src/internal.c
+@@ -20887,7 +20887,7 @@ static byte MaskPadding(const byte* data, int sz, int macSz)
+         checkSz = TLS_MAX_PAD_SZ;
+ 
+     for (i = 0; i < checkSz; i++) {
+-        byte mask = ctMaskLTE(i, paddingSz);
++        volatile byte mask = ctMaskLTE(i, paddingSz);
+         good |= mask & (data[sz - 1 - i] ^ paddingSz);
+     }
+ 
+@@ -20907,16 +20907,21 @@ static byte MaskPadding(const byte* data, int sz, int macSz)
+ static byte MaskMac(const byte* data, int sz, int macSz, byte* expMac)
+ {
+     int i, j;
+-    unsigned char mac[WC_MAX_DIGEST_SIZE];
+-    int scanStart = sz - 1 - TLS_MAX_PAD_SZ - macSz;
+-    int macEnd = sz - 1 - data[sz - 1];
+-    int macStart = macEnd - macSz;
+     int r = 0;
+-    unsigned char started, notEnded;
++    unsigned char mac[WC_MAX_DIGEST_SIZE];
++    volatile int scanStart = sz - 1 - TLS_MAX_PAD_SZ - macSz;
++    volatile int macEnd = sz - 1 - data[sz - 1];
++    volatile int macStart = macEnd - macSz;
++    volatile int maskScanStart;
++    volatile int maskMacStart;
++    volatile unsigned char started;
++    volatile unsigned char notEnded;
+     unsigned char good = 0;
+ 
+-    scanStart &= ctMaskIntGTE(scanStart, 0);
+-    macStart &= ctMaskIntGTE(macStart, 0);
++    maskScanStart = ctMaskIntGTE(scanStart, 0);
++    maskMacStart = ctMaskIntGTE(macStart, 0);
++    scanStart &= maskScanStart;
++    macStart &= maskMacStart;
+ 
+     /* Div on Intel has different speeds depending on value.
+      * Use a bitwise AND or mod a specific value (converted to mul). */
+@@ -41636,7 +41641,7 @@ static int DefTicketEncCb(WOLFSSL* ssl, byte key_name[WOLFSSL_TICKET_NAME_SZ],
+                     case rsa_kea:
+                     {
+                         RsaKey* key = (RsaKey*)ssl->hsKey;
+-                        int lenErrMask;
++                        volatile int lenErrMask;
+ 
+                         ret = RsaDec(ssl,
+                             input + args->idx,
+@@ -41850,7 +41855,7 @@ static int DefTicketEncCb(WOLFSSL* ssl, byte key_name[WOLFSSL_TICKET_NAME_SZ],
+                     case rsa_kea:
+                     {
+                         byte *tmpRsa;
+-                        byte mask;
++                        volatile byte mask;
+ 
+                         /* Add the signature length to idx */
+                         args->idx += args->length;
+diff --git a/src/tls.c b/src/tls.c
+index 6ad21c924..4f57ea938 100644
+--- a/src/tls.c
++++ b/src/tls.c
+@@ -944,7 +944,10 @@ static int Hmac_UpdateFinal_CT(Hmac* hmac, byte* digest, const byte* in,
+     unsigned int k;
+     int          blockBits, blockMask;
+     int          lastBlockLen, extraLen, eocIndex;
+-    int          blocks, safeBlocks, lenBlock, eocBlock;
++    int          blocks;
++    int          safeBlocks;
++    int          lenBlock;
++    int          eocBlock;
+     word32       maxLen;
+     int          blockSz, padSz;
+     int          ret;
+@@ -1054,7 +1057,8 @@ static int Hmac_UpdateFinal_CT(Hmac* hmac, byte* digest, const byte* in,
+ 
+         for (j = 0; j < blockSz; j++) {
+             unsigned char atEoc = ctMaskEq(j, eocIndex) & isEocBlock;
+-            unsigned char pastEoc = ctMaskGT(j, eocIndex) & isEocBlock;
++            volatile unsigned char maskPastEoc = ctMaskGT(j, eocIndex);
++            volatile unsigned char pastEoc = maskPastEoc & isEocBlock;
+             unsigned char b = 0;
+ 
+             if (k < headerSz)
+diff --git a/wolfcrypt/src/aes.c b/wolfcrypt/src/aes.c
+index 6e7f104dd..2cf7c695e 100644
+--- a/wolfcrypt/src/aes.c
++++ b/wolfcrypt/src/aes.c
+@@ -6577,7 +6577,7 @@ static WC_INLINE void RIGHTSHIFTX(byte* x)
+ {
+     int i;
+     int carryIn = 0;
+-    byte borrow = (byte)((0x00U - (x[15] & 0x01U)) & 0xE1U);
++    volatile byte borrow = (byte)((0x00U - (x[15] & 0x01U)) & 0xE1U);
+ 
+     for (i = 0; i < WC_AES_BLOCK_SIZE; i++) {
+         int carryOut = (x[i] & 0x01) << 7;
+@@ -9113,7 +9113,7 @@ int WARN_UNUSED_RESULT AES_GCM_decrypt_C(
+     ALIGN16 byte scratch[WC_AES_BLOCK_SIZE];
+     ALIGN16 byte Tprime[WC_AES_BLOCK_SIZE];
+     ALIGN16 byte EKY0[WC_AES_BLOCK_SIZE];
+-    sword32 res;
++    volatile sword32 res;
+ 
+     if (ivSz == GCM_NONCE_MID_SZ) {
+         /* Counter is IV with bottom 4 bytes set to: 0x00,0x00,0x00,0x01. */
+diff --git a/wolfcrypt/src/ecc.c b/wolfcrypt/src/ecc.c
+index 6d4cd4de7..1fd30cfd9 100644
+--- a/wolfcrypt/src/ecc.c
++++ b/wolfcrypt/src/ecc.c
+@@ -3166,7 +3166,7 @@ static int ecc_mulmod(const mp_int* k, ecc_point* P, ecc_point* Q,
+     ecc_point** R, mp_int* a, mp_int* modulus, mp_digit mp, WC_RNG* rng)
+ {
+     int      err = MP_OKAY;
+-    int      bytes = (mp_count_bits(modulus) + 7) / 8;
++    int      bytes = (mp_count_bits(modulus) + 7) >> 3;
+     int      i;
+     int      j = 1;
+     int      cnt = DIGIT_BIT;
+@@ -3406,7 +3406,7 @@ static int ecc_mulmod(const mp_int* k, ecc_point* P, ecc_point* Q,
+     ecc_point** R, mp_int* a, mp_int* modulus, mp_digit mp, WC_RNG* rng)
+ {
+     int          err = MP_OKAY;
+-    int          bytes = (mp_count_bits(modulus) + 7) / 8;
++    int          bytes = (mp_count_bits(modulus) + 7) >> 3;
+     int          i;
+     int          j = 1;
+     int          cnt;
+@@ -4450,7 +4450,7 @@ int wc_ecc_get_curve_id_from_params(int fieldSize,
+         Gx == NULL || Gy == NULL)
+         return BAD_FUNC_ARG;
+ 
+-    curveSz = (fieldSize + 1) / 8;    /* round up */
++    curveSz = (fieldSize + 1) >> 3;    /* round up */
+ 
+     for (idx = 0; ecc_sets[idx].size != 0; idx++) {
+         if (curveSz == ecc_sets[idx].size) {
+@@ -11922,7 +11922,7 @@ int wc_ecc_sig_size(const ecc_key* key)
+     keySz = key->dp->size;
+     orderBits = wc_ecc_get_curve_order_bit_count(key->dp);
+     if (orderBits > keySz * 8) {
+-        keySz = (orderBits + 7) / 8;
++        keySz = (orderBits + 7) >> 3;
+     }
+     /* maximum possible signature header size is 7 bytes */
+     maxSigSz = (keySz * 2) + SIG_HEADER_SZ;
+diff --git a/wolfcrypt/src/misc.c b/wolfcrypt/src/misc.c
+index 98b83c7ae..496b0dbcc 100644
+--- a/wolfcrypt/src/misc.c
++++ b/wolfcrypt/src/misc.c
+@@ -762,7 +762,7 @@ WC_MISC_STATIC WC_INLINE void ctMaskCopy(byte mask, byte* dst, byte* src,
+     WC_MISC_STATIC WC_INLINE word32 min(word32 a, word32 b)
+     {
+ #if !defined(WOLFSSL_NO_CT_OPS) && defined(WORD64_AVAILABLE)
+-        word32 gte_mask = (word32)ctMaskWord32GTE(a, b);
++        volatile word32 gte_mask = (word32)ctMaskWord32GTE(a, b);
+         return (a & ~gte_mask) | (b & gte_mask);
+ #else /* WOLFSSL_NO_CT_OPS */
+         return a > b ? b : a;
+@@ -778,7 +778,7 @@ WC_MISC_STATIC WC_INLINE void ctMaskCopy(byte mask, byte* dst, byte* src,
+     WC_MISC_STATIC WC_INLINE word32 max(word32 a, word32 b)
+     {
+ #if !defined(WOLFSSL_NO_CT_OPS) && defined(WORD64_AVAILABLE)
+-        word32 gte_mask = (word32)ctMaskWord32GTE(a, b);
++        volatile word32 gte_mask = (word32)ctMaskWord32GTE(a, b);
+         return (a & gte_mask) | (b & ~gte_mask);
+ #else /* WOLFSSL_NO_CT_OPS */
+         return a > b ? a : b;
+diff --git a/wolfcrypt/src/rsa.c b/wolfcrypt/src/rsa.c
+index 94d57bd8b..acd0c04c5 100644
+--- a/wolfcrypt/src/rsa.c
++++ b/wolfcrypt/src/rsa.c
+@@ -1561,11 +1561,11 @@ static int RsaUnPad_OAEP(byte *pkcsBlock, unsigned int pkcsBlockLen,
+                             byte* optLabel, word32 labelLen, void* heap)
+ {
+     word32 hLen;
+-    int ret;
++    volatile int ret;
+     byte h[WC_MAX_DIGEST_SIZE]; /* max digest size */
+     word32 idx;
+     word32 i;
+-    word32 inc;
++    volatile word32 inc;
+ 
+ #if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC)
+     byte* tmp  = NULL;
+@@ -1850,9 +1850,11 @@ static int RsaUnPad(const byte *pkcsBlock, unsigned int pkcsBlockLen,
+     }
+ #ifndef WOLFSSL_RSA_VERIFY_ONLY
+     else {
+-        unsigned int j;
+-        word16 pastSep = 0;
+-        byte   invalid = 0;
++        unsigned int    j;
++        volatile word16 pastSep = 0;
++        volatile byte   invalid = 0;
++        volatile byte   minPad;
++        volatile int    invalidMask;
+ 
+         i = 0;
+         /* Decrypted with private key - unpad must be constant time. */
+@@ -1864,7 +1866,8 @@ static int RsaUnPad(const byte *pkcsBlock, unsigned int pkcsBlockLen,
+         }
+ 
+         /* Minimum of 11 bytes of pre-message data - including leading 0x00. */
+-        invalid |= ctMaskLT(i, RSA_MIN_PAD_SZ);
++        minPad = ctMaskLT(i, RSA_MIN_PAD_SZ);
++        invalid |= minPad;
+         /* Must have seen separator. */
+         invalid |= (byte)~pastSep;
+         /* First byte must be 0x00. */
+@@ -1873,7 +1876,8 @@ static int RsaUnPad(const byte *pkcsBlock, unsigned int pkcsBlockLen,
+         invalid |= ctMaskNotEq(pkcsBlock[1], padValue);
+ 
+         *output = (byte *)(pkcsBlock + i);
+-        ret = ((int)-1 + (int)(invalid >> 7)) & ((int)pkcsBlockLen - i);
++        invalidMask = (int)-1 + (int)(invalid >> 7);
++        ret = invalidMask & ((int)pkcsBlockLen - i);
+     }
+ #endif
+ 
+diff --git a/wolfcrypt/src/sp_int.c b/wolfcrypt/src/sp_int.c
+index 1769840e7..0ee8aa252 100644
+--- a/wolfcrypt/src/sp_int.c
++++ b/wolfcrypt/src/sp_int.c
+@@ -5502,7 +5502,7 @@ int sp_exch(sp_int* a, sp_int* b)
+ int sp_cond_swap_ct_ex(sp_int* a, sp_int* b, int cnt, int swap, sp_int* t)
+ {
+     unsigned int i;
+-    sp_int_digit mask = (sp_int_digit)0 - (sp_int_digit)swap;
++    volatile sp_int_digit mask = (sp_int_digit)0 - (sp_int_digit)swap;
+ 
+     /* XOR other fields in sp_int into temp - mask set when swapping. */
+     t->used = (a->used ^ b->used) & (sp_size_t)mask;
+@@ -5772,7 +5772,7 @@ static int _sp_cmp_ct(const sp_int* a, const sp_int* b, unsigned int n)
+ {
+     int ret = MP_EQ;
+     int i;
+-    int mask = -1;
++    volatile int mask = -1;
+ 
+     for (i = n - 1; i >= 0; i--) {
+         sp_int_digit ad = a->dp[i] & ((sp_int_digit)0 - (i < (int)a->used));
+@@ -7305,7 +7305,8 @@ static void _sp_div_2(const sp_int* a, sp_int* r)
+ 
+     /* Shift down each word by 1 and include bottom bit of next at top. */
+     for (i = 0; i < (int)a->used - 1; i++) {
+-        r->dp[i] = (a->dp[i] >> 1) | (a->dp[i+1] << (SP_WORD_SIZE - 1));
++        r->dp[i]  = a->dp[i] >> 1;
++        r->dp[i] |= a->dp[i+1] << (SP_WORD_SIZE - 1);
+     }
+     /* Last word only needs to be shifted down. */
+     r->dp[i] = a->dp[i] >> 1;
+@@ -7385,7 +7386,7 @@ int sp_div_2_mod_ct(const sp_int* a, const sp_int* m, sp_int* r)
+         sp_int_digit t;
+     #endif
+         /* Mask to apply to modulus. */
+-        sp_int_digit mask = (sp_int_digit)0 - (a->dp[0] & 1);
++        volatile sp_int_digit mask = (sp_int_digit)0 - (a->dp[0] & 1);
+         sp_size_t i;
+ 
+     #if 0
+@@ -7396,7 +7397,7 @@ int sp_div_2_mod_ct(const sp_int* a, const sp_int* m, sp_int* r)
+         /* Add a to m, if a is odd, into r in constant time. */
+         for (i = 0; i < m->used; i++) {
+             /* Mask to apply to a - set when used value at index. */
+-            sp_int_digit mask_a = (sp_int_digit)0 - (i < a->used);
++            volatile sp_int_digit mask_a = (sp_int_digit)0 - (i < a->used);
+ 
+         #ifndef SQR_MUL_ASM
+             /* Conditionally add modulus. */
+@@ -8017,7 +8018,7 @@ static void sp_clamp_ct(sp_int* a)
+ {
+     int i;
+     sp_size_t used = a->used;
+-    sp_size_t mask = (sp_size_t)-1;
++    volatile sp_size_t mask = (sp_size_t)-1;
+ 
+     for (i = (int)a->used - 1; i >= 0; i--) {
+ #if ((SP_WORD_SIZE == 64) && \
+@@ -8066,9 +8067,9 @@ int sp_addmod_ct(const sp_int* a, const sp_int* b, const sp_int* m, sp_int* r)
+     sp_int_digit sh;
+     sp_int_digit t;
+ #endif
+-    sp_int_digit mask;
+-    sp_int_digit mask_a = (sp_int_digit)-1;
+-    sp_int_digit mask_b = (sp_int_digit)-1;
++    volatile sp_int_digit mask;
++    volatile sp_int_digit mask_a = (sp_int_digit)-1;
++    volatile sp_int_digit mask_b = (sp_int_digit)-1;
+     sp_size_t i;
+ 
+     /* Check result is as big as modulus. */
+@@ -8230,9 +8231,9 @@ static void _sp_submod_ct(const sp_int* a, const sp_int* b, const sp_int* m,
+     sp_int_digit h;
+     sp_int_digit t;
+ #endif
+-    sp_int_digit mask;
+-    sp_int_digit mask_a = (sp_int_digit)-1;
+-    sp_int_digit mask_b = (sp_int_digit)-1;
++    volatile sp_int_digit mask;
++    volatile sp_int_digit mask_a = (sp_int_digit)-1;
++    volatile sp_int_digit mask_b = (sp_int_digit)-1;
+     unsigned int i;
+ 
+     /* In constant time, subtract b from a putting result in r. */
+@@ -17458,7 +17459,7 @@ static int _sp_mont_red(sp_int* a, const sp_int* m, sp_int_digit mp, int ct)
+         /* 1. mask = (1 << (NumBits(m) % WORD_SIZE)) - 1
+          *    Mask when last digit of modulus doesn't have highest bit set.
+          */
+-        sp_int_digit mask = (sp_int_digit)
++        volatile sp_int_digit mask = (sp_int_digit)
+             (((sp_int_digit)1 << (bits & (SP_WORD_SIZE - 1))) - 1);
+         /* Overflow. */
+         sp_int_word o = 0;
+@@ -17539,7 +17540,7 @@ static int _sp_mont_red(sp_int* a, const sp_int* m, sp_int_digit mp, int ct)
+     int bits;
+     sp_int_digit mu;
+     sp_int_digit o;
+-    sp_int_digit mask;
++    volatile sp_int_digit mask;
+ 
+ #if 0
+     sp_print(a, "a");
+@@ -18041,7 +18042,7 @@ int sp_unsigned_bin_size(const sp_int* a)
+     int cnt = 0;
+ 
+     if (a != NULL) {
+-        cnt = (sp_count_bits(a) + 7) / 8;
++        cnt = (sp_count_bits(a) + 7) >> 3;
+     }
+ 
+     return cnt;
+@@ -18265,20 +18266,22 @@ int sp_to_unsigned_bin_len_ct(const sp_int* a, byte* out, int outSz)
+         /* Start at the end of the buffer - least significant byte. */
+         int j;
+         unsigned int i;
+-        sp_int_digit mask = (sp_int_digit)-1;
++        volatile sp_int_digit mask = (sp_int_digit)-1;
+         sp_int_digit d;
+ 
+         /* Put each digit in. */
+         i = 0;
+         for (j = outSz - 1; j >= 0; ) {
+             unsigned int b;
++            volatile unsigned int notFull = (i < (unsigned int)a->used - 1);
++
+             d = a->dp[i];
+             /* Place each byte of a digit into the buffer. */
+             for (b = 0; (j >= 0) && (b < SP_WORD_SIZEOF); b++) {
+                 out[j--] = (byte)(d & mask);
+                 d >>= 8;
+             }
+-            mask &= (sp_int_digit)0 - (i < (unsigned int)a->used - 1);
++            mask &= (sp_int_digit)0 - notFull;
+             i += (unsigned int)(1 & mask);
+         }
+     }
+@@ -18289,7 +18292,7 @@ int sp_to_unsigned_bin_len_ct(const sp_int* a, byte* out, int outSz)
+     if (err == MP_OKAY) {
+         unsigned int i;
+         int j;
+-        sp_int_digit mask = (sp_int_digit)-1;
++        volatile sp_int_digit mask = (sp_int_digit)-1;
+ 
+         i = 0;
+         for (j = outSz - 1; j >= 0; j--) {
+@@ -18360,11 +18363,12 @@ static int _sp_read_radix_16(sp_int* a, const char* in)
+     /* Step through string a character at a time starting at end - least
+      * significant byte. */
+     for (i = (int)(XSTRLEN(in) - 1); i >= 0; i--) {
++        volatile char c = in[i];
+         /* Convert character from hex. */
+-        int ch = (int)HexCharToByte(in[i]);
++        int ch = (int)HexCharToByte(c);
+         /* Check for invalid character. */
+         if (ch < 0) {
+-            if (!eol_done && CharIsWhiteSpace(in[i]))
++            if (!eol_done && CharIsWhiteSpace(c))
+                 continue;
+             err = MP_VAL;
+             break;
+@@ -18424,7 +18428,6 @@ static int _sp_read_radix_10(sp_int* a, const char* in)
+ {
+     int  err = MP_OKAY;
+     int  i;
+-    char ch;
+ 
+     /* Start with a being zero. */
+     _sp_zero(a);
+@@ -18432,7 +18435,7 @@ static int _sp_read_radix_10(sp_int* a, const char* in)
+     /* Process all characters. */
+     for (i = 0; in[i] != '\0'; i++) {
+         /* Get character. */
+-        ch = in[i];
++        volatile char ch = in[i];
+         /* Check character is valid. */
+         if ((ch >= '0') && (ch <= '9')) {
+             /* Assume '0'..'9' are continuous values as characters. */
+@@ -18794,7 +18797,7 @@ int sp_radix_size(const sp_int* a, int radix, int* size)
+         }
+         else {
+             /* Count of nibbles. */
+-            int cnt = (sp_count_bits(a) + 3) / 4;
++            int cnt = (sp_count_bits(a) + 3) >> 2;
+         #ifndef WC_DISABLE_RADIX_ZERO_PAD
+             /* Must have even number of nibbles to have complete bytes. */
+             if (cnt & 1) {
+@@ -19404,7 +19407,7 @@ static int _sp_prime_random_trials(const sp_int* a, int trials, int* result,
+ {
+     int err = MP_OKAY;
+     int bits = sp_count_bits(a);
+-    word32 baseSz = ((word32)bits + 7) / 8;
++    word32 baseSz = ((word32)bits + 7) >> 3;
+     DECL_SP_INT_ARRAY(ds, a->used + 1, 2);
+     DECL_SP_INT_ARRAY(d, a->used * 2 + 1, 2);
+ 
meta-networking/recipes-connectivity/wolfssl/wolfssl_5.8.0.bb +1 -0
index af591cfd7a..9cd7c07ad2 100644
@@ -16,6 +16,7 @@ SRC_URI = " \
     git://github.com/wolfSSL/wolfssl.git;protocol=https;branch=master \
     file://0001-wolfssl-wolfcrypt-logging.h-and-wolfcrypt-src-loggin.patch \
     file://run-ptest \
+    file://CVE-2025-13912.patch \
 "
 
 SRCREV = "b077c81eb635392e694ccedbab8b644297ec0285"
#1 lore raw

PATCH 2/3 wolfssl: patch CVE-2025-7395

From: Ankur Tyagi <[email protected]>

Details: https://nvd.nist.gov/vuln/detail/CVE-2025-7395

Backport patches from the PR[1] mentioned in the changelog[2]
[1] github.com/wolfSSL/wolfssl/pull/8833
[2] https://github.com/wolfSSL/wolfssl/blob/master/ChangeLog.md#wolfssl-release-582-july-17-2025

---
 .../wolfssl/files/CVE-2025-7395-1.patch       | 85 +++++++++++++++++++
 .../wolfssl/files/CVE-2025-7395-2.patch       | 28 ++++++
 .../wolfssl/files/CVE-2025-7395-3.patch       | 26 ++++++
 .../wolfssl/files/CVE-2025-7395-4.patch       | 27 ++++++
 .../wolfssl/wolfssl_5.8.0.bb                  |  4 +
 5 files changed, 170 insertions(+)
 create mode 100644 meta-networking/recipes-connectivity/wolfssl/files/CVE-2025-7395-1.patch
 create mode 100644 meta-networking/recipes-connectivity/wolfssl/files/CVE-2025-7395-2.patch
 create mode 100644 meta-networking/recipes-connectivity/wolfssl/files/CVE-2025-7395-3.patch
 create mode 100644 meta-networking/recipes-connectivity/wolfssl/files/CVE-2025-7395-4.patch
meta-networking/recipes-connectivity/wolfssl/files/CVE-2025-7395-1.patch new file +85 -0
new file mode 100644
index 0000000000..576d261dc3
@@ -0,0 +1,85 @@
+From 420f3390c4922febaf54d02a81da1fdab0ad5f04 Mon Sep 17 00:00:00 2001
+From: Ruby Martin <[email protected]>
+Date: Mon, 2 Jun 2025 16:38:32 -0600
+Subject: [PATCH] create policy for WOLFSSL_APPLE_NATIVE_CERT_VALIDATION,
+ domain name checking
+
+CVE: CVE-2025-7395
+Upstream-Status: Backport [https://github.com/wolfSSL/wolfssl/commit/9864959e41bd9259f258c09171ae2ec1c43fbc7f]
+(cherry picked from commit 9864959e41bd9259f258c09171ae2ec1c43fbc7f)
+Signed-off-by: Ankur Tyagi <[email protected]>
+---
+ src/internal.c | 25 ++++++++++++++++++++-----
+ 1 file changed, 20 insertions(+), 5 deletions(-)
+
+diff --git a/src/internal.c b/src/internal.c
+index 6b3a227bc..1b9a469ee 100644
+--- a/src/internal.c
++++ b/src/internal.c
+@@ -211,7 +211,7 @@ int writeAeadAuthData(WOLFSSL* ssl, word16 sz, byte type, byte* additional,
+ #include <Security/SecCertificate.h>
+ #include <Security/SecTrust.h>
+ #include <Security/SecPolicy.h>
+-static int DoAppleNativeCertValidation(const WOLFSSL_BUFFER_INFO* certs,
++static int DoAppleNativeCertValidation(WOLFSSL* ssl, const WOLFSSL_BUFFER_INFO* certs,
+                                             int totalCerts);
+ #endif /* #if defined(__APPLE__) && defined(WOLFSSL_SYS_CA_CERTS) */
+ 
+@@ -16775,7 +16775,7 @@ int ProcessPeerCerts(WOLFSSL* ssl, byte* input, word32* inOutIdx,
+              * into wolfSSL, try to validate against the system certificates
+              * using Apple's native trust APIs */
+             if ((ret != 0) && (ssl->ctx->doAppleNativeCertValidationFlag)) {
+-                if (DoAppleNativeCertValidation(args->certs,
++                if (DoAppleNativeCertValidation(ssl, args->certs,
+                                                      args->totalCerts)) {
+                     WOLFSSL_MSG("Apple native cert chain validation SUCCESS");
+                     ret = 0;
+@@ -42665,7 +42665,8 @@ cleanup:
+  * wolfSSL's built-in certificate validation mechanisms anymore. We instead
+  * must call into the Security Framework APIs to authenticate peer certificates
+  */
+-static int DoAppleNativeCertValidation(const WOLFSSL_BUFFER_INFO* certs,
++static int DoAppleNativeCertValidation(WOLFSSL* ssl,
++                                            const WOLFSSL_BUFFER_INFO* certs,
+                                             int totalCerts)
+ {
+     int i;
+@@ -42674,7 +42675,8 @@ static int DoAppleNativeCertValidation(const WOLFSSL_BUFFER_INFO* certs,
+     CFMutableArrayRef certArray = NULL;
+     SecCertificateRef secCert   = NULL;
+     SecTrustRef       trust     = NULL;
+-    SecPolicyRef      policy    = NULL ;
++    SecPolicyRef      policy    = NULL;
++    CFStringRef       hostname  = NULL;
+ 
+     WOLFSSL_ENTER("DoAppleNativeCertValidation");
+ 
+@@ -42703,7 +42705,17 @@ static int DoAppleNativeCertValidation(const WOLFSSL_BUFFER_INFO* certs,
+     }
+ 
+     /* Create trust object for SecCertifiate Ref */
+-    policy = SecPolicyCreateSSL(true, NULL);
++    if (ssl->buffers.domainName.buffer &&
++            ssl->buffers.domainName.length > 0) {
++        /* Create policy with specified value to require host name match */
++        hostname = CFStringCreateWithCString(kCFAllocatorDefault,
++        (const char*)ssl->buffers.domainName.buffer, kCFStringEncodingUTF8);
++    }
++    if (hostname != NULL) {
++        policy = SecPolicyCreateSSL(true, hostname);
++    } else {
++        policy = SecPolicyCreateSSL(true, NULL);
++    }
+     status = SecTrustCreateWithCertificates(certArray, policy, &trust);
+     if (status != errSecSuccess) {
+         WOLFSSL_MSG_EX("Error creating trust object, "
+@@ -42734,6 +42746,9 @@ cleanup:
+     if (policy) {
+         CFRelease(policy);
+     }
++    if (hostname) {
++        CFRelease(hostname);
++    }
+ 
+     WOLFSSL_LEAVE("DoAppleNativeCertValidation", ret);
+ 
meta-networking/recipes-connectivity/wolfssl/files/CVE-2025-7395-2.patch new file +28 -0
new file mode 100644
index 0000000000..223b6d52a0
@@ -0,0 +1,28 @@
+From 7867076975aa84ebaed4001fae1ebffd013322d5 Mon Sep 17 00:00:00 2001
+From: Brett <[email protected]>
+Date: Wed, 4 Jun 2025 15:48:15 -0600
+Subject: [PATCH] prevent apple native cert validation from overriding error
+ codes other than ASN_NO_SIGNER_E
+
+CVE: CVE-2025-7395
+Upstream-Status: Backport [https://github.com/wolfSSL/wolfssl/commit/bc8eeea703253bd65d472a9541b54fef326e8050]
+(cherry picked from commit bc8eeea703253bd65d472a9541b54fef326e8050)
+Signed-off-by: Ankur Tyagi <[email protected]>
+---
+ src/internal.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/src/internal.c b/src/internal.c
+index 1b9a469ee..6a76eb130 100644
+--- a/src/internal.c
++++ b/src/internal.c
+@@ -16774,7 +16774,8 @@ int ProcessPeerCerts(WOLFSSL* ssl, byte* input, word32* inOutIdx,
+             /* If we can't validate the peer cert chain against the CAs loaded
+              * into wolfSSL, try to validate against the system certificates
+              * using Apple's native trust APIs */
+-            if ((ret != 0) && (ssl->ctx->doAppleNativeCertValidationFlag)) {
++            if ((ret == ASN_NO_SIGNER_E) &&
++                (ssl->ctx->doAppleNativeCertValidationFlag)) {
+                 if (DoAppleNativeCertValidation(ssl, args->certs,
+                                                      args->totalCerts)) {
+                     WOLFSSL_MSG("Apple native cert chain validation SUCCESS");
meta-networking/recipes-connectivity/wolfssl/files/CVE-2025-7395-3.patch new file +26 -0
new file mode 100644
index 0000000000..f786656765
@@ -0,0 +1,26 @@
+From 70302af2c21a121845e1e721ed27b3b106f186f6 Mon Sep 17 00:00:00 2001
+From: Brett <[email protected]>
+Date: Wed, 4 Jun 2025 16:56:16 -0600
+Subject: [PATCH] add missing error trace macro
+
+CVE: CVE-2025-7395
+Upstream-Status: Backport [https://github.com/wolfSSL/wolfssl/commit/0e2a3fd0b64bc6ba633aa9227e92ecacb42b5b1b]
+(cherry picked from commit 0e2a3fd0b64bc6ba633aa9227e92ecacb42b5b1b)
+Signed-off-by: Ankur Tyagi <[email protected]>
+---
+ src/internal.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/internal.c b/src/internal.c
+index 6a76eb130..1d01ee095 100644
+--- a/src/internal.c
++++ b/src/internal.c
+@@ -16774,7 +16774,7 @@ int ProcessPeerCerts(WOLFSSL* ssl, byte* input, word32* inOutIdx,
+             /* If we can't validate the peer cert chain against the CAs loaded
+              * into wolfSSL, try to validate against the system certificates
+              * using Apple's native trust APIs */
+-            if ((ret == ASN_NO_SIGNER_E) &&
++            if ((ret == WC_NO_ERR_TRACE(ASN_NO_SIGNER_E)) &&
+                 (ssl->ctx->doAppleNativeCertValidationFlag)) {
+                 if (DoAppleNativeCertValidation(ssl, args->certs,
+                                                      args->totalCerts)) {
meta-networking/recipes-connectivity/wolfssl/files/CVE-2025-7395-4.patch new file +27 -0
new file mode 100644
index 0000000000..8af431f938
@@ -0,0 +1,27 @@
+From 71d4cb57ceada7830457938787583c2aa6ba3555 Mon Sep 17 00:00:00 2001
+From: Brett <[email protected]>
+Date: Wed, 4 Jun 2025 18:29:05 -0600
+Subject: [PATCH] formatting
+
+CVE: CVE-2025-7395
+Upstream-Status: Backport [https://github.com/wolfSSL/wolfssl/commit/89be92f1a8b255d85c0d8bfb8849571d259c199c]
+(cherry picked from commit 89be92f1a8b255d85c0d8bfb8849571d259c199c)
+Signed-off-by: Ankur Tyagi <[email protected]>
+---
+ src/internal.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/src/internal.c b/src/internal.c
+index 1d01ee095..992c10d2c 100644
+--- a/src/internal.c
++++ b/src/internal.c
+@@ -42710,7 +42710,8 @@ static int DoAppleNativeCertValidation(WOLFSSL* ssl,
+             ssl->buffers.domainName.length > 0) {
+         /* Create policy with specified value to require host name match */
+         hostname = CFStringCreateWithCString(kCFAllocatorDefault,
+-        (const char*)ssl->buffers.domainName.buffer, kCFStringEncodingUTF8);
++                                (const char*)ssl->buffers.domainName.buffer,
++                                 kCFStringEncodingUTF8);
+     }
+     if (hostname != NULL) {
+         policy = SecPolicyCreateSSL(true, hostname);
meta-networking/recipes-connectivity/wolfssl/wolfssl_5.8.0.bb +4 -0
index 9cd7c07ad2..4f323ec128 100644
@@ -17,6 +17,10 @@ SRC_URI = " \
     file://0001-wolfssl-wolfcrypt-logging.h-and-wolfcrypt-src-loggin.patch \
     file://run-ptest \
     file://CVE-2025-13912.patch \
+    file://CVE-2025-7395-1.patch \
+    file://CVE-2025-7395-2.patch \
+    file://CVE-2025-7395-3.patch \
+    file://CVE-2025-7395-4.patch \
 "
 
 SRCREV = "b077c81eb635392e694ccedbab8b644297ec0285"
#2 lore raw

PATCH 3/3 wolfssl: patch CVE-2025-7394

In reply to [email protected]

From: Ankur Tyagi <[email protected]>

Details: https://nvd.nist.gov/vuln/detail/CVE-2025-7394

Backport patches from the PR[1][2][3] mentioned in the changelog[4].

[1] https://github.com/wolfSSL/wolfssl/pull/8849
[2] https://github.com/wolfSSL/wolfssl/pull/8867
[3] https://github.com/wolfSSL/wolfssl/pull/8898
[4] https://github.com/wolfSSL/wolfssl/blob/master/ChangeLog.md#wolfssl-release-582-july-17-2025

Dropped changes to github workflow and tests during backport.

---
 .../wolfssl/files/CVE-2025-7394-1.patch       |  46 +++
 .../wolfssl/files/CVE-2025-7394-2.patch       | 276 ++++++++++++++++++
 .../wolfssl/files/CVE-2025-7394-3.patch       | 125 ++++++++
 .../wolfssl/files/CVE-2025-7394-4.patch       |  88 ++++++
 .../wolfssl/files/CVE-2025-7394-5.patch       |  42 +++
 .../wolfssl/files/CVE-2025-7394-6.patch       |  49 ++++
 .../wolfssl/wolfssl_5.8.0.bb                  |   6 +
 7 files changed, 632 insertions(+)
 create mode 100644 meta-networking/recipes-connectivity/wolfssl/files/CVE-2025-7394-1.patch
 create mode 100644 meta-networking/recipes-connectivity/wolfssl/files/CVE-2025-7394-2.patch
 create mode 100644 meta-networking/recipes-connectivity/wolfssl/files/CVE-2025-7394-3.patch
 create mode 100644 meta-networking/recipes-connectivity/wolfssl/files/CVE-2025-7394-4.patch
 create mode 100644 meta-networking/recipes-connectivity/wolfssl/files/CVE-2025-7394-5.patch
 create mode 100644 meta-networking/recipes-connectivity/wolfssl/files/CVE-2025-7394-6.patch
meta-networking/recipes-connectivity/wolfssl/files/CVE-2025-7394-1.patch new file +46 -0
new file mode 100644
index 0000000000..5c680cd7cd
@@ -0,0 +1,46 @@
+From 95f350e136ed89eadb1de68d82b7357b9078d167 Mon Sep 17 00:00:00 2001
+From: Josh Holtrop <[email protected]>
+Date: Thu, 5 Jun 2025 19:48:34 -0400
+Subject: [PATCH] Reseed DRBG in RAND_poll()
+
+CVE: CVE-2025-7394
+Upstream-Status: Backport [https://github.com/wolfSSL/wolfssl/commit/0c12337194ee6dd082f082f0ccaed27fc4ee44f5]
+(cherry picked from commit 0c12337194ee6dd082f082f0ccaed27fc4ee44f5)
+Signed-off-by: Ankur Tyagi <[email protected]>
+---
+ src/ssl.c | 20 +++++++++++++++++---
+ 1 file changed, 17 insertions(+), 3 deletions(-)
+
+diff --git a/src/ssl.c b/src/ssl.c
+index 0b74065fa..95739f098 100644
+--- a/src/ssl.c
++++ b/src/ssl.c
+@@ -26017,11 +26017,25 @@ int wolfSSL_RAND_poll(void)
+         return  WOLFSSL_FAILURE;
+     }
+     ret = wc_GenerateSeed(&globalRNG.seed, entropy, entropy_sz);
+-    if (ret != 0){
++    if (ret != 0) {
+         WOLFSSL_MSG("Bad wc_RNG_GenerateBlock");
+         ret = WOLFSSL_FAILURE;
+-    }else
+-        ret = WOLFSSL_SUCCESS;
++    }
++    else {
++#ifdef HAVE_HASHDRBG
++        ret = wc_RNG_DRBG_Reseed(&globalRNG, entropy, entropy_sz);
++        if (ret != 0) {
++            WOLFSSL_MSG("Error reseeding DRBG");
++            ret = WOLFSSL_FAILURE;
++        }
++        else {
++            ret = WOLFSSL_SUCCESS;
++        }
++#else
++        WOLFSSL_MSG("RAND_poll called with HAVE_HASHDRBG not set");
++        ret = WOLFSSL_FAILURE;
++#endif
++    }
+ 
+     return ret;
+ }
meta-networking/recipes-connectivity/wolfssl/files/CVE-2025-7394-2.patch new file +276 -0

276 lines not on this page · raw message

meta-networking/recipes-connectivity/wolfssl/files/CVE-2025-7394-3.patch new file +125 -0

125 lines not on this page · raw message

meta-networking/recipes-connectivity/wolfssl/files/CVE-2025-7394-4.patch new file +88 -0

88 lines not on this page · raw message

meta-networking/recipes-connectivity/wolfssl/files/CVE-2025-7394-5.patch new file +42 -0

42 lines not on this page · raw message

meta-networking/recipes-connectivity/wolfssl/files/CVE-2025-7394-6.patch new file +49 -0

49 lines not on this page · raw message

meta-networking/recipes-connectivity/wolfssl/wolfssl_5.8.0.bb +6 -0
index 4f323ec128..78d17630c7 100644
@@ -21,6 +21,12 @@ SRC_URI = " \
     file://CVE-2025-7395-2.patch \
     file://CVE-2025-7395-3.patch \
     file://CVE-2025-7395-4.patch \
+    file://CVE-2025-7394-1.patch \
+    file://CVE-2025-7394-2.patch \
+    file://CVE-2025-7394-3.patch \
+    file://CVE-2025-7394-4.patch \
+    file://CVE-2025-7394-5.patch \
+    file://CVE-2025-7394-6.patch \
 "
 
 SRCREV = "b077c81eb635392e694ccedbab8b644297ec0285"
#3 lore raw
In reply to [email protected]
Quoted 29 lines · Ankur Tyagi via lists.openembedded.org

From: Ankur Tyagi <[email protected]>

Backport changes from PR[1] mentioned in nvd[2]

[1] https://github.com/wolfSSL/wolfssl/pull/9148
[2] https://nvd.nist.gov/vuln/detail/CVE-2025-13912

---
 .../wolfssl/files/CVE-2025-13912.patch        | 439 ++++++++++++++++++
 .../wolfssl/wolfssl_5.8.0.bb                  |   1 +
 2 files changed, 440 insertions(+)
 create mode 100644 meta-networking/recipes-connectivity/wolfssl/files/CVE-2025-13912.patch
meta-networking/recipes-connectivity/wolfssl/files/CVE-2025-13912.patch new file +8 -0
new file mode 100644
index 0000000000..32252058f7
@@ -0,0 +1,439 @@
+From 797e0e7abf5830d515ca838201c03a47f83356b0 Mon Sep 17 00:00:00 2001
+From: Daniel Pouzzner <[email protected]>
+Date: Tue, 30 Sep 2025 20:35:52 -0500
+Subject: [PATCH] Merge pull request #9148 from SparkiDev/ct_volatile
+
+Mark variables as volatile
+
+CVE: CVE-2025-13912

meta-networking/recipes-connectivity/wolfssl/files/CVE-2025-13912.patch line 18

Quoted 10 lines
meta-networking/recipes-connectivity/wolfssl/files/CVE-2025-13912.patch new file +10 -0
+Upstream-Status: Backport [https://github.com/wolfSSL/wolfssl/commit/234ba7780ad3b7c8c1509973accdc43ed6c328b3]
+Signed-off-by: Ankur Tyagi <[email protected]>
+---
+ src/internal.c         | 25 ++++++++++++---------
+ src/tls.c              |  8 +++++--
+ wolfcrypt/src/aes.c    |  4 ++--
+ wolfcrypt/src/ecc.c    |  8 +++----
+ wolfcrypt/src/misc.c   |  4 ++--
+ wolfcrypt/src/rsa.c    | 18 +++++++++------
+ wolfcrypt/src/sp_int.c | 51 ++++++++++++++++++++++--------------------

This seems to be missing a few more volatile related changes when compared to the patch mentioned above. Did you skip those on purpose?

Quoted 442 lines
meta-networking/recipes-connectivity/wolfssl/files/CVE-2025-13912.patch new file +421 -0
+ 7 files changed, 67 insertions(+), 51 deletions(-)
+
+diff --git a/src/internal.c b/src/internal.c
+index eb2f16d63..6b3a227bc 100644
+--- a/src/internal.c
++++ b/src/internal.c
+@@ -20887,7 +20887,7 @@ static byte MaskPadding(const byte* data, int sz, int macSz)
+         checkSz = TLS_MAX_PAD_SZ;
+
+     for (i = 0; i < checkSz; i++) {
+-        byte mask = ctMaskLTE(i, paddingSz);
++        volatile byte mask = ctMaskLTE(i, paddingSz);
+         good |= mask & (data[sz - 1 - i] ^ paddingSz);
+     }
+
+@@ -20907,16 +20907,21 @@ static byte MaskPadding(const byte* data, int sz, int macSz)
+ static byte MaskMac(const byte* data, int sz, int macSz, byte* expMac)
+ {
+     int i, j;
+-    unsigned char mac[WC_MAX_DIGEST_SIZE];
+-    int scanStart = sz - 1 - TLS_MAX_PAD_SZ - macSz;
+-    int macEnd = sz - 1 - data[sz - 1];
+-    int macStart = macEnd - macSz;
+     int r = 0;
+-    unsigned char started, notEnded;
++    unsigned char mac[WC_MAX_DIGEST_SIZE];
++    volatile int scanStart = sz - 1 - TLS_MAX_PAD_SZ - macSz;
++    volatile int macEnd = sz - 1 - data[sz - 1];
++    volatile int macStart = macEnd - macSz;
++    volatile int maskScanStart;
++    volatile int maskMacStart;
++    volatile unsigned char started;
++    volatile unsigned char notEnded;
+     unsigned char good = 0;
+
+-    scanStart &= ctMaskIntGTE(scanStart, 0);
+-    macStart &= ctMaskIntGTE(macStart, 0);
++    maskScanStart = ctMaskIntGTE(scanStart, 0);
++    maskMacStart = ctMaskIntGTE(macStart, 0);
++    scanStart &= maskScanStart;
++    macStart &= maskMacStart;
+
+     /* Div on Intel has different speeds depending on value.
+      * Use a bitwise AND or mod a specific value (converted to mul). */
+@@ -41636,7 +41641,7 @@ static int DefTicketEncCb(WOLFSSL* ssl, byte key_name[WOLFSSL_TICKET_NAME_SZ],
+                     case rsa_kea:
+                     {
+                         RsaKey* key = (RsaKey*)ssl->hsKey;
+-                        int lenErrMask;
++                        volatile int lenErrMask;
+
+                         ret = RsaDec(ssl,
+                             input + args->idx,
+@@ -41850,7 +41855,7 @@ static int DefTicketEncCb(WOLFSSL* ssl, byte key_name[WOLFSSL_TICKET_NAME_SZ],
+                     case rsa_kea:
+                     {
+                         byte *tmpRsa;
+-                        byte mask;
++                        volatile byte mask;
+
+                         /* Add the signature length to idx */
+                         args->idx += args->length;
+diff --git a/src/tls.c b/src/tls.c
+index 6ad21c924..4f57ea938 100644
+--- a/src/tls.c
++++ b/src/tls.c
+@@ -944,7 +944,10 @@ static int Hmac_UpdateFinal_CT(Hmac* hmac, byte* digest, const byte* in,
+     unsigned int k;
+     int          blockBits, blockMask;
+     int          lastBlockLen, extraLen, eocIndex;
+-    int          blocks, safeBlocks, lenBlock, eocBlock;
++    int          blocks;
++    int          safeBlocks;
++    int          lenBlock;
++    int          eocBlock;
+     word32       maxLen;
+     int          blockSz, padSz;
+     int          ret;
+@@ -1054,7 +1057,8 @@ static int Hmac_UpdateFinal_CT(Hmac* hmac, byte* digest, const byte* in,
+
+         for (j = 0; j < blockSz; j++) {
+             unsigned char atEoc = ctMaskEq(j, eocIndex) & isEocBlock;
+-            unsigned char pastEoc = ctMaskGT(j, eocIndex) & isEocBlock;
++            volatile unsigned char maskPastEoc = ctMaskGT(j, eocIndex);
++            volatile unsigned char pastEoc = maskPastEoc & isEocBlock;
+             unsigned char b = 0;
+
+             if (k < headerSz)
+diff --git a/wolfcrypt/src/aes.c b/wolfcrypt/src/aes.c
+index 6e7f104dd..2cf7c695e 100644
+--- a/wolfcrypt/src/aes.c
++++ b/wolfcrypt/src/aes.c
+@@ -6577,7 +6577,7 @@ static WC_INLINE void RIGHTSHIFTX(byte* x)
+ {
+     int i;
+     int carryIn = 0;
+-    byte borrow = (byte)((0x00U - (x[15] & 0x01U)) & 0xE1U);
++    volatile byte borrow = (byte)((0x00U - (x[15] & 0x01U)) & 0xE1U);
+
+     for (i = 0; i < WC_AES_BLOCK_SIZE; i++) {
+         int carryOut = (x[i] & 0x01) << 7;
+@@ -9113,7 +9113,7 @@ int WARN_UNUSED_RESULT AES_GCM_decrypt_C(
+     ALIGN16 byte scratch[WC_AES_BLOCK_SIZE];
+     ALIGN16 byte Tprime[WC_AES_BLOCK_SIZE];
+     ALIGN16 byte EKY0[WC_AES_BLOCK_SIZE];
+-    sword32 res;
++    volatile sword32 res;
+
+     if (ivSz == GCM_NONCE_MID_SZ) {
+         /* Counter is IV with bottom 4 bytes set to: 0x00,0x00,0x00,0x01. */
+diff --git a/wolfcrypt/src/ecc.c b/wolfcrypt/src/ecc.c
+index 6d4cd4de7..1fd30cfd9 100644
+--- a/wolfcrypt/src/ecc.c
++++ b/wolfcrypt/src/ecc.c
+@@ -3166,7 +3166,7 @@ static int ecc_mulmod(const mp_int* k, ecc_point* P, ecc_point* Q,
+     ecc_point** R, mp_int* a, mp_int* modulus, mp_digit mp, WC_RNG* rng)
+ {
+     int      err = MP_OKAY;
+-    int      bytes = (mp_count_bits(modulus) + 7) / 8;
++    int      bytes = (mp_count_bits(modulus) + 7) >> 3;
+     int      i;
+     int      j = 1;
+     int      cnt = DIGIT_BIT;
+@@ -3406,7 +3406,7 @@ static int ecc_mulmod(const mp_int* k, ecc_point* P, ecc_point* Q,
+     ecc_point** R, mp_int* a, mp_int* modulus, mp_digit mp, WC_RNG* rng)
+ {
+     int          err = MP_OKAY;
+-    int          bytes = (mp_count_bits(modulus) + 7) / 8;
++    int          bytes = (mp_count_bits(modulus) + 7) >> 3;
+     int          i;
+     int          j = 1;
+     int          cnt;
+@@ -4450,7 +4450,7 @@ int wc_ecc_get_curve_id_from_params(int fieldSize,
+         Gx == NULL || Gy == NULL)
+         return BAD_FUNC_ARG;
+
+-    curveSz = (fieldSize + 1) / 8;    /* round up */
++    curveSz = (fieldSize + 1) >> 3;    /* round up */
+
+     for (idx = 0; ecc_sets[idx].size != 0; idx++) {
+         if (curveSz == ecc_sets[idx].size) {
+@@ -11922,7 +11922,7 @@ int wc_ecc_sig_size(const ecc_key* key)
+     keySz = key->dp->size;
+     orderBits = wc_ecc_get_curve_order_bit_count(key->dp);
+     if (orderBits > keySz * 8) {
+-        keySz = (orderBits + 7) / 8;
++        keySz = (orderBits + 7) >> 3;
+     }
+     /* maximum possible signature header size is 7 bytes */
+     maxSigSz = (keySz * 2) + SIG_HEADER_SZ;
+diff --git a/wolfcrypt/src/misc.c b/wolfcrypt/src/misc.c
+index 98b83c7ae..496b0dbcc 100644
+--- a/wolfcrypt/src/misc.c
++++ b/wolfcrypt/src/misc.c
+@@ -762,7 +762,7 @@ WC_MISC_STATIC WC_INLINE void ctMaskCopy(byte mask, byte* dst, byte* src,
+     WC_MISC_STATIC WC_INLINE word32 min(word32 a, word32 b)
+     {
+ #if !defined(WOLFSSL_NO_CT_OPS) && defined(WORD64_AVAILABLE)
+-        word32 gte_mask = (word32)ctMaskWord32GTE(a, b);
++        volatile word32 gte_mask = (word32)ctMaskWord32GTE(a, b);
+         return (a & ~gte_mask) | (b & gte_mask);
+ #else /* WOLFSSL_NO_CT_OPS */
+         return a > b ? b : a;
+@@ -778,7 +778,7 @@ WC_MISC_STATIC WC_INLINE void ctMaskCopy(byte mask, byte* dst, byte* src,
+     WC_MISC_STATIC WC_INLINE word32 max(word32 a, word32 b)
+     {
+ #if !defined(WOLFSSL_NO_CT_OPS) && defined(WORD64_AVAILABLE)
+-        word32 gte_mask = (word32)ctMaskWord32GTE(a, b);
++        volatile word32 gte_mask = (word32)ctMaskWord32GTE(a, b);
+         return (a & gte_mask) | (b & ~gte_mask);
+ #else /* WOLFSSL_NO_CT_OPS */
+         return a > b ? a : b;
+diff --git a/wolfcrypt/src/rsa.c b/wolfcrypt/src/rsa.c
+index 94d57bd8b..acd0c04c5 100644
+--- a/wolfcrypt/src/rsa.c
++++ b/wolfcrypt/src/rsa.c
+@@ -1561,11 +1561,11 @@ static int RsaUnPad_OAEP(byte *pkcsBlock, unsigned int pkcsBlockLen,
+                             byte* optLabel, word32 labelLen, void* heap)
+ {
+     word32 hLen;
+-    int ret;
++    volatile int ret;
+     byte h[WC_MAX_DIGEST_SIZE]; /* max digest size */
+     word32 idx;
+     word32 i;
+-    word32 inc;
++    volatile word32 inc;
+
+ #if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC)
+     byte* tmp  = NULL;
+@@ -1850,9 +1850,11 @@ static int RsaUnPad(const byte *pkcsBlock, unsigned int pkcsBlockLen,
+     }
+ #ifndef WOLFSSL_RSA_VERIFY_ONLY
+     else {
+-        unsigned int j;
+-        word16 pastSep = 0;
+-        byte   invalid = 0;
++        unsigned int    j;
++        volatile word16 pastSep = 0;
++        volatile byte   invalid = 0;
++        volatile byte   minPad;
++        volatile int    invalidMask;
+
+         i = 0;
+         /* Decrypted with private key - unpad must be constant time. */
+@@ -1864,7 +1866,8 @@ static int RsaUnPad(const byte *pkcsBlock, unsigned int pkcsBlockLen,
+         }
+
+         /* Minimum of 11 bytes of pre-message data - including leading 0x00. */
+-        invalid |= ctMaskLT(i, RSA_MIN_PAD_SZ);
++        minPad = ctMaskLT(i, RSA_MIN_PAD_SZ);
++        invalid |= minPad;
+         /* Must have seen separator. */
+         invalid |= (byte)~pastSep;
+         /* First byte must be 0x00. */
+@@ -1873,7 +1876,8 @@ static int RsaUnPad(const byte *pkcsBlock, unsigned int pkcsBlockLen,
+         invalid |= ctMaskNotEq(pkcsBlock[1], padValue);
+
+         *output = (byte *)(pkcsBlock + i);
+-        ret = ((int)-1 + (int)(invalid >> 7)) & ((int)pkcsBlockLen - i);
++        invalidMask = (int)-1 + (int)(invalid >> 7);
++        ret = invalidMask & ((int)pkcsBlockLen - i);
+     }
+ #endif
+
+diff --git a/wolfcrypt/src/sp_int.c b/wolfcrypt/src/sp_int.c
+index 1769840e7..0ee8aa252 100644
+--- a/wolfcrypt/src/sp_int.c
++++ b/wolfcrypt/src/sp_int.c
+@@ -5502,7 +5502,7 @@ int sp_exch(sp_int* a, sp_int* b)
+ int sp_cond_swap_ct_ex(sp_int* a, sp_int* b, int cnt, int swap, sp_int* t)
+ {
+     unsigned int i;
+-    sp_int_digit mask = (sp_int_digit)0 - (sp_int_digit)swap;
++    volatile sp_int_digit mask = (sp_int_digit)0 - (sp_int_digit)swap;
+
+     /* XOR other fields in sp_int into temp - mask set when swapping. */
+     t->used = (a->used ^ b->used) & (sp_size_t)mask;
+@@ -5772,7 +5772,7 @@ static int _sp_cmp_ct(const sp_int* a, const sp_int* b, unsigned int n)
+ {
+     int ret = MP_EQ;
+     int i;
+-    int mask = -1;
++    volatile int mask = -1;
+
+     for (i = n - 1; i >= 0; i--) {
+         sp_int_digit ad = a->dp[i] & ((sp_int_digit)0 - (i < (int)a->used));
+@@ -7305,7 +7305,8 @@ static void _sp_div_2(const sp_int* a, sp_int* r)
+
+     /* Shift down each word by 1 and include bottom bit of next at top. */
+     for (i = 0; i < (int)a->used - 1; i++) {
+-        r->dp[i] = (a->dp[i] >> 1) | (a->dp[i+1] << (SP_WORD_SIZE - 1));
++        r->dp[i]  = a->dp[i] >> 1;
++        r->dp[i] |= a->dp[i+1] << (SP_WORD_SIZE - 1);
+     }
+     /* Last word only needs to be shifted down. */
+     r->dp[i] = a->dp[i] >> 1;
+@@ -7385,7 +7386,7 @@ int sp_div_2_mod_ct(const sp_int* a, const sp_int* m, sp_int* r)
+         sp_int_digit t;
+     #endif
+         /* Mask to apply to modulus. */
+-        sp_int_digit mask = (sp_int_digit)0 - (a->dp[0] & 1);
++        volatile sp_int_digit mask = (sp_int_digit)0 - (a->dp[0] & 1);
+         sp_size_t i;
+
+     #if 0
+@@ -7396,7 +7397,7 @@ int sp_div_2_mod_ct(const sp_int* a, const sp_int* m, sp_int* r)
+         /* Add a to m, if a is odd, into r in constant time. */
+         for (i = 0; i < m->used; i++) {
+             /* Mask to apply to a - set when used value at index. */
+-            sp_int_digit mask_a = (sp_int_digit)0 - (i < a->used);
++            volatile sp_int_digit mask_a = (sp_int_digit)0 - (i < a->used);
+
+         #ifndef SQR_MUL_ASM
+             /* Conditionally add modulus. */
+@@ -8017,7 +8018,7 @@ static void sp_clamp_ct(sp_int* a)
+ {
+     int i;
+     sp_size_t used = a->used;
+-    sp_size_t mask = (sp_size_t)-1;
++    volatile sp_size_t mask = (sp_size_t)-1;
+
+     for (i = (int)a->used - 1; i >= 0; i--) {
+ #if ((SP_WORD_SIZE == 64) && \
+@@ -8066,9 +8067,9 @@ int sp_addmod_ct(const sp_int* a, const sp_int* b, const sp_int* m, sp_int* r)
+     sp_int_digit sh;
+     sp_int_digit t;
+ #endif
+-    sp_int_digit mask;
+-    sp_int_digit mask_a = (sp_int_digit)-1;
+-    sp_int_digit mask_b = (sp_int_digit)-1;
++    volatile sp_int_digit mask;
++    volatile sp_int_digit mask_a = (sp_int_digit)-1;
++    volatile sp_int_digit mask_b = (sp_int_digit)-1;
+     sp_size_t i;
+
+     /* Check result is as big as modulus. */
+@@ -8230,9 +8231,9 @@ static void _sp_submod_ct(const sp_int* a, const sp_int* b, const sp_int* m,
+     sp_int_digit h;
+     sp_int_digit t;
+ #endif
+-    sp_int_digit mask;
+-    sp_int_digit mask_a = (sp_int_digit)-1;
+-    sp_int_digit mask_b = (sp_int_digit)-1;
++    volatile sp_int_digit mask;
++    volatile sp_int_digit mask_a = (sp_int_digit)-1;
++    volatile sp_int_digit mask_b = (sp_int_digit)-1;
+     unsigned int i;
+
+     /* In constant time, subtract b from a putting result in r. */
+@@ -17458,7 +17459,7 @@ static int _sp_mont_red(sp_int* a, const sp_int* m, sp_int_digit mp, int ct)
+         /* 1. mask = (1 << (NumBits(m) % WORD_SIZE)) - 1
+          *    Mask when last digit of modulus doesn't have highest bit set.
+          */
+-        sp_int_digit mask = (sp_int_digit)
++        volatile sp_int_digit mask = (sp_int_digit)
+             (((sp_int_digit)1 << (bits & (SP_WORD_SIZE - 1))) - 1);
+         /* Overflow. */
+         sp_int_word o = 0;
+@@ -17539,7 +17540,7 @@ static int _sp_mont_red(sp_int* a, const sp_int* m, sp_int_digit mp, int ct)
+     int bits;
+     sp_int_digit mu;
+     sp_int_digit o;
+-    sp_int_digit mask;
++    volatile sp_int_digit mask;
+
+ #if 0
+     sp_print(a, "a");
+@@ -18041,7 +18042,7 @@ int sp_unsigned_bin_size(const sp_int* a)
+     int cnt = 0;
+
+     if (a != NULL) {
+-        cnt = (sp_count_bits(a) + 7) / 8;
++        cnt = (sp_count_bits(a) + 7) >> 3;
+     }
+
+     return cnt;
+@@ -18265,20 +18266,22 @@ int sp_to_unsigned_bin_len_ct(const sp_int* a, byte* out, int outSz)
+         /* Start at the end of the buffer - least significant byte. */
+         int j;
+         unsigned int i;
+-        sp_int_digit mask = (sp_int_digit)-1;
++        volatile sp_int_digit mask = (sp_int_digit)-1;
+         sp_int_digit d;
+
+         /* Put each digit in. */
+         i = 0;
+         for (j = outSz - 1; j >= 0; ) {
+             unsigned int b;
++            volatile unsigned int notFull = (i < (unsigned int)a->used - 1);
++
+             d = a->dp[i];
+             /* Place each byte of a digit into the buffer. */
+             for (b = 0; (j >= 0) && (b < SP_WORD_SIZEOF); b++) {
+                 out[j--] = (byte)(d & mask);
+                 d >>= 8;
+             }
+-            mask &= (sp_int_digit)0 - (i < (unsigned int)a->used - 1);
++            mask &= (sp_int_digit)0 - notFull;
+             i += (unsigned int)(1 & mask);
+         }
+     }
+@@ -18289,7 +18292,7 @@ int sp_to_unsigned_bin_len_ct(const sp_int* a, byte* out, int outSz)
+     if (err == MP_OKAY) {
+         unsigned int i;
+         int j;
+-        sp_int_digit mask = (sp_int_digit)-1;
++        volatile sp_int_digit mask = (sp_int_digit)-1;
+
+         i = 0;
+         for (j = outSz - 1; j >= 0; j--) {
+@@ -18360,11 +18363,12 @@ static int _sp_read_radix_16(sp_int* a, const char* in)
+     /* Step through string a character at a time starting at end - least
+      * significant byte. */
+     for (i = (int)(XSTRLEN(in) - 1); i >= 0; i--) {
++        volatile char c = in[i];
+         /* Convert character from hex. */
+-        int ch = (int)HexCharToByte(in[i]);
++        int ch = (int)HexCharToByte(c);
+         /* Check for invalid character. */
+         if (ch < 0) {
+-            if (!eol_done && CharIsWhiteSpace(in[i]))
++            if (!eol_done && CharIsWhiteSpace(c))
+                 continue;
+             err = MP_VAL;
+             break;
+@@ -18424,7 +18428,6 @@ static int _sp_read_radix_10(sp_int* a, const char* in)
+ {
+     int  err = MP_OKAY;
+     int  i;
+-    char ch;
+
+     /* Start with a being zero. */
+     _sp_zero(a);
+@@ -18432,7 +18435,7 @@ static int _sp_read_radix_10(sp_int* a, const char* in)
+     /* Process all characters. */
+     for (i = 0; in[i] != '\0'; i++) {
+         /* Get character. */
+-        ch = in[i];
++        volatile char ch = in[i];
+         /* Check character is valid. */
+         if ((ch >= '0') && (ch <= '9')) {
+             /* Assume '0'..'9' are continuous values as characters. */
+@@ -18794,7 +18797,7 @@ int sp_radix_size(const sp_int* a, int radix, int* size)
+         }
+         else {
+             /* Count of nibbles. */
+-            int cnt = (sp_count_bits(a) + 3) / 4;
++            int cnt = (sp_count_bits(a) + 3) >> 2;
+         #ifndef WC_DISABLE_RADIX_ZERO_PAD
+             /* Must have even number of nibbles to have complete bytes. */
+             if (cnt & 1) {
+@@ -19404,7 +19407,7 @@ static int _sp_prime_random_trials(const sp_int* a, int trials, int* result,
+ {
+     int err = MP_OKAY;
+     int bits = sp_count_bits(a);
+-    word32 baseSz = ((word32)bits + 7) / 8;
++    word32 baseSz = ((word32)bits + 7) >> 3;
+     DECL_SP_INT_ARRAY(ds, a->used + 1, 2);
+     DECL_SP_INT_ARRAY(d, a->used * 2 + 1, 2);
+
meta-networking/recipes-connectivity/wolfssl/wolfssl_5.8.0.bb +1 -1
index af591cfd7a..9cd7c07ad2 100644
@@ -16,6 +16,7 @@ SRC_URI = " \
     git://github.com/wolfSSL/wolfssl.git;protocol=https;branch=master \
     file://0001-wolfssl-wolfcrypt-logging.h-and-wolfcrypt-src-loggin.patch \
     file://run-ptest \
+    file://CVE-2025-13912.patch \
 "
 
 SRCREV = "b077c81eb635392e694ccedbab8b644297ec0285"
 
-=-=-=-=-=-=-=-=-=-=-=-

Links: You receive all messages sent to this group.
View/Reply Online (#124586): https://lists.openembedded.org/g/openembedded-devel/message/124586
Mute This Topic: https://lists.openembedded.org/mt/117981422/3616702
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#4 lore raw
Quoted 37 lines · Anuj Mittal
Quoted 34 lines · Ankur Tyagi via lists.openembedded.org

From: Ankur Tyagi <[email protected]>

Backport changes from PR[1] mentioned in nvd[2]

[1] https://github.com/wolfSSL/wolfssl/pull/9148
[2] https://nvd.nist.gov/vuln/detail/CVE-2025-13912

---
 .../wolfssl/files/CVE-2025-13912.patch        | 439 ++++++++++++++++++
 .../wolfssl/wolfssl_5.8.0.bb                  |   1 +
 2 files changed, 440 insertions(+)
 create mode 100644 meta-networking/recipes-connectivity/wolfssl/files/CVE-2025-13912.patch
meta-networking/recipes-connectivity/wolfssl/files/CVE-2025-13912.patch new file +13 -0
new file mode 100644
index 0000000000..32252058f7
@@ -0,0 +1,439 @@
+From 797e0e7abf5830d515ca838201c03a47f83356b0 Mon Sep 17 00:00:00 2001
+From: Daniel Pouzzner <[email protected]>
+Date: Tue, 30 Sep 2025 20:35:52 -0500
+Subject: [PATCH] Merge pull request #9148 from SparkiDev/ct_volatile
+
+Mark variables as volatile
+
+CVE: CVE-2025-13912
+Upstream-Status: Backport [https://github.com/wolfSSL/wolfssl/commit/234ba7780ad3b7c8c1509973accdc43ed6c328b3]
+Signed-off-by: Ankur Tyagi <[email protected]>
+---
+ src/internal.c         | 25 ++++++++++++---------
+ src/tls.c              |  8 +++++--
Quoted 8 lines

meta-networking/recipes-connectivity/wolfssl/files/CVE-2025-13912.patch line 18

Quoted 5 lines
meta-networking/recipes-connectivity/wolfssl/files/CVE-2025-13912.patch new file +5 -0
+ wolfcrypt/src/aes.c    |  4 ++--
+ wolfcrypt/src/ecc.c    |  8 +++----
+ wolfcrypt/src/misc.c   |  4 ++--
+ wolfcrypt/src/rsa.c    | 18 +++++++++------
+ wolfcrypt/src/sp_int.c | 51 ++++++++++++++++++++++--------------------

This seems to be missing a few more volatile related changes when compared to the patch mentioned above. Did you skip those on purpose?

Yes, those changes were not applicable for v5.8.0

Quoted 442 lines
Quoted 442 lines
meta-networking/recipes-connectivity/wolfssl/files/CVE-2025-13912.patch new file +421 -0
+ 7 files changed, 67 insertions(+), 51 deletions(-)
+
+diff --git a/src/internal.c b/src/internal.c
+index eb2f16d63..6b3a227bc 100644
+--- a/src/internal.c
++++ b/src/internal.c
+@@ -20887,7 +20887,7 @@ static byte MaskPadding(const byte* data, int sz, int macSz)
+         checkSz = TLS_MAX_PAD_SZ;
+
+     for (i = 0; i < checkSz; i++) {
+-        byte mask = ctMaskLTE(i, paddingSz);
++        volatile byte mask = ctMaskLTE(i, paddingSz);
+         good |= mask & (data[sz - 1 - i] ^ paddingSz);
+     }
+
+@@ -20907,16 +20907,21 @@ static byte MaskPadding(const byte* data, int sz, int macSz)
+ static byte MaskMac(const byte* data, int sz, int macSz, byte* expMac)
+ {
+     int i, j;
+-    unsigned char mac[WC_MAX_DIGEST_SIZE];
+-    int scanStart = sz - 1 - TLS_MAX_PAD_SZ - macSz;
+-    int macEnd = sz - 1 - data[sz - 1];
+-    int macStart = macEnd - macSz;
+     int r = 0;
+-    unsigned char started, notEnded;
++    unsigned char mac[WC_MAX_DIGEST_SIZE];
++    volatile int scanStart = sz - 1 - TLS_MAX_PAD_SZ - macSz;
++    volatile int macEnd = sz - 1 - data[sz - 1];
++    volatile int macStart = macEnd - macSz;
++    volatile int maskScanStart;
++    volatile int maskMacStart;
++    volatile unsigned char started;
++    volatile unsigned char notEnded;
+     unsigned char good = 0;
+
+-    scanStart &= ctMaskIntGTE(scanStart, 0);
+-    macStart &= ctMaskIntGTE(macStart, 0);
++    maskScanStart = ctMaskIntGTE(scanStart, 0);
++    maskMacStart = ctMaskIntGTE(macStart, 0);
++    scanStart &= maskScanStart;
++    macStart &= maskMacStart;
+
+     /* Div on Intel has different speeds depending on value.
+      * Use a bitwise AND or mod a specific value (converted to mul). */
+@@ -41636,7 +41641,7 @@ static int DefTicketEncCb(WOLFSSL* ssl, byte key_name[WOLFSSL_TICKET_NAME_SZ],
+                     case rsa_kea:
+                     {
+                         RsaKey* key = (RsaKey*)ssl->hsKey;
+-                        int lenErrMask;
++                        volatile int lenErrMask;
+
+                         ret = RsaDec(ssl,
+                             input + args->idx,
+@@ -41850,7 +41855,7 @@ static int DefTicketEncCb(WOLFSSL* ssl, byte key_name[WOLFSSL_TICKET_NAME_SZ],
+                     case rsa_kea:
+                     {
+                         byte *tmpRsa;
+-                        byte mask;
++                        volatile byte mask;
+
+                         /* Add the signature length to idx */
+                         args->idx += args->length;
+diff --git a/src/tls.c b/src/tls.c
+index 6ad21c924..4f57ea938 100644
+--- a/src/tls.c
++++ b/src/tls.c
+@@ -944,7 +944,10 @@ static int Hmac_UpdateFinal_CT(Hmac* hmac, byte* digest, const byte* in,
+     unsigned int k;
+     int          blockBits, blockMask;
+     int          lastBlockLen, extraLen, eocIndex;
+-    int          blocks, safeBlocks, lenBlock, eocBlock;
++    int          blocks;
++    int          safeBlocks;
++    int          lenBlock;
++    int          eocBlock;
+     word32       maxLen;
+     int          blockSz, padSz;
+     int          ret;
+@@ -1054,7 +1057,8 @@ static int Hmac_UpdateFinal_CT(Hmac* hmac, byte* digest, const byte* in,
+
+         for (j = 0; j < blockSz; j++) {
+             unsigned char atEoc = ctMaskEq(j, eocIndex) & isEocBlock;
+-            unsigned char pastEoc = ctMaskGT(j, eocIndex) & isEocBlock;
++            volatile unsigned char maskPastEoc = ctMaskGT(j, eocIndex);
++            volatile unsigned char pastEoc = maskPastEoc & isEocBlock;
+             unsigned char b = 0;
+
+             if (k < headerSz)
+diff --git a/wolfcrypt/src/aes.c b/wolfcrypt/src/aes.c
+index 6e7f104dd..2cf7c695e 100644
+--- a/wolfcrypt/src/aes.c
++++ b/wolfcrypt/src/aes.c
+@@ -6577,7 +6577,7 @@ static WC_INLINE void RIGHTSHIFTX(byte* x)
+ {
+     int i;
+     int carryIn = 0;
+-    byte borrow = (byte)((0x00U - (x[15] & 0x01U)) & 0xE1U);
++    volatile byte borrow = (byte)((0x00U - (x[15] & 0x01U)) & 0xE1U);
+
+     for (i = 0; i < WC_AES_BLOCK_SIZE; i++) {
+         int carryOut = (x[i] & 0x01) << 7;
+@@ -9113,7 +9113,7 @@ int WARN_UNUSED_RESULT AES_GCM_decrypt_C(
+     ALIGN16 byte scratch[WC_AES_BLOCK_SIZE];
+     ALIGN16 byte Tprime[WC_AES_BLOCK_SIZE];
+     ALIGN16 byte EKY0[WC_AES_BLOCK_SIZE];
+-    sword32 res;
++    volatile sword32 res;
+
+     if (ivSz == GCM_NONCE_MID_SZ) {
+         /* Counter is IV with bottom 4 bytes set to: 0x00,0x00,0x00,0x01. */
+diff --git a/wolfcrypt/src/ecc.c b/wolfcrypt/src/ecc.c
+index 6d4cd4de7..1fd30cfd9 100644
+--- a/wolfcrypt/src/ecc.c
++++ b/wolfcrypt/src/ecc.c
+@@ -3166,7 +3166,7 @@ static int ecc_mulmod(const mp_int* k, ecc_point* P, ecc_point* Q,
+     ecc_point** R, mp_int* a, mp_int* modulus, mp_digit mp, WC_RNG* rng)
+ {
+     int      err = MP_OKAY;
+-    int      bytes = (mp_count_bits(modulus) + 7) / 8;
++    int      bytes = (mp_count_bits(modulus) + 7) >> 3;
+     int      i;
+     int      j = 1;
+     int      cnt = DIGIT_BIT;
+@@ -3406,7 +3406,7 @@ static int ecc_mulmod(const mp_int* k, ecc_point* P, ecc_point* Q,
+     ecc_point** R, mp_int* a, mp_int* modulus, mp_digit mp, WC_RNG* rng)
+ {
+     int          err = MP_OKAY;
+-    int          bytes = (mp_count_bits(modulus) + 7) / 8;
++    int          bytes = (mp_count_bits(modulus) + 7) >> 3;
+     int          i;
+     int          j = 1;
+     int          cnt;
+@@ -4450,7 +4450,7 @@ int wc_ecc_get_curve_id_from_params(int fieldSize,
+         Gx == NULL || Gy == NULL)
+         return BAD_FUNC_ARG;
+
+-    curveSz = (fieldSize + 1) / 8;    /* round up */
++    curveSz = (fieldSize + 1) >> 3;    /* round up */
+
+     for (idx = 0; ecc_sets[idx].size != 0; idx++) {
+         if (curveSz == ecc_sets[idx].size) {
+@@ -11922,7 +11922,7 @@ int wc_ecc_sig_size(const ecc_key* key)
+     keySz = key->dp->size;
+     orderBits = wc_ecc_get_curve_order_bit_count(key->dp);
+     if (orderBits > keySz * 8) {
+-        keySz = (orderBits + 7) / 8;
++        keySz = (orderBits + 7) >> 3;
+     }
+     /* maximum possible signature header size is 7 bytes */
+     maxSigSz = (keySz * 2) + SIG_HEADER_SZ;
+diff --git a/wolfcrypt/src/misc.c b/wolfcrypt/src/misc.c
+index 98b83c7ae..496b0dbcc 100644
+--- a/wolfcrypt/src/misc.c
++++ b/wolfcrypt/src/misc.c
+@@ -762,7 +762,7 @@ WC_MISC_STATIC WC_INLINE void ctMaskCopy(byte mask, byte* dst, byte* src,
+     WC_MISC_STATIC WC_INLINE word32 min(word32 a, word32 b)
+     {
+ #if !defined(WOLFSSL_NO_CT_OPS) && defined(WORD64_AVAILABLE)
+-        word32 gte_mask = (word32)ctMaskWord32GTE(a, b);
++        volatile word32 gte_mask = (word32)ctMaskWord32GTE(a, b);
+         return (a & ~gte_mask) | (b & gte_mask);
+ #else /* WOLFSSL_NO_CT_OPS */
+         return a > b ? b : a;
+@@ -778,7 +778,7 @@ WC_MISC_STATIC WC_INLINE void ctMaskCopy(byte mask, byte* dst, byte* src,
+     WC_MISC_STATIC WC_INLINE word32 max(word32 a, word32 b)
+     {
+ #if !defined(WOLFSSL_NO_CT_OPS) && defined(WORD64_AVAILABLE)
+-        word32 gte_mask = (word32)ctMaskWord32GTE(a, b);
++        volatile word32 gte_mask = (word32)ctMaskWord32GTE(a, b);
+         return (a & gte_mask) | (b & ~gte_mask);
+ #else /* WOLFSSL_NO_CT_OPS */
+         return a > b ? a : b;
+diff --git a/wolfcrypt/src/rsa.c b/wolfcrypt/src/rsa.c
+index 94d57bd8b..acd0c04c5 100644
+--- a/wolfcrypt/src/rsa.c
++++ b/wolfcrypt/src/rsa.c
+@@ -1561,11 +1561,11 @@ static int RsaUnPad_OAEP(byte *pkcsBlock, unsigned int pkcsBlockLen,
+                             byte* optLabel, word32 labelLen, void* heap)
+ {
+     word32 hLen;
+-    int ret;
++    volatile int ret;
+     byte h[WC_MAX_DIGEST_SIZE]; /* max digest size */
+     word32 idx;
+     word32 i;
+-    word32 inc;
++    volatile word32 inc;
+
+ #if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC)
+     byte* tmp  = NULL;
+@@ -1850,9 +1850,11 @@ static int RsaUnPad(const byte *pkcsBlock, unsigned int pkcsBlockLen,
+     }
+ #ifndef WOLFSSL_RSA_VERIFY_ONLY
+     else {
+-        unsigned int j;
+-        word16 pastSep = 0;
+-        byte   invalid = 0;
++        unsigned int    j;
++        volatile word16 pastSep = 0;
++        volatile byte   invalid = 0;
++        volatile byte   minPad;
++        volatile int    invalidMask;
+
+         i = 0;
+         /* Decrypted with private key - unpad must be constant time. */
+@@ -1864,7 +1866,8 @@ static int RsaUnPad(const byte *pkcsBlock, unsigned int pkcsBlockLen,
+         }
+
+         /* Minimum of 11 bytes of pre-message data - including leading 0x00. */
+-        invalid |= ctMaskLT(i, RSA_MIN_PAD_SZ);
++        minPad = ctMaskLT(i, RSA_MIN_PAD_SZ);
++        invalid |= minPad;
+         /* Must have seen separator. */
+         invalid |= (byte)~pastSep;
+         /* First byte must be 0x00. */
+@@ -1873,7 +1876,8 @@ static int RsaUnPad(const byte *pkcsBlock, unsigned int pkcsBlockLen,
+         invalid |= ctMaskNotEq(pkcsBlock[1], padValue);
+
+         *output = (byte *)(pkcsBlock + i);
+-        ret = ((int)-1 + (int)(invalid >> 7)) & ((int)pkcsBlockLen - i);
++        invalidMask = (int)-1 + (int)(invalid >> 7);
++        ret = invalidMask & ((int)pkcsBlockLen - i);
+     }
+ #endif
+
+diff --git a/wolfcrypt/src/sp_int.c b/wolfcrypt/src/sp_int.c
+index 1769840e7..0ee8aa252 100644
+--- a/wolfcrypt/src/sp_int.c
++++ b/wolfcrypt/src/sp_int.c
+@@ -5502,7 +5502,7 @@ int sp_exch(sp_int* a, sp_int* b)
+ int sp_cond_swap_ct_ex(sp_int* a, sp_int* b, int cnt, int swap, sp_int* t)
+ {
+     unsigned int i;
+-    sp_int_digit mask = (sp_int_digit)0 - (sp_int_digit)swap;
++    volatile sp_int_digit mask = (sp_int_digit)0 - (sp_int_digit)swap;
+
+     /* XOR other fields in sp_int into temp - mask set when swapping. */
+     t->used = (a->used ^ b->used) & (sp_size_t)mask;
+@@ -5772,7 +5772,7 @@ static int _sp_cmp_ct(const sp_int* a, const sp_int* b, unsigned int n)
+ {
+     int ret = MP_EQ;
+     int i;
+-    int mask = -1;
++    volatile int mask = -1;
+
+     for (i = n - 1; i >= 0; i--) {
+         sp_int_digit ad = a->dp[i] & ((sp_int_digit)0 - (i < (int)a->used));
+@@ -7305,7 +7305,8 @@ static void _sp_div_2(const sp_int* a, sp_int* r)
+
+     /* Shift down each word by 1 and include bottom bit of next at top. */
+     for (i = 0; i < (int)a->used - 1; i++) {
+-        r->dp[i] = (a->dp[i] >> 1) | (a->dp[i+1] << (SP_WORD_SIZE - 1));
++        r->dp[i]  = a->dp[i] >> 1;
++        r->dp[i] |= a->dp[i+1] << (SP_WORD_SIZE - 1);
+     }
+     /* Last word only needs to be shifted down. */
+     r->dp[i] = a->dp[i] >> 1;
+@@ -7385,7 +7386,7 @@ int sp_div_2_mod_ct(const sp_int* a, const sp_int* m, sp_int* r)
+         sp_int_digit t;
+     #endif
+         /* Mask to apply to modulus. */
+-        sp_int_digit mask = (sp_int_digit)0 - (a->dp[0] & 1);
++        volatile sp_int_digit mask = (sp_int_digit)0 - (a->dp[0] & 1);
+         sp_size_t i;
+
+     #if 0
+@@ -7396,7 +7397,7 @@ int sp_div_2_mod_ct(const sp_int* a, const sp_int* m, sp_int* r)
+         /* Add a to m, if a is odd, into r in constant time. */
+         for (i = 0; i < m->used; i++) {
+             /* Mask to apply to a - set when used value at index. */
+-            sp_int_digit mask_a = (sp_int_digit)0 - (i < a->used);
++            volatile sp_int_digit mask_a = (sp_int_digit)0 - (i < a->used);
+
+         #ifndef SQR_MUL_ASM
+             /* Conditionally add modulus. */
+@@ -8017,7 +8018,7 @@ static void sp_clamp_ct(sp_int* a)
+ {
+     int i;
+     sp_size_t used = a->used;
+-    sp_size_t mask = (sp_size_t)-1;
++    volatile sp_size_t mask = (sp_size_t)-1;
+
+     for (i = (int)a->used - 1; i >= 0; i--) {
+ #if ((SP_WORD_SIZE == 64) && \
+@@ -8066,9 +8067,9 @@ int sp_addmod_ct(const sp_int* a, const sp_int* b, const sp_int* m, sp_int* r)
+     sp_int_digit sh;
+     sp_int_digit t;
+ #endif
+-    sp_int_digit mask;
+-    sp_int_digit mask_a = (sp_int_digit)-1;
+-    sp_int_digit mask_b = (sp_int_digit)-1;
++    volatile sp_int_digit mask;
++    volatile sp_int_digit mask_a = (sp_int_digit)-1;
++    volatile sp_int_digit mask_b = (sp_int_digit)-1;
+     sp_size_t i;
+
+     /* Check result is as big as modulus. */
+@@ -8230,9 +8231,9 @@ static void _sp_submod_ct(const sp_int* a, const sp_int* b, const sp_int* m,
+     sp_int_digit h;
+     sp_int_digit t;
+ #endif
+-    sp_int_digit mask;
+-    sp_int_digit mask_a = (sp_int_digit)-1;
+-    sp_int_digit mask_b = (sp_int_digit)-1;
++    volatile sp_int_digit mask;
++    volatile sp_int_digit mask_a = (sp_int_digit)-1;
++    volatile sp_int_digit mask_b = (sp_int_digit)-1;
+     unsigned int i;
+
+     /* In constant time, subtract b from a putting result in r. */
+@@ -17458,7 +17459,7 @@ static int _sp_mont_red(sp_int* a, const sp_int* m, sp_int_digit mp, int ct)
+         /* 1. mask = (1 << (NumBits(m) % WORD_SIZE)) - 1
+          *    Mask when last digit of modulus doesn't have highest bit set.
+          */
+-        sp_int_digit mask = (sp_int_digit)
++        volatile sp_int_digit mask = (sp_int_digit)
+             (((sp_int_digit)1 << (bits & (SP_WORD_SIZE - 1))) - 1);
+         /* Overflow. */
+         sp_int_word o = 0;
+@@ -17539,7 +17540,7 @@ static int _sp_mont_red(sp_int* a, const sp_int* m, sp_int_digit mp, int ct)
+     int bits;
+     sp_int_digit mu;
+     sp_int_digit o;
+-    sp_int_digit mask;
++    volatile sp_int_digit mask;
+
+ #if 0
+     sp_print(a, "a");
+@@ -18041,7 +18042,7 @@ int sp_unsigned_bin_size(const sp_int* a)
+     int cnt = 0;
+
+     if (a != NULL) {
+-        cnt = (sp_count_bits(a) + 7) / 8;
++        cnt = (sp_count_bits(a) + 7) >> 3;
+     }
+
+     return cnt;
+@@ -18265,20 +18266,22 @@ int sp_to_unsigned_bin_len_ct(const sp_int* a, byte* out, int outSz)
+         /* Start at the end of the buffer - least significant byte. */
+         int j;
+         unsigned int i;
+-        sp_int_digit mask = (sp_int_digit)-1;
++        volatile sp_int_digit mask = (sp_int_digit)-1;
+         sp_int_digit d;
+
+         /* Put each digit in. */
+         i = 0;
+         for (j = outSz - 1; j >= 0; ) {
+             unsigned int b;
++            volatile unsigned int notFull = (i < (unsigned int)a->used - 1);
++
+             d = a->dp[i];
+             /* Place each byte of a digit into the buffer. */
+             for (b = 0; (j >= 0) && (b < SP_WORD_SIZEOF); b++) {
+                 out[j--] = (byte)(d & mask);
+                 d >>= 8;
+             }
+-            mask &= (sp_int_digit)0 - (i < (unsigned int)a->used - 1);
++            mask &= (sp_int_digit)0 - notFull;
+             i += (unsigned int)(1 & mask);
+         }
+     }
+@@ -18289,7 +18292,7 @@ int sp_to_unsigned_bin_len_ct(const sp_int* a, byte* out, int outSz)
+     if (err == MP_OKAY) {
+         unsigned int i;
+         int j;
+-        sp_int_digit mask = (sp_int_digit)-1;
++        volatile sp_int_digit mask = (sp_int_digit)-1;
+
+         i = 0;
+         for (j = outSz - 1; j >= 0; j--) {
+@@ -18360,11 +18363,12 @@ static int _sp_read_radix_16(sp_int* a, const char* in)
+     /* Step through string a character at a time starting at end - least
+      * significant byte. */
+     for (i = (int)(XSTRLEN(in) - 1); i >= 0; i--) {
++        volatile char c = in[i];
+         /* Convert character from hex. */
+-        int ch = (int)HexCharToByte(in[i]);
++        int ch = (int)HexCharToByte(c);
+         /* Check for invalid character. */
+         if (ch < 0) {
+-            if (!eol_done && CharIsWhiteSpace(in[i]))
++            if (!eol_done && CharIsWhiteSpace(c))
+                 continue;
+             err = MP_VAL;
+             break;
+@@ -18424,7 +18428,6 @@ static int _sp_read_radix_10(sp_int* a, const char* in)
+ {
+     int  err = MP_OKAY;
+     int  i;
+-    char ch;
+
+     /* Start with a being zero. */
+     _sp_zero(a);
+@@ -18432,7 +18435,7 @@ static int _sp_read_radix_10(sp_int* a, const char* in)
+     /* Process all characters. */
+     for (i = 0; in[i] != '\0'; i++) {
+         /* Get character. */
+-        ch = in[i];
++        volatile char ch = in[i];
+         /* Check character is valid. */
+         if ((ch >= '0') && (ch <= '9')) {
+             /* Assume '0'..'9' are continuous values as characters. */
+@@ -18794,7 +18797,7 @@ int sp_radix_size(const sp_int* a, int radix, int* size)
+         }
+         else {
+             /* Count of nibbles. */
+-            int cnt = (sp_count_bits(a) + 3) / 4;
++            int cnt = (sp_count_bits(a) + 3) >> 2;
+         #ifndef WC_DISABLE_RADIX_ZERO_PAD
+             /* Must have even number of nibbles to have complete bytes. */
+             if (cnt & 1) {
+@@ -19404,7 +19407,7 @@ static int _sp_prime_random_trials(const sp_int* a, int trials, int* result,
+ {
+     int err = MP_OKAY;
+     int bits = sp_count_bits(a);
+-    word32 baseSz = ((word32)bits + 7) / 8;
++    word32 baseSz = ((word32)bits + 7) >> 3;
+     DECL_SP_INT_ARRAY(ds, a->used + 1, 2);
+     DECL_SP_INT_ARRAY(d, a->used * 2 + 1, 2);
+
meta-networking/recipes-connectivity/wolfssl/wolfssl_5.8.0.bb +1 -1
index af591cfd7a..9cd7c07ad2 100644
@@ -16,6 +16,7 @@ SRC_URI = " \
     git://github.com/wolfSSL/wolfssl.git;protocol=https;branch=master \
     file://0001-wolfssl-wolfcrypt-logging.h-and-wolfcrypt-src-loggin.patch \
     file://run-ptest \
+    file://CVE-2025-13912.patch \
 "
 
 SRCREV = "b077c81eb635392e694ccedbab8b644297ec0285"
 
-=-=-=-=-=-=-=-=-=-=-=-

Links: You receive all messages sent to this group.
View/Reply Online (#124586): https://lists.openembedded.org/g/openembedded-devel/message/124586
Mute This Topic: https://lists.openembedded.org/mt/117981422/3616702
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-