diff options
author | Andreas Schneider <asn@cryptomilk.org> | 2011-08-21 13:43:20 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2011-08-21 13:43:20 +0200 |
commit | 1b57445f6b9c850a97e69a122537e918de0e02c5 (patch) | |
tree | 192131488f547809486ada434129923dd4fe5cf6 /src | |
parent | af82d8dfabc73fdf6477c2da521f2ba23deb2ca5 (diff) | |
download | libssh-1b57445f6b9c850a97e69a122537e918de0e02c5.tar.gz libssh-1b57445f6b9c850a97e69a122537e918de0e02c5.tar.xz libssh-1b57445f6b9c850a97e69a122537e918de0e02c5.zip |
pki: Add ssh_pki_do_sign_agent().
Diffstat (limited to 'src')
-rw-r--r-- | src/pki.c | 53 |
1 files changed, 53 insertions, 0 deletions
@@ -48,6 +48,7 @@ #include "libssh/keys.h" #include "libssh/buffer.h" #include "libssh/misc.h" +#include "libssh/agent.h" void ssh_pki_log(const char *format, ...) { @@ -1028,6 +1029,58 @@ ssh_string ssh_pki_do_sign(ssh_session session, ssh_buffer sigbuf, return signature; } +#ifndef _WIN32 +ssh_string ssh_pki_do_sign_agent(ssh_session session, + struct ssh_buffer_struct *buf, + const ssh_key pubkey) { + struct ssh_crypto_struct *crypto; + ssh_string session_id; + ssh_string sig_blob; + ssh_buffer sig_buf; + int rc; + + if (session->current_crypto) { + crypto = session->current_crypto; + } else { + crypto = session->next_crypto; + } + + /* prepend session identifier */ + session_id = ssh_string_new(crypto->digest_len); + if (session_id == NULL) { + return NULL; + } + ssh_string_fill(session_id, crypto->session_id, crypto->digest_len); + + sig_buf = ssh_buffer_new(); + if (sig_buf == NULL) { + ssh_string_free(session_id); + return NULL; + } + + rc = buffer_add_ssh_string(sig_buf, session_id); + if (rc < 0) { + ssh_string_free(session_id); + ssh_buffer_free(sig_buf); + return NULL; + } + ssh_string_free(session_id); + + /* append out buffer */ + if (buffer_add_buffer(sig_buf, buf) < 0) { + ssh_buffer_free(sig_buf); + return NULL; + } + + /* create signature */ + sig_blob = ssh_agent_sign_data(session, pubkey, sig_buf); + + ssh_buffer_free(sig_buf); + + return sig_blob; +} +#endif /* _WIN32 */ + /** * @} |