This is my protocol:
Encryption and signing - user A
- cipher using the public key from user B
- sign the encrypted message with the private key A
Verifying and decrypting - user B
- verify the signature with the public key A
- decrypt the message with the private key B
The private key A and B are the same (128 bit)
I want to send the text using this protocol with AES in mode CBC so i create this code but doesnt work ,apperar in signature:
bytes object has no attribute n
the code is the following:
def firmar(self, datos):
try:
h = SHA256.new(datos)
signature = pss.new(self.keyprivada).sign(h)
return signature
except (ValueError, TypeError):
return None
def comprobar(self, text, signature):
h = SHA256.new(text)
print(h.hexdigest())
verifier = pss.new(self.keypublica)
try:
verifier.verify(h, signature)
return True
except (ValueError, TypeError):
return False