[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Passphrase not working for ssh_pki_export_privkey_file


Hi,

I have that snippet of pki_generate and pki_export listed below.
I would expect priv_key to contain plain RSA private key and
priv_key_encrypted to be an encrypted version.

But I get two identical files with plain RSA private key, 
am I missing something here?

Thanks a lot for your help.

Julian

---
#include <stdio.h>
#include <libssh/libssh.h>

int main(void)
{
    ssh_key mKey;
    int rc;
    const char *passphrase = "secret";

    rc = ssh_pki_generate(SSH_KEYTYPE_RSA, 2048, &mKey);
    if(rc != SSH_OK)
        fprintf(stderr, "Error");

    rc = ssh_pki_export_privkey_file(mKey, 
				     NULL, 
				     NULL, 
	                             NULL, 
				     "/tmp/priv_key");
    if(rc != SSH_OK)
        fprintf(stderr, "Error");

    rc = ssh_pki_export_privkey_file(mKey, 
                                     passphrase, 
                                     NULL, 
                                     NULL, 
                                     "/tmp/priv_key_encrypted");
    if(rc != SSH_OK)
        fprintf(stderr, "Error");

    return 0;
}


Archive administrator: postmaster@lists.cynapses.org