summaryrefslogtreecommitdiff
path: root/kexkems.c
diff options
context:
space:
mode:
Diffstat (limited to 'kexkems.c')
-rw-r--r--kexkems.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/kexkems.c b/kexkems.c
index 10ef12196..3ba8f0df5 100644
--- a/kexkems.c
+++ b/kexkems.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: kexkems.c,v 1.4 2019/01/21 10:29:56 djm Exp $ */ 1/* $OpenBSD: kexkems.c,v 1.5 2019/01/21 10:35:09 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2019 Markus Friedl. All rights reserved. 3 * Copyright (c) 2019 Markus Friedl. All rights reserved.
4 * 4 *
@@ -53,17 +53,17 @@ input_kex_kem_init(int type, u_int32_t seq, struct ssh *ssh)
53 struct sshkey *server_host_private, *server_host_public; 53 struct sshkey *server_host_private, *server_host_public;
54 struct sshbuf *shared_secret = NULL; 54 struct sshbuf *shared_secret = NULL;
55 struct sshbuf *server_pubkey = NULL; 55 struct sshbuf *server_pubkey = NULL;
56 struct sshbuf *client_pubkey = NULL;
56 u_char *server_host_key_blob = NULL, *signature = NULL; 57 u_char *server_host_key_blob = NULL, *signature = NULL;
57 u_char *client_pubkey = NULL;
58 u_char hash[SSH_DIGEST_MAX_LENGTH]; 58 u_char hash[SSH_DIGEST_MAX_LENGTH];
59 size_t slen, pklen, sbloblen, hashlen; 59 size_t slen, sbloblen, hashlen;
60 int r; 60 int r;
61 61
62 if ((r = kex_load_hostkey(ssh, &server_host_private, 62 if ((r = kex_load_hostkey(ssh, &server_host_private,
63 &server_host_public)) != 0) 63 &server_host_public)) != 0)
64 goto out; 64 goto out;
65 65
66 if ((r = sshpkt_get_string(ssh, &client_pubkey, &pklen)) != 0 || 66 if ((r = sshpkt_getb_froms(ssh, &client_pubkey)) != 0 ||
67 (r = sshpkt_get_end(ssh)) != 0) 67 (r = sshpkt_get_end(ssh)) != 0)
68 goto out; 68 goto out;
69 69
@@ -74,19 +74,19 @@ input_kex_kem_init(int type, u_int32_t seq, struct ssh *ssh)
74 case KEX_DH_GRP14_SHA256: 74 case KEX_DH_GRP14_SHA256:
75 case KEX_DH_GRP16_SHA512: 75 case KEX_DH_GRP16_SHA512:
76 case KEX_DH_GRP18_SHA512: 76 case KEX_DH_GRP18_SHA512:
77 r = kex_dh_enc(kex, client_pubkey, pklen, &server_pubkey, 77 r = kex_dh_enc(kex, client_pubkey, &server_pubkey,
78 &shared_secret); 78 &shared_secret);
79 break; 79 break;
80 case KEX_ECDH_SHA2: 80 case KEX_ECDH_SHA2:
81 r = kex_ecdh_enc(kex, client_pubkey, pklen, &server_pubkey, 81 r = kex_ecdh_enc(kex, client_pubkey, &server_pubkey,
82 &shared_secret); 82 &shared_secret);
83 break; 83 break;
84 case KEX_C25519_SHA256: 84 case KEX_C25519_SHA256:
85 r = kex_c25519_enc(kex, client_pubkey, pklen, &server_pubkey, 85 r = kex_c25519_enc(kex, client_pubkey, &server_pubkey,
86 &shared_secret); 86 &shared_secret);
87 break; 87 break;
88 case KEX_KEM_SNTRUP4591761X25519_SHA512: 88 case KEX_KEM_SNTRUP4591761X25519_SHA512:
89 r = kex_kem_sntrup4591761x25519_enc(kex, client_pubkey, pklen, 89 r = kex_kem_sntrup4591761x25519_enc(kex, client_pubkey,
90 &server_pubkey, &shared_secret); 90 &server_pubkey, &shared_secret);
91 break; 91 break;
92 default: 92 default:
@@ -108,9 +108,9 @@ input_kex_kem_init(int type, u_int32_t seq, struct ssh *ssh)
108 sshbuf_ptr(kex->peer), sshbuf_len(kex->peer), 108 sshbuf_ptr(kex->peer), sshbuf_len(kex->peer),
109 sshbuf_ptr(kex->my), sshbuf_len(kex->my), 109 sshbuf_ptr(kex->my), sshbuf_len(kex->my),
110 server_host_key_blob, sbloblen, 110 server_host_key_blob, sbloblen,
111 client_pubkey, pklen, 111 client_pubkey,
112 sshbuf_ptr(server_pubkey), sshbuf_len(server_pubkey), 112 server_pubkey,
113 sshbuf_ptr(shared_secret), sshbuf_len(shared_secret), 113 shared_secret,
114 hash, &hashlen)) != 0) 114 hash, &hashlen)) != 0)
115 goto out; 115 goto out;
116 116
@@ -133,8 +133,8 @@ out:
133 explicit_bzero(hash, sizeof(hash)); 133 explicit_bzero(hash, sizeof(hash));
134 free(server_host_key_blob); 134 free(server_host_key_blob);
135 free(signature); 135 free(signature);
136 free(client_pubkey);
137 sshbuf_free(shared_secret); 136 sshbuf_free(shared_secret);
137 sshbuf_free(client_pubkey);
138 sshbuf_free(server_pubkey); 138 sshbuf_free(server_pubkey);
139 return r; 139 return r;
140} 140}