File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1555,15 +1555,16 @@ int wc_LmsKey_SigsLeft(LmsKey* key)
15551555 if (cbRet == 0 ) {
15561556 return (sigsLeft != 0 ) ? 1 : 0 ;
15571557 }
1558- /* The device owns the private state; no safe software fallback
1559- * exists because key->priv_raw does not reflect HSM state. */
15601558 if (cbRet != WC_NO_ERR_TRACE (CRYPTOCB_UNAVAILABLE )) {
1559+ /* Device returned an actual error; the device owns the
1560+ * private state so no safe software fallback exists. */
15611561 WOLFSSL_MSG ("PqcStatefulSigSigsLeft returned an error" );
1562+ return 0 ;
15621563 }
1563- else {
1564- WOLFSSL_MSG ( "LMS SigsLeft not supported by device" );
1565- }
1566- return 0 ;
1564+ /* Cryptocb declined. priv_raw reflects software state from the
1565+ * CRYPTOCB_UNAVAILABLE fall-through in MakeKey/Reload, so the
1566+ * software check below is valid. */
1567+ WOLFSSL_MSG ( "LMS SigsLeft not supported by device, using software" ) ;
15671568 }
15681569 #endif
15691570 ret = wc_hss_sigsleft (key -> params , key -> priv_raw );
Original file line number Diff line number Diff line change @@ -1521,15 +1521,16 @@ int wc_XmssKey_SigsLeft(XmssKey* key)
15211521 if (cbRet == 0 ) {
15221522 return (sigsLeft != 0 ) ? 1 : 0 ;
15231523 }
1524- /* The device owns the private state; no safe software fallback
1525- * exists because key->sk does not reflect HSM state. */
15261524 if (cbRet != WC_NO_ERR_TRACE (CRYPTOCB_UNAVAILABLE )) {
1525+ /* Device returned an actual error; the device owns the
1526+ * private state so no safe software fallback exists. */
15271527 WOLFSSL_MSG ("PqcStatefulSigSigsLeft returned an error" );
1528+ return 0 ;
15281529 }
1529- else {
1530- WOLFSSL_MSG ( "XMSS SigsLeft not supported by device" );
1531- }
1532- return 0 ;
1530+ /* Cryptocb declined. Fall through to the software path: state
1531+ * reflects the CRYPTOCB_UNAVAILABLE fall-through in MakeKey/Reload,
1532+ * and read_private_key can repopulate sk from NV storage. */
1533+ WOLFSSL_MSG ( "XMSS SigsLeft not supported by device, using software" ) ;
15331534 }
15341535#endif
15351536
You can’t perform that action at this time.
0 commit comments