mirror of
https://github.com/polhenarejos/pico-hsm.git
synced 2026-01-17 01:18:06 +00:00
Added X25519 and X448 exchange test.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
parent
0e1c82196a
commit
e18c413268
1 changed files with 22 additions and 1 deletions
|
|
@ -20,7 +20,7 @@
|
|||
import pytest
|
||||
import hashlib
|
||||
from picohsm import DOPrefixes
|
||||
from cryptography.hazmat.primitives.asymmetric import ec
|
||||
from cryptography.hazmat.primitives.asymmetric import ec, x25519, x448
|
||||
from picohsm.const import DEFAULT_RETRIES, DEFAULT_DKEK_SHARES
|
||||
from const import DEFAULT_DKEK
|
||||
|
||||
|
|
@ -51,3 +51,24 @@ def test_exchange_ecc(device, curve):
|
|||
|
||||
device.delete_file(DOPrefixes.KEY_PREFIX, keyid)
|
||||
device.delete_file(DOPrefixes.EE_CERTIFICATE_PREFIX, keyid)
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"curve", [x25519.X25519PrivateKey, x448.X448PrivateKey]
|
||||
)
|
||||
def test_exchange_montgomery(device, curve):
|
||||
pkeyA = curve.generate()
|
||||
pbkeyA = pkeyA.public_key()
|
||||
keyid = device.import_key(pkeyA)
|
||||
pkeyB = curve.generate()
|
||||
pbkeyB = pkeyB.public_key()
|
||||
|
||||
sharedB = pkeyB.exchange(pbkeyA)
|
||||
sharedA = device.exchange(keyid, pbkeyB)
|
||||
|
||||
assert(sharedA == sharedB)
|
||||
|
||||
sharedAA = pkeyA.exchange(pbkeyB)
|
||||
assert(sharedA == sharedAA)
|
||||
|
||||
device.delete_file(DOPrefixes.KEY_PREFIX, keyid)
|
||||
device.delete_file(DOPrefixes.EE_CERTIFICATE_PREFIX, keyid)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue