Skip to content

Commit

Permalink
Merge pull request #453 from prebuilder/internal_keyid_consistency
Browse files Browse the repository at this point in the history
Made internal keyids consistent
  • Loading branch information
lukpueh authored Feb 9, 2023
2 parents 34e50cb + 7c159c9 commit f41b2a9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions securesystemslib/ecdsa_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,12 @@ def generate_public_and_private(scheme="ecdsa-sha2-nistp256"):
encoding=serialization.Encoding.PEM,
format=serialization.PrivateFormat.TraditionalOpenSSL,
encryption_algorithm=serialization.NoEncryption(),
)
).strip()

public_pem = public_key.public_bytes(
encoding=serialization.Encoding.PEM,
format=serialization.PublicFormat.SubjectPublicKeyInfo,
)
).strip()

return public_pem.decode("utf-8"), private_pem.decode("utf-8")

Expand Down Expand Up @@ -434,12 +434,12 @@ def create_ecdsa_public_and_private_from_pem(pem, password=None):
encoding=serialization.Encoding.PEM,
format=serialization.PrivateFormat.TraditionalOpenSSL,
encryption_algorithm=serialization.NoEncryption(),
)
).strip()

public = public.public_bytes(
encoding=serialization.Encoding.PEM,
format=serialization.PublicFormat.SubjectPublicKeyInfo,
)
).strip()

return public.decode("utf-8"), private.decode("utf-8")

Expand Down Expand Up @@ -506,7 +506,7 @@ def create_ecdsa_encrypted_pem(private_pem, passphrase):
encryption_algorithm=serialization.BestAvailableEncryption(
passphrase.encode("utf-8")
),
)
).strip()

return encrypted_private_pem

Expand Down
10 changes: 5 additions & 5 deletions securesystemslib/rsa_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,15 +220,15 @@ def generate_rsa_public_and_private(bits=_DEFAULT_RSA_KEY_BITS):
encoding=serialization.Encoding.PEM,
format=serialization.PrivateFormat.TraditionalOpenSSL,
encryption_algorithm=serialization.NoEncryption(),
)
).strip()

# Need to generate the public pem from the private key before serialization
# to PEM.
public_key = private_key.public_key()
public_pem = public_key.public_bytes(
encoding=serialization.Encoding.PEM,
format=serialization.PublicFormat.SubjectPublicKeyInfo,
)
).strip()

return public_pem.decode("utf-8"), private_pem.decode("utf-8")

Expand Down Expand Up @@ -582,7 +582,7 @@ def create_rsa_encrypted_pem(private_key, passphrase):
encryption_algorithm=serialization.BestAvailableEncryption(
passphrase.encode("utf-8")
),
)
).strip()

return encrypted_pem.decode()

Expand Down Expand Up @@ -705,15 +705,15 @@ def create_rsa_public_and_private_from_pem(pem, passphrase=None):
encoding=serialization.Encoding.PEM,
format=serialization.PrivateFormat.TraditionalOpenSSL,
encryption_algorithm=serialization.NoEncryption(),
)
).strip()

# Need to generate the public key from the private one before serializing
# to PEM format.
public_key = private_key.public_key()
public_pem = public_key.public_bytes(
encoding=serialization.Encoding.PEM,
format=serialization.PublicFormat.SubjectPublicKeyInfo,
)
).strip()

return public_pem.decode(), private_pem.decode()

Expand Down

0 comments on commit f41b2a9

Please sign in to comment.