Skip to content

Commit 126af2e

Browse files
committed
CBMC: Prove keccak_f1600_x4_native based on keccak_f1600_x4_scalar_v8a_v84a_asm_hybrid
Signed-off-by: Matthias J. Kannwischer <matthias@kannwischer.eu>
1 parent 6c93f0c commit 126af2e

File tree

4 files changed

+80
-4
lines changed

4 files changed

+80
-4
lines changed

dev/fips202/aarch64/src/fips202_native_aarch64.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ __contract__(
5151
#define mlk_keccak_f1600_x4_scalar_v8a_v84a_hybrid_asm \
5252
MLK_NAMESPACE(keccak_f1600_x4_scalar_v8a_v84a_hybrid_asm)
5353
void mlk_keccak_f1600_x4_scalar_v8a_v84a_hybrid_asm(uint64_t *state,
54-
uint64_t const *rc);
55-
54+
uint64_t const *rc)
55+
__contract__(
56+
requires(memory_no_alias(state, sizeof(uint64_t) * 25 * 4))
57+
requires(rc == mlk_keccakf1600_round_constants)
58+
assigns(memory_slice(state, sizeof(uint64_t) * 25 * 4))
59+
);
5660

5761
#endif /* !MLK_DEV_FIPS202_AARCH64_SRC_FIPS202_NATIVE_AARCH64_H */

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ __contract__(
5151
#define mlk_keccak_f1600_x4_scalar_v8a_v84a_hybrid_asm \
5252
MLK_NAMESPACE(keccak_f1600_x4_scalar_v8a_v84a_hybrid_asm)
5353
void mlk_keccak_f1600_x4_scalar_v8a_v84a_hybrid_asm(uint64_t *state,
54-
uint64_t const *rc);
55-
54+
uint64_t const *rc)
55+
__contract__(
56+
requires(memory_no_alias(state, sizeof(uint64_t) * 25 * 4))
57+
requires(rc == mlk_keccakf1600_round_constants)
58+
assigns(memory_slice(state, sizeof(uint64_t) * 25 * 4))
59+
);
5660

5761
#endif /* !MLK_FIPS202_NATIVE_AARCH64_SRC_FIPS202_NATIVE_AARCH64_H */
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_x4_native_aarch64_scalar_v8a_v84a_hybrid_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_x4_native_aarch64_scalar_v8a_v84a_hybrid
12+
13+
DEFINES += -DMLK_CONFIG_USE_NATIVE_BACKEND_FIPS202 -DMLK_CONFIG_FIPS202_BACKEND_FILE="\"$(SRCDIR)/mlkem/fips202/native/aarch64/x4_v8a_v84a_scalar.h\"" -DMLK_CHECK_APIS
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_x4_native
23+
USE_FUNCTION_CONTRACTS=mlk_keccak_f1600_x4_scalar_v8a_v84a_hybrid_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_x4_native_aarch64_scalar_v8a_v84a_hybrid
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
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_x4_native(uint64_t *state);
8+
9+
void harness(void)
10+
{
11+
uint64_t *s;
12+
mlk_keccak_f1600_x4_native(s);
13+
}

0 commit comments

Comments
 (0)