If the board is RP2350 or ESP32, the requested certificate must be for secp256k1 key.

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
Pol Henarejos 2024-11-12 19:24:10 +01:00
parent 99a9803328
commit 6f572954d5
No known key found for this signature in database
GPG key ID: C0095B7870A4CCD3

View file

@ -39,7 +39,7 @@ except ModuleNotFoundError:
sys.exit(-1) sys.exit(-1)
try: try:
from picohsm import PicoHSM, PinType, DOPrefixes, KeyType, EncryptionMode, utils, APDUResponse, SWCodes, AES from picohsm import PicoHSM, PinType, DOPrefixes, KeyType, EncryptionMode, utils, APDUResponse, SWCodes, AES, Platform
except ModuleNotFoundError: except ModuleNotFoundError:
print('ERROR: picohsm module not found! Install picohsm package.\nTry with `pip install pypicohsm`') print('ERROR: picohsm module not found! Install picohsm package.\nTry with `pip install pypicohsm`')
sys.exit(-1) sys.exit(-1)
@ -226,7 +226,10 @@ def initialize(picohsm, args):
print(f'Public Point: {hexlify(Y).decode()}') print(f'Public Point: {hexlify(Y).decode()}')
pbk = base64.urlsafe_b64encode(Y) pbk = base64.urlsafe_b64encode(Y)
data = urllib.parse.urlencode({'pubkey': pbk}).encode() params = {'pubkey': pbk}
if (picohsm.platform in (Platform.RP2350, Platform.ESP32)):
params['curve'] = 'secp256k1'
data = urllib.parse.urlencode(params).encode()
j = get_pki_data('cvc', data=data) j = get_pki_data('cvc', data=data)
print('Device name: '+j['devname']) print('Device name: '+j['devname'])
dataef = base64.urlsafe_b64decode( dataef = base64.urlsafe_b64decode(