| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssh/src/sshbuf-getput-crypto.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||
| 2 | - | |||||||||||||||||||
| 3 | - | |||||||||||||||||||
| 4 | - | |||||||||||||||||||
| 5 | - | |||||||||||||||||||
| 6 | - | |||||||||||||||||||
| 7 | - | |||||||||||||||||||
| 8 | - | |||||||||||||||||||
| 9 | - | |||||||||||||||||||
| 10 | int | - | ||||||||||||||||||
| 11 | sshbuf_get_bignum2(struct sshbuf *buf, BIGNUM *v) | - | ||||||||||||||||||
| 12 | { | - | ||||||||||||||||||
| 13 | const u_char *d; | - | ||||||||||||||||||
| 14 | size_t len; | - | ||||||||||||||||||
| 15 | int r; | - | ||||||||||||||||||
| 16 | - | |||||||||||||||||||
| 17 | if ((
| 64784-1242461 | ||||||||||||||||||
| 18 | return executed 1242461 times by 2 tests: r;return r;Executed by:
executed 1242461 times by 2 tests: return r;Executed by:
| 1242461 | ||||||||||||||||||
| 19 | if (v !=
| 0-64784 | ||||||||||||||||||
| 20 | ((void *)0)
| 0-64784 | ||||||||||||||||||
| 21 | && BN_bin2bn(d, len, v) ==
| 0-64784 | ||||||||||||||||||
| 22 | ((void *)0)
| 0-64784 | ||||||||||||||||||
| 23 | ) | - | ||||||||||||||||||
| 24 | return never executed: -2;return -2;never executed: return -2; | 0 | ||||||||||||||||||
| 25 | return executed 64784 times by 6 tests: 0;return 0;Executed by:
executed 64784 times by 6 tests: return 0;Executed by:
| 64784 | ||||||||||||||||||
| 26 | } | - | ||||||||||||||||||
| 27 | - | |||||||||||||||||||
| 28 | int | - | ||||||||||||||||||
| 29 | sshbuf_get_bignum1(struct sshbuf *buf, BIGNUM *v) | - | ||||||||||||||||||
| 30 | { | - | ||||||||||||||||||
| 31 | const u_char *d = sshbuf_ptr(buf); | - | ||||||||||||||||||
| 32 | u_int16_t len_bits; | - | ||||||||||||||||||
| 33 | size_t len_bytes; | - | ||||||||||||||||||
| 34 | - | |||||||||||||||||||
| 35 | - | |||||||||||||||||||
| 36 | if (sshbuf_len(buf) < 2
| 0-1239382 | ||||||||||||||||||
| 37 | return never executed: -3;return -3;never executed: return -3; | 0 | ||||||||||||||||||
| 38 | len_bits = (((u_int16_t)(((const u_char *)(d))[0]) << 8) | (u_int16_t)(((const u_char *)(d))[1])); | - | ||||||||||||||||||
| 39 | len_bytes = (len_bits + 7) >> 3; | - | ||||||||||||||||||
| 40 | if (len_bytes > (16384 / 8)
| 4-1239378 | ||||||||||||||||||
| 41 | return executed 1239378 times by 1 test: -7;return -7;Executed by:
executed 1239378 times by 1 test: return -7;Executed by:
| 1239378 | ||||||||||||||||||
| 42 | if (sshbuf_len(buf) < 2 + len_bytes
| 2 | ||||||||||||||||||
| 43 | return executed 2 times by 1 test: -3;return -3;Executed by:
executed 2 times by 1 test: return -3;Executed by:
| 2 | ||||||||||||||||||
| 44 | if (v !=
| 0-2 | ||||||||||||||||||
| 45 | ((void *)0)
| 0-2 | ||||||||||||||||||
| 46 | && BN_bin2bn(d + 2, len_bytes, v) ==
| 0-2 | ||||||||||||||||||
| 47 | ((void *)0)
| 0-2 | ||||||||||||||||||
| 48 | ) | - | ||||||||||||||||||
| 49 | return never executed: -2;return -2;never executed: return -2; | 0 | ||||||||||||||||||
| 50 | if (sshbuf_consume(buf, 2 + len_bytes) != 0
| 0-2 | ||||||||||||||||||
| 51 | ; | - | ||||||||||||||||||
| 52 | ; | - | ||||||||||||||||||
| 53 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||
| 54 | } | - | ||||||||||||||||||
| 55 | return executed 2 times by 1 test: 0;return 0;Executed by:
executed 2 times by 1 test: return 0;Executed by:
| 2 | ||||||||||||||||||
| 56 | } | - | ||||||||||||||||||
| 57 | - | |||||||||||||||||||
| 58 | - | |||||||||||||||||||
| 59 | static int | - | ||||||||||||||||||
| 60 | get_ec(const u_char *d, size_t len, EC_POINT *v, const EC_GROUP *g) | - | ||||||||||||||||||
| 61 | { | - | ||||||||||||||||||
| 62 | - | |||||||||||||||||||
| 63 | if (len == 0
| 0-6788 | ||||||||||||||||||
| 64 | return executed 3 times by 1 test: -8;return -8;Executed by:
executed 3 times by 1 test: return -8;Executed by:
| 3 | ||||||||||||||||||
| 65 | - | |||||||||||||||||||
| 66 | if (*
| 27-6758 | ||||||||||||||||||
| 67 | return executed 27 times by 1 test: -4;return -4;Executed by:
executed 27 times by 1 test: return -4;Executed by:
| 27 | ||||||||||||||||||
| 68 | if (v !=
| 0-6758 | ||||||||||||||||||
| 69 | ((void *)0)
| 0-6758 | ||||||||||||||||||
| 70 | && EC_POINT_oct2point(g, v, d, len,
| 1739-5019 | ||||||||||||||||||
| 71 | ((void *)0)
| 1739-5019 | ||||||||||||||||||
| 72 | ) != 1
| 1739-5019 | ||||||||||||||||||
| 73 | return executed 1739 times by 1 test: -4;return -4;Executed by:
executed 1739 times by 1 test: return -4;Executed by:
| 1739 | ||||||||||||||||||
| 74 | return executed 5019 times by 5 tests: 0;return 0;Executed by:
executed 5019 times by 5 tests: return 0;Executed by:
| 5019 | ||||||||||||||||||
| 75 | } | - | ||||||||||||||||||
| 76 | - | |||||||||||||||||||
| 77 | int | - | ||||||||||||||||||
| 78 | sshbuf_get_ec(struct sshbuf *buf, EC_POINT *v, const EC_GROUP *g) | - | ||||||||||||||||||
| 79 | { | - | ||||||||||||||||||
| 80 | const u_char *d; | - | ||||||||||||||||||
| 81 | size_t len; | - | ||||||||||||||||||
| 82 | int r; | - | ||||||||||||||||||
| 83 | - | |||||||||||||||||||
| 84 | if ((
| 235-6786 | ||||||||||||||||||
| 85 | return executed 235 times by 1 test: r;return r;Executed by:
executed 235 times by 1 test: return r;Executed by:
| 235 | ||||||||||||||||||
| 86 | if ((
| 1769-5017 | ||||||||||||||||||
| 87 | return executed 1769 times by 1 test: r;return r;Executed by:
executed 1769 times by 1 test: return r;Executed by:
| 1769 | ||||||||||||||||||
| 88 | - | |||||||||||||||||||
| 89 | if (sshbuf_get_string_direct(buf,
| 0-5017 | ||||||||||||||||||
| 90 | ((void *)0)
| 0-5017 | ||||||||||||||||||
| 91 | ,
| 0-5017 | ||||||||||||||||||
| 92 | ((void *)0)
| 0-5017 | ||||||||||||||||||
| 93 | ) != 0
| 0-5017 | ||||||||||||||||||
| 94 | - | |||||||||||||||||||
| 95 | ; | - | ||||||||||||||||||
| 96 | ; | - | ||||||||||||||||||
| 97 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||
| 98 | } | - | ||||||||||||||||||
| 99 | return executed 5017 times by 4 tests: 0;return 0;Executed by:
executed 5017 times by 4 tests: return 0;Executed by:
| 5017 | ||||||||||||||||||
| 100 | } | - | ||||||||||||||||||
| 101 | - | |||||||||||||||||||
| 102 | int | - | ||||||||||||||||||
| 103 | sshbuf_get_eckey(struct sshbuf *buf, EC_KEY *v) | - | ||||||||||||||||||
| 104 | { | - | ||||||||||||||||||
| 105 | EC_POINT *pt = EC_POINT_new(EC_KEY_get0_group(v)); | - | ||||||||||||||||||
| 106 | int r; | - | ||||||||||||||||||
| 107 | const u_char *d; | - | ||||||||||||||||||
| 108 | size_t len; | - | ||||||||||||||||||
| 109 | - | |||||||||||||||||||
| 110 | if (pt ==
| 0-1239379 | ||||||||||||||||||
| 111 | ((void *)0)
| 0-1239379 | ||||||||||||||||||
| 112 | ) { | - | ||||||||||||||||||
| 113 | ; | - | ||||||||||||||||||
| 114 | return never executed: -2;return -2;never executed: return -2; | 0 | ||||||||||||||||||
| 115 | } | - | ||||||||||||||||||
| 116 | if ((
| 2-1239377 | ||||||||||||||||||
| 117 | EC_POINT_free(pt); | - | ||||||||||||||||||
| 118 | return executed 1239377 times by 1 test: r;return r;Executed by:
executed 1239377 times by 1 test: return r;Executed by:
| 1239377 | ||||||||||||||||||
| 119 | } | - | ||||||||||||||||||
| 120 | if ((
| 0-2 | ||||||||||||||||||
| 121 | EC_POINT_free(pt); | - | ||||||||||||||||||
| 122 | return never executed: r;return r;never executed: return r; | 0 | ||||||||||||||||||
| 123 | } | - | ||||||||||||||||||
| 124 | if (EC_KEY_set_public_key(v, pt) != 1
| 0-2 | ||||||||||||||||||
| 125 | EC_POINT_free(pt); | - | ||||||||||||||||||
| 126 | return never executed: -2;return -2;never executed: return -2; | 0 | ||||||||||||||||||
| 127 | } | - | ||||||||||||||||||
| 128 | EC_POINT_free(pt); | - | ||||||||||||||||||
| 129 | - | |||||||||||||||||||
| 130 | if (sshbuf_get_string_direct(buf,
| 0-2 | ||||||||||||||||||
| 131 | ((void *)0)
| 0-2 | ||||||||||||||||||
| 132 | ,
| 0-2 | ||||||||||||||||||
| 133 | ((void *)0)
| 0-2 | ||||||||||||||||||
| 134 | ) != 0
| 0-2 | ||||||||||||||||||
| 135 | - | |||||||||||||||||||
| 136 | ; | - | ||||||||||||||||||
| 137 | ; | - | ||||||||||||||||||
| 138 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||
| 139 | } | - | ||||||||||||||||||
| 140 | return executed 2 times by 2 tests: 0;return 0;Executed by:
executed 2 times by 2 tests: return 0;Executed by:
| 2 | ||||||||||||||||||
| 141 | } | - | ||||||||||||||||||
| 142 | - | |||||||||||||||||||
| 143 | - | |||||||||||||||||||
| 144 | int | - | ||||||||||||||||||
| 145 | sshbuf_put_bignum2(struct sshbuf *buf, const BIGNUM *v) | - | ||||||||||||||||||
| 146 | { | - | ||||||||||||||||||
| 147 | u_char d[(16384 / 8) + 1]; | - | ||||||||||||||||||
| 148 | int len = | - | ||||||||||||||||||
| 149 | ((BN_num_bits( | - | ||||||||||||||||||
| 150 | v | - | ||||||||||||||||||
| 151 | )+7)/8) | - | ||||||||||||||||||
| 152 | , prepend = 0, r; | - | ||||||||||||||||||
| 153 | - | |||||||||||||||||||
| 154 | if (len < 0
| 0-1778 | ||||||||||||||||||
| 155 | return never executed: -10;return -10;never executed: return -10; | 0 | ||||||||||||||||||
| 156 | *d = '\0'; | - | ||||||||||||||||||
| 157 | if (BN_bn2bin(v, d + 1) != len
| 0-1778 | ||||||||||||||||||
| 158 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||
| 159 | - | |||||||||||||||||||
| 160 | if (len > 0
| 0-1778 | ||||||||||||||||||
| 161 | prepend = 1; executed 957 times by 5 tests: prepend = 1;Executed by:
| 957 | ||||||||||||||||||
| 162 | if ((
| 2-1776 | ||||||||||||||||||
| 163 | explicit_bzero(d, sizeof(d)); | - | ||||||||||||||||||
| 164 | return executed 2 times by 1 test: r;return r;Executed by:
executed 2 times by 1 test: return r;Executed by:
| 2 | ||||||||||||||||||
| 165 | } | - | ||||||||||||||||||
| 166 | explicit_bzero(d, sizeof(d)); | - | ||||||||||||||||||
| 167 | return executed 1776 times by 5 tests: 0;return 0;Executed by:
executed 1776 times by 5 tests: return 0;Executed by:
| 1776 | ||||||||||||||||||
| 168 | } | - | ||||||||||||||||||
| 169 | - | |||||||||||||||||||
| 170 | int | - | ||||||||||||||||||
| 171 | sshbuf_put_bignum1(struct sshbuf *buf, const BIGNUM *v) | - | ||||||||||||||||||
| 172 | { | - | ||||||||||||||||||
| 173 | int r, len_bits = BN_num_bits(v); | - | ||||||||||||||||||
| 174 | size_t len_bytes = (len_bits + 7) / 8; | - | ||||||||||||||||||
| 175 | u_char d[(16384 / 8)], *dp; | - | ||||||||||||||||||
| 176 | - | |||||||||||||||||||
| 177 | if (len_bits < 0
| 0-4 | ||||||||||||||||||
| 178 | return never executed: -10;return -10;never executed: return -10; | 0 | ||||||||||||||||||
| 179 | if (BN_bn2bin(v, d) != (int)len_bytes
| 0-4 | ||||||||||||||||||
| 180 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||
| 181 | if ((
| 2 | ||||||||||||||||||
| 182 | explicit_bzero(d, sizeof(d)); | - | ||||||||||||||||||
| 183 | return executed 2 times by 1 test: r;return r;Executed by:
executed 2 times by 1 test: return r;Executed by:
| 2 | ||||||||||||||||||
| 184 | } | - | ||||||||||||||||||
| 185 | do { const u_int16_t __v = (len_bits); ((u_char *)(dp))[0] = (__v >> 8) & 0xff; ((u_char *)(dp))[1] = __v & 0xff; } while (0); | - | ||||||||||||||||||
| 186 | if (len_bytes != 0
| 0-2 | ||||||||||||||||||
| 187 | memcpy(dp + 2, d, len_bytes); executed 2 times by 1 test: memcpy(dp + 2, d, len_bytes);Executed by:
| 2 | ||||||||||||||||||
| 188 | explicit_bzero(d, sizeof(d)); | - | ||||||||||||||||||
| 189 | return executed 2 times by 1 test: 0;return 0;Executed by:
executed 2 times by 1 test: return 0;Executed by:
| 2 | ||||||||||||||||||
| 190 | } | - | ||||||||||||||||||
| 191 | - | |||||||||||||||||||
| 192 | - | |||||||||||||||||||
| 193 | int | - | ||||||||||||||||||
| 194 | sshbuf_put_ec(struct sshbuf *buf, const EC_POINT *v, const EC_GROUP *g) | - | ||||||||||||||||||
| 195 | { | - | ||||||||||||||||||
| 196 | u_char d[((528 * 2 / 8) + 1)]; | - | ||||||||||||||||||
| 197 | BN_CTX *bn_ctx; | - | ||||||||||||||||||
| 198 | size_t len; | - | ||||||||||||||||||
| 199 | int ret; | - | ||||||||||||||||||
| 200 | - | |||||||||||||||||||
| 201 | if ((
| 0-412 | ||||||||||||||||||
| 202 | ((void *)0)
| 0-412 | ||||||||||||||||||
| 203 | ) | - | ||||||||||||||||||
| 204 | return never executed: -2;return -2;never executed: return -2; | 0 | ||||||||||||||||||
| 205 | if ((
| 0-412 | ||||||||||||||||||
| 206 |
| 0-412 | ||||||||||||||||||
| 207 | ((void *)0)
| 0-412 | ||||||||||||||||||
| 208 | , 0, bn_ctx)) > ((528 * 2 / 8) + 1)
| 0-412 | ||||||||||||||||||
| 209 | BN_CTX_free(bn_ctx); | - | ||||||||||||||||||
| 210 | return never executed: -10;return -10;never executed: return -10; | 0 | ||||||||||||||||||
| 211 | } | - | ||||||||||||||||||
| 212 | if (EC_POINT_point2oct(g, v, POINT_CONVERSION_UNCOMPRESSED,
| 0-412 | ||||||||||||||||||
| 213 | d, len, bn_ctx) != len
| 0-412 | ||||||||||||||||||
| 214 | BN_CTX_free(bn_ctx); | - | ||||||||||||||||||
| 215 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||
| 216 | } | - | ||||||||||||||||||
| 217 | BN_CTX_free(bn_ctx); | - | ||||||||||||||||||
| 218 | ret = sshbuf_put_string(buf, d, len); | - | ||||||||||||||||||
| 219 | explicit_bzero(d, len); | - | ||||||||||||||||||
| 220 | return executed 412 times by 4 tests: ret;return ret;Executed by:
executed 412 times by 4 tests: return ret;Executed by:
| 412 | ||||||||||||||||||
| 221 | } | - | ||||||||||||||||||
| 222 | - | |||||||||||||||||||
| 223 | int | - | ||||||||||||||||||
| 224 | sshbuf_put_eckey(struct sshbuf *buf, const EC_KEY *v) | - | ||||||||||||||||||
| 225 | { | - | ||||||||||||||||||
| 226 | return executed 52 times by 4 tests: sshbuf_put_ec(buf, EC_KEY_get0_public_key(v),return sshbuf_put_ec(buf, EC_KEY_get0_public_key(v), EC_KEY_get0_group(v));Executed by:
executed 52 times by 4 tests: return sshbuf_put_ec(buf, EC_KEY_get0_public_key(v), EC_KEY_get0_group(v));Executed by:
| 52 | ||||||||||||||||||
| 227 | EC_KEY_get0_group(v)); executed 52 times by 4 tests: return sshbuf_put_ec(buf, EC_KEY_get0_public_key(v), EC_KEY_get0_group(v));Executed by:
| 52 | ||||||||||||||||||
| 228 | } | - | ||||||||||||||||||
| Switch to Source code | Preprocessed file |