Skip to content

Commit

Permalink
Moving ECDH derive spec to its own file.
Browse files Browse the repository at this point in the history
  • Loading branch information
apetcher-amazon committed Apr 8, 2024
1 parent f5dad26 commit 57dec43
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
5 changes: 2 additions & 3 deletions SAW/proof/EC/EC.saw
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ include "../EVP/EVP_CTX.saw";
import "../../spec/EC/EC_FIPS.cry";
include "EC_P384_private.saw";


let points_to_p384_bignum_st ptr d_ptr flags = points_to_bignum_st ptr d_ptr ec_words ec_words flags;


Expand Down Expand Up @@ -1412,7 +1411,7 @@ ec_felem_to_bytes_ov <- llvm_verify m
"ec_felem_to_bytes"
[bignum_fromlebytes_6_ov,
bignum_tolebytes_6_ov,
bignum_deamont_p384_ov
bignum_deamont_p384_same_ov
]
true
ec_felem_to_bytes_spec
Expand All @@ -1427,7 +1426,7 @@ ec_get_x_coordinate_as_bytes_ov <- llvm_verify m
[BN_num_bytes_ec_bits_ov,
bignum_tolebytes_6_ov,
bignum_fromlebytes_6_ov,
bignum_deamont_p384_ov,
bignum_deamont_p384_same_ov,
ec_GFp_nistp384_point_get_affine_coordinates_x_ov,
ec_felem_to_bytes_ov]
true
Expand Down
4 changes: 2 additions & 2 deletions SAW/proof/ECDH/ECDH.saw
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
import "../../../cryptol-specs/Common/EC/EC_P384.cry";
import "../../../cryptol-specs/Common/utils.cry";


include "../ECDSA/goal-rewrites.saw";


/*
* Verification parameters.
*/
Expand All @@ -29,6 +27,8 @@ include "../common/memory.saw";
include "../BN/BN.saw";
include "../EC/EC.saw";

import "../../spec/EC/ECDH.cry";


let ptr_to_new_evp_pkey_ctx_st pkey_ptr = do {
ptr <- crucible_alloc (llvm_struct "struct.evp_pkey_ctx_st");
Expand Down
17 changes: 17 additions & 0 deletions SAW/spec/EC/ECDH.cry
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/

module ECDH where

import Common::EC::EC_P384
import EC_primitives
import EC_P384_5

ECDH_derive_bv : JacobianBVPoint -> scalar -> [bit_length]
ECDH_derive_bv peer_pub_key priv_key =
reverse_bytes (felem_to_bytes (felem_from_mont (felem_from_bytes (jacobianToAffine (point_mul_generic peer_pub_key priv_key)).X)))



5 changes: 0 additions & 5 deletions SAW/spec/EC/EC_mul.cry
Original file line number Diff line number Diff line change
Expand Up @@ -375,9 +375,4 @@ validate_one_wrapper: () -> felem -> Bit
validate_one_wrapper _ x = validate_one x


ECDH_derive_bv : JacobianBVPoint -> scalar -> [bit_length]
ECDH_derive_bv peer_pub_key priv_key =
reverse_bytes (felem_to_bytes (felem_from_mont (felem_from_bytes (jacobianToAffine (point_mul_generic peer_pub_key priv_key)).X)))



0 comments on commit 57dec43

Please sign in to comment.