mirror of
https://github.com/polhenarejos/pico-hsm.git
synced 2026-01-17 01:18:06 +00:00
Fixes in windows backend.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
parent
8718f55df2
commit
abf980d84e
2 changed files with 8 additions and 8 deletions
|
|
@ -2,7 +2,7 @@ import sys
|
|||
import keyring
|
||||
|
||||
DOMAIN = "PicoKeys.com"
|
||||
USERNAME = "Pico-Fido"
|
||||
USERNAME = "Pico-HSM"
|
||||
|
||||
try:
|
||||
import keyring
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import os
|
|||
import base64
|
||||
|
||||
DOMAIN = "PicoKeys.com"
|
||||
USERNAME = "Pico-Fido"
|
||||
USERNAME = "Pico-HSM"
|
||||
|
||||
try:
|
||||
import keyring
|
||||
|
|
@ -12,7 +12,7 @@ except:
|
|||
sys.exit(-1)
|
||||
|
||||
try:
|
||||
from cryptography.hazmat.primitives.serialization import Encoding, PrivateFormat, NoEncryption
|
||||
from cryptography.hazmat.primitives.serialization import Encoding, PrivateFormat, NoEncryption, load_pem_private_key
|
||||
from cryptography.hazmat.primitives.asymmetric import ec
|
||||
except:
|
||||
print('ERROR: cryptography module not found! Install cryptography package.\nTry with `pip install cryptography`')
|
||||
|
|
@ -26,19 +26,19 @@ def generate_secure_key():
|
|||
return keyring.get_password(DOMAIN, USERNAME)
|
||||
|
||||
def get_d(key):
|
||||
return key.private_numbers().private_value.to_bytes(32, 'big')
|
||||
return load_pem_private_key(key, password=None).private_numbers().private_value.to_bytes(32, 'big')
|
||||
|
||||
def set_secure_key(pk):
|
||||
try:
|
||||
keyring.delete_password(DOMAIN, USERNAME)
|
||||
except:
|
||||
pass
|
||||
keyring.set_password(DOMAIN, USERNAME, pk.private_bytes(Encoding.PEM, PrivateFormat.TraditionalOpenSSL, NoEncryption()))
|
||||
keyring.set_password(DOMAIN, USERNAME, pk.private_bytes(Encoding.PEM, PrivateFormat.PKCS8, NoEncryption()).decode())
|
||||
|
||||
def get_secure_key():
|
||||
key = None
|
||||
try:
|
||||
key = keyring.get_password(DOMAIN, USERNAME)[0]
|
||||
key = keyring.get_password(DOMAIN, USERNAME)
|
||||
except keyring.errors.KeyringError:
|
||||
key = generate_secure_key()[0]
|
||||
return get_d(key)
|
||||
key = generate_secure_key()
|
||||
return get_d(key.encode())
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue