Skip to content

Commit

Permalink
Add overrides value_barrier_u32_ov and value_barrier_w_ov for EC rela…
Browse files Browse the repository at this point in the history
…ted proofs (#120)

and disable RSA proof in debug mode
  • Loading branch information
pennyannn authored Oct 10, 2023
1 parent 076973c commit 70e3732
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[submodule "src"]
path = src
branch = main
url = https://github.com/aws/aws-lc.git
branch = upstream-merge-2023-10-02
url = https://github.com/dkostic/aws-lc.git
[submodule "cryptol-specs"]
path = cryptol-specs
branch = sha-imperative
Expand Down
14 changes: 14 additions & 0 deletions SAW/patch/noinline-value_barrier_u32.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
diff --git a/crypto/internal.h b/crypto/internal.h
index 295f1dd97..a5470c17a 100644
--- a/crypto/internal.h
+++ b/crypto/internal.h
@@ -289,7 +289,8 @@ static inline crypto_word_t value_barrier_w(crypto_word_t a) {
}

// value_barrier_u32 behaves like |value_barrier_w| but takes a |uint32_t|.
-static inline uint32_t value_barrier_u32(uint32_t a) {
+__attribute__((noinline))
+static uint32_t value_barrier_u32(uint32_t a) {
#if defined(__GNUC__) || defined(__clang__)
__asm__("" : "+r"(a) : /* no inputs */);
#endif
3 changes: 2 additions & 1 deletion SAW/proof/EC/EC.saw
Original file line number Diff line number Diff line change
Expand Up @@ -1191,7 +1191,8 @@ ec_point_mul_scalar_ov <- llvm_verify m "ec_point_mul_scalar"

ec_point_mul_scalar_base_ov <- llvm_verify m "ec_point_mul_scalar_base"
[ p384_point_mul_base_ov
, ec_GFp_simple_is_on_curve_ov]
, ec_GFp_simple_is_on_curve_ov
, value_barrier_u32_ov ]
true
ec_point_mul_scalar_base_spec
(do {
Expand Down
6 changes: 6 additions & 0 deletions SAW/proof/EC/EC_P384_primitives.saw
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,7 @@ p384_point_add_jac_ov <- llvm_verify m "p384_point_add"
, p384_felem_cmovznz_same_r_ov
, constant_time_is_zero_w_ov
, p384_point_double_ov
, value_barrier_w_ov
]
true
(p384_point_add_spec 0)
Expand Down Expand Up @@ -547,6 +548,7 @@ p384_point_add_mixed_ov <- llvm_verify m "p384_point_add"
, p384_felem_cmovznz_same_r_ov
, constant_time_is_zero_w_ov
, p384_point_double_ov
, value_barrier_w_ov
]
true
(p384_point_add_spec 1)
Expand Down Expand Up @@ -581,6 +583,7 @@ p384_point_add_same_r_jac_ov <- llvm_verify m "p384_point_add"
, p384_felem_cmovznz_same_r_ov
, constant_time_is_zero_w_ov
, p384_point_double_ov
, value_barrier_w_ov
]
true
(p384_point_add_same_r_spec 0)
Expand Down Expand Up @@ -616,6 +619,7 @@ p384_point_add_same_l_jac_ov <- llvm_verify m "p384_point_add"
, p384_felem_cmovznz_same_l_ov
, constant_time_is_zero_w_ov
, p384_point_double_same_ov
, value_barrier_w_ov
]
true
(p384_point_add_same_l_spec 0)
Expand Down Expand Up @@ -651,6 +655,7 @@ p384_point_add_same_l_mixed_ov <- llvm_verify m "p384_point_add"
, p384_felem_cmovznz_same_l_ov
, constant_time_is_zero_w_ov
, p384_point_double_same_ov
, value_barrier_w_ov
]
true
(p384_point_add_same_l_spec 1)
Expand Down Expand Up @@ -686,6 +691,7 @@ p384_point_add_same_r_mixed_ov <- llvm_verify m "p384_point_add"
, p384_felem_cmovznz_same_l_ov
, constant_time_is_zero_w_ov
, p384_point_double_ov
, value_barrier_w_ov
]
true
p384_point_add_same_r_mixed_spec
Expand Down
1 change: 1 addition & 0 deletions SAW/proof/ECDSA/verify-ECDSA.saw
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ ECDSA_do_sign_ov <- llvm_verify m "ECDSA_do_sign"
, ec_GFp_mont_mul_public_batch_ov
, ec_GFp_mont_cmp_x_coordinate_ov
, value_barrier_w_ov
, value_barrier_u32_ov
]
true
ECDSA_do_sign_spec
Expand Down
15 changes: 15 additions & 0 deletions SAW/proof/common/internal.saw
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ let value_barrier_w_spec = do {
crucible_return (crucible_term a);
};

