def test_verify_stored_key(self):
     key64 = base64.b64encode(TEST_KEY)
     nonce64 = base64.b64encode(TEST_IV)
     aes = AES.new(TEST_KEY, AES.MODE_CBC, TEST_IV)
     cipertext = aes.encrypt(server.aes_pad(nonce64))
     verifier64 = base64.b64encode(cipertext)
     self.assertTrue(self.context._verify(nonce64, verifier64))
 def test_sign(self, new_iv):
     key64 = base64.b64encode(TEST_KEY)
     new_iv.return_value = TEST_IV
     nonce64 = base64.b64encode(TEST_IV)
     aes = AES.new(TEST_KEY, AES.MODE_CBC, TEST_IV)
     verifier64 = base64.b64encode(aes.encrypt(server.aes_pad(nonce64)))
     resp = {}
     self.context._sign(resp)
     self.assertEqual(resp['Nonce'], nonce64)
     self.assertEqual(resp['Verifier'], verifier64)
     self.assertEqual(resp['Version'], '2.0.0.0')
     self.assertEqual(resp['Id'], 'bar')
 def test_aes_pad_even(self):
     data = '0123456789ABCDEF'
     self.assertEqual('%s%s' % (data, '\x10' * 16),
                      server.aes_pad(data))
 def test_aes_pad(self):
     data = '0123456789ABCDE'
     self.assertEqual('%s\x01' % data,
                      server.aes_pad(data))