Skip to content

Commit 07f5f32

Browse files
committed
Pass raw message through CryptoCb; expose HashMsg helpers
Reverts the dispatcher-side pre-hashing introduced in 958c5f4 so the crypto-callback receives the raw message and can decide for itself whether to operate on the message (wolfHSM-style) or on a pre-computed digest (PKCS#11 v3.2 CKM_HSS / CKM_XMSS / CKM_XMSSMT). - wc_CryptoInfo.pk.pqc_stateful_sig_sign / _verify go back to msg / msgSz fields. - wc_CryptoCb_PqcStatefulSigSign / _Verify take msg / msgSz again. - wc_lms.c / wc_xmss.c stop hashing before dispatch. The hashing helpers are kept and promoted to public API so a PKCS#11-style callback can produce the right digest from inside the callback when needed: - wc_LmsKey_HashMsg(key, msg, msgSz, hash, *hashSz) declared in wolfssl/wolfcrypt/lms.h. - wc_XmssKey_HashMsg(key, msg, msgSz, hash, *hashSz) declared in wolfssl/wolfcrypt/xmss.h. Both honour the parameter set's hash family (SHA-256 / SHA-256-192 / SHAKE256 / SHAKE256-192 for LMS; SHA-256 / SHA-512 / SHAKE128 / SHAKE256 for XMSS) and now live outside the WOLF_CRYPTO_CB ifdef so they remain available when CryptoCb is disabled. All three config combinations (lms+xmss+cryptocb, lms+xmss, cryptocb alone) build and pass testwolfcrypt. https://claude.ai/code/session_01MixzJP9kPWkS8bhfDDDBnX
1 parent 958c5f4 commit 07f5f32

7 files changed

Lines changed: 120 additions & 90 deletions

File tree

wolfcrypt/src/cryptocb.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,7 +1068,7 @@ int wc_CryptoCb_PqcStatefulSigKeyGen(int type, void* key, WC_RNG* rng)
10681068
return wc_CryptoCb_TranslateErrorCode(ret);
10691069
}
10701070