let value_barrier_u32_spec = do {

a <- crucible_fresh_var "a" (llvm_int 32);
crucible_execute_func [crucible_term a];
crucible_return (crucible_term a);
};


let CRYPTO_REFCOUNT_MAX = 0xffffffff;

Expand Down Expand Up @@ -82,6 +89,14 @@ value_barrier_w_ov <- llvm_verify_x86 m "../../build/x86/crypto/crypto_test" "va
w4_unint_yices [];
});

value_barrier_u32_ov <- llvm_verify_x86 m "../../build/x86/crypto/crypto_test" "value_barrier_u32"
[]
true
value_barrier_u32_spec
(do {
w4_unint_yices [];
});


CRYPTO_refcount_inc_ov <- crucible_llvm_unsafe_assume_spec
m
Expand Down
17 changes: 10 additions & 7 deletions SAW/scripts/entrypoint_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ apply_patch "noinline-ec_point_mul_scalar_base"
apply_patch "noinline-ec_get_x_coordinate_as_bytes"
apply_patch "noinline-ec_get_x_coordinate_as_scalar"
apply_patch "noinline-value_barrier_w"
apply_patch "noinline-value_barrier_u32"
apply_patch "noinline-GetInPlaceMethods"
apply_patch "noinline-fiat_p384_sub"
apply_patch "noinline-p384_get_bit"
Expand All @@ -54,12 +55,14 @@ apply_patch "noinline-EVP_DigestVerifyUpdate"
./scripts/post_build.sh
./scripts/run_checks_release.sh

# ...finally, check the proofs using CMake's Debug settings.

rm -rf build/
rm -rf build_src/
# Disabling the proof for RSA in debug mode
# # ...finally, check the proofs using CMake's Debug settings.

./scripts/build_x86.sh "Debug"
./scripts/build_llvm.sh "Debug"
./scripts/post_build.sh
./scripts/run_checks_debug.sh
# rm -rf build/
# rm -rf build_src/

