diff options
Diffstat (limited to 'crypto/pubkey-ppk.c')
-rw-r--r-- | crypto/pubkey-ppk.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/crypto/pubkey-ppk.c b/crypto/pubkey-ppk.c new file mode 100644 index 00000000..7ffb570a --- /dev/null +++ b/crypto/pubkey-ppk.c @@ -0,0 +1,29 @@ +/* + * 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); +} |