X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/putty/blobdiff_plain/7cca0d811c4d1b5bb346cd60fdfa461a558aefec..3b4c589946c888bfee8bc84a75dd3a8cd249396c:/sshdes.c diff --git a/sshdes.c b/sshdes.c index bc1fe59e..1665b3d6 100644 --- a/sshdes.c +++ b/sshdes.c @@ -1,8 +1,4 @@ #include -#include /* FIXME */ -#include /* FIXME */ -#include /* FIXME */ -#include "putty.h" /* FIXME */ #include "ssh.h" @@ -782,22 +778,40 @@ void des3_decrypt_pubkey(unsigned char *key, des_3cbc_decrypt(blk, blk, len, ourkeys); } -struct ssh_cipher ssh_3des_ssh2 = { - NULL, +void des3_encrypt_pubkey(unsigned char *key, + unsigned char *blk, int len) { + DESContext ourkeys[3]; + des_key_setup(GET_32BIT_MSB_FIRST(key), + GET_32BIT_MSB_FIRST(key+4), &ourkeys[0]); + des_key_setup(GET_32BIT_MSB_FIRST(key+8), + GET_32BIT_MSB_FIRST(key+12), &ourkeys[1]); + des_key_setup(GET_32BIT_MSB_FIRST(key), + GET_32BIT_MSB_FIRST(key+4), &ourkeys[2]); + des_3cbc_encrypt(blk, blk, len, ourkeys); +} + +static const struct ssh2_cipher ssh_3des_ssh2 = { des3_csiv, des3_cskey, des3_sciv, des3_sckey, des3_ssh2_encrypt_blk, des3_ssh2_decrypt_blk, "3des-cbc", - 8 + 8, 168 +}; + +static const struct ssh2_cipher *const des3_list[] = { + &ssh_3des_ssh2 +}; + +const struct ssh2_ciphers ssh2_3des = { + sizeof(des3_list) / sizeof(*des3_list), + des3_list }; -struct ssh_cipher ssh_3des = { +const struct ssh_cipher ssh_3des = { des3_sesskey, - NULL, NULL, NULL, NULL, des3_encrypt_blk, des3_decrypt_blk, - "3des-cbc", 8 }; @@ -815,11 +829,9 @@ static void des_decrypt_blk(unsigned char *blk, int len) { des_cbc_decrypt(blk, blk, len, cskeys); } -struct ssh_cipher ssh_des = { +const struct ssh_cipher ssh_des = { des_sesskey, - NULL, NULL, NULL, NULL, /* SSH 2 bits - unused */ des_encrypt_blk, des_decrypt_blk, - "des-cbc", /* should never be used - not a valid cipher in ssh2 */ 8 };