diff options
author | Jakub Jelen <jjelen@redhat.com> | 2018-11-22 15:57:37 +0100 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2019-01-09 10:14:56 +0100 |
commit | 8e0c047031d69bdf882f550886e3dd43afd8db05 (patch) | |
tree | 0ffd94b05abc4693c92efe60492fca690bd9dd32 /src/pki.c | |
parent | 8d9026666190eecc55548899461b83a4f6cf45ce (diff) | |
download | libssh-8e0c047031d69bdf882f550886e3dd43afd8db05.tar.gz libssh-8e0c047031d69bdf882f550886e3dd43afd8db05.tar.xz libssh-8e0c047031d69bdf882f550886e3dd43afd8db05.zip |
packet: Introduce a new function to access crypto
And remove most of the direct access to the structure throughout the code
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Daiki Ueno <dueno@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Diffstat (limited to 'src/pki.c')
-rw-r--r-- | src/pki.c | 21 |
1 files changed, 9 insertions, 12 deletions
@@ -2009,10 +2009,9 @@ int ssh_pki_signature_verify(ssh_session session, * the content of sigbuf */ ssh_string ssh_pki_do_sign(ssh_session session, ssh_buffer sigbuf, - const ssh_key privkey) { - struct ssh_crypto_struct *crypto = - session->current_crypto ? session->current_crypto : - session->next_crypto; + const ssh_key privkey) +{ + struct ssh_crypto_struct *crypto = NULL; ssh_signature sig = NULL; ssh_string sig_blob; ssh_string session_id; @@ -2022,6 +2021,7 @@ ssh_string ssh_pki_do_sign(ssh_session session, return NULL; } + crypto = ssh_packet_get_current_crypto(session, SSH_DIRECTION_BOTH); session_id = ssh_string_new(crypto->digest_len); if (session_id == NULL) { return NULL; @@ -2144,18 +2144,15 @@ ssh_string ssh_pki_do_sign(ssh_session session, #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; + const ssh_key pubkey) +{ + struct ssh_crypto_struct *crypto = NULL; 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; - } + crypto = ssh_packet_get_current_crypto(session, SSH_DIRECTION_BOTH); /* prepend session identifier */ session_id = ssh_string_new(crypto->digest_len); @@ -2197,7 +2194,7 @@ ssh_string ssh_pki_do_sign_agent(ssh_session session, ssh_string ssh_srv_pki_do_sign_sessionid(ssh_session session, const ssh_key privkey) { - struct ssh_crypto_struct *crypto; + struct ssh_crypto_struct *crypto = NULL; ssh_signature sig = NULL; ssh_string sig_blob; int rc; |