# ./scripts/build_x86.sh "Debug"
# ./scripts/build_llvm.sh "Debug"
# ./scripts/post_build.sh
# ./scripts/run_checks_debug.sh
2 changes: 1 addition & 1 deletion src
Submodule src updated 98 files
+0 −4 .gitignore
+6 −2 CMakeLists.txt
+1 −6 crypto/CMakeLists.txt
+13 −3 crypto/bytestring/cbb.c
+9 −0 crypto/bytestring/cbs.c
+19 −1 crypto/chacha/chacha.c
+110 −0 crypto/chacha/chacha_test.cc
+8 −1 crypto/chacha/internal.h
+4 −1 crypto/compiler_test.cc
+1 −0 crypto/conf/conf_test.cc
+2 −2 crypto/curve25519/curve25519.c
+2 −1 crypto/curve25519/curve25519_nohw.c
+9 −0 crypto/curve25519/ed25519_test.cc
+76 −11 crypto/curve25519/x25519_test.cc
+2 −0 crypto/decrepit/evp/evp_do_all.c
+1 −0 crypto/digest_extra/digest_extra.c
+14 −5 crypto/digest_extra/digest_test.cc
+250 −0 crypto/endian_test.cc
+2 −0 crypto/evp_extra/evp_extra_test.cc
+2 −0 crypto/evp_extra/evp_test.cc
+5 −0 crypto/fipsmodule/CMakeLists.txt
+5 −2 crypto/fipsmodule/bcm.c
+30 −0 crypto/fipsmodule/bn/bn_test.cc
+60 −11 crypto/fipsmodule/bn/bytes.c
+62 −17 crypto/fipsmodule/bn/exponentiation.c
+5 −6 crypto/fipsmodule/bn/gcd.c
+9 −3 crypto/fipsmodule/bn/internal.h
+24 −0 crypto/fipsmodule/digest/digests.c
+5 −2 crypto/fipsmodule/ec/ec.c
+3 −2 crypto/fipsmodule/ec/ec_montgomery.c
+2 −1 crypto/fipsmodule/ec/internal.h
+5 −8 crypto/fipsmodule/ec/p224-64.c
+2 −1 crypto/fipsmodule/ec/p256-nistz.c
+3 −2 crypto/fipsmodule/ec/p256.c
+2 −2 crypto/fipsmodule/ec/p384.c
+2 −2 crypto/fipsmodule/ec/p521.c
+3 −0 crypto/fipsmodule/ec/simple_mul.c
+8 −2 crypto/fipsmodule/ecdsa/ecdsa.c
+4 −3 crypto/fipsmodule/evp/p_ec.c
+3 −1 crypto/fipsmodule/hmac/hmac.c
+4 −4 crypto/fipsmodule/rand/internal.h
+0 −9 crypto/fipsmodule/rand/rand.c
+9 −3 crypto/fipsmodule/rsa/padding.c
+7 −0 crypto/fipsmodule/rsa/rsa.c
+18 −8 crypto/fipsmodule/rsa/rsa_impl.c
+5 −2 crypto/fipsmodule/service_indicator/service_indicator.c
+52 −3 crypto/fipsmodule/service_indicator/service_indicator_test.cc
+55 −1 crypto/fipsmodule/sha/sha512.c
+12 −0 crypto/hmac_extra/hmac_test.cc
+10 −0 crypto/hmac_extra/hmac_tests.txt
+84 −5 crypto/internal.h
+16 −1 crypto/obj/obj_dat.h
+1 −0 crypto/obj/obj_mac.num
+1 −0 crypto/obj/objects.txt
+0 −63 crypto/rand_extra/rand_test.cc
+160 −133 generated-src/crypto_test_data.cc
+10 −3 include/openssl/base.h
+0 −2 include/openssl/bn.h
+6 −0 include/openssl/chacha.h
+1 −0 include/openssl/digest.h
+5 −0 include/openssl/nid.h
+22 −1 include/openssl/sha.h
+57 −1 include/openssl/ssl.h
+2 −0 sources.cmake
+28 −18 ssl/handshake_server.cc
+14 −3 ssl/internal.h
+9 −17 ssl/s3_both.cc
+9 −0 ssl/ssl_lib.cc
+154 −13 ssl/ssl_test.cc
+128 −0 ssl/ssl_x509.cc
+10 −11 ssl/tls13_server.cc
+0 −1 tests/check_licenses.go
+1 −1 tests/ci/README.md
+57 −8 tests/ci/cdk/cdk/codebuild/github_ci_integration_omnibus.yaml
+5 −1 tests/ci/docker_images/linux-aarch/amazonlinux-2023_base/Dockerfile
+19 −3 tests/ci/docker_images/linux-aarch/ubuntu-22.04_base/Dockerfile
+34 −0 third_party/s2n-bignum/include/s2n-bignum_aws-lc.h
+1,978 −0 third_party/wycheproof_testvectors/hmac_sha512_224_test.json
+1,403 −0 third_party/wycheproof_testvectors/hmac_sha512_224_test.txt
+1,993 −0 third_party/wycheproof_testvectors/hmac_sha512_256_test.json
+1,416 −0 third_party/wycheproof_testvectors/hmac_sha512_256_test.txt
+4 −0 tool/digest.cc
+1 −0 tool/internal.h
+42 −1 tool/speed.cc
+7 −5 util/convert_wycheproof/convert_wycheproof.go
+3 −0 util/fipstools/acvp/ACVP.md
+2 −0 util/fipstools/acvp/acvptool/subprocess/subprocess.go
+ util/fipstools/acvp/acvptool/test/expected/HMAC-SHA2-512-224.bz2
+ util/fipstools/acvp/acvptool/test/expected/SHA2-512-224.bz2
+1 −0 util/fipstools/acvp/acvptool/test/sha-tests/sha512-224-tests.json
+1 −0 util/fipstools/acvp/acvptool/test/tests.json
+ util/fipstools/acvp/acvptool/test/vectors/HMAC-SHA2-512-224.bz2
+ util/fipstools/acvp/acvptool/test/vectors/SHA2-512-224.bz2
+2 −0 util/fipstools/acvp/modulewrapper/main.cc
+67 −0 util/fipstools/acvp/modulewrapper/modulewrapper.cc
+9 −0 util/fipstools/delocate/delocate.go
+4 −0 util/fipstools/delocate/testdata/aarch64-Basic/in.s
+11 −0 util/fipstools/delocate/testdata/aarch64-Basic/out.s

0 comments on commit 70e3732

Please sign in to comment.