diff options
author | Andreas Schneider <asn@cryptomilk.org> | 2011-09-05 11:02:23 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2011-09-05 11:28:19 +0200 |
commit | 808c7a9be4f110605e76ea5678bf0b1986cc9b38 (patch) | |
tree | 75823375575323a4b59aa6f9b381a0e3e0e2c183 /src/pki_crypto.c | |
parent | 6901e25085f8924f9d83e12107c05f935bd24287 (diff) | |
download | libssh-808c7a9be4f110605e76ea5678bf0b1986cc9b38.tar.gz libssh-808c7a9be4f110605e76ea5678bf0b1986cc9b38.tar.xz libssh-808c7a9be4f110605e76ea5678bf0b1986cc9b38.zip |
pki: Add ssh_pki_export_pubkey_rsa1().
Diffstat (limited to 'src/pki_crypto.c')
-rw-r--r-- | src/pki_crypto.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/pki_crypto.c b/src/pki_crypto.c index 29e589f1..32ee13d1 100644 --- a/src/pki_crypto.c +++ b/src/pki_crypto.c @@ -519,6 +519,35 @@ fail: return NULL; } +int pki_export_pubkey_rsa1(const ssh_key key, + const char *host, + char *rsa1, + size_t rsa1_len) +{ + char *e; + char *n; + int rsa_size = RSA_size(key->rsa); + + e = bignum_bn2dec(key->rsa->e); + if (e == NULL) { + return SSH_ERROR; + } + + n = bignum_bn2dec(key->rsa->n); + if (n == NULL) { + OPENSSL_free(e); + return SSH_ERROR; + } + + snprintf(rsa1, rsa1_len, + "%s %d %s %s\n", + host, rsa_size << 3, e, n); + OPENSSL_free(e); + OPENSSL_free(n); + + return SSH_OK; +} + /** * @internal * |