Skip to content

Commit a2298dd

Browse files
authored
Merge pull request #10105 from padelsbach/lms-sign-external
Add buffer size and callback checks to external wc_LmsKey_Sign
2 parents 5f54de0 + 2ac3020 commit a2298dd

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

wolfcrypt/src/ext_lms.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,22 @@ int wc_LmsKey_Sign(LmsKey* key, byte * sig, word32 * sigSz, const byte * msg,
840840
return -1;
841841
}
842842

843+
if ((size_t)*sigSz < len) {
844+
/* Signature buffer too small. */
845+
WOLFSSL_MSG("error: LMS sig buffer too small");
846+
return BUFFER_E;
847+
}
848+
849+
if (key->write_private_key == NULL) {
850+
WOLFSSL_MSG("error: LmsKey write/read callbacks are not set");
851+
return BAD_FUNC_ARG;
852+
}
853+
854+
if (key->context == NULL) {
855+
WOLFSSL_MSG("error: LmsKey context is not set");
856+
return BAD_FUNC_ARG;
857+
}
858+
843859
result = hss_generate_signature(key->working_key, LmsWritePrivKey,
844860
key, (const void *) msg, msgSz,
845861
sig, len, &key->info);

0 commit comments

Comments
 (0)