Skip to content

Commit

Permalink
fix: add ECDH error message for Rust (aws#574)
Browse files Browse the repository at this point in the history
* fix: add ECDH error message for Rust
  • Loading branch information
ajewellamz authored and lucasmcdonald3 committed Sep 26, 2024
1 parent 6dc1508 commit 06ecfed
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions AwsCryptographyPrimitives/test/TestECDH.dfy
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ module TestECDH {
const OUT_OF_BOUNDS_ERR_MSG_NET6 := "value invalid for Fp field element (Parameter 'x')"
const OUT_OF_BOUNDS_ERR_MSG_NE48 := "value invalid for Fp field element\r\nParameter name: x"

// Rust does not provide a separate error message for infinity or out of bounds
const BAD_X509_KEY_ERR_MSG_RUST := "Invalid X509 Public Key."

method {:test} TestKeyGen()
{
var supportedCurves := [P256, P384, P521];
Expand Down Expand Up @@ -285,6 +288,7 @@ module TestECDH {
var errMsg := validPublicKey.error.message;

expect (
errMsg == BAD_X509_KEY_ERR_MSG_RUST ||
errMsg == INFINITY_POINT_ERR_MSG_JAVA ||
errMsg == INFINITY_POINT_ERR_MSG_NET6 ||
errMsg == INFINITY_POINT_ERR_MSG_NET48
Expand Down Expand Up @@ -334,6 +338,7 @@ module TestECDH {
var errMsg := validPublicKey.error.message;
expect (
seq_contains(errMsg, OUT_OF_BOUNDS_ERR_MSG_JAVA) ||
errMsg == BAD_X509_KEY_ERR_MSG_RUST ||
errMsg == OUT_OF_BOUNDS_ERR_MSG_NET6 ||
errMsg == OUT_OF_BOUNDS_ERR_MSG_NE48
);
Expand Down

0 comments on commit 06ecfed

Please sign in to comment.