mirror of
https://github.com/theupdateframework/python-tuf
synced 2026-05-24 10:08:28 +00:00
Encode signatures in pycrypto_keys.py to match pyca_crypto_keys.py
This commit is contained in:
parent
d0d4ee42db
commit
bfb4399a49
1 changed files with 3 additions and 3 deletions
|
|
@ -291,7 +291,7 @@ def create_rsa_signature(private_key, data):
|
|||
# If the passphrase is incorrect, PyCrypto returns: "RSA key format is not
|
||||
# supported".
|
||||
try:
|
||||
sha256_object = Crypto.Hash.SHA256.new(data)
|
||||
sha256_object = Crypto.Hash.SHA256.new(data.encode('utf-8'))
|
||||
rsa_key_object = Crypto.PublicKey.RSA.importKey(private_key)
|
||||
|
||||
except (ValueError, IndexError, TypeError) as e:
|
||||
|
|
@ -390,7 +390,7 @@ def verify_rsa_signature(signature, signature_method, public_key, data):
|
|||
try:
|
||||
rsa_key_object = Crypto.PublicKey.RSA.importKey(public_key)
|
||||
pkcs1_pss_verifier = Crypto.Signature.PKCS1_PSS.new(rsa_key_object)
|
||||
sha256_object = Crypto.Hash.SHA256.new(data)
|
||||
sha256_object = Crypto.Hash.SHA256.new(data.encode('utf'))
|
||||
valid_signature = pkcs1_pss_verifier.verify(sha256_object, signature)
|
||||
|
||||
except (ValueError, IndexError, TypeError) as e:
|
||||
|
|
@ -590,7 +590,7 @@ def create_rsa_public_and_private_from_encrypted_pem(encrypted_pem, passphrase):
|
|||
except (ValueError): #pragma: no cover
|
||||
message = 'The public and private keys cannot be exported in PEM format.'
|
||||
raise tuf.CryptoError(message)
|
||||
|
||||
|
||||
return public.decode(), private.decode()
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue