Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssh/src/kexdhs.c |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||
2 | - | |||||||||||||
3 | - | |||||||||||||
4 | - | |||||||||||||
5 | - | |||||||||||||
6 | - | |||||||||||||
7 | - | |||||||||||||
8 | - | |||||||||||||
9 | - | |||||||||||||
10 | - | |||||||||||||
11 | - | |||||||||||||
12 | - | |||||||||||||
13 | static int input_kex_dh_init(int, u_int32_t, struct ssh *); | - | ||||||||||||
14 | - | |||||||||||||
15 | int | - | ||||||||||||
16 | kexdh_server(struct ssh *ssh) | - | ||||||||||||
17 | { | - | ||||||||||||
18 | struct kex *kex = ssh->kex; | - | ||||||||||||
19 | int r; | - | ||||||||||||
20 | - | |||||||||||||
21 | - | |||||||||||||
22 | switch (kex->kex_type) { | - | ||||||||||||
23 | case executed 20 times by 1 test: KEX_DH_GRP1_SHA1:case KEX_DH_GRP1_SHA1: Executed by:
executed 20 times by 1 test: case KEX_DH_GRP1_SHA1: Executed by:
| 20 | ||||||||||||
24 | kex->dh = dh_new_group1(); | - | ||||||||||||
25 | break; executed 20 times by 1 test: break; Executed by:
| 20 | ||||||||||||
26 | case executed 20 times by 1 test: KEX_DH_GRP14_SHA1:case KEX_DH_GRP14_SHA1: Executed by:
executed 20 times by 1 test: case KEX_DH_GRP14_SHA1: Executed by:
| 20 | ||||||||||||
27 | case never executed: KEX_DH_GRP14_SHA256:case KEX_DH_GRP14_SHA256: never executed: case KEX_DH_GRP14_SHA256: | 0 | ||||||||||||
28 | kex->dh = dh_new_group14(); | - | ||||||||||||
29 | break; executed 20 times by 1 test: break; Executed by:
| 20 | ||||||||||||
30 | case never executed: KEX_DH_GRP16_SHA512:case KEX_DH_GRP16_SHA512: never executed: case KEX_DH_GRP16_SHA512: | 0 | ||||||||||||
31 | kex->dh = dh_new_group16(); | - | ||||||||||||
32 | break; never executed: break; | 0 | ||||||||||||
33 | case never executed: KEX_DH_GRP18_SHA512:case KEX_DH_GRP18_SHA512: never executed: case KEX_DH_GRP18_SHA512: | 0 | ||||||||||||
34 | kex->dh = dh_new_group18(); | - | ||||||||||||
35 | break; never executed: break; | 0 | ||||||||||||
36 | default never executed: :default: never executed: default: | 0 | ||||||||||||
37 | r = -10; | - | ||||||||||||
38 | goto never executed: out;goto out; never executed: goto out; | 0 | ||||||||||||
39 | } | - | ||||||||||||
40 | if (kex->dh ==
| 0-40 | ||||||||||||
41 | ((void *)0)
| 0-40 | ||||||||||||
42 | ) { | - | ||||||||||||
43 | r = -2; | - | ||||||||||||
44 | goto never executed: out;goto out; never executed: goto out; | 0 | ||||||||||||
45 | } | - | ||||||||||||
46 | if ((
| 0-40 | ||||||||||||
47 | goto never executed: out;goto out; never executed: goto out; | 0 | ||||||||||||
48 | - | |||||||||||||
49 | debug("expecting SSH2_MSG_KEXDH_INIT"); | - | ||||||||||||
50 | ssh_dispatch_set(ssh, 30, &input_kex_dh_init); | - | ||||||||||||
51 | r = 0; | - | ||||||||||||
52 | out: code before this statement executed 40 times by 1 test: out: Executed by:
| 40 | ||||||||||||
53 | return executed 40 times by 1 test: r;return r; Executed by:
executed 40 times by 1 test: return r; Executed by:
| 40 | ||||||||||||
54 | } | - | ||||||||||||
55 | - | |||||||||||||
56 | int | - | ||||||||||||
57 | input_kex_dh_init(int type, u_int32_t seq, struct ssh *ssh) | - | ||||||||||||
58 | { | - | ||||||||||||
59 | struct kex *kex = ssh->kex; | - | ||||||||||||
60 | BIGNUM *shared_secret = | - | ||||||||||||
61 | ((void *)0) | - | ||||||||||||
62 | , *dh_client_pub = | - | ||||||||||||
63 | ((void *)0) | - | ||||||||||||
64 | ; | - | ||||||||||||
65 | const BIGNUM *pub_key; | - | ||||||||||||
66 | struct sshkey *server_host_public, *server_host_private; | - | ||||||||||||
67 | u_char *kbuf = | - | ||||||||||||
68 | ((void *)0) | - | ||||||||||||
69 | , *signature = | - | ||||||||||||
70 | ((void *)0) | - | ||||||||||||
71 | , *server_host_key_blob = | - | ||||||||||||
72 | ((void *)0) | - | ||||||||||||
73 | ; | - | ||||||||||||
74 | u_char hash[64]; | - | ||||||||||||
75 | size_t sbloblen, slen; | - | ||||||||||||
76 | size_t klen = 0, hashlen; | - | ||||||||||||
77 | int kout, r; | - | ||||||||||||
78 | - | |||||||||||||
79 | if (kex->load_host_public_key ==
| 0-40 | ||||||||||||
80 | ((void *)0)
| 0-40 | ||||||||||||
81 | || | - | ||||||||||||
82 | kex->load_host_private_key ==
| 0-40 | ||||||||||||
83 | ((void *)0)
| 0-40 | ||||||||||||
84 | ) { | - | ||||||||||||
85 | r = -10; | - | ||||||||||||
86 | goto never executed: out;goto out; never executed: goto out; | 0 | ||||||||||||
87 | } | - | ||||||||||||
88 | server_host_public = kex->load_host_public_key(kex->hostkey_type, | - | ||||||||||||
89 | kex->hostkey_nid, ssh); | - | ||||||||||||
90 | server_host_private = kex->load_host_private_key(kex->hostkey_type, | - | ||||||||||||
91 | kex->hostkey_nid, ssh); | - | ||||||||||||
92 | if (server_host_public ==
| 0-40 | ||||||||||||
93 | ((void *)0)
| 0-40 | ||||||||||||
94 | ) { | - | ||||||||||||
95 | r = -36; | - | ||||||||||||
96 | goto never executed: out;goto out; never executed: goto out; | 0 | ||||||||||||
97 | } | - | ||||||||||||
98 | - | |||||||||||||
99 | - | |||||||||||||
100 | if ((
| 0-40 | ||||||||||||
101 | ((void *)0)
| 0-40 | ||||||||||||
102 | ) { | - | ||||||||||||
103 | r = -2; | - | ||||||||||||
104 | goto never executed: out;goto out; never executed: goto out; | 0 | ||||||||||||
105 | } | - | ||||||||||||
106 | DH_get0_key(kex->dh, &pub_key, | - | ||||||||||||
107 | ((void *)0) | - | ||||||||||||
108 | ); | - | ||||||||||||
109 | if ((
| 0-40 | ||||||||||||
110 | (
| 0-40 | ||||||||||||
111 | goto never executed: out;goto out; never executed: goto out; | 0 | ||||||||||||
112 | if (!dh_pub_is_valid(kex->dh, dh_client_pub)
| 0-40 | ||||||||||||
113 | sshpkt_disconnect(ssh, "bad client public DH value"); | - | ||||||||||||
114 | r = -3; | - | ||||||||||||
115 | goto never executed: out;goto out; never executed: goto out; | 0 | ||||||||||||
116 | } | - | ||||||||||||
117 | - | |||||||||||||
118 | klen = DH_size(kex->dh); | - | ||||||||||||
119 | if ((
| 0-40 | ||||||||||||
120 | ((void *)0)
| 0-40 | ||||||||||||
121 | || | - | ||||||||||||
122 | (
| 0-40 | ||||||||||||
123 | ((void *)0)
| 0-40 | ||||||||||||
124 | ) { | - | ||||||||||||
125 | r = -2; | - | ||||||||||||
126 | goto never executed: out;goto out; never executed: goto out; | 0 | ||||||||||||
127 | } | - | ||||||||||||
128 | if ((
| 0-40 | ||||||||||||
129 | BN_bin2bn(kbuf, kout, shared_secret) ==
| 0-40 | ||||||||||||
130 | ((void *)0)
| 0-40 | ||||||||||||
131 | ) { | - | ||||||||||||
132 | r = -22; | - | ||||||||||||
133 | goto never executed: out;goto out; never executed: goto out; | 0 | ||||||||||||
134 | } | - | ||||||||||||
135 | - | |||||||||||||
136 | - | |||||||||||||
137 | - | |||||||||||||
138 | if ((
| 0-40 | ||||||||||||
139 | &sbloblen)) != 0
| 0-40 | ||||||||||||
140 | goto never executed: out;goto out; never executed: goto out; | 0 | ||||||||||||
141 | - | |||||||||||||
142 | hashlen = sizeof(hash); | - | ||||||||||||
143 | if ((
| 0-40 | ||||||||||||
144 | kex->hash_alg,
| 0-40 | ||||||||||||
145 | kex->client_version_string,
| 0-40 | ||||||||||||
146 | kex->server_version_string,
| 0-40 | ||||||||||||
147 | sshbuf_ptr(kex->peer), sshbuf_len(kex->peer),
| 0-40 | ||||||||||||
148 | sshbuf_ptr(kex->my), sshbuf_len(kex->my),
| 0-40 | ||||||||||||
149 | server_host_key_blob, sbloblen,
| 0-40 | ||||||||||||
150 | dh_client_pub,
| 0-40 | ||||||||||||
151 | pub_key,
| 0-40 | ||||||||||||
152 | shared_secret,
| 0-40 | ||||||||||||
153 | hash, &hashlen)) != 0
| 0-40 | ||||||||||||
154 | goto never executed: out;goto out; never executed: goto out; | 0 | ||||||||||||
155 | - | |||||||||||||
156 | - | |||||||||||||
157 | if (kex->session_id ==
| 8-32 | ||||||||||||
158 | ((void *)0)
| 8-32 | ||||||||||||
159 | ) { | - | ||||||||||||
160 | kex->session_id_len = hashlen; | - | ||||||||||||
161 | kex->session_id = malloc(kex->session_id_len); | - | ||||||||||||
162 | if (kex->session_id ==
| 0-8 | ||||||||||||
163 | ((void *)0)
| 0-8 | ||||||||||||
164 | ) { | - | ||||||||||||
165 | r = -2; | - | ||||||||||||
166 | goto never executed: out;goto out; never executed: goto out; | 0 | ||||||||||||
167 | } | - | ||||||||||||
168 | memcpy(kex->session_id, hash, kex->session_id_len); | - | ||||||||||||
169 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||
170 | - | |||||||||||||
171 | - | |||||||||||||
172 | if ((
| 0-40 | ||||||||||||
173 | &slen, hash, hashlen, kex->hostkey_alg, ssh->compat)) < 0
| 0-40 | ||||||||||||
174 | goto never executed: out;goto out; never executed: goto out; | 0 | ||||||||||||
175 | - | |||||||||||||
176 | - | |||||||||||||
177 | - | |||||||||||||
178 | - | |||||||||||||
179 | if ((
| 0-40 | ||||||||||||
180 | (
| 0-40 | ||||||||||||
181 | (
| 0-40 | ||||||||||||
182 | (
| 0-40 | ||||||||||||
183 | (
| 0-40 | ||||||||||||
184 | goto never executed: out;goto out; never executed: goto out; | 0 | ||||||||||||
185 | - | |||||||||||||
186 | if ((
| 0-40 | ||||||||||||
187 | r = kex_send_newkeys(ssh); executed 40 times by 1 test: r = kex_send_newkeys(ssh); Executed by:
| 40 | ||||||||||||
188 | out: code before this statement executed 40 times by 1 test: out: Executed by:
| 40 | ||||||||||||
189 | explicit_bzero(hash, sizeof(hash)); | - | ||||||||||||
190 | DH_free(kex->dh); | - | ||||||||||||
191 | kex->dh = | - | ||||||||||||
192 | ((void *)0) | - | ||||||||||||
193 | ; | - | ||||||||||||
194 | BN_clear_free(dh_client_pub); | - | ||||||||||||
195 | if (kbuf
| 0-40 | ||||||||||||
196 | explicit_bzero(kbuf, klen); | - | ||||||||||||
197 | free(kbuf); | - | ||||||||||||
198 | } executed 40 times by 1 test: end of block Executed by:
| 40 | ||||||||||||
199 | BN_clear_free(shared_secret); | - | ||||||||||||
200 | free(server_host_key_blob); | - | ||||||||||||
201 | free(signature); | - | ||||||||||||
202 | return executed 40 times by 1 test: r;return r; Executed by:
executed 40 times by 1 test: return r; Executed by:
| 40 | ||||||||||||
203 | } | - | ||||||||||||
Switch to Source code | Preprocessed file |