Skip to content

Commit 8c2bf1d

Browse files
committed
Remove wc_*Key_HashMsg functions and PKCS#11 references
1 parent 7906e67 commit 8c2bf1d

5 files changed

Lines changed: 0 additions & 150 deletions

File tree

wolfcrypt/src/wc_lms.c

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,66 +1282,6 @@ int wc_LmsKey_GetPrivLen(const LmsKey* key, word32* len)
12821282
return ret;
12831283
}
12841284

1285-
/* Compute the digest of msg using the hash function dictated by the LMS
1286-
* parameter set. Crypto-callback / HSM backends that follow PKCS#11 v3.2
1287-
* CKM_HSS semantics (pre-computed digest input) can call this from within
1288-
* their callback; backends that take the raw message (e.g. wolfHSM) can
1289-
* ignore it. *hashSz is in/out: it must be at least params->hash_len on
1290-
* entry and is set to the actual digest length on success.
1291-
*
1292-
* @param [in] key LMS key (must have a parameter set bound).
1293-
* @param [in] msg Message to hash.
1294-
* @param [in] msgSz Length of msg in bytes.
1295-
* @param [out] hash Buffer receiving the digest.
1296-
* @param [in,out] hashSz On entry, size of hash buffer. On success,
1297-
* the digest length.
1298-
* @return 0 on success.
1299-
* @return BAD_FUNC_ARG when an argument is NULL or the buffer is too
1300-
* small for the digest.
1301-
* @return NOT_COMPILED_IN when the param set's hash family is disabled.
1302-
*/
1303-
int wc_LmsKey_HashMsg(const LmsKey* key, const byte* msg, word32 msgSz,
1304-
byte* hash, word32* hashSz)
1305-
{
1306-
int ret = 0;
1307-
word32 needSz;
1308-
1309-
if ((key == NULL) || (msg == NULL) || (hash == NULL) || (hashSz == NULL))
1310-
return BAD_FUNC_ARG;
1311-
if (key->params == NULL)
1312-
return BAD_FUNC_ARG;
1313-
needSz = (word32)key->params->hash_len;
1314-
if (*hashSz < needSz)
1315-
return BAD_FUNC_ARG;
1316-
1317-
switch (key->params->lmsType & LMS_HASH_MASK) {
1318-
case LMS_SHA256: /* 32-byte SHA-256 */
1319-
case LMS_SHA256_192: /* SHA-256 truncated to 24 bytes */ {
1320-
byte full[WC_SHA256_DIGEST_SIZE];
1321-
ret = wc_Sha256Hash(msg, msgSz, full);
1322-
if (ret == 0)
1323-
XMEMCPY(hash, full, needSz);
1324-
break;
1325-
}
1326-
#ifdef WOLFSSL_LMS_SHAKE256
1327-
case LMS_SHAKE256: /* SHAKE256 with 32-byte output */
1328-
case LMS_SHAKE256_192: /* SHAKE256 with 24-byte output */ {
1329-
ret = wc_Shake256Hash(msg, msgSz, hash, needSz);
1330-
break;
1331-
}
1332-
#endif
1333-
default:
1334-
WOLFSSL_MSG("LMS: unsupported hash family for HashMsg");
1335-
ret = NOT_COMPILED_IN;
1336-
break;
1337-
}
1338-
1339-
if (ret == 0)
1340-
*hashSz = needSz;
1341-
1342-
return ret;
1343-
}
1344-
13451285
/* Sign a message.
13461286
*
13471287
* @param [in, out] key LMS key to sign with.

wolfcrypt/src/wc_xmss.c

Lines changed: 0 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,79 +1421,6 @@ int wc_XmssKey_GetPrivLen(const XmssKey* key, word32* len)
14211421
return ret;
14221422
}
14231423

1424-
/* Compute the digest of msg using the hash function dictated by the XMSS
1425-
* parameter set. Crypto-callback / HSM backends that follow PKCS#11 v3.2
1426-
* CKM_XMSS / CKM_XMSSMT semantics (pre-computed digest input, see section
1427-
* 6.66.8 "XMSS and XMSSMT without hashing") can call this from within
1428-
* their callback; backends that take the raw message (e.g. wolfHSM) can
1429-
* ignore it. *hashSz is in/out: it must be at least params->n on entry
1430-
* and is set to the actual digest length on success.
1431-
*
1432-
* @param [in] key XMSS key (must have a parameter set bound).
1433-
* @param [in] msg Message to hash.
1434-
* @param [in] msgSz Length of msg in bytes.
1435-
* @param [out] hash Buffer receiving the digest.
1436-
* @param [in,out] hashSz On entry, size of hash buffer. On success,
1437-
* the digest length.
1438-
* @return 0 on success.
1439-
* @return BAD_FUNC_ARG when an argument is NULL or the buffer is too
1440-
* small for the digest.
1441-
* @return NOT_COMPILED_IN when the param set's hash family is disabled.
1442-
*/
1443-
int wc_XmssKey_HashMsg(const XmssKey* key, const byte* msg, word32 msgSz,
1444-
byte* hash, word32* hashSz)
1445-
{
1446-
int ret = 0;
1447-
word32 needSz;
1448-
1449-
if ((key == NULL) || (msg == NULL) || (hash == NULL) || (hashSz == NULL))
1450-
return BAD_FUNC_ARG;
1451-
if (key->params == NULL)
1452-
return BAD_FUNC_ARG;
1453-
needSz = (word32)key->params->n;
1454-
if (*hashSz < needSz)
1455-
return BAD_FUNC_ARG;
1456-
1457-
switch (key->params->hash) {
1458-
#ifdef WC_XMSS_SHA256
1459-
case WC_HASH_TYPE_SHA256: {
1460-
/* SHA2_*_192 variants set n=24, but wc_Hash rejects an output
1461-
* smaller than WC_SHA256_DIGEST_SIZE. Hash to a full buffer and
1462-
* copy the requested prefix. */
1463-
byte full[WC_SHA256_DIGEST_SIZE];
1464-
ret = wc_Sha256Hash(msg, msgSz, full);
1465-
if (ret == 0)
1466-
XMEMCPY(hash, full, needSz);
1467-
break;
1468-
}
1469-
#endif
1470-
#ifdef WC_XMSS_SHA512
1471-
case WC_HASH_TYPE_SHA512:
1472-
ret = wc_Hash(WC_HASH_TYPE_SHA512, msg, msgSz, hash, needSz);
1473-
break;
1474-
#endif
1475-
#ifdef WC_XMSS_SHAKE128
1476-
case WC_HASH_TYPE_SHAKE128:
1477-
ret = wc_Shake128Hash(msg, msgSz, hash, needSz);
1478-
break;
1479-
#endif
1480-
#ifdef WC_XMSS_SHAKE256
1481-
case WC_HASH_TYPE_SHAKE256:
1482-
ret = wc_Shake256Hash(msg, msgSz, hash, needSz);
1483-
break;
1484-
#endif
1485-
default:
1486-
WOLFSSL_MSG("XMSS: unsupported hash for HashMsg");
1487-
ret = NOT_COMPILED_IN;
1488-
break;
1489-
}
1490-
1491-
if (ret == 0)
1492-
*hashSz = needSz;
1493-
1494-
return ret;
1495-
}
1496-
14971424
/* Sign the message using the XMSS secret key.
14981425
*
14991426
* @param [in] key XMSS key to use to sign.

wolfssl/wolfcrypt/cryptocb.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -357,11 +357,6 @@ typedef struct wc_CryptoInfo {
357357
int type; /* enum wc_PqcStatefulSignatureType */
358358
} pqc_stateful_sig_kg;
359359
struct {
360-
/* Raw message. Backends following the PKCS#11 v3.2
361-
* CKM_HSS / CKM_XMSS convention of operating on a
362-
* pre-computed digest can call wc_LmsKey_HashMsg /
363-
* wc_XmssKey_HashMsg from inside the callback to obtain
364-
* the algorithm-dictated digest of msg. */
365360
const byte* msg;
366361
word32 msgSz;
367362
byte* out;
@@ -372,7 +367,6 @@ typedef struct wc_CryptoInfo {
372367
struct {
373368
const byte* sig;
374369
word32 sigSz;
375-
/* Raw message. See sign note. */
376370
const byte* msg;
377371
word32 msgSz;
378372
int* res;
@@ -757,9 +751,6 @@ WOLFSSL_LOCAL int wc_CryptoCb_PqcStatefulSigGetDevId(int type, void* key);
757751

758752
WOLFSSL_LOCAL int wc_CryptoCb_PqcStatefulSigKeyGen(int type, void* key,
759753
WC_RNG* rng);
760-
/* The raw message is forwarded to the callback. Backends that follow the
761-
* PKCS#11 v3.2 CKM_HSS / CKM_XMSS convention (digest input) can call
762-
* wc_LmsKey_HashMsg / wc_XmssKey_HashMsg from inside the callback. */
763754
WOLFSSL_LOCAL int wc_CryptoCb_PqcStatefulSigSign(const byte* msg,
764755
word32 msgSz, byte* out, word32* outSz, int type, void* key);
765756
WOLFSSL_LOCAL int wc_CryptoCb_PqcStatefulSigVerify(const byte* sig,

wolfssl/wolfcrypt/wc_lms.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -825,8 +825,6 @@ WOLFSSL_API int wc_LmsKey_ImportPubRaw(LmsKey * key, const byte * in,
825825
word32 inLen);
826826
WOLFSSL_API int wc_LmsKey_Verify(LmsKey * key, const byte * sig, word32 sigSz,
827827
const byte * msg, int msgSz);
828-
WOLFSSL_API int wc_LmsKey_HashMsg(const LmsKey * key, const byte * msg,
829-
word32 msgSz, byte * hash, word32 * hashSz);
830828
WOLFSSL_API const char * wc_LmsKey_ParmToStr(enum wc_LmsParm lmsParm);
831829
WOLFSSL_API const char * wc_LmsKey_RcToStr(enum wc_LmsRc lmsRc);
832830

wolfssl/wolfcrypt/wc_xmss.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -457,12 +457,6 @@ WOLFSSL_API int wc_XmssKey_ImportPubRaw(XmssKey* key, const byte* in,
457457
word32 inLen);
458458
WOLFSSL_API int wc_XmssKey_Verify(XmssKey* key, const byte* sig, word32 sigSz,
459459
const byte* msg, int msgSz);
460-
/* Compute the digest of a message with the hash function dictated by the
461-
* XMSS parameter set. Useful for crypto-callback / HSM backends that follow
462-
* the PKCS#11 v3.2 CKM_XMSS / CKM_XMSSMT convention of taking a
463-
* pre-computed digest. */
464-
WOLFSSL_API int wc_XmssKey_HashMsg(const XmssKey* key, const byte* msg,
465-
word32 msgSz, byte* hash, word32* hashSz);
466460

467461
WOLFSSL_LOCAL int wc_xmssmt_keygen(XmssState *state, const unsigned char* seed,
468462
unsigned char *sk, unsigned char *pk);

0 commit comments

Comments
 (0)