Add buffer size and callback checks to external wc_LmsKey_Sign

This commit is contained in:
Paul Adelsbach
2026-03-30 15:02:13 -07:00
parent 0a61997059
commit 2ac3020bb6
+16
View File
@@ -840,6 +840,22 @@ int wc_LmsKey_Sign(LmsKey* key, byte * sig, word32 * sigSz, const byte * msg,
return -1;
}
if ((size_t)*sigSz < len) {
/* Signature buffer too small. */
WOLFSSL_MSG("error: LMS sig buffer too small");
return BUFFER_E;
}
if (key->write_private_key == NULL) {
WOLFSSL_MSG("error: LmsKey write/read callbacks are not set");
return BAD_FUNC_ARG;
}
if (key->context == NULL) {
WOLFSSL_MSG("error: LmsKey context is not set");
return BAD_FUNC_ARG;
}
result = hss_generate_signature(key->working_key, LmsWritePrivKey,
key, (const void *) msg, msgSz,
sig, len, &key->info);