You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#error "MAXQ10xx root-cert provisioning key is undefined. Define MAXQ10XX_PRODUCTION_KEY (with a real maxq10xx_key.h) for production, or WOLFPKCS11_MAXQ10XX_TEST_KEY to explicitly opt into the built-in INSECURE test key for evaluation-kit development."
3366
3420
#endif /* MAXQ10XX_PRODUCTION_KEY */
3367
3421
3368
3422
static int crypto_sha256(const byte *buf, word32 len, byte *hash,
for (curr = slot->session; curr != NULL; curr = curr->next)
7989
8057
wp11_Session_Final(curr);
7990
8058
WP11_Lock_UnlockRW(&slot->lock);
8059
+
8060
+
/* PKCS#11: closing an application's last session with a token logs the
8061
+
* application out. Mirror the single-session close path and reset the
8062
+
* token login state (outside the slot lock, as WP11_Slot_Logout takes it).
8063
+
*/
8064
+
WP11_Slot_Logout(slot);
7991
8065
}
7992
8066
7993
8067
/**
@@ -8056,6 +8130,21 @@ static int HashPIN(char* pin, int pinLen, byte* seed, int seedLen, byte* hash,
8056
8130
WP11_HASH_PIN_COST, WP11_HASH_PIN_BLOCKSIZE,
8057
8131
WP11_HASH_PIN_PARALLEL, hashLen);
8058
8132
#elif !defined(NO_SHA256)
8133
+
/* Fallback: unsalted single-pass SHA-256 of the PIN. This provides no
8134
+
* salt (the per-token seed is discarded) and no key stretching, so an
8135
+
* attacker with the token-store file can brute-force a weak PIN offline
8136
+
* and recover the token storage key. Configure WOLFPKCS11_PBKDF2 or
8137
+
* HAVE_SCRYPT for a salted, stretched KDF. The selection is compile-time
8138
+
* and otherwise silent, so warn integrators unless they opt out (F-6232).
8139
+
* Note: changing this derivation would invalidate existing token stores,
8140
+
* so hardening it in place is left as a deliberate maintainer decision. */
8141
+
#ifndef WOLFPKCS11_ALLOW_WEAK_PIN_KDF
8142
+
#if defined(_MSC_VER)
8143
+
#pragma message("wolfPKCS11: no PBKDF2/scrypt - PIN hashing and token key derivation use unsalted SHA-256; define WOLFPKCS11_PBKDF2 or HAVE_SCRYPT for a strong KDF, or WOLFPKCS11_ALLOW_WEAK_PIN_KDF to silence")
8144
+
#elif defined(__GNUC__) || defined(__clang__)
8145
+
#warning "wolfPKCS11: no PBKDF2/scrypt - PIN hashing and token key derivation use unsalted SHA-256; define WOLFPKCS11_PBKDF2 or HAVE_SCRYPT for a strong KDF, or WOLFPKCS11_ALLOW_WEAK_PIN_KDF to silence"
8146
+
#endif
8147
+
#endif
8059
8148
/* fallback to simple SHA2-256 hash of pin */
8060
8149
(void)seed;
8061
8150
(void)seedLen;
@@ -9461,6 +9550,13 @@ int WP11_Session_SetCbcParams(WP11_Session* session, unsigned char* iv,
9461
9550
WP11_CbcParams* cbc = &session->params.cbc;
9462
9551
WP11_Data* key;
9463
9552
9553
+
/* The session params union is shared by every mechanism and is only zeroed
9554
+
* at allocation, so a prior operation can leave stale multi-part streaming
9555
+
* state here. Reset it before use (as the other Set*Params routines do) so
9556
+
* a fresh CBC operation cannot inherit a bogus partial-block count. */
9557
+
cbc->partialSz = 0;
9558
+
XMEMSET(cbc->partial, 0, sizeof(cbc->partial));
9559
+
9464
9560
/* AES object on session. */
9465
9561
ret = wc_AesInit(&cbc->aes, NULL, object->devId);
9466
9562
#ifdef WOLFSSL_STM32U5_DHUK
@@ -15453,6 +15549,13 @@ int WP11_AesCbc_EncryptUpdate(unsigned char* plain, word32 plainSz,
15453
15549
int sz = 0;
15454
15550
int outSz = 0;
15455
15551
15552
+
/* Serialize the read-modify-write of cbc->partial/partialSz. Without this
15553
+
* two threads sharing one session handle can both read partialSz, both
15554
+
* copy into cbc->partial and both add, driving partialSz past
15555
+
* AES_BLOCK_SIZE so the next call computes a negative sz and overflows the
0 commit comments