mirror of
https://github.com/polhenarejos/pico-hsm.git
synced 2024-09-20 03:10:09 +00:00
Added some tests for HD ciphering.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
parent
f631e4a5f3
commit
57188ff877
@ -27,7 +27,7 @@ from cvc.certificates import CVC
|
||||
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!'
|
||||
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user