helper.py moved to main.py

This commit is contained in:
Oscar Krause 2022-12-20 14:45:44 +01:00
parent 64946312fa
commit 3c252e2a4c
2 changed files with 12 additions and 21 deletions

View File

@ -1,20 +0,0 @@
from Crypto.PublicKey import RSA
from Crypto.PublicKey.RSA import RsaKey
def load_file(filename) -> bytes:
with open(filename, 'rb') as file:
content = file.read()
return content
def load_key(filename) -> RsaKey:
return RSA.import_key(extern_key=load_file(filename), passphrase=None)
def private_bytes(rsa: RsaKey) -> bytes:
return rsa.export_key(format='PEM', passphrase=None, protection=None)
def public_key(rsa: RsaKey) -> bytes:
return rsa.public_key().export_key(format='PEM')

View File

@ -12,8 +12,19 @@ from calendar import timegm
from jose import jws, jwk, jwt
from jose.constants import ALGORITHMS
from starlette.responses import StreamingResponse, JSONResponse
from Crypto.PublicKey import RSA
from Crypto.PublicKey.RSA import RsaKey
def load_file(filename) -> bytes:
with open(filename, 'rb') as file:
content = file.read()
return content
def load_key(filename) -> RsaKey:
return RSA.import_key(extern_key=load_file(filename), passphrase=None)
from helper import load_key, private_bytes, public_key
# todo: initialize certificate (or should be done by user, and passed through "volumes"?)