Skip to content

Commit 2cb1371

Browse files
mkannwischerhanno-becker
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 5dc4211 commit 2cb1371

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
@@ -1004,7 +1004,10 @@ int mld_sign(uint8_t *sm, size_t *smlen, const uint8_t *m, size_t mlen,
10041004
}
10051005
ret = mld_sign_signature(sm, smlen, sm + MLDSA_CRYPTO_BYTES, mlen, ctx,
10061006
ctxlen, sk, context);
1007-
*smlen += mlen;
1007+
if (ret == 0)
1008+
{
1009+
*smlen += mlen;
1010+
}
10081011
return ret;
10091012
}
10101013
#endif /* !MLD_CONFIG_NO_RANDOMIZED_API */

0 commit comments

Comments
 (0)