Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
JiriKr authored and zbohm committed Jul 22, 2022
1 parent a2d46fa commit a142130
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pycsob/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,17 @@ def send(self, request, **kwargs):

def sign(payload, keyfile):
msg = mk_msg_for_sign(payload)
key = RSA.importKey(open(keyfile).read())
with open(keyfile, "rb") as f:
key = RSA.importKey(f.read())
h = SHA.new(msg)
signer = PKCS1_v1_5.new(key)
return b64encode(signer.sign(h)).decode()


def verify(payload, signature, pubkeyfile):
msg = mk_msg_for_sign(payload)
key = RSA.importKey(open(pubkeyfile).read())
with open(pubkeyfile, "rb") as f:
key = RSA.importKey(f.read())
h = SHA.new(msg)
verifier = PKCS1_v1_5.new(key)
return verifier.verify(h, b64decode(signature))
Expand Down

0 comments on commit a142130

Please sign in to comment.