diff options
author | Andreas Schneider <asn@cryptomilk.org> | 2011-08-07 19:53:03 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2011-08-08 15:28:31 +0200 |
commit | bec483bc1874909be8fd9c8fbc909f53be5ba27a (patch) | |
tree | fd00ee7897dbe20e96e1772e30654a44c1eac728 /src/pki_crypto.c | |
parent | f81444bd57095cf8ff8e76b50f662aad0757f574 (diff) | |
download | libssh-bec483bc1874909be8fd9c8fbc909f53be5ba27a.tar.gz libssh-bec483bc1874909be8fd9c8fbc909f53be5ba27a.tar.xz libssh-bec483bc1874909be8fd9c8fbc909f53be5ba27a.zip |
pki: Add ssh_pki_import_pubkey_base64().
Diffstat (limited to 'src/pki_crypto.c')
-rw-r--r-- | src/pki_crypto.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/pki_crypto.c b/src/pki_crypto.c index 2c99daf8..2f95d297 100644 --- a/src/pki_crypto.c +++ b/src/pki_crypto.c @@ -36,6 +36,7 @@ #include "libssh/callbacks.h" #include "libssh/pki.h" #include "libssh/keys.h" +#include "libssh/dh.h" static int pem_get_password(char *buf, int size, int rwflag, void *userdata) { ssh_session session = userdata; @@ -162,6 +163,50 @@ fail: return NULL; } +int pki_pubkey_build_dss(ssh_key key, + ssh_string p, + ssh_string q, + ssh_string g, + ssh_string pubkey) { + key->dsa = DSA_new(); + if (key->dsa == NULL) { + return SSH_ERROR; + } + + key->dsa->p = make_string_bn(p); + key->dsa->q = make_string_bn(q); + key->dsa->g = make_string_bn(g); + key->dsa->pub_key = make_string_bn(pubkey); + if (key->dsa->p == NULL || + key->dsa->q == NULL || + key->dsa->g == NULL || + key->dsa->pub_key == NULL) { + DSA_free(key->dsa); + return SSH_ERROR; + } + + return SSH_OK; +} + +int pki_pubkey_build_rsa(ssh_key key, + ssh_string e, + ssh_string n) { + key->rsa = RSA_new(); + if (key->rsa == NULL) { + return SSH_ERROR; + } + + key->rsa->e = make_string_bn(e); + key->rsa->n = make_string_bn(n); + if (key->rsa->e == NULL || + key->rsa->n == NULL) { + RSA_free(key->rsa); + return SSH_ERROR; + } + + return SSH_OK; +} + ssh_key pki_publickey_from_privatekey(ssh_key privkey) { ssh_key pubkey = NULL; |