mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-06-30 19:12:48 -05:00
Added a framework for importing foreign key formats, and implemented
importing of OpenSSH SSH2 private key files (both encrypted and unencrypted). Seems to work fine. [originally from svn r1668]
This commit is contained in:
30
sshdes.c
30
sshdes.c
@ -854,6 +854,36 @@ void des3_encrypt_pubkey(unsigned char *key, unsigned char *blk, int len)
|
||||
des_3cbc_encrypt(blk, blk, len, ourkeys);
|
||||
}
|
||||
|
||||
void des3_decrypt_pubkey_ossh(unsigned char *key, unsigned char *iv,
|
||||
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 + 16),
|
||||
GET_32BIT_MSB_FIRST(key + 20), &ourkeys[2]);
|
||||
ourkeys[0].div0 = GET_32BIT_MSB_FIRST(iv);
|
||||
ourkeys[0].div1 = GET_32BIT_MSB_FIRST(iv+4);
|
||||
des_cbc3_decrypt(blk, blk, len, ourkeys);
|
||||
}
|
||||
|
||||
void des3_encrypt_pubkey_ossh(unsigned char *key, unsigned char *iv,
|
||||
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 + 16),
|
||||
GET_32BIT_MSB_FIRST(key + 20), &ourkeys[2]);
|
||||
ourkeys[0].eiv0 = GET_32BIT_MSB_FIRST(iv);
|
||||
ourkeys[0].eiv1 = GET_32BIT_MSB_FIRST(iv+4);
|
||||
des_cbc3_encrypt(blk, blk, len, ourkeys);
|
||||
}
|
||||
|
||||
static const struct ssh2_cipher ssh_3des_ssh2 = {
|
||||
des3_csiv, des3_cskey,
|
||||
des3_sciv, des3_sckey,
|
||||
|
Reference in New Issue
Block a user