From 3c252e2a4cf3fddbe9bf2e31cfdac777533464e4 Mon Sep 17 00:00:00 2001 From: Oscar Krause Date: Tue, 20 Dec 2022 14:45:44 +0100 Subject: [PATCH] helper.py moved to main.py --- app/helper.py | 20 -------------------- app/main.py | 13 ++++++++++++- 2 files changed, 12 insertions(+), 21 deletions(-) delete mode 100644 app/helper.py diff --git a/app/helper.py b/app/helper.py deleted file mode 100644 index b416ab3..0000000 --- a/app/helper.py +++ /dev/null @@ -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') diff --git a/app/main.py b/app/main.py index 42ac2d2..39d3641 100644 --- a/app/main.py +++ b/app/main.py @@ -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"?)