Skip to content

Commit

Permalink
Added some tests for HD ciphering.
Browse files Browse the repository at this point in the history
Signed-off-by: Pol Henarejos <[email protected]>
  • Loading branch information
polhenarejos committed Jul 24, 2023
1 parent f631e4a commit 57188ff
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions tests/pico-hsm/test_095_bip_slip.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from cvc import oid
from cryptography.hazmat.primitives.asymmetric import ec
from cryptography.hazmat.primitives import hashes
from picohsm import DOPrefixes, APDUResponse, SWCodes, PicoHSM
from picohsm import EncryptionMode, APDUResponse, SWCodes, PicoHSM
import hashlib

TEST_STRING = b'Pico Keys are awesome!'
Expand Down Expand Up @@ -438,4 +438,16 @@ def test_signature_slip(device, path):
pub = device.hd_derive_node(path)
with pytest.raises(APDUResponse) as e:
resp = device.hd_signature(path, TEST_STRING)
assert (e.value.sw == SWCodes.SW_CONDITIONS_NOT_SATISFIED)
assert (e.value.sw == SWCodes.SW_CONDITIONS_NOT_SATISFIED)

@pytest.mark.parametrize(
"ask_on_encrypt", [True, False]
)
@pytest.mark.parametrize(
"ask_on_decrypt", [True, False]
)
def test_cipher_slip(device, ask_on_encrypt, ask_on_decrypt):
MSG1 = b"testing message!"
enctext = device.hd_cipher([7, b"\x01", b"\x02"], b"test", MSG1, EncryptionMode.ENCRYPT, ask_on_encrypt, ask_on_decrypt)
resp = device.hd_cipher([7, b"\x01", b"\x02"], b"test", enctext, EncryptionMode.DECRYPT, ask_on_encrypt, ask_on_decrypt)
assert(resp == MSG1)

0 comments on commit 57188ff

Please sign in to comment.