mirror of
https://github.com/Sneed-Group/pypush-plus-plus
synced 2024-12-23 19:32:29 -06:00
fix weird typing thing
This commit is contained in:
parent
f6f2c304af
commit
7d3fc921ec
1 changed files with 3 additions and 6 deletions
|
@ -16,10 +16,7 @@ def dearmour(armoured: str) -> str:
|
|||
)
|
||||
|
||||
from cryptography.hazmat.primitives import serialization
|
||||
from cryptography.hazmat.primitives.asymmetric.types import (
|
||||
PrivateKeyTypes,
|
||||
PublicKeyTypes,
|
||||
)
|
||||
from cryptography.hazmat.primitives.asymmetric import ec, rsa
|
||||
def parse_key(key: str):
|
||||
# Check if it is a public or private key
|
||||
if "PUBLIC" in key:
|
||||
|
@ -27,8 +24,8 @@ def parse_key(key: str):
|
|||
else:
|
||||
return serialization.load_pem_private_key(key.encode(), None)
|
||||
|
||||
def serialize_key(key: PrivateKeyTypes | PublicKeyTypes):
|
||||
if isinstance(key, PrivateKeyTypes):
|
||||
def serialize_key(key):
|
||||
if isinstance(key, ec.EllipticCurvePrivateKey) or isinstance(key, rsa.RSAPrivateKey):
|
||||
return key.private_bytes(
|
||||
encoding=serialization.Encoding.PEM,
|
||||
format=serialization.PrivateFormat.TraditionalOpenSSL,
|
||||
|
|
Loading…
Reference in a new issue