Line | Source | Count |
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | extern int crypto_scalarmult_curve25519(u_char a[32], | - |
9 | const u_char b[32], const u_char c[32]) | - |
10 | __attribute__(()) | - |
11 | __attribute__(()) | - |
12 | __attribute__(()); | - |
13 | | - |
14 | void | - |
15 | kexc25519_keygen(u_char key[32], u_char pub[32]) | - |
16 | { | - |
17 | static const u_char basepoint[32] = {9}; | - |
18 | | - |
19 | arc4random_buf(key, 32); | - |
20 | crypto_scalarmult_curve25519(pub, key, basepoint); | - |
21 | }executed 40 times by 1 test: end of block | 40 |
22 | | - |
23 | int | - |
24 | kexc25519_shared_key(const u_char key[32], | - |
25 | const u_char pub[32], struct sshbuf *out) | - |
26 | { | - |
27 | u_char shared_key[32]; | - |
28 | int r; | - |
29 | | - |
30 | | - |
31 | explicit_bzero(shared_key, 32); | - |
32 | if (timingsafe_bcmp(pub, shared_key, 32) == 0TRUE | never evaluated | FALSE | evaluated 40 times by 1 test |
) | 0-40 |
33 | return never executed: return -20; -20;never executed: return -20; | 0 |
34 | | - |
35 | crypto_scalarmult_curve25519(shared_key, key, pub); | - |
36 | | - |
37 | | - |
38 | | - |
39 | sshbuf_reset(out); | - |
40 | r = sshbuf_put_bignum2_bytes(out, shared_key, 32); | - |
41 | explicit_bzero(shared_key, 32); | - |
42 | returnexecuted 40 times by 1 test: return r; r;executed 40 times by 1 test: return r; | 40 |
43 | } | - |
44 | | - |
45 | int | - |
46 | kex_c25519_hash( | - |
47 | int hash_alg, | - |
48 | const char *client_version_string, | - |
49 | const char *server_version_string, | - |
50 | const u_char *ckexinit, size_t ckexinitlen, | - |
51 | const u_char *skexinit, size_t skexinitlen, | - |
52 | const u_char *serverhostkeyblob, size_t sbloblen, | - |
53 | const u_char client_dh_pub[32], | - |
54 | const u_char server_dh_pub[32], | - |
55 | const u_char *shared_secret, size_t secretlen, | - |
56 | u_char *hash, size_t *hashlen) | - |
57 | { | - |
58 | struct sshbuf *b; | - |
59 | int r; | - |
60 | | - |
61 | if (*TRUE | never evaluated | FALSE | evaluated 40 times by 1 test |
hashlen < ssh_digest_bytes(hash_alg)TRUE | never evaluated | FALSE | evaluated 40 times by 1 test |
) | 0-40 |
62 | return never executed: return -10; -10;never executed: return -10; | 0 |
63 | if ((TRUE | never evaluated | FALSE | evaluated 40 times by 1 test |
b = sshbuf_new()) == TRUE | never evaluated | FALSE | evaluated 40 times by 1 test |
| 0-40 |
64 | ((void *)0)TRUE | never evaluated | FALSE | evaluated 40 times by 1 test |
| 0-40 |
65 | ) | - |
66 | return never executed: return -2; -2;never executed: return -2; | 0 |
67 | if ((TRUE | never evaluated | FALSE | evaluated 40 times by 1 test |
r = sshbuf_put_cstring(b, client_version_string)) < 0TRUE | never evaluated | FALSE | evaluated 40 times by 1 test |
|| | 0-40 |
68 | (TRUE | never evaluated | FALSE | evaluated 40 times by 1 test |
r = sshbuf_put_cstring(b, server_version_string)) < 0TRUE | never evaluated | FALSE | evaluated 40 times by 1 test |
|| | 0-40 |
69 | | - |
70 | (TRUE | never evaluated | FALSE | evaluated 40 times by 1 test |
r = sshbuf_put_u32(b, ckexinitlen+1)) < 0TRUE | never evaluated | FALSE | evaluated 40 times by 1 test |
|| | 0-40 |
71 | (TRUE | never evaluated | FALSE | evaluated 40 times by 1 test |
r = sshbuf_put_u8(b, 20)) < 0TRUE | never evaluated | FALSE | evaluated 40 times by 1 test |
|| | 0-40 |
72 | (TRUE | never evaluated | FALSE | evaluated 40 times by 1 test |
r = sshbuf_put(b, ckexinit, ckexinitlen)) < 0TRUE | never evaluated | FALSE | evaluated 40 times by 1 test |
|| | 0-40 |
73 | (TRUE | never evaluated | FALSE | evaluated 40 times by 1 test |
r = sshbuf_put_u32(b, skexinitlen+1)) < 0TRUE | never evaluated | FALSE | evaluated 40 times by 1 test |
|| | 0-40 |
74 | (TRUE | never evaluated | FALSE | evaluated 40 times by 1 test |
r = sshbuf_put_u8(b, 20)) < 0TRUE | never evaluated | FALSE | evaluated 40 times by 1 test |
|| | 0-40 |
75 | (TRUE | never evaluated | FALSE | evaluated 40 times by 1 test |
r = sshbuf_put(b, skexinit, skexinitlen)) < 0TRUE | never evaluated | FALSE | evaluated 40 times by 1 test |
|| | 0-40 |
76 | (TRUE | never evaluated | FALSE | evaluated 40 times by 1 test |
r = sshbuf_put_string(b, serverhostkeyblob, sbloblen)) < 0TRUE | never evaluated | FALSE | evaluated 40 times by 1 test |
|| | 0-40 |
77 | (TRUE | never evaluated | FALSE | evaluated 40 times by 1 test |
r = sshbuf_put_string(b, client_dh_pub, 32)) < 0TRUE | never evaluated | FALSE | evaluated 40 times by 1 test |
|| | 0-40 |
78 | (TRUE | never evaluated | FALSE | evaluated 40 times by 1 test |
r = sshbuf_put_string(b, server_dh_pub, 32)) < 0TRUE | never evaluated | FALSE | evaluated 40 times by 1 test |
|| | 0-40 |
79 | (TRUE | never evaluated | FALSE | evaluated 40 times by 1 test |
r = sshbuf_put(b, shared_secret, secretlen)) < 0TRUE | never evaluated | FALSE | evaluated 40 times by 1 test |
) { | 0-40 |
80 | sshbuf_free(b); | - |
81 | return never executed: return r; r;never executed: return r; | 0 |
82 | } | - |
83 | | - |
84 | | - |
85 | | - |
86 | if (ssh_digest_buffer(hash_alg, b, hash, *hashlen) != 0TRUE | never evaluated | FALSE | evaluated 40 times by 1 test |
) { | 0-40 |
87 | sshbuf_free(b); | - |
88 | return never executed: return -22; -22;never executed: return -22; | 0 |
89 | } | - |
90 | sshbuf_free(b); | - |
91 | *hashlen = ssh_digest_bytes(hash_alg); | - |
92 | | - |
93 | | - |
94 | | - |
95 | returnexecuted 40 times by 1 test: return 0; 0;executed 40 times by 1 test: return 0; | 40 |
96 | } | - |
| | |