Merge pull request #7838 from jepler/more-aes-vectors
add more test vectors for aes
This commit is contained in:
commit
e0a7edbe54
@ -97,3 +97,47 @@ for i in range(0, len(plaintext), 16):
|
||||
cipher.decrypt_into(cyphertext[i : i + 16], output)
|
||||
print(str(hexlify(output), ""))
|
||||
print()
|
||||
|
||||
print("truncated-CTR-1")
|
||||
## Truncated CTR test case
|
||||
plaintext = unhexlify("6bc1bee22e409f96e93d7e117393172a" "ae2d")
|
||||
|
||||
key = unhexlify("2b7e151628aed2a6abf7158809cf4f3c")
|
||||
counter = unhexlify("f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff")
|
||||
cyphertext = bytearray(len(plaintext))
|
||||
cipher = aesio.AES(key, aesio.MODE_CTR, IV=counter)
|
||||
for i in range(0, len(plaintext), 16):
|
||||
output = memoryview(cyphertext)[i : i + 16]
|
||||
cipher.encrypt_into(plaintext[i : i + 16], output)
|
||||
print(str(hexlify(output), ""))
|
||||
print()
|
||||
|
||||
plaintext = bytearray(len(plaintext))
|
||||
cipher = aesio.AES(key, aesio.MODE_CTR, IV=counter)
|
||||
for i in range(0, len(plaintext), 16):
|
||||
output = memoryview(plaintext)[i : i + 16]
|
||||
cipher.decrypt_into(cyphertext[i : i + 16], output)
|
||||
print(str(hexlify(output), ""))
|
||||
print()
|
||||
|
||||
print("truncated-CTR-2")
|
||||
## Truncated CTR test case #2
|
||||
plaintext = unhexlify("6bc1bee22e409f96e93d7e117393172a" "ae")
|
||||
|
||||
key = unhexlify("2b7e151628aed2a6abf7158809cf4f3c")
|
||||
counter = unhexlify("f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff")
|
||||
cyphertext = bytearray(len(plaintext))
|
||||
cipher = aesio.AES(key, aesio.MODE_CTR, IV=counter)
|
||||
cipher.encrypt_into(plaintext, cyphertext)
|
||||
for i in range(0, len(plaintext), 16):
|
||||
output = memoryview(cyphertext)[i : i + 16]
|
||||
print(str(hexlify(output), ""))
|
||||
print()
|
||||
|
||||
plaintext = bytearray(len(plaintext))
|
||||
cipher = aesio.AES(key, aesio.MODE_CTR, IV=counter)
|
||||
cipher.decrypt_into(cyphertext, plaintext)
|
||||
for i in range(0, len(plaintext), 16):
|
||||
output = memoryview(plaintext)[i : i + 16]
|
||||
print(str(hexlify(output), ""))
|
||||
print()
|
||||
|
@ -34,3 +34,17 @@ ae2d8a571e03ac9c9eb76fac45af8e51
|
||||
30c81c46a35ce411e5fbc1191a0a52ef
|
||||
f69f2445df4f9b17ad2b417be66c3710
|
||||
|
||||
truncated-CTR-1
|
||||
874d6191b620e3261bef6864990db6ce
|
||||
9806
|
||||
|
||||
6bc1bee22e409f96e93d7e117393172a
|
||||
ae2d
|
||||
|
||||
truncated-CTR-2
|
||||
874d6191b620e3261bef6864990db6ce
|
||||
98
|
||||
|
||||
6bc1bee22e409f96e93d7e117393172a
|
||||
ae
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user