mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-09 17:38:00 +00:00
30 lines
787 B
C
30 lines
787 B
C
|
/*
|
||
|
* Convenience functions to encrypt and decrypt PuTTY's own .PPK
|
||
|
* format for SSH-2 private key files, which uses 256-bit AES in CBC
|
||
|
* mode.
|
||
|
*/
|
||
|
|
||
|
#include "ssh.h"
|
||
|
|
||
|
static ssh_cipher *aes256_pubkey_cipher(const void *key, const void *iv)
|
||
|
{
|
||
|
ssh_cipher *cipher = ssh_cipher_new(&ssh_aes256_cbc);
|
||
|
ssh_cipher_setkey(cipher, key);
|
||
|
ssh_cipher_setiv(cipher, iv);
|
||
|
return cipher;
|
||
|
}
|
||
|
|
||
|
void aes256_encrypt_pubkey(const void *key, const void *iv, void *blk, int len)
|
||
|
{
|
||
|
ssh_cipher *c = aes256_pubkey_cipher(key, iv);
|
||
|
ssh_cipher_encrypt(c, blk, len);
|
||
|
ssh_cipher_free(c);
|
||
|
}
|
||
|
|
||
|
void aes256_decrypt_pubkey(const void *key, const void *iv, void *blk, int len)
|
||
|
{
|
||
|
ssh_cipher *c = aes256_pubkey_cipher(key, iv);
|
||
|
ssh_cipher_decrypt(c, blk, len);
|
||
|
ssh_cipher_free(c);
|
||
|
}
|