mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-09 09:27:59 +00:00
5b30e6f7a6
Similarly to 'utils', I've moved all the stuff in the crypto build-time library into a source directory of its own, and while I'm at it, split up the monolithic sshauxcrypt.c into its various unrelated parts. This is also an opportunity to remove the annoying 'ssh' prefix from the front of the file names, and give several of them less cryptic names.
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);
|
|
}
|