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

Support for selecting AES from the GUI. In the process, I've had to

introduce another layer of abstraction in SSH2 ciphers, such that a
single `logical cipher' (as desired by a user) can equate to more
than one `physical cipher'. This is because AES comes in several key
lengths (PuTTY will pick the highest supported by the remote end)
and several different SSH2-protocol-level names (aes*-cbc,
rijndael*-cbc, and an unofficial one rijndael-cbc@lysator.liu.se).

[originally from svn r967]
This commit is contained in:
Simon Tatham
2001-03-02 13:55:23 +00:00
parent bf25fd405c
commit b182356f99
8 changed files with 156 additions and 89 deletions

View File

@ -1023,8 +1023,7 @@ static void aes_ssh2_decrypt_blk(unsigned char *blk, int len) {
aes_decrypt_cbc(blk, len, &scctx);
}
struct ssh_cipher ssh_aes128_ssh2 = {
NULL,
static struct ssh2_cipher ssh_aes128 = {
aes_csiv, aes128_cskey,
aes_sciv, aes128_sckey,
aes_ssh2_encrypt_blk,
@ -1033,8 +1032,7 @@ struct ssh_cipher ssh_aes128_ssh2 = {
16, 128
};
struct ssh_cipher ssh_aes192_ssh2 = {
NULL,
static struct ssh2_cipher ssh_aes192 = {
aes_csiv, aes192_cskey,
aes_sciv, aes192_sckey,
aes_ssh2_encrypt_blk,
@ -1043,8 +1041,7 @@ struct ssh_cipher ssh_aes192_ssh2 = {
16, 192
};
struct ssh_cipher ssh_aes256_ssh2 = {
NULL,
static struct ssh2_cipher ssh_aes256 = {
aes_csiv, aes256_cskey,
aes_sciv, aes256_sckey,
aes_ssh2_encrypt_blk,
@ -1053,31 +1050,53 @@ struct ssh_cipher ssh_aes256_ssh2 = {
16, 256
};
#ifdef TESTMODE
static struct ssh2_cipher ssh_rijndael128 = {
aes_csiv, aes128_cskey,
aes_sciv, aes128_sckey,
aes_ssh2_encrypt_blk,
aes_ssh2_decrypt_blk,
"rijndael128-cbc",
16, 128
};
#include <stdio.h>
static struct ssh2_cipher ssh_rijndael192 = {
aes_csiv, aes192_cskey,
aes_sciv, aes192_sckey,
aes_ssh2_encrypt_blk,
aes_ssh2_decrypt_blk,
"rijndael192-cbc",
16, 192
};
int main(void) {
AESContext c;
static unsigned char key[32] = {};
word32 block[32];
int i, j, k;
static struct ssh2_cipher ssh_rijndael256 = {
aes_csiv, aes256_cskey,
aes_sciv, aes256_sckey,
aes_ssh2_encrypt_blk,
aes_ssh2_decrypt_blk,
"rijndael256-cbc",
16, 256
};
for (i = 16; i <= 32; i += 8) {
for (j = 16; j <= 32; j += 8) {
printf("b%d, k%d: ", i, j);
fflush(stdout);
aes_setup(&c, i, key, j);
memset(block, 0, sizeof(block));
aes_encrypt(&c, block);
aes_decrypt(&c, block);
for (k = 0; k < i/4; k++)
printf("%08x ", block[k]);
printf("\n");
}
}
static struct ssh2_cipher ssh_rijndael_lysator = {
aes_csiv, aes256_cskey,
aes_sciv, aes256_sckey,
aes_ssh2_encrypt_blk,
aes_ssh2_decrypt_blk,
"rijndael-cbc@lysator.liu.se",
16, 256
};
return 0;
}
static struct ssh2_cipher *aes_list[] = {
&ssh_aes256,
&ssh_rijndael256,
&ssh_rijndael_lysator,
&ssh_aes192,
&ssh_rijndael192,
&ssh_aes128,
&ssh_rijndael128,
};
#endif
struct ssh2_ciphers ssh2_aes = {
sizeof(aes_list) / sizeof(*aes_list),
aes_list
};