Skip to content

Commit

Permalink
[fi] Add crypto_kmac_static test
Browse files Browse the repository at this point in the history
Signed-off-by: Pascal Nasahl <nasahlpa@lowrisc.org>
  • Loading branch information
nasahlpa committed May 24, 2024
1 parent f1b1a62 commit d2a0e62
Showing 2 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -38,6 +38,7 @@ test:
# which_test: "crypto_kmac_key"
which_test: "crypto_kmac_absorb"
# which_test: "crypto_kmac_squeeze"
# which_test: "crypto_kmac_static"
expected_result: '{"ciphertext":[184,34,91,108,231,47,251,27],"alerts":0,"err_status":0}'
# Set to true if the test should ignore alerts returned by the test. As the
# alert handler on the device could sometime fire alerts that are not
20 changes: 17 additions & 3 deletions target/communication/fi_crypto_commands.py
Original file line number Diff line number Diff line change
@@ -99,7 +99,7 @@ def crypto_kmac_key(self) -> None:
# Mode payload.
time.sleep(0.01)
mode = {"key_trigger": True, "absorb_trigger": False,
"squeeze_trigger": False}
"static_trigger": False, "squeeze_trigger": False}
self.target.write(json.dumps(mode).encode("ascii"))

def crypto_kmac_absorb(self) -> None:
@@ -113,7 +113,7 @@ def crypto_kmac_absorb(self) -> None:
# Mode payload.
time.sleep(0.01)
mode = {"key_trigger": False, "absorb_trigger": True,
"squeeze_trigger": False}
"static_trigger": False, "squeeze_trigger": False}
self.target.write(json.dumps(mode).encode("ascii"))

def crypto_kmac_squeeze(self) -> None:
@@ -127,7 +127,21 @@ def crypto_kmac_squeeze(self) -> None:
# Mode payload.
time.sleep(0.01)
mode = {"key_trigger": False, "absorb_trigger": False,
"squeeze_trigger": True}
"static_trigger": False, "squeeze_trigger": True}
self.target.write(json.dumps(mode).encode("ascii"))

def crypto_kmac_static(self) -> None:
""" Starts the crypto.fi.kmac_static test.
"""
# CryptoFi command.
self._ujson_crypto_cmd()
# Kmac command.
time.sleep(0.01)
self.target.write(json.dumps("Kmac").encode("ascii"))
# Mode payload.
time.sleep(0.01)
mode = {"key_trigger": False, "absorb_trigger": False,
"static_trigger": True, "squeeze_trigger": False}
self.target.write(json.dumps(mode).encode("ascii"))

def start_test(self, cfg: dict) -> None:

0 comments on commit d2a0e62

Please sign in to comment.