Line | Source | Count |
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | static int input_kex_c25519_init(int, u_int32_t, struct ssh *); | - |
8 | | - |
9 | int | - |
10 | kexc25519_server(struct ssh *ssh) | - |
11 | { | - |
12 | debug("expecting SSH2_MSG_KEX_ECDH_INIT"); | - |
13 | ssh_dispatch_set(ssh, 30, &input_kex_c25519_init); | - |
14 | returnexecuted 20 times by 1 test: return 0; 0;executed 20 times by 1 test: return 0; | 20 |
15 | } | - |
16 | | - |
17 | static int | - |
18 | input_kex_c25519_init(int type, u_int32_t seq, struct ssh *ssh) | - |
19 | { | - |
20 | struct kex *kex = ssh->kex; | - |
21 | struct sshkey *server_host_private, *server_host_public; | - |
22 | struct sshbuf *shared_secret = | - |
23 | ((void *)0) | - |
24 | ; | - |
25 | u_char *server_host_key_blob = | - |
26 | ((void *)0) | - |
27 | , *signature = | - |
28 | ((void *)0) | - |
29 | ; | - |
30 | u_char server_key[32]; | - |
31 | u_char *client_pubkey = | - |
32 | ((void *)0) | - |
33 | ; | - |
34 | u_char server_pubkey[32]; | - |
35 | u_char hash[64]; | - |
36 | size_t slen, pklen, sbloblen, hashlen; | - |
37 | int r; | - |
38 | | - |
39 | | - |
40 | kexc25519_keygen(server_key, server_pubkey); | - |
41 | | - |
42 | | - |
43 | | - |
44 | if (kex->load_host_public_key == TRUE | never evaluated | FALSE | evaluated 20 times by 1 test |
| 0-20 |
45 | ((void *)0)TRUE | never evaluated | FALSE | evaluated 20 times by 1 test |
| 0-20 |
46 | || | - |
47 | kex->load_host_private_key == TRUE | never evaluated | FALSE | evaluated 20 times by 1 test |
| 0-20 |
48 | ((void *)0)TRUE | never evaluated | FALSE | evaluated 20 times by 1 test |
| 0-20 |
49 | ) { | - |
50 | r = -10; | - |
51 | goto never executed: goto out; out;never executed: goto out; | 0 |
52 | } | - |
53 | server_host_public = kex->load_host_public_key(kex->hostkey_type, | - |
54 | kex->hostkey_nid, ssh); | - |
55 | server_host_private = kex->load_host_private_key(kex->hostkey_type, | - |
56 | kex->hostkey_nid, ssh); | - |
57 | if (server_host_public == TRUE | never evaluated | FALSE | evaluated 20 times by 1 test |
| 0-20 |
58 | ((void *)0)TRUE | never evaluated | FALSE | evaluated 20 times by 1 test |
| 0-20 |
59 | ) { | - |
60 | r = -36; | - |
61 | goto never executed: goto out; out;never executed: goto out; | 0 |
62 | } | - |
63 | | - |
64 | if ((TRUE | never evaluated | FALSE | evaluated 20 times by 1 test |
r = sshpkt_get_string(ssh, &client_pubkey, &pklen)) != 0TRUE | never evaluated | FALSE | evaluated 20 times by 1 test |
|| | 0-20 |
65 | (TRUE | never evaluated | FALSE | evaluated 20 times by 1 test |
r = sshpkt_get_end(ssh)) != 0TRUE | never evaluated | FALSE | evaluated 20 times by 1 test |
) | 0-20 |
66 | goto never executed: goto out; out;never executed: goto out; | 0 |
67 | if (pklen != 32TRUE | never evaluated | FALSE | evaluated 20 times by 1 test |
) { | 0-20 |
68 | r = -21; | - |
69 | goto never executed: goto out; out;never executed: goto out; | 0 |
70 | } | - |
71 | | - |
72 | | - |
73 | | - |
74 | | - |
75 | if ((TRUE | never evaluated | FALSE | evaluated 20 times by 1 test |
shared_secret = sshbuf_new()) == TRUE | never evaluated | FALSE | evaluated 20 times by 1 test |
| 0-20 |
76 | ((void *)0)TRUE | never evaluated | FALSE | evaluated 20 times by 1 test |
| 0-20 |
77 | ) { | - |
78 | r = -2; | - |
79 | goto never executed: goto out; out;never executed: goto out; | 0 |
80 | } | - |
81 | if ((TRUE | never evaluated | FALSE | evaluated 20 times by 1 test |
r = kexc25519_shared_key(server_key, client_pubkey,TRUE | never evaluated | FALSE | evaluated 20 times by 1 test |
| 0-20 |
82 | shared_secret)) < 0TRUE | never evaluated | FALSE | evaluated 20 times by 1 test |
) | 0-20 |
83 | goto never executed: goto out; out;never executed: goto out; | 0 |
84 | | - |
85 | | - |
86 | if ((TRUE | never evaluated | FALSE | evaluated 20 times by 1 test |
r = sshkey_to_blob(server_host_public, &server_host_key_blob,TRUE | never evaluated | FALSE | evaluated 20 times by 1 test |
| 0-20 |
87 | &sbloblen)) != 0TRUE | never evaluated | FALSE | evaluated 20 times by 1 test |
) | 0-20 |
88 | goto never executed: goto out; out;never executed: goto out; | 0 |
89 | hashlen = sizeof(hash); | - |
90 | if ((TRUE | never evaluated | FALSE | evaluated 20 times by 1 test |
r = kex_c25519_hash(TRUE | never evaluated | FALSE | evaluated 20 times by 1 test |
| 0-20 |
91 | kex->hash_alg,TRUE | never evaluated | FALSE | evaluated 20 times by 1 test |
| 0-20 |
92 | kex->client_version_string,TRUE | never evaluated | FALSE | evaluated 20 times by 1 test |
| 0-20 |
93 | kex->server_version_string,TRUE | never evaluated | FALSE | evaluated 20 times by 1 test |
| 0-20 |
94 | sshbuf_ptr(kex->peer), sshbuf_len(kex->peer),TRUE | never evaluated | FALSE | evaluated 20 times by 1 test |
| 0-20 |
95 | sshbuf_ptr(kex->my), sshbuf_len(kex->my),TRUE | never evaluated | FALSE | evaluated 20 times by 1 test |
| 0-20 |
96 | server_host_key_blob, sbloblen,TRUE | never evaluated | FALSE | evaluated 20 times by 1 test |
| 0-20 |
97 | client_pubkey,TRUE | never evaluated | FALSE | evaluated 20 times by 1 test |
| 0-20 |
98 | server_pubkey,TRUE | never evaluated | FALSE | evaluated 20 times by 1 test |
| 0-20 |
99 | sshbuf_ptr(shared_secret), sshbuf_len(shared_secret),TRUE | never evaluated | FALSE | evaluated 20 times by 1 test |
| 0-20 |
100 | hash, &hashlen)) < 0TRUE | never evaluated | FALSE | evaluated 20 times by 1 test |
) | 0-20 |
101 | goto never executed: goto out; out;never executed: goto out; | 0 |
102 | | - |
103 | | - |
104 | if (kex->session_id == TRUE | evaluated 4 times by 1 test | FALSE | evaluated 16 times by 1 test |
| 4-16 |
105 | ((void *)0)TRUE | evaluated 4 times by 1 test | FALSE | evaluated 16 times by 1 test |
| 4-16 |
106 | ) { | - |
107 | kex->session_id_len = hashlen; | - |
108 | kex->session_id = malloc(kex->session_id_len); | - |
109 | if (kex->session_id == TRUE | never evaluated | FALSE | evaluated 4 times by 1 test |
| 0-4 |
110 | ((void *)0)TRUE | never evaluated | FALSE | evaluated 4 times by 1 test |
| 0-4 |
111 | ) { | - |
112 | r = -2; | - |
113 | goto never executed: goto out; out;never executed: goto out; | 0 |
114 | } | - |
115 | memcpy(kex->session_id, hash, kex->session_id_len); | - |
116 | }executed 4 times by 1 test: end of block | 4 |
117 | | - |
118 | | - |
119 | if ((TRUE | never evaluated | FALSE | evaluated 20 times by 1 test |
r = kex->sign(server_host_private, server_host_public, &signature,TRUE | never evaluated | FALSE | evaluated 20 times by 1 test |
| 0-20 |
120 | &slen, hash, hashlen, kex->hostkey_alg, ssh->compat)) < 0TRUE | never evaluated | FALSE | evaluated 20 times by 1 test |
) | 0-20 |
121 | goto never executed: goto out; out;never executed: goto out; | 0 |
122 | | - |
123 | | - |
124 | if ((TRUE | never evaluated | FALSE | evaluated 20 times by 1 test |
r = sshpkt_start(ssh, 31)) != 0TRUE | never evaluated | FALSE | evaluated 20 times by 1 test |
|| | 0-20 |
125 | (TRUE | never evaluated | FALSE | evaluated 20 times by 1 test |
r = sshpkt_put_string(ssh, server_host_key_blob, sbloblen)) != 0TRUE | never evaluated | FALSE | evaluated 20 times by 1 test |
|| | 0-20 |
126 | (TRUE | never evaluated | FALSE | evaluated 20 times by 1 test |
r = sshpkt_put_string(ssh, server_pubkey, sizeof(server_pubkey))) != 0TRUE | never evaluated | FALSE | evaluated 20 times by 1 test |
|| | 0-20 |
127 | (TRUE | never evaluated | FALSE | evaluated 20 times by 1 test |
r = sshpkt_put_string(ssh, signature, slen)) != 0TRUE | never evaluated | FALSE | evaluated 20 times by 1 test |
|| | 0-20 |
128 | (TRUE | never evaluated | FALSE | evaluated 20 times by 1 test |
r = sshpkt_send(ssh)) != 0TRUE | never evaluated | FALSE | evaluated 20 times by 1 test |
) | 0-20 |
129 | goto never executed: goto out; out;never executed: goto out; | 0 |
130 | | - |
131 | if ((TRUE | evaluated 20 times by 1 test | FALSE | never evaluated |
r = kex_derive_keys(ssh, hash, hashlen, shared_secret)) == 0TRUE | evaluated 20 times by 1 test | FALSE | never evaluated |
) | 0-20 |
132 | r = kex_send_newkeys(ssh);executed 20 times by 1 test: r = kex_send_newkeys(ssh); | 20 |
133 | out:code before this statement executed 20 times by 1 test: out: | 20 |
134 | explicit_bzero(hash, sizeof(hash)); | - |
135 | explicit_bzero(server_key, sizeof(server_key)); | - |
136 | free(server_host_key_blob); | - |
137 | free(signature); | - |
138 | free(client_pubkey); | - |
139 | sshbuf_free(shared_secret); | - |
140 | returnexecuted 20 times by 1 test: return r; r;executed 20 times by 1 test: return r; | 20 |
141 | } | - |
| | |