From kaushalgoa at gmail.com Tue Jan 11 20:13:37 2011 From: kaushalgoa at gmail.com (Kaushal Bhandankar) Date: Wed, 12 Jan 2011 00:43:37 +0530 Subject: [python-crypto] Test Vector verification in AES_CTR Message-ID: Hi, An old threaddescribes how to use PyCrypto . However, I am not able to get the desired ciphered output as per the Test Vectors in SelfTests for AES in AES_CTR mode. ( lib/Crypto/SelfTest/Cipher/test_AES.py - RFC 3686 test vectors). Any help would be greatly appreciated. Thanks, Kaushal -------------- next part -------------- An HTML attachment was scrubbed... URL: From kaushalgoa at gmail.com Wed Jan 12 06:39:03 2011 From: kaushalgoa at gmail.com (Kaushal Bhandankar) Date: Wed, 12 Jan 2011 11:09:03 +0530 Subject: [python-crypto] Test Vector verification in AES_CTR In-Reply-To: References: Message-ID: I have figured out that the below code gives the correct ciphered output as per the Test Vectors in RFC 3686. I have tried this for *"Test Vector #1"*and I can see that a) Prefix in counter is concatenated AES-CTR IV and nonce b) nbits = 32 from Crypto.Cipher import AES from Crypto.Util import Counter import binascii def main(): plaintext = '53696e676c6520626c6f636b206d7367' ctr = Counter.new(nbits=32, prefix=binascii.a2b_hex('000000300000000000000000')) crypto = AES.new(binascii.a2b_hex('ae6852f8121067cc4bf7a5765577f39e'),AES.MODE_CTR,counter = ctr) encrypted = crypto.encrypt(binascii.a2b_hex(plaintext)) encrypted_2 = binascii.b2a_hex(encrypted) print encrypted_2 if __name__ == "__main__": main() Regards, Kaushal On Wed, Jan 12, 2011 at 12:43 AM, Kaushal Bhandankar wrote: > Hi, > An old threaddescribes how to use PyCrypto . However, I am not able to get the desired > ciphered output as per the Test Vectors in SelfTests for AES in AES_CTR > mode. ( lib/Crypto/SelfTest/Cipher/test_AES.py - RFC 3686 test vectors). > > Any help would be greatly appreciated. > > Thanks, > Kaushal > -------------- next part -------------- An HTML attachment was scrubbed... URL: