Пример #1
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"
     for version in KNOWN_PW_HASH_VERSIONS:
         enc = crypto.pw_encode(payload, password, version=version)
         with self.assertRaises(InvalidPassword):
             crypto.pw_decode(enc, wrong_password, version=version)
Пример #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"
     for version in SUPPORTED_PW_HASH_VERSIONS:
         enc = crypto.pw_encode(payload, password, version=version)
         with self.assertRaises(InvalidPassword):
             crypto.pw_decode(enc, wrong_password, version=version)
Пример #3
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"
     for version in SUPPORTED_PW_HASH_VERSIONS:
         enc = crypto.pw_encode(payload, password, version=version)
         with self.assertRaises(InvalidPassword):
             crypto.pw_decode(enc, wrong_password, version=version)
     # sometimes the PKCS7 padding gets removed cleanly,
     # but then UnicodeDecodeError gets raised (internally):
     enc = 'smJ7j6ccr8LnMOlx98s/ajgikv9s3R1PQuG3GyyIMmo='
     with self.assertRaises(InvalidPassword):
         crypto.pw_decode(enc, wrong_password, version=1)
Пример #4
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 = crypto.pw_encode(payload, password)
     dec = crypto.pw_decode(enc, password)
     self.assertEqual(dec, payload)
Пример #5
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 = crypto.pw_encode(payload, password)
     dec = crypto.pw_decode(enc, password)
     self.assertEqual(dec, payload)
Пример #6
0
 def test_aes_homomorphic(self):
     """Make sure AES is homomorphic."""
     payload = u'\u66f4\u7a33\u5b9a\u7684\u4ea4\u6613\u5e73\u53f0'
     password = u'secret'
     for version in SUPPORTED_PW_HASH_VERSIONS:
         enc = crypto.pw_encode(payload, password, version=version)
         dec = crypto.pw_decode(enc, password, version=version)
         self.assertEqual(dec, payload)
Пример #7
0
 def test_aes_homomorphic(self):
     """Make sure AES is homomorphic."""
     payload = u'\u66f4\u7a33\u5b9a\u7684\u4ea4\u6613\u5e73\u53f0'
     password = u'secret'
     for version in KNOWN_PW_HASH_VERSIONS:
         enc = crypto.pw_encode(payload, password, version=version)
         dec = crypto.pw_decode(enc, password, version=version)
         self.assertEqual(dec, payload)
Пример #8
0
 def test_aes_deencode_without_password(self):
     """When not passed a password, pw_decode is noop on the payload."""
     payload = u'\u66f4\u7a33\u5b9a\u7684\u4ea4\u6613\u5e73\u53f0'
     enc = crypto.pw_decode(payload, None)
     self.assertEqual(payload, enc)
Пример #9
0
 def test_aes_deencode_without_password(self):
     """When not passed a password, pw_decode is noop on the payload."""
     payload = u'\u66f4\u7a33\u5b9a\u7684\u4ea4\u6613\u5e73\u53f0'
     for version in SUPPORTED_PW_HASH_VERSIONS:
         enc = crypto.pw_decode(payload, None, version=version)
         self.assertEqual(payload, enc)
Пример #10
0
 def test_aes_deencode_without_password(self):
     """When not passed a password, pw_decode is noop on the payload."""
     payload = u'\u66f4\u7a33\u5b9a\u7684\u4ea4\u6613\u5e73\u53f0'
     enc = crypto.pw_decode(payload, None)
     self.assertEqual(payload, enc)
Пример #11
0
 def test_aes_deencode_without_password(self):
     """When not passed a password, pw_decode is noop on the payload."""
     payload = u'\u66f4\u7a33\u5b9a\u7684\u4ea4\u6613\u5e73\u53f0'
     for version in KNOWN_PW_HASH_VERSIONS:
         enc = crypto.pw_decode(payload, None, version=version)
         self.assertEqual(payload, enc)