1071-
int wc_CryptoCb_PqcStatefulSigSign(const byte* hash, word32 hashSz, byte* out,
1071+
int wc_CryptoCb_PqcStatefulSigSign(const byte* msg, word32 msgSz, byte* out,
10721072
word32* outSz, int type, void* key)
10731073
{
10741074
int ret = WC_NO_ERR_TRACE(CRYPTOCB_UNAVAILABLE);
@@ -1088,8 +1088,8 @@ int wc_CryptoCb_PqcStatefulSigSign(const byte* hash, word32 hashSz, byte* out,
10881088
XMEMSET(&cryptoInfo, 0, sizeof(cryptoInfo));
10891089
cryptoInfo.algo_type = WC_ALGO_TYPE_PK;
10901090
cryptoInfo.pk.type = WC_PK_TYPE_PQC_STATEFUL_SIG_SIGN;
1091-
cryptoInfo.pk.pqc_stateful_sig_sign.hash = hash;
1092-
cryptoInfo.pk.pqc_stateful_sig_sign.hashSz = hashSz;
1091+
cryptoInfo.pk.pqc_stateful_sig_sign.msg = msg;
1092+
cryptoInfo.pk.pqc_stateful_sig_sign.msgSz = msgSz;
10931093
cryptoInfo.pk.pqc_stateful_sig_sign.out = out;
10941094
cryptoInfo.pk.pqc_stateful_sig_sign.outSz = outSz;
10951095
cryptoInfo.pk.pqc_stateful_sig_sign.key = key;
@@ -1102,7 +1102,7 @@ int wc_CryptoCb_PqcStatefulSigSign(const byte* hash, word32 hashSz, byte* out,
11021102
}
11031103

11041104
int wc_CryptoCb_PqcStatefulSigVerify(const byte* sig, word32 sigSz,
1105-
const byte* hash, word32 hashSz, int* res, int type, void* key)
1105+
const byte* msg, word32 msgSz, int* res, int type, void* key)
11061106
{
11071107
int ret = WC_NO_ERR_TRACE(CRYPTOCB_UNAVAILABLE);
11081108
int devId = INVALID_DEVID;
@@ -1123,8 +1123,8 @@ int wc_CryptoCb_PqcStatefulSigVerify(const byte* sig, word32 sigSz,
11231123
cryptoInfo.pk.type = WC_PK_TYPE_PQC_STATEFUL_SIG_VERIFY;
11241124
cryptoInfo.pk.pqc_stateful_sig_verify.sig = sig;
11251125
cryptoInfo.pk.pqc_stateful_sig_verify.sigSz = sigSz;
1126-
cryptoInfo.pk.pqc_stateful_sig_verify.hash = hash;
1127-
cryptoInfo.pk.pqc_stateful_sig_verify.hashSz = hashSz;
1126+
cryptoInfo.pk.pqc_stateful_sig_verify.msg = msg;
1127+
cryptoInfo.pk.pqc_stateful_sig_verify.msgSz = msgSz;
11281128
cryptoInfo.pk.pqc_stateful_sig_verify.res = res;
11291129
cryptoInfo.pk.pqc_stateful_sig_verify.key = key;
11301130
cryptoInfo.pk.pqc_stateful_sig_verify.type = type;

wolfcrypt/src/wc_lms.c

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -38,28 +38,47 @@
3838

3939
#ifdef WOLF_CRYPTO_CB
4040
#include <wolfssl/wolfcrypt/cryptocb.h>
41+
#endif
4142

42-
/* Pre-compute the message digest with the hash function dictated by the LMS
43-
* parameter set. PKCS#11 v3.2 section 6.65 specifies that CKM_HSS takes the
44-
* pre-computed digest, not the raw message, so every Sign/Verify dispatch
45-
* through the crypto-callback layer funnels through this helper. */
46-
static int wc_lms_hash_msg(const LmsParams* params, const byte* msg,
47-
word32 msgSz, byte* hash, word32 hashSz)
43+
/* Compute the digest of msg using the hash function dictated by the LMS
44+
* parameter set. Crypto-callback / HSM backends that follow PKCS#11 v3.2
45+
* CKM_HSS semantics (pre-computed digest input) can call this from within
46+
* their callback; backends that take the raw message (e.g. wolfHSM) can
47+
* ignore it. *hashSz is in/out: it must be at least params->hash_len on
48+
* entry and is set to the actual digest length on success.
49+
*
50+
* @param [in] key LMS key (must have a parameter set bound).
51+
* @param [in] msg Message to hash.
52+
* @param [in] msgSz Length of msg in bytes.
53+
* @param [out] hash Buffer receiving the digest.
54+
* @param [in,out] hashSz On entry, size of hash buffer. On success,
55+
* the digest length.
56+
* @return 0 on success.
57+
* @return BAD_FUNC_ARG when an argument is NULL or the buffer is too
58+
* small for the digest.
59+
* @return NOT_COMPILED_IN when the param set's hash family is disabled.
60+
*/
61+
int wc_LmsKey_HashMsg(const LmsKey* key, const byte* msg, word32 msgSz,
62+
byte* hash, word32* hashSz)
4863
{
4964
int ret = 0;
65+
word32 needSz;
5066

51-
if ((params == NULL) || (msg == NULL) || (hash == NULL))
67+
if ((key == NULL) || (msg == NULL) || (hash == NULL) || (hashSz == NULL))
68+
return BAD_FUNC_ARG;
69+
if (key->params == NULL)
5270
return BAD_FUNC_ARG;
53-
if (hashSz != params->hash_len)
71+
needSz = (word32)key->params->hash_len;
72+
if (*hashSz < needSz)
5473
return BAD_FUNC_ARG;
5574

56-
switch (params->lmsType & 0xF000) {
75+
switch (key->params->lmsType & 0xF000) {
5776
case LMS_SHA256: /* 32-byte SHA-256 */
5877
case LMS_SHA256_192: /* SHA-256 truncated to 24 bytes */ {
5978
byte full[WC_SHA256_DIGEST_SIZE];
6079
ret = wc_Sha256Hash(msg, msgSz, full);
6180
if (ret == 0)
62-
XMEMCPY(hash, full, hashSz);
81+
XMEMCPY(hash, full, needSz);
6382
break;
6483
}
6584
#ifdef WOLFSSL_LMS_SHAKE256
@@ -70,21 +89,23 @@ static int wc_lms_hash_msg(const LmsParams* params, const byte* msg,
7089
if (ret == 0) {
7190
ret = wc_Shake256_Update(&shake, msg, msgSz);
7291
if (ret == 0)
73-
ret = wc_Shake256_Final(&shake, hash, hashSz);
92+
ret = wc_Shake256_Final(&shake, hash, needSz);
7493
wc_Shake256_Free(&shake);
7594
}
7695
break;
7796
}
7897
#endif
7998
default:
80-
WOLFSSL_MSG("LMS: unsupported hash family for CryptoCb pre-hash");
99+
WOLFSSL_MSG("LMS: unsupported hash family for HashMsg");
81100
ret = NOT_COMPILED_IN;
82101
break;
83102
}
84103

104+
if (ret == 0)
105+
*hashSz = needSz;
106+
85107
return ret;
86108
}
87-
#endif
88109

89110

90111
/* Calculate u. Appendix B. Works for w of 1, 2, 4, or 8.
@@ -1318,13 +1339,8 @@ int wc_LmsKey_Sign(LmsKey* key, byte* sig, word32* sigSz, const byte* msg,
13181339
* device owns the private state. On CRYPTOCB_UNAVAILABLE fall-through the
13191340
* software checks below still run. */
13201341
if ((ret == 0) && (key->devId != INVALID_DEVID)) {
1321-
byte hash[LMS_MAX_NODE_LEN];
1322-
word32 hashSz = key->params->hash_len;
1323-
ret = wc_lms_hash_msg(key->params, msg, (word32)msgSz, hash, hashSz);
1324-
if (ret == 0) {
1325-
ret = wc_CryptoCb_PqcStatefulSigSign(hash, hashSz, sig, sigSz,
1326-
WC_PQC_STATEFUL_SIG_TYPE_LMS, key);
1327-
}
1342+
ret = wc_CryptoCb_PqcStatefulSigSign(msg, (word32)msgSz, sig, sigSz,
1343+
WC_PQC_STATEFUL_SIG_TYPE_LMS, key);
13281344
if (ret != WC_NO_ERR_TRACE(CRYPTOCB_UNAVAILABLE))
13291345
return ret;
13301346
ret = 0; /* fall through to software path */
@@ -1645,14 +1661,9 @@ int wc_LmsKey_Verify(LmsKey* key, const byte* sig, word32 sigSz,
16451661

16461662
#ifdef WOLF_CRYPTO_CB
16471663
if ((ret == 0) && (key->devId != INVALID_DEVID)) {
1648-
byte hash[LMS_MAX_NODE_LEN];
1649-
word32 hashSz = key->params->hash_len;
16501664
int res = 0;
1651-
ret = wc_lms_hash_msg(key->params, msg, (word32)msgSz, hash, hashSz);
1652-
if (ret == 0) {
1653-
ret = wc_CryptoCb_PqcStatefulSigVerify(sig, sigSz, hash, hashSz,
1654-
&res, WC_PQC_STATEFUL_SIG_TYPE_LMS, key);
1655-
}
1665+
ret = wc_CryptoCb_PqcStatefulSigVerify(sig, sigSz, msg, (word32)msgSz,
1666+
&res, WC_PQC_STATEFUL_SIG_TYPE_LMS, key);
16561667
if (ret != WC_NO_ERR_TRACE(CRYPTOCB_UNAVAILABLE)) {
16571668
if (ret == 0 && res != 1)
16581669
ret = SIG_VERIFY_E;

wolfcrypt/src/wc_xmss.c

Lines changed: 41 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -38,31 +38,50 @@
3838

3939
#ifdef WOLF_CRYPTO_CB
4040
#include <wolfssl/wolfcrypt/cryptocb.h>
41+
#endif
4142

42-
/* Pre-compute the message digest with the hash function dictated by the XMSS
43-
* parameter set. PKCS#11 v3.2 section 6.66 specifies that CKM_XMSS and
44-
* CKM_XMSSMT take the pre-computed digest, not the raw message (the section
45-
* is titled "XMSS and XMSSMT without hashing"), so every Sign/Verify
46-
* dispatch through the crypto-callback layer funnels through this helper. */
47-
static int wc_xmss_hash_msg(const XmssParams* params, const byte* msg,
48-
word32 msgSz, byte* hash, word32 hashSz)
43+
/* Compute the digest of msg using the hash function dictated by the XMSS
44+
* parameter set. Crypto-callback / HSM backends that follow PKCS#11 v3.2
45+
* CKM_XMSS / CKM_XMSSMT semantics (pre-computed digest input, see section
46+
* 6.66.8 "XMSS and XMSSMT without hashing") can call this from within
47+
* their callback; backends that take the raw message (e.g. wolfHSM) can
48+
* ignore it. *hashSz is in/out: it must be at least params->n on entry
49+
* and is set to the actual digest length on success.
50+
*
51+
* @param [in] key XMSS key (must have a parameter set bound).
52+
* @param [in] msg Message to hash.
53+
* @param [in] msgSz Length of msg in bytes.
54+
* @param [out] hash Buffer receiving the digest.
55+
* @param [in,out] hashSz On entry, size of hash buffer. On success,
56+
* the digest length.
57+
* @return 0 on success.
58+
* @return BAD_FUNC_ARG when an argument is NULL or the buffer is too
59+
* small for the digest.
60+
* @return NOT_COMPILED_IN when the param set's hash family is disabled.
61+
*/
62+
int wc_XmssKey_HashMsg(const XmssKey* key, const byte* msg, word32 msgSz,
63+
byte* hash, word32* hashSz)
4964
{
5065
int ret = 0;
66+
word32 needSz;
5167

52-
if ((params == NULL) || (msg == NULL) || (hash == NULL))
68+
if ((key == NULL) || (msg == NULL) || (hash == NULL) || (hashSz == NULL))
69+
return BAD_FUNC_ARG;
70+
if (key->params == NULL)
5371
return BAD_FUNC_ARG;
54-
if (hashSz != params->n)
72+
needSz = (word32)key->params->n;
73+
if (*hashSz < needSz)
5574
return BAD_FUNC_ARG;
5675

57-
switch (params->hash) {
76+
switch (key->params->hash) {
5877
#ifdef WC_XMSS_SHA256
5978
case WC_HASH_TYPE_SHA256:
60-
ret = wc_Hash(WC_HASH_TYPE_SHA256, msg, msgSz, hash, hashSz);
79+
ret = wc_Hash(WC_HASH_TYPE_SHA256, msg, msgSz, hash, needSz);
6180
break;
6281
#endif
6382
#ifdef WC_XMSS_SHA512
6483
case WC_HASH_TYPE_SHA512:
65-
ret = wc_Hash(WC_HASH_TYPE_SHA512, msg, msgSz, hash, hashSz);
84+
ret = wc_Hash(WC_HASH_TYPE_SHA512, msg, msgSz, hash, needSz);
6685
break;
6786
#endif
6887
#ifdef WC_XMSS_SHAKE128
@@ -72,7 +91,7 @@ static int wc_xmss_hash_msg(const XmssParams* params, const byte* msg,
7291
if (ret == 0) {
7392
ret = wc_Shake128_Update(&shake, msg, msgSz);
7493
if (ret == 0)
75-
ret = wc_Shake128_Final(&shake, hash, hashSz);
94+
ret = wc_Shake128_Final(&shake, hash, needSz);
7695
wc_Shake128_Free(&shake);
7796
}
7897
break;
@@ -85,21 +104,23 @@ static int wc_xmss_hash_msg(const XmssParams* params, const byte* msg,
85104
if (ret == 0) {
86105
ret = wc_Shake256_Update(&shake, msg, msgSz);
87106
if (ret == 0)
88-
ret = wc_Shake256_Final(&shake, hash, hashSz);
107+
ret = wc_Shake256_Final(&shake, hash, needSz);
89108
wc_Shake256_Free(&shake);
90109
}
91110
break;
92111
}
93112
#endif
94113
default:
95-
WOLFSSL_MSG("XMSS: unsupported hash for CryptoCb pre-hash");
114+
WOLFSSL_MSG("XMSS: unsupported hash for HashMsg");
96115
ret = NOT_COMPILED_IN;
97116
break;
98117
}
99118

119+
if (ret == 0)
120+
*hashSz = needSz;
121+
100122
return ret;
101123
}
102-
#endif
103124

104125

105126
/***************************
@@ -1412,13 +1433,8 @@ int wc_XmssKey_Sign(XmssKey* key, byte* sig, word32* sigLen, const byte* msg,
14121433
* device owns the private state. On CRYPTOCB_UNAVAILABLE fall-through the
14131434
* software checks below still run. */
14141435
if ((ret == 0) && (key->devId != INVALID_DEVID)) {
1415-
byte hash[WC_XMSS_MAX_N];
1416-
word32 hashSz = key->params->n;
1417-
ret = wc_xmss_hash_msg(key->params, msg, (word32)msgLen, hash, hashSz);
1418-
if (ret == 0) {
1419-
ret = wc_CryptoCb_PqcStatefulSigSign(hash, hashSz, sig, sigLen,
1420-
WC_PQC_STATEFUL_SIG_TYPE_XMSS, key);
1421-
}
1436+
ret = wc_CryptoCb_PqcStatefulSigSign(msg, (word32)msgLen, sig, sigLen,
1437+
WC_PQC_STATEFUL_SIG_TYPE_XMSS, key);
14221438
if (ret != WC_NO_ERR_TRACE(CRYPTOCB_UNAVAILABLE))
14231439
return ret;
14241440
ret = 0; /* fall through to software path */
@@ -1765,14 +1781,9 @@ int wc_XmssKey_Verify(XmssKey* key, const byte* sig, word32 sigLen,
17651781

17661782
#ifdef WOLF_CRYPTO_CB
17671783
if ((ret == 0) && (key->devId != INVALID_DEVID)) {
1768-
byte hash[WC_XMSS_MAX_N];
1769-
word32 hashSz = key->params->n;
17701784
int res = 0;
1771-
ret = wc_xmss_hash_msg(key->params, m, (word32)mLen, hash, hashSz);
1772-
if (ret == 0) {
1773-
ret = wc_CryptoCb_PqcStatefulSigVerify(sig, sigLen, hash, hashSz,
1774-
&res, WC_PQC_STATEFUL_SIG_TYPE_XMSS, key);
1775-
}
1785+
ret = wc_CryptoCb_PqcStatefulSigVerify(sig, sigLen, m, (word32)mLen,
1786+
&res, WC_PQC_STATEFUL_SIG_TYPE_XMSS, key);
17761787
if (ret != WC_NO_ERR_TRACE(CRYPTOCB_UNAVAILABLE)) {
17771788
if (ret == 0 && res != 1)
17781789
ret = SIG_VERIFY_E;

wolfcrypt/test/test.c

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -68286,19 +68286,14 @@ static int myCryptoDevCb(int devIdArg, wc_CryptoInfo* info, void* ctx)
6828668286
else if (info->pk.type == WC_PK_TYPE_PQC_STATEFUL_SIG_SIGN) {
6828768287
int pqcType = info->pk.pqc_stateful_sig_sign.type;
6828868288
word32 sigSz = *info->pk.pqc_stateful_sig_sign.outSz;
68289-
/* The dispatcher pre-hashed the message per PKCS#11 v3.2
68290-
* CKM_HSS / CKM_XMSS semantics. Feed that digest back into
68291-
* the software API as the "message"; both Sign and Verify
68292-
* paths do the same pre-hashing so the resulting signature
68293-
* self-verifies within this harness. */
6829468289
#if defined(WOLFSSL_HAVE_LMS) && !defined(WOLFSSL_LMS_VERIFY_ONLY)
6829568290
if (pqcType == WC_PQC_STATEFUL_SIG_TYPE_LMS) {
6829668291
LmsKey* lk = (LmsKey*)info->pk.pqc_stateful_sig_sign.key;
6829768292
lk->devId = INVALID_DEVID;
6829868293
ret = wc_LmsKey_Sign(lk,
6829968294
info->pk.pqc_stateful_sig_sign.out, &sigSz,
68300-
info->pk.pqc_stateful_sig_sign.hash,
68301-
(int)info->pk.pqc_stateful_sig_sign.hashSz);
68295+
info->pk.pqc_stateful_sig_sign.msg,
68296+
(int)info->pk.pqc_stateful_sig_sign.msgSz);
6830268297
lk->devId = devIdArg;
6830368298
}
6830468299
#endif
@@ -68308,8 +68303,8 @@ static int myCryptoDevCb(int devIdArg, wc_CryptoInfo* info, void* ctx)
6830868303
xk->devId = INVALID_DEVID;
6830968304
ret = wc_XmssKey_Sign(xk,
6831068305
info->pk.pqc_stateful_sig_sign.out, &sigSz,
68311-
info->pk.pqc_stateful_sig_sign.hash,
68312-
(int)info->pk.pqc_stateful_sig_sign.hashSz);
68306+
info->pk.pqc_stateful_sig_sign.msg,
68307+
(int)info->pk.pqc_stateful_sig_sign.msgSz);
6831368308
xk->devId = devIdArg;
6831468309
}
6831568310
#endif
@@ -68325,8 +68320,8 @@ static int myCryptoDevCb(int devIdArg, wc_CryptoInfo* info, void* ctx)
6832568320
verifyRet = wc_LmsKey_Verify(lk,
6832668321
info->pk.pqc_stateful_sig_verify.sig,
6832768322
info->pk.pqc_stateful_sig_verify.sigSz,
68328-
info->pk.pqc_stateful_sig_verify.hash,
68329-
(int)info->pk.pqc_stateful_sig_verify.hashSz);
68323+
info->pk.pqc_stateful_sig_verify.msg,
68324+
(int)info->pk.pqc_stateful_sig_verify.msgSz);
6833068325
lk->devId = devIdArg;
6833168326
}
6833268327
#endif
@@ -68337,8 +68332,8 @@ static int myCryptoDevCb(int devIdArg, wc_CryptoInfo* info, void* ctx)
6833768332
verifyRet = wc_XmssKey_Verify(xk,
6833868333
info->pk.pqc_stateful_sig_verify.sig,
6833968334
info->pk.pqc_stateful_sig_verify.sigSz,
68340-
info->pk.pqc_stateful_sig_verify.hash,
68341-
(int)info->pk.pqc_stateful_sig_verify.hashSz);
68335+
info->pk.pqc_stateful_sig_verify.msg,
68336+
(int)info->pk.pqc_stateful_sig_verify.msgSz);
6834268337
xk->devId = devIdArg;
6834368338
}
6834468339
#endif

wolfssl/wolfcrypt/cryptocb.h

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -362,12 +362,13 @@ typedef struct wc_CryptoInfo {
362362
int type; /* enum wc_PqcStatefulSignatureType */
363363
} pqc_stateful_sig_kg;
364364
struct {
365-
/* Pre-computed digest of the message. PKCS#11 v3.2
366-
* section 6.65/6.66 ("HSS" / "XMSS and XMSSMT without
367-
* hashing") specifies that CKM_HSS, CKM_XMSS and
368-
* CKM_XMSSMT take a hash, not the raw message. */
369-
const byte* hash;
370-
word32 hashSz;
365+
/* Raw message. Backends following the PKCS#11 v3.2
366+
* CKM_HSS / CKM_XMSS convention of operating on a
367+
* pre-computed digest can call wc_LmsKey_HashMsg /
368+
* wc_XmssKey_HashMsg from inside the callback to obtain
369+
* the algorithm-dictated digest of msg. */
370+
const byte* msg;
371+
word32 msgSz;
371372
byte* out;
372373
word32* outSz;
373374
void* key;
@@ -376,9 +377,9 @@ typedef struct wc_CryptoInfo {
376377
struct {
377378
const byte* sig;
378379
word32 sigSz;
379-
/* Pre-computed digest of the message. See sign note. */
380-
const byte* hash;
381-
word32 hashSz;
380+
/* Raw message. See sign note. */
381+
const byte* msg;
382+
word32 msgSz;
382383
int* res;
383384
void* key;
384385
int type; /* enum wc_PqcStatefulSignatureType */
@@ -761,12 +762,13 @@ WOLFSSL_LOCAL int wc_CryptoCb_PqcStatefulSigGetDevId(int type, void* key);
761762

762763
WOLFSSL_LOCAL int wc_CryptoCb_PqcStatefulSigKeyGen(int type, void* key,
763764
WC_RNG* rng);
764-
/* hash is the pre-computed digest of the message; CKM_HSS, CKM_XMSS and
765-
* CKM_XMSSMT all take the digest, not the raw message (PKCS#11 v3.2). */
766-
WOLFSSL_LOCAL int wc_CryptoCb_PqcStatefulSigSign(const byte* hash,
767-
word32 hashSz, byte* out, word32* outSz, int type, void* key);
765+
/* The raw message is forwarded to the callback. Backends that follow the
766+
* PKCS#11 v3.2 CKM_HSS / CKM_XMSS convention (digest input) can call
767+
* wc_LmsKey_HashMsg / wc_XmssKey_HashMsg from inside the callback. */
768+
WOLFSSL_LOCAL int wc_CryptoCb_PqcStatefulSigSign(const byte* msg,
769+
word32 msgSz, byte* out, word32* outSz, int type, void* key);
768770
WOLFSSL_LOCAL int wc_CryptoCb_PqcStatefulSigVerify(const byte* sig,
769-
word32 sigSz, const byte* hash, word32 hashSz, int* res, int type,
771+
word32 sigSz, const byte* msg, word32 msgSz, int* res, int type,
770772
void* key);
771773
WOLFSSL_LOCAL int wc_CryptoCb_PqcStatefulSigSigsLeft(int type, void* key,
772774
word32* sigsLeft);

0 commit comments

Comments
 (0)