1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-06-30 19:12:48 -05:00

Add an IV argument to aes_{en,de}crypt_pubkey.

No functional change: currently, the IV passed in is always zero
(except in the test suite). But this prepares to change that in a
future revision of the key file format.
This commit is contained in:
Simon Tatham
2021-02-18 17:48:06 +00:00
parent 609502b04b
commit c61158aa34
6 changed files with 36 additions and 19 deletions

View File

@ -1410,11 +1410,20 @@ class crypt(MyTestBase):
p = b'three AES blocks, or six DES, of arbitrary input'
k = b'thirty-two-byte aes-256 test key'
iv = b'\0' * 16
c = unhex('7b112d00c0fc95bc13fcdacfd43281bf'
'de9389db1bbcfde79d59a303d41fd2eb'
'0955c9477ae4ee3a4d6c1fbe474c0ef6')
self.assertEqualBin(aes256_encrypt_pubkey(k, p), c)
self.assertEqualBin(aes256_decrypt_pubkey(k, c), p)
self.assertEqualBin(aes256_encrypt_pubkey(k, iv, p), c)
self.assertEqualBin(aes256_decrypt_pubkey(k, iv, c), p)
# same k as in the previous case
iv = unhex('0102030405060708090a0b0c0d0e0f10')
c = unhex('9e9c8a91b739677b834397bdd8e70c05'
'c3e2cf6cce68d376d798a59848621c6d'
'42b9e7101260a438daadd7b742875a36')
self.assertEqualBin(aes256_encrypt_pubkey(k, iv, p), c)
self.assertEqualBin(aes256_decrypt_pubkey(k, iv, c), p)
k = b'3des with keys distinct.'
iv = b'randomIV'