def init_jwt(self): jwt_key = EccKey(curve='p256', d=int(self.config.private_key, 16)) self.config.jwt_secret_key = jwt_key.export_key(format='PEM') self.config.jwt_public_key = self.config.jwt_public_key or jwt_key.public_key( ).export_key(format='PEM') self.config.jwt_options = { 'verify_signature': True, 'verify_exp': True, 'verify_nbf': False, 'verify_iat': True, 'verify_aud': False }
def _pack_envelope_key(key: ECC.EccKey) -> bytes: return key.export_key(format='DER', compress=True)
def exportKeyToFile(key: ECC.EccKey, path): with open(path, "wt") as file: file.write(key.export_key(format="PEM"))
def exportKeyToFileEncrypted(key: ECC.EccKey, path, password): with open(path, "wt") as file: file.write( key.export_key(format="PEM", passphrase=password, protection="PBKDF2WithHMAC-SHA1AndAES128-CBC"))
def serialize_public_key(public_key: ECC.EccKey): return public_key.export_key(format='DER')