Welcome to mirror list, hosted at ThFree Co, Russian Federation.

pubkey-pem.c « crypto - github.com/mRemoteNG/PuTTYNG.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3eaa16aadde019b1e58647b4c04be7f5f96aeb46 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*
 * Convenience functions to encrypt and decrypt OpenSSH PEM format for
 * SSH-2 private key files. This uses triple-DES in SSH-2 style (one
 * CBC layer), with three distinct keys, and an IV also generated from
 * the passphrase.
 */

#include "ssh.h"

static ssh_cipher *des3_pubkey_ossh_cipher(const void *vkey, const void *viv)
{
    ssh_cipher *c = ssh_cipher_new(&ssh_3des_ssh2);
    ssh_cipher_setkey(c, vkey);
    ssh_cipher_setiv(c, viv);
    return c;
}

void des3_decrypt_pubkey_ossh(const void *vkey, const void *viv,
                              void *vblk, int len)
{
    ssh_cipher *c = des3_pubkey_ossh_cipher(vkey, viv);
    ssh_cipher_decrypt(c, vblk, len);
    ssh_cipher_free(c);
}

void des3_encrypt_pubkey_ossh(const void *vkey, const void *viv,
                              void *vblk, int len)
{
    ssh_cipher *c = des3_pubkey_ossh_cipher(vkey, viv);
    ssh_cipher_encrypt(c, vblk, len);
    ssh_cipher_free(c);
}