Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,38 @@ jobs:
runs-on: ${{ matrix.target.runner }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: "PCT enabled"
uses: ./.github/actions/multi-functest
with:
gh_token: ${{ secrets.GITHUB_TOKEN }}
compile_mode: native
cflags: "-DMLD_CONFIG_KEYGEN_PCT -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all"
func: true
kat: true
acvp: true
- name: "PCT enabled + broken"
run: |
make clean
CFLAGS='-DMLD_CONFIG_FILE=\"../test/break_pct_config.h\"' make func -j4
# PCT breakage is done at runtime via MLD_BREAK_PCT
make run_func # Should be OK
MLD_BREAK_PCT=0 make run_func # Should be OK
if (MLD_BREAK_PCT=1 make run_func 2>&1 >/dev/null); then
echo "PCT failure expected"
exit 1
else
echo "PCT failed as expected"
fi
- name: "Custom zeroization (explicit_bzero)"
uses: ./.github/actions/multi-functest
with:
gh_token: ${{ secrets.GITHUB_TOKEN }}
compile_mode: native
cflags: "-std=c11 -D_GNU_SOURCE -DMLD_CONFIG_FILE=\\\\\\\"../test/custom_zeroize_config.h\\\\\\\" -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all"
func: true
kat: true
acvp: true
examples: false # Some examples use a custom config themselves
- name: "No ASM"
uses: ./.github/actions/multi-functest
with:
Expand Down
12 changes: 11 additions & 1 deletion mldsa/sign.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ __contract__(
#endif /* MLDSA_MODE == 5 */
}

MLD_MUST_CHECK_RETURN_VALUE
int crypto_sign_keypair_internal(uint8_t *pk, uint8_t *sk,
const uint8_t seed[MLDSA_SEEDBYTES])
{
Expand Down Expand Up @@ -193,6 +194,7 @@ int crypto_sign_keypair_internal(uint8_t *pk, uint8_t *sk,
return 0;
}

MLD_MUST_CHECK_RETURN_VALUE
int crypto_sign_keypair(uint8_t *pk, uint8_t *sk)
{
uint8_t seed[MLDSA_SEEDBYTES];
Expand Down Expand Up @@ -291,6 +293,7 @@ __contract__(
* step into a distinct function here in order to improve
* efficiency of CBMC proof.
**************************************************/
MLD_MUST_CHECK_RETURN_VALUE
static int mld_attempt_signature_generation(
uint8_t *sig, const uint8_t *mu, const uint8_t rhoprime[MLDSA_CRHBYTES],
uint16_t nonce, const mld_polyvecl mat[MLDSA_K], const mld_polyvecl *s1,
Expand Down Expand Up @@ -471,7 +474,7 @@ __contract__(

return 0; /* success */
}

MLD_MUST_CHECK_RETURN_VALUE
int crypto_sign_signature_internal(uint8_t *sig, size_t *siglen,
const uint8_t *m, size_t mlen,
const uint8_t *pre, size_t prelen,
Expand Down Expand Up @@ -565,6 +568,7 @@ int crypto_sign_signature_internal(uint8_t *sig, size_t *siglen,
}
}

MLD_MUST_CHECK_RETURN_VALUE
int crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m,
size_t mlen, const uint8_t *ctx, size_t ctxlen,
const uint8_t *sk)
Expand Down Expand Up @@ -613,6 +617,7 @@ int crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m,
return result;
}

MLD_MUST_CHECK_RETURN_VALUE
int crypto_sign_signature_extmu(uint8_t *sig, size_t *siglen,
const uint8_t mu[MLDSA_CRHBYTES],
const uint8_t *sk)
Expand All @@ -636,6 +641,7 @@ int crypto_sign_signature_extmu(uint8_t *sig, size_t *siglen,
return result;
}

MLD_MUST_CHECK_RETURN_VALUE
int crypto_sign(uint8_t *sm, size_t *smlen, const uint8_t *m, size_t mlen,
const uint8_t *ctx, size_t ctxlen, const uint8_t *sk)
{
Expand All @@ -656,6 +662,7 @@ int crypto_sign(uint8_t *sm, size_t *smlen, const uint8_t *m, size_t mlen,
return ret;
}

MLD_MUST_CHECK_RETURN_VALUE
int crypto_sign_verify_internal(const uint8_t *sig, size_t siglen,
const uint8_t *m, size_t mlen,
const uint8_t *pre, size_t prelen,
Expand Down Expand Up @@ -763,6 +770,7 @@ int crypto_sign_verify_internal(const uint8_t *sig, size_t siglen,
return 0;
}

MLD_MUST_CHECK_RETURN_VALUE
int crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m,
size_t mlen, const uint8_t *ctx, size_t ctxlen,
const uint8_t *pk)
Expand Down Expand Up @@ -795,6 +803,7 @@ int crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m,
return result;
}

MLD_MUST_CHECK_RETURN_VALUE
int crypto_sign_verify_extmu(const uint8_t *sig, size_t siglen,
const uint8_t mu[MLDSA_CRHBYTES],
const uint8_t *pk)
Expand All @@ -803,6 +812,7 @@ int crypto_sign_verify_extmu(const uint8_t *sig, size_t siglen,
pk, 1);
}

MLD_MUST_CHECK_RETURN_VALUE
int crypto_sign_open(uint8_t *m, size_t *mlen, const uint8_t *sm, size_t smlen,
const uint8_t *ctx, size_t ctxlen, const uint8_t *pk)
{
Expand Down
11 changes: 11 additions & 0 deletions mldsa/sign.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "common.h"
#include "poly.h"
#include "polyvec.h"
#include "sys.h"

#define crypto_sign_keypair_internal MLD_NAMESPACE(keypair_internal)
/*************************************************
Expand All @@ -30,6 +31,7 @@
*
* Returns 0 (success) or -1 (PCT failure)
**************************************************/
MLD_MUST_CHECK_RETURN_VALUE
int crypto_sign_keypair_internal(uint8_t *pk, uint8_t *sk,
const uint8_t seed[MLDSA_SEEDBYTES])
__contract__(
Expand Down Expand Up @@ -57,6 +59,7 @@ __contract__(
*
* Returns 0 (success) or -1 (PCT failure)
**************************************************/
MLD_MUST_CHECK_RETURN_VALUE
int crypto_sign_keypair(uint8_t *pk, uint8_t *sk)
__contract__(
requires(memory_no_alias(pk, CRYPTO_PUBLICKEYBYTES))
Expand Down Expand Up @@ -92,6 +95,7 @@ __contract__(
* in that it adds an explicit check for nonce exhaustion
* and can return -1 in that case.
**************************************************/
MLD_MUST_CHECK_RETURN_VALUE
int crypto_sign_signature_internal(uint8_t *sig, size_t *siglen,
const uint8_t *m, size_t mlen,
const uint8_t *pre, size_t prelen,
Expand Down Expand Up @@ -130,6 +134,7 @@ __contract__(
*
* Returns 0 (success) or -1 (context string too long OR nonce exhaustion)
**************************************************/
MLD_MUST_CHECK_RETURN_VALUE
int crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m,
size_t mlen, const uint8_t *ctx, size_t ctxlen,
const uint8_t *sk)
Expand Down Expand Up @@ -160,6 +165,7 @@ __contract__(
*
* Returns 0 (success) or -1 (context string too long OR nonce exhaustion)
**************************************************/
MLD_MUST_CHECK_RETURN_VALUE
int crypto_sign_signature_extmu(uint8_t *sig, size_t *siglen,
const uint8_t mu[MLDSA_CRHBYTES],
const uint8_t *sk)
Expand Down Expand Up @@ -193,6 +199,7 @@ __contract__(
*
* Returns 0 (success) or -1 (context string too long OR nonce exhausted)
**************************************************/
MLD_MUST_CHECK_RETURN_VALUE
int crypto_sign(uint8_t *sm, size_t *smlen, const uint8_t *m, size_t mlen,
const uint8_t *ctx, size_t ctxlen, const uint8_t *sk)
__contract__(
Expand Down Expand Up @@ -225,6 +232,7 @@ __contract__(
*
* Returns 0 if signature could be verified correctly and -1 otherwise
**************************************************/
MLD_MUST_CHECK_RETURN_VALUE
int crypto_sign_verify_internal(const uint8_t *sig, size_t siglen,
const uint8_t *m, size_t mlen,
const uint8_t *pre, size_t prelen,
Expand Down Expand Up @@ -256,6 +264,7 @@ __contract__(
*
* Returns 0 if signature could be verified correctly and -1 otherwise
**************************************************/
MLD_MUST_CHECK_RETURN_VALUE
int crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m,
size_t mlen, const uint8_t *ctx, size_t ctxlen,
const uint8_t *pk)
Expand All @@ -281,6 +290,7 @@ __contract__(
*
* Returns 0 if signature could be verified correctly and -1 otherwise
**************************************************/
MLD_MUST_CHECK_RETURN_VALUE
int crypto_sign_verify_extmu(const uint8_t *sig, size_t siglen,
const uint8_t mu[MLDSA_CRHBYTES],
const uint8_t *pk)
Expand Down Expand Up @@ -308,6 +318,7 @@ __contract__(
*
* Returns 0 if signed message could be verified correctly and -1 otherwise
**************************************************/
MLD_MUST_CHECK_RETURN_VALUE
int crypto_sign_open(uint8_t *m, size_t *mlen, const uint8_t *sm, size_t smlen,
const uint8_t *ctx, size_t ctxlen, const uint8_t *pk)
__contract__(
Expand Down
Loading
Loading