buffers: adapt ecdh.c to ssh_buffer_(un)pack()
Reviewed-by: Andreas Schneider <asn@samba.org>
Этот коммит содержится в:
родитель
e9fd14c7f0
Коммит
9457685320
32
src/ecdh.c
32
src/ecdh.c
@ -285,12 +285,6 @@ int ssh_server_ecdh_init(ssh_session session, ssh_buffer packet){
|
|||||||
session->next_crypto->ecdh_privkey = ecdh_key;
|
session->next_crypto->ecdh_privkey = ecdh_key;
|
||||||
session->next_crypto->ecdh_server_pubkey = q_s_string;
|
session->next_crypto->ecdh_server_pubkey = q_s_string;
|
||||||
|
|
||||||
rc = buffer_add_u8(session->out_buffer, SSH2_MSG_KEXDH_REPLY);
|
|
||||||
if (rc < 0) {
|
|
||||||
ssh_set_error_oom(session);
|
|
||||||
return SSH_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* build k and session_id */
|
/* build k and session_id */
|
||||||
rc = ecdh_build_k(session);
|
rc = ecdh_build_k(session);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
@ -310,30 +304,22 @@ int ssh_server_ecdh_init(ssh_session session, ssh_buffer packet){
|
|||||||
return SSH_ERROR;
|
return SSH_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add host's public key */
|
|
||||||
rc = buffer_add_ssh_string(session->out_buffer,
|
|
||||||
session->next_crypto->server_pubkey);
|
|
||||||
if (rc < 0) {
|
|
||||||
ssh_set_error_oom(session);
|
|
||||||
return SSH_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* add ecdh public key */
|
|
||||||
rc = buffer_add_ssh_string(session->out_buffer, q_s_string);
|
|
||||||
if (rc < 0) {
|
|
||||||
ssh_set_error_oom(session);
|
|
||||||
return SSH_ERROR;
|
|
||||||
}
|
|
||||||
/* add signature blob */
|
|
||||||
sig_blob = ssh_srv_pki_do_sign_sessionid(session, privkey);
|
sig_blob = ssh_srv_pki_do_sign_sessionid(session, privkey);
|
||||||
if (sig_blob == NULL) {
|
if (sig_blob == NULL) {
|
||||||
ssh_set_error(session, SSH_FATAL, "Could not sign the session id");
|
ssh_set_error(session, SSH_FATAL, "Could not sign the session id");
|
||||||
return SSH_ERROR;
|
return SSH_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = buffer_add_ssh_string(session->out_buffer, sig_blob);
|
rc = ssh_buffer_pack(session->out_buffer,
|
||||||
|
"bSSS",
|
||||||
|
SSH2_MSG_KEXDH_REPLY,
|
||||||
|
session->next_crypto->server_pubkey, /* host's pubkey */
|
||||||
|
q_s_string, /* ecdh public key */
|
||||||
|
sig_blob); /* signature blob */
|
||||||
|
|
||||||
ssh_string_free(sig_blob);
|
ssh_string_free(sig_blob);
|
||||||
if (rc < 0) {
|
|
||||||
|
if (rc != SSH_OK) {
|
||||||
ssh_set_error_oom(session);
|
ssh_set_error_oom(session);
|
||||||
return SSH_ERROR;
|
return SSH_ERROR;
|
||||||
}
|
}
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user