Skip to content

Commit 7f272ff

Browse files
committed
CBMC: Prove keccak_f1600_x2_native based on keccak_f1600_x2_v84a_asm
Signed-off-by: Matthias J. Kannwischer <matthias@kannwischer.eu>
1 parent fbf2d6d commit 7f272ff

File tree

4 files changed

+80
-2
lines changed

4 files changed

+80
-2
lines changed

dev/fips202/aarch64/src/fips202_native_aarch64.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@ __contract__(
3131
);
3232

3333
#define mlk_keccak_f1600_x2_v84a_asm MLK_NAMESPACE(keccak_f1600_x2_v84a_asm)
34-
void mlk_keccak_f1600_x2_v84a_asm(uint64_t *state, uint64_t const *rc);
34+
void mlk_keccak_f1600_x2_v84a_asm(uint64_t *state, uint64_t const *rc)
35+
__contract__(
36+
requires(memory_no_alias(state, sizeof(uint64_t) * 25 * 2))
37+
requires(rc == mlk_keccakf1600_round_constants)
38+
assigns(memory_slice(state, sizeof(uint64_t) * 25 * 2))
39+
);
3540

3641
#define mlk_keccak_f1600_x2_v8a_v84a_asm_hybrid \
3742
MLK_NAMESPACE(keccak_f1600_x2_v8a_v84a_asm_hybrid)

mlkem/fips202/native/aarch64/src/fips202_native_aarch64.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@ __contract__(
3131
);
3232

3333
#define mlk_keccak_f1600_x2_v84a_asm MLK_NAMESPACE(keccak_f1600_x2_v84a_asm)
34-
void mlk_keccak_f1600_x2_v84a_asm(uint64_t *state, uint64_t const *rc);
34+
void mlk_keccak_f1600_x2_v84a_asm(uint64_t *state, uint64_t const *rc)
35+
__contract__(
36+
requires(memory_no_alias(state, sizeof(uint64_t) * 25 * 2))
37+
requires(rc == mlk_keccakf1600_round_constants)
38+
assigns(memory_slice(state, sizeof(uint64_t) * 25 * 2))
39+
);
3540

3641
#define mlk_keccak_f1600_x2_v8a_v84a_asm_hybrid \
3742
MLK_NAMESPACE(keccak_f1600_x2_v8a_v84a_asm_hybrid)
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Copyright (c) The mlkem-native project authors
2+
# SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
3+
4+
include ../Makefile_params.common
5+
6+
HARNESS_ENTRY = harness
7+
HARNESS_FILE = keccak_f1600_x2_native_aarch64_v84a_harness
8+
9+
# This should be a unique identifier for this proof, and will appear on the
10+
# Litani dashboard. It can be human-readable and contain spaces if you wish.
11+
PROOF_UID = keccak_f1600_x2_native_aarch64_v84a
12+
13+
DEFINES += -DMLK_CONFIG_USE_NATIVE_BACKEND_FIPS202 -DMLK_CONFIG_FIPS202_BACKEND_FILE="\"$(SRCDIR)/mlkem/fips202/native/aarch64/x2_v84a.h\"" -DMLK_CHECK_APIS -D__ARM_FEATURE_SHA3
14+
INCLUDES +=
15+
16+
REMOVE_FUNCTION_BODY +=
17+
UNWINDSET +=
18+
19+
PROOF_SOURCES += $(PROOFDIR)/$(HARNESS_FILE).c
20+
PROJECT_SOURCES += $(SRCDIR)/mlkem/fips202/native/aarch64/src/keccakf1600_round_constants.c
21+
22+
CHECK_FUNCTION_CONTRACTS=mlk_keccak_f1600_x2_native
23+
USE_FUNCTION_CONTRACTS=mlk_keccak_f1600_x2_v84a_asm
24+
APPLY_LOOP_CONTRACTS=on
25+
USE_DYNAMIC_FRAMES=1
26+
27+
# Disable any setting of EXTERNAL_SAT_SOLVER, and choose SMT backend instead
28+
EXTERNAL_SAT_SOLVER=
29+
CBMCFLAGS=--bitwuzla
30+
31+
FUNCTION_NAME = keccak_f1600_x2_native_aarch64_v84a
32+
33+
# If this proof is found to consume huge amounts of RAM, you can set the
34+
# EXPENSIVE variable. With new enough versions of the proof tools, this will
35+
# restrict the number of EXPENSIVE CBMC jobs running at once. See the
36+
# documentation in Makefile.common under the "Job Pools" heading for details.
37+
# EXPENSIVE = true
38+
39+
# This function is large enough to need...
40+
CBMC_OBJECT_BITS = 8
41+
42+
# If you require access to a file-local ("static") function or object to conduct
43+
# your proof, set the following (and do not include the original source file
44+
# ("mlkem/poly.c") in PROJECT_SOURCES).
45+
# REWRITTEN_SOURCES = $(PROOFDIR)/<__SOURCE_FILE_BASENAME__>.i
46+
# include ../Makefile.common
47+
# $(PROOFDIR)/<__SOURCE_FILE_BASENAME__>.i_SOURCE = $(SRCDIR)/mlkem/poly.c
48+
# $(PROOFDIR)/<__SOURCE_FILE_BASENAME__>.i_FUNCTIONS = foo bar
49+
# $(PROOFDIR)/<__SOURCE_FILE_BASENAME__>.i_OBJECTS = baz
50+
# Care is required with variables on the left-hand side: REWRITTEN_SOURCES must
51+
# be set before including Makefile.common, but any use of variables on the
52+
# left-hand side requires those variables to be defined. Hence, _SOURCE,
53+
# _FUNCTIONS, _OBJECTS is set after including Makefile.common.
54+
55+
include ../Makefile.common
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright (c) The mlkem-native project authors
2+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
// SPDX-License-Identifier: MIT-0
4+
5+
#include <stdint.h>
6+
7+
void mlk_keccak_f1600_x2_native(uint64_t *state);
8+
9+
void harness(void)
10+
{
11+
uint64_t *s;
12+
mlk_keccak_f1600_x2_native(s);
13+
}

0 commit comments

Comments
 (0)