Exemple #1
0
 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
     }
Exemple #2
0
 def _pack_envelope_key(key: ECC.EccKey) -> bytes:
     return key.export_key(format='DER', compress=True)
Exemple #3
0
def exportKeyToFile(key: ECC.EccKey, path):
    with open(path, "wt") as file:
        file.write(key.export_key(format="PEM"))
Exemple #4
0
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"))
Exemple #5
0
def serialize_public_key(public_key: ECC.EccKey):
    return public_key.export_key(format='DER')