Ejemplo n.º 1
0
 def test_aes_homomorphic(self):
     """Make sure AES is homomorphic."""
     payload = u'\u66f4\u7a33\u5b9a\u7684\u4ea4\u6613\u5e73\u53f0'
     password = u'secret'
     enc = pw_encode(payload, password)
     dec = pw_decode(enc, password)
     self.assertEqual(dec, payload)
Ejemplo n.º 2
0
 def test_aes_decode_with_invalid_password(self):
     """pw_decode raises an Exception when supplied an invalid password."""
     payload = u"blah"
     password = u"uber secret"
     wrong_password = u"not the password"
     enc = pw_encode(payload, password)
     self.assertRaises(Exception, pw_decode, enc, wrong_password)
Ejemplo n.º 3
0
 def test_aes_homomorphic(self):
     """Make sure AES is homomorphic."""
     payload = u'\u66f4\u7a33\u5b9a\u7684\u4ea4\u6613\u5e73\u53f0'
     password = u'secret'
     enc = pw_encode(payload, password)
     dec = pw_decode(enc, password)
     self.assertEqual(dec, payload)
Ejemplo n.º 4
0
 def test_aes_decode_with_invalid_password(self):
     """pw_decode raises an Exception when supplied an invalid password."""
     payload = u"blah"
     password = u"uber secret"
     wrong_password = u"not the password"
     enc = pw_encode(payload, password)
     self.assertRaises(Exception, pw_decode, enc, wrong_password)
Ejemplo n.º 5
0
 def test_aes_decode_with_invalid_password(self):
     """pw_decode raises an Exception when supplied an invalid password."""
     payload = u"blah"
     password = u"uber secret"
     wrong_password = u"not the password"
     enc = pw_encode(payload, password)
     # FIXME: pyaes does not check that padding is consistent
     # before removing it, wich causes this test to randomly fail.
     # Wallets are unaffected by this, because check_password
     # includes a test of the decoded public key.
     self.assertRaises(Exception, pw_decode, enc, wrong_password)
Ejemplo n.º 6
0
 def test_aes_encode_without_password(self):
     """When not passed a password, pw_encode is noop on the payload."""
     payload = u'\u66f4\u7a33\u5b9a\u7684\u4ea4\u6613\u5e73\u53f0'
     enc = pw_encode(payload, None)
     self.assertEqual(payload, enc)
Ejemplo n.º 7
0
 def test_aes_encode_without_password(self):
     """When not passed a password, pw_encode is noop on the payload."""
     payload = u'\u66f4\u7a33\u5b9a\u7684\u4ea4\u6613\u5e73\u53f0'
     enc = pw_encode(payload, None)
     self.assertEqual(payload, enc)