Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_decrypt_protected_key(self, rsa_enc, rsa_pub):
emsg = rsa_pub.encrypt(PGPMessage.new("asdf"))
with pytest.raises(PGPError):
rsa_enc.decrypt(emsg)
def test_decrypt_unencrypted(self):
msg = PGPMessage.from_file('tests/testdata/messages/message.signed.asc')
with pytest.raises(PGPError):
msg.decrypt("Password")
def test_pgp_validation(self):
self.assertEqual(None, self.good.pgp_message)
self.assertEqual(self.signed.source, 'testdeb')
with pytest.raises(DscBadSignatureError):
self.badsigned.source_files
self.assertIsInstance(self.signed.pgp_message, PGPMessage)
def sign_encrypt(entity, private_key, public_key):
message = pgpy.PGPMessage.new(json.dumps(entity))
message |= private_key.sign(message)
return str(public_key.encrypt(message))
def test_decrypt_unencrypted_message(self, rsa_sec, recwarn):
lit = PGPMessage.new('tests/testdata/lit', file=True)
rsa_sec.decrypt(lit)
w = recwarn.pop(UserWarning)
assert str(w.message) == "This message is not encrypted"
assert w.filename == __file__
def process_data(self, message_wrapper):
clearsigned_message_str = message_wrapper['data']
clearsigned_message = pgpy.PGPMessage().from_blob(clearsigned_message_str)
if not self._quedex_key.verify(clearsigned_message):
self.on_error(Exception('Signature verification failed on message: %s' % clearsigned_message_str))
self._parse_message(clearsigned_message.message)