Skip to content

Commit 33337c7

Browse files
mkannwischerrod-chapman
authored andcommitted
sign: Set smlen to 0 in case of failure
In mld_sign if a failure is returned from mld_sign_signature, we currently set the smlen to mlen (mld_sign_signature returns smlen=0, and we increment it by mlen). This commit changes it so that in the case of failure smlen=0 is returned. Signed-off-by: Matthias J. Kannwischer <matthias@kannwischer.eu>
1 parent 0b1c536 commit 33337c7

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

mldsa/src/sign.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -964,7 +964,10 @@ int mld_sign(uint8_t *sm, size_t *smlen, const uint8_t *m, size_t mlen,
964964
}
965965
ret = mld_sign_signature(sm, smlen, sm + MLDSA_CRYPTO_BYTES, mlen, ctx,
966966
ctxlen, sk, context);
967-
*smlen += mlen;
967+
if (ret == 0)
968+
{
969+
*smlen += mlen;
970+
}
968971
return ret;
969972
}
970973
#endif /* !MLD_CONFIG_NO_RANDOMIZED_API */

0 commit comments

Comments
 (0)