1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-04-21 21:15:03 -05:00

Reinstate CBC flag in AES-CBC ciphers.

That flag was missing from all the CBC vtables' flags fields, because
my recent rewrite forgot to put it in. As a result the SSH_MSG_IGNORE
defence against CBC length oracle attacks was not being enabled.
This commit is contained in:
Simon Tatham 2019-01-23 20:22:29 +00:00
parent 891c2b9616
commit de797aa40e

View File

@ -103,37 +103,42 @@ struct aes_extra {
const ssh_cipheralg *sw, *hw; const ssh_cipheralg *sw, *hw;
}; };
#define VTABLES(cid, pid, bits, name, encsuffix, decsuffix, setiv) \ #define VTABLES_INNER(cid, pid, bits, name, encsuffix, \
static void cid##_sw##encsuffix(ssh_cipher *, void *blk, int len); \ decsuffix, setiv, flags) \
static void cid##_sw##decsuffix(ssh_cipher *, void *blk, int len); \ static void cid##_sw##encsuffix(ssh_cipher *, void *blk, int len); \
const ssh_cipheralg ssh_##cid##_sw = { \ static void cid##_sw##decsuffix(ssh_cipher *, void *blk, int len); \
const ssh_cipheralg ssh_##cid##_sw = { \
aes_sw_new, aes_sw_free, aes_sw_##setiv, aes_sw_setkey, \ aes_sw_new, aes_sw_free, aes_sw_##setiv, aes_sw_setkey, \
cid##_sw##encsuffix, cid##_sw##decsuffix, NULL, NULL, \ cid##_sw##encsuffix, cid##_sw##decsuffix, NULL, NULL, \
pid, 16, bits, bits/8, 0, name " (unaccelerated)", \ pid, 16, bits, bits/8, flags, name " (unaccelerated)", \
NULL, NULL }; \ NULL, NULL }; \
\ \
static void cid##_hw##encsuffix(ssh_cipher *, void *blk, int len); \ static void cid##_hw##encsuffix(ssh_cipher *, void *blk, int len); \
static void cid##_hw##decsuffix(ssh_cipher *, void *blk, int len); \ static void cid##_hw##decsuffix(ssh_cipher *, void *blk, int len); \
const ssh_cipheralg ssh_##cid##_hw = { \ const ssh_cipheralg ssh_##cid##_hw = { \
aes_hw_new, aes_hw_free, aes_hw_##setiv, aes_hw_setkey, \ aes_hw_new, aes_hw_free, aes_hw_##setiv, aes_hw_setkey, \
cid##_hw##encsuffix, cid##_hw##decsuffix, NULL, NULL, \ cid##_hw##encsuffix, cid##_hw##decsuffix, NULL, NULL, \
pid, 16, bits, bits/8, 0, name HW_NAME_SUFFIX, \ pid, 16, bits, bits/8, flags, name HW_NAME_SUFFIX, \
NULL, NULL }; \ NULL, NULL }; \
\ \
const struct aes_extra extra_##cid = { \ const struct aes_extra extra_##cid = { \
&ssh_##cid##_sw, &ssh_##cid##_hw }; \ &ssh_##cid##_sw, &ssh_##cid##_hw }; \
\ \
const ssh_cipheralg ssh_##cid = { \ const ssh_cipheralg ssh_##cid = { \
aes_select, NULL, NULL, NULL, NULL, NULL, NULL, NULL, \ aes_select, NULL, NULL, NULL, NULL, NULL, NULL, NULL, \
pid, 16, bits, bits/8, 0, name " (dummy selector vtable)", \ pid, 16, bits, bits/8, flags, name " (dummy selector vtable)", \
NULL, &extra_##cid }; \ NULL, &extra_##cid }; \
VTABLES(aes128_cbc, "aes128", 128, "AES-128 CBC", _encrypt,_decrypt,setiv_cbc) #define VTABLES(keylen) \
VTABLES(aes192_cbc, "aes192", 192, "AES-192 CBC", _encrypt,_decrypt,setiv_cbc) VTABLES_INNER(aes ## keylen ## _cbc, "aes" #keylen, \
VTABLES(aes256_cbc, "aes256", 256, "AES-256 CBC", _encrypt,_decrypt,setiv_cbc) keylen, "AES-" #keylen " CBC", _encrypt, _decrypt, \
VTABLES(aes128_sdctr, "aes128-ctr", 128, "AES-128 SDCTR",,, setiv_sdctr) setiv_cbc, SSH_CIPHER_IS_CBC) \
VTABLES(aes192_sdctr, "aes192-ctr", 192, "AES-192 SDCTR",,, setiv_sdctr) VTABLES_INNER(aes ## keylen ## _sdctr, "aes" #keylen "-ctr", \
VTABLES(aes256_sdctr, "aes256-ctr", 256, "AES-256 SDCTR",,, setiv_sdctr) keylen, "AES-" #keylen " SDCTR",,, setiv_sdctr, 0)
VTABLES(128)
VTABLES(192)
VTABLES(256)
static const ssh_cipheralg ssh_rijndael_lysator = { static const ssh_cipheralg ssh_rijndael_lysator = {
/* Same as aes256_cbc, but with a different protocol ID */ /* Same as aes256_cbc, but with a different protocol ID */