From d2a0e623ed6bc3f2ccab7e19e13ed798ba19b7af Mon Sep 17 00:00:00 2001 From: Pascal Nasahl Date: Fri, 24 May 2024 15:15:37 +0200 Subject: [PATCH] [fi] Add crypto_kmac_static test Signed-off-by: Pascal Nasahl --- .../pen.global_fi.crypto.kmac.cw310.yaml | 1 + target/communication/fi_crypto_commands.py | 20 ++++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/fault_injection/configs/pen.global_fi.crypto.kmac.cw310.yaml b/fault_injection/configs/pen.global_fi.crypto.kmac.cw310.yaml index c676a5a9..adbe5285 100644 --- a/fault_injection/configs/pen.global_fi.crypto.kmac.cw310.yaml +++ b/fault_injection/configs/pen.global_fi.crypto.kmac.cw310.yaml @@ -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 diff --git a/target/communication/fi_crypto_commands.py b/target/communication/fi_crypto_commands.py index 132758fb..9e58f485 100644 --- a/target/communication/fi_crypto_commands.py +++ b/target/communication/fi_crypto_commands.py @@ -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: