1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 17:38:00 +00:00

Rename the AES vtables.

The old names like ssh_aes128 and ssh_aes128_ctr reflect the SSH
protocol IDs, which is all very well, but I think a more important
principle is that it should be easy for me to remember which cipher
mode each one refers to. So I've renamed them so that they all end in
_cbc and _sdctr.

(I've left alone the string identifiers used by testcrypt, for the
moment. Perhaps I'll go back and change those later.)
This commit is contained in:
Simon Tatham 2019-01-13 13:46:16 +00:00
parent ee8025dd1c
commit be5c0e6356
4 changed files with 29 additions and 29 deletions

View File

@ -547,7 +547,7 @@ static ssh2_userkey *openssh_pem_read(
des3_decrypt_pubkey_ossh(keybuf, key->iv,
key->keyblob->u, key->keyblob->len);
else {
ssh2_cipher *cipher = ssh2_cipher_new(&ssh_aes128);
ssh2_cipher *cipher = ssh2_cipher_new(&ssh_aes128_cbc);
ssh2_cipher_setkey(cipher, keybuf);
ssh2_cipher_setiv(cipher, key->iv);
ssh2_cipher_decrypt(cipher, key->keyblob->u, key->keyblob->len);
@ -1390,7 +1390,7 @@ static ssh2_userkey *openssh_new_read(
{
ssh2_cipher *cipher = ssh2_cipher_new(
key->cipher == ON_E_AES256CBC ?
&ssh_aes256 : &ssh_aes256_ctr);
&ssh_aes256_cbc : &ssh_aes256_sdctr);
ssh2_cipher_setkey(cipher, keybuf);
ssh2_cipher_setiv(cipher, keybuf + 32);
/* Decrypt the private section in place, casting away
@ -1594,7 +1594,7 @@ static bool openssh_new_write(
bcrypt_salt, sizeof(bcrypt_salt), bcrypt_rounds,
keybuf, sizeof(keybuf));
cipher = ssh2_cipher_new(&ssh_aes256_ctr);
cipher = ssh2_cipher_new(&ssh_aes256_sdctr);
ssh2_cipher_setkey(cipher, keybuf);
ssh2_cipher_setiv(cipher, keybuf + 32);
ssh2_cipher_encrypt(cipher, cpblob->u, cpblob->len);

12
ssh.h
View File

@ -856,12 +856,12 @@ extern const ssh2_cipheralg ssh_3des_ssh2_ctr;
extern const ssh2_cipheralg ssh_3des_ssh2;
extern const ssh2_cipheralg ssh_des_ssh2;
extern const ssh2_cipheralg ssh_des_sshcom_ssh2;
extern const ssh2_cipheralg ssh_aes256_ctr;
extern const ssh2_cipheralg ssh_aes256;
extern const ssh2_cipheralg ssh_aes192_ctr;
extern const ssh2_cipheralg ssh_aes192;
extern const ssh2_cipheralg ssh_aes128_ctr;
extern const ssh2_cipheralg ssh_aes128;
extern const ssh2_cipheralg ssh_aes256_sdctr;
extern const ssh2_cipheralg ssh_aes256_cbc;
extern const ssh2_cipheralg ssh_aes192_sdctr;
extern const ssh2_cipheralg ssh_aes192_cbc;
extern const ssh2_cipheralg ssh_aes128_sdctr;
extern const ssh2_cipheralg ssh_aes128_cbc;
extern const ssh2_cipheralg ssh_blowfish_ssh2_ctr;
extern const ssh2_cipheralg ssh_blowfish_ssh2;
extern const ssh2_cipheralg ssh_arcfour256_ssh2;

View File

@ -1027,7 +1027,7 @@ void aes256_encrypt_pubkey(const void *key, void *blk, int len)
{
char iv[16];
memset(iv, 0, 16);
ssh2_cipher *cipher = ssh2_cipher_new(&ssh_aes256);
ssh2_cipher *cipher = ssh2_cipher_new(&ssh_aes256_cbc);
ssh2_cipher_setkey(cipher, key);
ssh2_cipher_setiv(cipher, iv);
ssh2_cipher_encrypt(cipher, blk, len);
@ -1038,7 +1038,7 @@ void aes256_decrypt_pubkey(const void *key, void *blk, int len)
{
char iv[16];
memset(iv, 0, 16);
ssh2_cipher *cipher = ssh2_cipher_new(&ssh_aes256);
ssh2_cipher *cipher = ssh2_cipher_new(&ssh_aes256_cbc);
ssh2_cipher_setkey(cipher, key);
ssh2_cipher_setiv(cipher, iv);
ssh2_cipher_decrypt(cipher, blk, len);
@ -1094,7 +1094,7 @@ static void aes_ssh2_sdctr_method(ssh2_cipher *cipher, void *blk, int len)
aes_sdctr(blk, len, &ctx->context);
}
const ssh2_cipheralg ssh_aes128_ctr = {
const ssh2_cipheralg ssh_aes128_sdctr = {
aes_ssh2_new, aes_ssh2_free, aes_ssh2_setiv, aes_ssh2_setkey,
aes_ssh2_sdctr_method, aes_ssh2_sdctr_method, NULL, NULL,
"aes128-ctr",
@ -1102,7 +1102,7 @@ const ssh2_cipheralg ssh_aes128_ctr = {
NULL
};
const ssh2_cipheralg ssh_aes192_ctr = {
const ssh2_cipheralg ssh_aes192_sdctr = {
aes_ssh2_new, aes_ssh2_free, aes_ssh2_setiv, aes_ssh2_setkey,
aes_ssh2_sdctr_method, aes_ssh2_sdctr_method, NULL, NULL,
"aes192-ctr",
@ -1110,7 +1110,7 @@ const ssh2_cipheralg ssh_aes192_ctr = {
NULL
};
const ssh2_cipheralg ssh_aes256_ctr = {
const ssh2_cipheralg ssh_aes256_sdctr = {
aes_ssh2_new, aes_ssh2_free, aes_ssh2_setiv, aes_ssh2_setkey,
aes_ssh2_sdctr_method, aes_ssh2_sdctr_method, NULL, NULL,
"aes256-ctr",
@ -1118,7 +1118,7 @@ const ssh2_cipheralg ssh_aes256_ctr = {
NULL
};
const ssh2_cipheralg ssh_aes128 = {
const ssh2_cipheralg ssh_aes128_cbc = {
aes_ssh2_new, aes_ssh2_free, aes_ssh2_setiv, aes_ssh2_setkey,
aes_ssh2_encrypt, aes_ssh2_decrypt, NULL, NULL,
"aes128-cbc",
@ -1126,7 +1126,7 @@ const ssh2_cipheralg ssh_aes128 = {
NULL
};
const ssh2_cipheralg ssh_aes192 = {
const ssh2_cipheralg ssh_aes192_cbc = {
aes_ssh2_new, aes_ssh2_free, aes_ssh2_setiv, aes_ssh2_setkey,
aes_ssh2_encrypt, aes_ssh2_decrypt, NULL, NULL,
"aes192-cbc",
@ -1134,7 +1134,7 @@ const ssh2_cipheralg ssh_aes192 = {
NULL
};
const ssh2_cipheralg ssh_aes256 = {
const ssh2_cipheralg ssh_aes256_cbc = {
aes_ssh2_new, aes_ssh2_free, aes_ssh2_setiv, aes_ssh2_setkey,
aes_ssh2_encrypt, aes_ssh2_decrypt, NULL, NULL,
"aes256-cbc",
@ -1153,13 +1153,13 @@ static const ssh2_cipheralg ssh_rijndael_lysator = {
};
static const ssh2_cipheralg *const aes_list[] = {
&ssh_aes256_ctr,
&ssh_aes256,
&ssh_aes256_sdctr,
&ssh_aes256_cbc,
&ssh_rijndael_lysator,
&ssh_aes192_ctr,
&ssh_aes192,
&ssh_aes128_ctr,
&ssh_aes128,
&ssh_aes192_sdctr,
&ssh_aes192_cbc,
&ssh_aes128_sdctr,
&ssh_aes128_cbc,
};
const ssh2_ciphers ssh2_aes = { lenof(aes_list), aes_list };

View File

@ -269,12 +269,12 @@ static const ssh2_cipheralg *get_ssh2_cipheralg(BinarySource *in)
{"3des", &ssh_3des_ssh2},
{"des", &ssh_des_ssh2},
{"des_sshcom", &ssh_des_sshcom_ssh2},
{"aes256_ctr", &ssh_aes256_ctr},
{"aes256", &ssh_aes256},
{"aes192_ctr", &ssh_aes192_ctr},
{"aes192", &ssh_aes192},
{"aes128_ctr", &ssh_aes128_ctr},
{"aes128", &ssh_aes128},
{"aes256_ctr", &ssh_aes256_sdctr},
{"aes256", &ssh_aes256_cbc},
{"aes192_ctr", &ssh_aes192_sdctr},
{"aes192", &ssh_aes192_cbc},
{"aes128_ctr", &ssh_aes128_sdctr},
{"aes128", &ssh_aes128_cbc},
{"blowfish", &ssh_blowfish_ssh2_ctr},
{"blowfish", &ssh_blowfish_ssh2},
{"arcfour256", &ssh_arcfour256_ssh2},