diff options
author | Andreas Schneider <asn@cryptomilk.org> | 2011-08-21 10:11:05 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2011-08-21 10:11:05 +0200 |
commit | 4f19a304d182ada3e67290c61bad47a0a6c16f5b (patch) | |
tree | d415688df25a60b2ce586e4120bfda5274226326 /src/pki.c | |
parent | ab0354dbb69aa6aa55427ccb8a6e696879b272cf (diff) | |
download | libssh-4f19a304d182ada3e67290c61bad47a0a6c16f5b.tar.gz libssh-4f19a304d182ada3e67290c61bad47a0a6c16f5b.tar.xz libssh-4f19a304d182ada3e67290c61bad47a0a6c16f5b.zip |
pki: Add ssh_pki_export_signature_blob().
Diffstat (limited to 'src/pki.c')
-rw-r--r-- | src/pki.c | 56 |
1 files changed, 56 insertions, 0 deletions
@@ -857,6 +857,62 @@ int ssh_pki_export_pubkey_file(const ssh_key key, return SSH_OK; } +int ssh_pki_export_signature_blob(const ssh_signature sig, + ssh_string *sig_blob) +{ + ssh_buffer buf = NULL; + ssh_string str; + int rc; + + if (sig == NULL || sig_blob == NULL) { + return SSH_ERROR; + } + + buf = ssh_buffer_new(); + if (buf == NULL) { + return SSH_ERROR; + } + + str = ssh_string_from_char(ssh_key_type_to_char(sig->type)); + if (str == NULL) { + ssh_buffer_free(buf); + return SSH_ERROR; + } + + rc = buffer_add_ssh_string(buf, str); + ssh_string_free(str); + if (rc < 0) { + ssh_buffer_free(buf); + return SSH_ERROR; + } + + str = pki_signature_to_blob(sig); + if (str == NULL) { + ssh_buffer_free(buf); + return SSH_ERROR; + } + + rc = buffer_add_ssh_string(buf, str); + ssh_string_free(str); + if (rc < 0) { + ssh_buffer_free(buf); + return SSH_ERROR; + } + + str = ssh_string_new(buffer_get_rest_len(buf)); + if (str == NULL) { + ssh_buffer_free(buf); + return SSH_ERROR; + } + + ssh_string_fill(str, buffer_get_rest(buf), buffer_get_rest_len(buf)); + ssh_buffer_free(buf); + + *sig_blob = str; + + return SSH_OK; +} + /* * This function signs the session id (known as H) as a string then * the content of sigbuf */ |