コード例 #1
0
ファイル: obfs2.py プロジェクト: larrycameron80/prism
 def _derive_padding_crypto(self, seed,
                            pad_string):  # XXX consider secret_seed
     """
     Derive and return an obfs2 padding key using the pad string in 'pad_string'.
     """
     secret = self.mac(pad_string, seed, self.shared_secret)
     return aes.AES_CTR_128(secret[:KEYLEN], secret[KEYLEN:])
コード例 #2
0
 def _derive_crypto(self, pad_string):
     """
     Derive and return an obfs3 key using the pad string in 'pad_string'.
     """
     secret = hmac_sha256.hmac_sha256_digest(self.shared_secret, pad_string)
     return aes.AES_CTR_128(secret[:KEYLEN], secret[KEYLEN:],
                            counter_wraparound=True)
コード例 #3
0
ファイル: test_aes.py プロジェクト: 309972460/software
    def test_encrypt_decrypt_small_ASCII(self):
        """
        Validate that decryption and encryption work as intended on a small ASCII string.
        """
        self.key = "\xe3\xb0\xc4\x42\x98\xfc\x1c\x14\x9a\xfb\xf4\xc8\x99\x6f\xb9\x24"
        self.iv = "\x27\xae\x41\xe4\x64\x9b\x93\x4c\xa4\x95\x99\x1b\x78\x52\xb8\x55"

        test_string = "This unittest kills fascists."

        cipher1 = aes.AES_CTR_128(self.key, self.iv)
        cipher2 = aes.AES_CTR_128(self.key, self.iv)

        ct = cipher1.crypt(test_string)
        pt = cipher2.crypt(ct)

        self.assertEqual(test_string, pt)
コード例 #4
0
ファイル: obfs2.py プロジェクト: larrycameron80/prism
 def _derive_crypto(self, pad_string):  # XXX consider secret_seed
     """
     Derive and return an obfs2 key using the pad string in 'pad_string'.
     """
     secret = self.mac(pad_string,
                       self.initiator_seed + self.responder_seed,
                       self.shared_secret)
     return aes.AES_CTR_128(secret[:KEYLEN], secret[KEYLEN:])