mirror of
https://git.collinwebdesigns.de/oscar.krause/fastapi-dls.git
synced 2024-11-23 23:41:06 +03:00
migrated from "cryptography" to "pycryptodome"
This commit is contained in:
parent
7042862600
commit
fd73ac5f20
@ -1,6 +1,5 @@
|
|||||||
from cryptography.hazmat.primitives.asymmetric.rsa import RSAPrivateKeyWithSerialization
|
from Crypto.PublicKey import RSA
|
||||||
from cryptography.hazmat.primitives.serialization import load_pem_private_key, Encoding, PrivateFormat, PublicFormat, \
|
from Crypto.PublicKey.RSA import RsaKey
|
||||||
NoEncryption
|
|
||||||
|
|
||||||
|
|
||||||
def load_file(filename) -> bytes:
|
def load_file(filename) -> bytes:
|
||||||
@ -9,20 +8,13 @@ def load_file(filename) -> bytes:
|
|||||||
return content
|
return content
|
||||||
|
|
||||||
|
|
||||||
def load_key(filename) -> RSAPrivateKeyWithSerialization:
|
def load_key(filename) -> RsaKey:
|
||||||
return load_pem_private_key(data=load_file(filename), password=None)
|
return RSA.import_key(extern_key=load_file(filename), passphrase=None)
|
||||||
|
|
||||||
|
|
||||||
def private_bytes(rsa: RSAPrivateKeyWithSerialization) -> bytes:
|
def private_bytes(rsa: RsaKey) -> bytes:
|
||||||
return rsa.private_bytes(
|
return rsa.export_key(format='PEM', passphrase=None, protection=None)
|
||||||
encoding=Encoding.PEM,
|
|
||||||
format=PrivateFormat.TraditionalOpenSSL,
|
|
||||||
encryption_algorithm=NoEncryption()
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def public_key(rsa: RSAPrivateKeyWithSerialization) -> bytes:
|
def public_key(rsa: RsaKey) -> bytes:
|
||||||
return rsa.public_key().public_bytes(
|
return rsa.public_key().export_key(format='PEM')
|
||||||
encoding=Encoding.PEM,
|
|
||||||
format=PublicFormat.SubjectPublicKeyInfo
|
|
||||||
)
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
fastapi==0.88.0
|
fastapi==0.88.0
|
||||||
uvicorn[standard]==0.20.0
|
uvicorn[standard]==0.20.0
|
||||||
python-jose==3.3.0
|
python-jose==3.3.0
|
||||||
cryptography==38.0.4
|
pycryptodome==3.16.0
|
||||||
|
Loading…
Reference in New Issue
Block a user