| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/ssl/tls13_enc.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||||||||
| 2 | - | |||||||||||||||||||||||||
| 3 | - | |||||||||||||||||||||||||
| 4 | - | |||||||||||||||||||||||||
| 5 | - | |||||||||||||||||||||||||
| 6 | static const unsigned char default_zeros[64]; | - | ||||||||||||||||||||||||
| 7 | - | |||||||||||||||||||||||||
| 8 | - | |||||||||||||||||||||||||
| 9 | - | |||||||||||||||||||||||||
| 10 | - | |||||||||||||||||||||||||
| 11 | - | |||||||||||||||||||||||||
| 12 | - | |||||||||||||||||||||||||
| 13 | - | |||||||||||||||||||||||||
| 14 | int tls13_hkdf_expand(SSL *s, const EVP_MD *md, const unsigned char *secret, | - | ||||||||||||||||||||||||
| 15 | const unsigned char *label, size_t labellen, | - | ||||||||||||||||||||||||
| 16 | const unsigned char *data, size_t datalen, | - | ||||||||||||||||||||||||
| 17 | unsigned char *out, size_t outlen) | - | ||||||||||||||||||||||||
| 18 | { | - | ||||||||||||||||||||||||
| 19 | const unsigned char label_prefix[] = "tls13 "; | - | ||||||||||||||||||||||||
| 20 | EVP_PKEY_CTX *pctx = EVP_PKEY_CTX_new_id(1036, | - | ||||||||||||||||||||||||
| 21 | ((void *)0) | - | ||||||||||||||||||||||||
| 22 | ); | - | ||||||||||||||||||||||||
| 23 | int ret; | - | ||||||||||||||||||||||||
| 24 | size_t hkdflabellen; | - | ||||||||||||||||||||||||
| 25 | size_t hashlen; | - | ||||||||||||||||||||||||
| 26 | - | |||||||||||||||||||||||||
| 27 | - | |||||||||||||||||||||||||
| 28 | - | |||||||||||||||||||||||||
| 29 | - | |||||||||||||||||||||||||
| 30 | unsigned char hkdflabel[sizeof(uint16_t) + sizeof(uint8_t) + | - | ||||||||||||||||||||||||
| 31 | + sizeof(label_prefix) + 246 | - | ||||||||||||||||||||||||
| 32 | + 64]; | - | ||||||||||||||||||||||||
| 33 | WPACKET pkt; | - | ||||||||||||||||||||||||
| 34 | - | |||||||||||||||||||||||||
| 35 | if (pctx ==
| 0-27761 | ||||||||||||||||||||||||
| 36 | ((void *)0)
| 0-27761 | ||||||||||||||||||||||||
| 37 | ) | - | ||||||||||||||||||||||||
| 38 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 39 | - | |||||||||||||||||||||||||
| 40 | hashlen = EVP_MD_size(md); | - | ||||||||||||||||||||||||
| 41 | - | |||||||||||||||||||||||||
| 42 | if (!WPACKET_init_static_len(&pkt, hkdflabel, sizeof(hkdflabel), 0)
| 0-27761 | ||||||||||||||||||||||||
| 43 | || !WPACKET_put_bytes__((&pkt), (outlen), 2)
| 0-27761 | ||||||||||||||||||||||||
| 44 | || !WPACKET_start_sub_packet_len__((&pkt), 1)
| 0-27761 | ||||||||||||||||||||||||
| 45 | || !WPACKET_memcpy(&pkt, label_prefix, sizeof(label_prefix) - 1)
| 0-27761 | ||||||||||||||||||||||||
| 46 | || !WPACKET_memcpy(&pkt, label, labellen)
| 0-27761 | ||||||||||||||||||||||||
| 47 | || !WPACKET_close(&pkt)
| 0-27761 | ||||||||||||||||||||||||
| 48 | || !WPACKET_sub_memcpy__((&pkt), (data), ((data ==
| 0-27761 | ||||||||||||||||||||||||
| 49 | ((void *)0)
| 0-27761 | ||||||||||||||||||||||||
| 50 | ) ? 0 : datalen), 1)
| 0-27761 | ||||||||||||||||||||||||
| 51 | || !WPACKET_get_total_written(&pkt, &hkdflabellen)
| 0-27761 | ||||||||||||||||||||||||
| 52 | || !WPACKET_finish(&pkt)
| 0-27761 | ||||||||||||||||||||||||
| 53 | EVP_PKEY_CTX_free(pctx); | - | ||||||||||||||||||||||||
| 54 | WPACKET_cleanup(&pkt); | - | ||||||||||||||||||||||||
| 55 | ossl_statem_fatal((s), (80), (561), ((4|64)), | - | ||||||||||||||||||||||||
| 56 | __FILE__ | - | ||||||||||||||||||||||||
| 57 | , | - | ||||||||||||||||||||||||
| 58 | 63 | - | ||||||||||||||||||||||||
| 59 | ) | - | ||||||||||||||||||||||||
| 60 | ; | - | ||||||||||||||||||||||||
| 61 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 62 | } | - | ||||||||||||||||||||||||
| 63 | - | |||||||||||||||||||||||||
| 64 | ret = EVP_PKEY_derive_init(pctx) <= 0
| 0-27761 | ||||||||||||||||||||||||
| 65 | || EVP_PKEY_CTX_ctrl(pctx, -1, (1<<10), (0x1000 + 7), 2,
| 0-27761 | ||||||||||||||||||||||||
| 66 | ((void *)0)
| 0-27761 | ||||||||||||||||||||||||
| 67 | )
| 0-27761 | ||||||||||||||||||||||||
| 68 | <= 0
| 0-27761 | ||||||||||||||||||||||||
| 69 | || EVP_PKEY_CTX_ctrl(pctx, -1, (1<<10), (0x1000 + 3), 0, (void *)(md)) <= 0
| 0-27761 | ||||||||||||||||||||||||
| 70 | || EVP_PKEY_CTX_ctrl(pctx, -1, (1<<10), (0x1000 + 5), hashlen, (void *)(secret)) <= 0
| 0-27761 | ||||||||||||||||||||||||
| 71 | || EVP_PKEY_CTX_ctrl(pctx, -1, (1<<10), (0x1000 + 6), hkdflabellen, (void *)(hkdflabel)) <= 0
| 0-27761 | ||||||||||||||||||||||||
| 72 | || EVP_PKEY_derive(pctx, out, &outlen) <= 0
| 0-27761 | ||||||||||||||||||||||||
| 73 | - | |||||||||||||||||||||||||
| 74 | EVP_PKEY_CTX_free(pctx); | - | ||||||||||||||||||||||||
| 75 | - | |||||||||||||||||||||||||
| 76 | if (ret != 0
| 0-27761 | ||||||||||||||||||||||||
| 77 | ossl_statem_fatal((s), (80), (561), ((4|64)), never executed: ossl_statem_fatal((s), (80), (561), ((4|64)), __FILE__ , 79 ) ; | 0 | ||||||||||||||||||||||||
| 78 | __FILE__ never executed: ossl_statem_fatal((s), (80), (561), ((4|64)), __FILE__ , 79 ) ; | 0 | ||||||||||||||||||||||||
| 79 | , never executed: ossl_statem_fatal((s), (80), (561), ((4|64)), __FILE__ , 79 ) ; | 0 | ||||||||||||||||||||||||
| 80 | 79 never executed: ossl_statem_fatal((s), (80), (561), ((4|64)), __FILE__ , 79 ) ; | 0 | ||||||||||||||||||||||||
| 81 | ) never executed: ossl_statem_fatal((s), (80), (561), ((4|64)), __FILE__ , 79 ) ; | 0 | ||||||||||||||||||||||||
| 82 | ; never executed: ossl_statem_fatal((s), (80), (561), ((4|64)), __FILE__ , 79 ) ; | 0 | ||||||||||||||||||||||||
| 83 | - | |||||||||||||||||||||||||
| 84 | return executed 27761 times by 2 tests: ret == 0;return ret == 0;Executed by:
executed 27761 times by 2 tests: return ret == 0;Executed by:
| 27761 | ||||||||||||||||||||||||
| 85 | } | - | ||||||||||||||||||||||||
| 86 | - | |||||||||||||||||||||||||
| 87 | - | |||||||||||||||||||||||||
| 88 | - | |||||||||||||||||||||||||
| 89 | - | |||||||||||||||||||||||||
| 90 | - | |||||||||||||||||||||||||
| 91 | int tls13_derive_key(SSL *s, const EVP_MD *md, const unsigned char *secret, | - | ||||||||||||||||||||||||
| 92 | unsigned char *key, size_t keylen) | - | ||||||||||||||||||||||||
| 93 | { | - | ||||||||||||||||||||||||
| 94 | static const unsigned char keylabel[] = "key"; | - | ||||||||||||||||||||||||
| 95 | - | |||||||||||||||||||||||||
| 96 | return executed 5550 times by 2 tests: tls13_hkdf_expand(s, md, secret, keylabel, sizeof(keylabel) - 1,return tls13_hkdf_expand(s, md, secret, keylabel, sizeof(keylabel) - 1, ((void *)0) , 0, key, keylen);Executed by:
executed 5550 times by 2 tests: return tls13_hkdf_expand(s, md, secret, keylabel, sizeof(keylabel) - 1, ((void *)0) , 0, key, keylen);Executed by:
| 5550 | ||||||||||||||||||||||||
| 97 | executed 5550 times by 2 tests: return tls13_hkdf_expand(s, md, secret, keylabel, sizeof(keylabel) - 1, ((void *)0) , 0, key, keylen);Executed by:
| 5550 | ||||||||||||||||||||||||
| 98 | ((void *)0) executed 5550 times by 2 tests: return tls13_hkdf_expand(s, md, secret, keylabel, sizeof(keylabel) - 1, ((void *)0) , 0, key, keylen);Executed by:
| 5550 | ||||||||||||||||||||||||
| 99 | , 0, key, keylen); executed 5550 times by 2 tests: return tls13_hkdf_expand(s, md, secret, keylabel, sizeof(keylabel) - 1, ((void *)0) , 0, key, keylen);Executed by:
| 5550 | ||||||||||||||||||||||||
| 100 | } | - | ||||||||||||||||||||||||
| 101 | - | |||||||||||||||||||||||||
| 102 | - | |||||||||||||||||||||||||
| 103 | - | |||||||||||||||||||||||||
| 104 | - | |||||||||||||||||||||||||
| 105 | - | |||||||||||||||||||||||||
| 106 | int tls13_derive_iv(SSL *s, const EVP_MD *md, const unsigned char *secret, | - | ||||||||||||||||||||||||
| 107 | unsigned char *iv, size_t ivlen) | - | ||||||||||||||||||||||||
| 108 | { | - | ||||||||||||||||||||||||
| 109 | static const unsigned char ivlabel[] = "iv"; | - | ||||||||||||||||||||||||
| 110 | - | |||||||||||||||||||||||||
| 111 | return executed 5550 times by 2 tests: tls13_hkdf_expand(s, md, secret, ivlabel, sizeof(ivlabel) - 1,return tls13_hkdf_expand(s, md, secret, ivlabel, sizeof(ivlabel) - 1, ((void *)0) , 0, iv, ivlen);Executed by:
executed 5550 times by 2 tests: return tls13_hkdf_expand(s, md, secret, ivlabel, sizeof(ivlabel) - 1, ((void *)0) , 0, iv, ivlen);Executed by:
| 5550 | ||||||||||||||||||||||||
| 112 | executed 5550 times by 2 tests: return tls13_hkdf_expand(s, md, secret, ivlabel, sizeof(ivlabel) - 1, ((void *)0) , 0, iv, ivlen);Executed by:
| 5550 | ||||||||||||||||||||||||
| 113 | ((void *)0) executed 5550 times by 2 tests: return tls13_hkdf_expand(s, md, secret, ivlabel, sizeof(ivlabel) - 1, ((void *)0) , 0, iv, ivlen);Executed by:
| 5550 | ||||||||||||||||||||||||
| 114 | , 0, iv, ivlen); executed 5550 times by 2 tests: return tls13_hkdf_expand(s, md, secret, ivlabel, sizeof(ivlabel) - 1, ((void *)0) , 0, iv, ivlen);Executed by:
| 5550 | ||||||||||||||||||||||||
| 115 | } | - | ||||||||||||||||||||||||
| 116 | - | |||||||||||||||||||||||||
| 117 | int tls13_derive_finishedkey(SSL *s, const EVP_MD *md, | - | ||||||||||||||||||||||||
| 118 | const unsigned char *secret, | - | ||||||||||||||||||||||||
| 119 | unsigned char *fin, size_t finlen) | - | ||||||||||||||||||||||||
| 120 | { | - | ||||||||||||||||||||||||
| 121 | static const unsigned char finishedlabel[] = "finished"; | - | ||||||||||||||||||||||||
| 122 | - | |||||||||||||||||||||||||
| 123 | return executed 3248 times by 1 test: tls13_hkdf_expand(s, md, secret, finishedlabel,return tls13_hkdf_expand(s, md, secret, finishedlabel, sizeof(finishedlabel) - 1, ((void *)0) , 0, fin, finlen);Executed by:
executed 3248 times by 1 test: return tls13_hkdf_expand(s, md, secret, finishedlabel, sizeof(finishedlabel) - 1, ((void *)0) , 0, fin, finlen);Executed by:
| 3248 | ||||||||||||||||||||||||
| 124 | sizeof(finishedlabel) - 1, executed 3248 times by 1 test: return tls13_hkdf_expand(s, md, secret, finishedlabel, sizeof(finishedlabel) - 1, ((void *)0) , 0, fin, finlen);Executed by:
| 3248 | ||||||||||||||||||||||||
| 125 | ((void *)0) executed 3248 times by 1 test: return tls13_hkdf_expand(s, md, secret, finishedlabel, sizeof(finishedlabel) - 1, ((void *)0) , 0, fin, finlen);Executed by:
| 3248 | ||||||||||||||||||||||||
| 126 | , 0, fin, finlen); executed 3248 times by 1 test: return tls13_hkdf_expand(s, md, secret, finishedlabel, sizeof(finishedlabel) - 1, ((void *)0) , 0, fin, finlen);Executed by:
| 3248 | ||||||||||||||||||||||||
| 127 | } | - | ||||||||||||||||||||||||
| 128 | - | |||||||||||||||||||||||||
| 129 | - | |||||||||||||||||||||||||
| 130 | - | |||||||||||||||||||||||||
| 131 | - | |||||||||||||||||||||||||
| 132 | - | |||||||||||||||||||||||||
| 133 | - | |||||||||||||||||||||||||
| 134 | int tls13_generate_secret(SSL *s, const EVP_MD *md, | - | ||||||||||||||||||||||||
| 135 | const unsigned char *prevsecret, | - | ||||||||||||||||||||||||
| 136 | const unsigned char *insecret, | - | ||||||||||||||||||||||||
| 137 | size_t insecretlen, | - | ||||||||||||||||||||||||
| 138 | unsigned char *outsecret) | - | ||||||||||||||||||||||||
| 139 | { | - | ||||||||||||||||||||||||
| 140 | size_t mdlen, prevsecretlen; | - | ||||||||||||||||||||||||
| 141 | int mdleni; | - | ||||||||||||||||||||||||
| 142 | int ret; | - | ||||||||||||||||||||||||
| 143 | EVP_PKEY_CTX *pctx = EVP_PKEY_CTX_new_id(1036, | - | ||||||||||||||||||||||||
| 144 | ((void *)0) | - | ||||||||||||||||||||||||
| 145 | ); | - | ||||||||||||||||||||||||
| 146 | static const char derived_secret_label[] = "derived"; | - | ||||||||||||||||||||||||
| 147 | unsigned char preextractsec[64]; | - | ||||||||||||||||||||||||
| 148 | - | |||||||||||||||||||||||||
| 149 | if (pctx ==
| 0-4462 | ||||||||||||||||||||||||
| 150 | ((void *)0)
| 0-4462 | ||||||||||||||||||||||||
| 151 | ) { | - | ||||||||||||||||||||||||
| 152 | ossl_statem_fatal((s), (80), (591), ((4|64)), | - | ||||||||||||||||||||||||
| 153 | __FILE__ | - | ||||||||||||||||||||||||
| 154 | , | - | ||||||||||||||||||||||||
| 155 | 140 | - | ||||||||||||||||||||||||
| 156 | ) | - | ||||||||||||||||||||||||
| 157 | ; | - | ||||||||||||||||||||||||
| 158 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 159 | } | - | ||||||||||||||||||||||||
| 160 | - | |||||||||||||||||||||||||
| 161 | mdleni = EVP_MD_size(md); | - | ||||||||||||||||||||||||
| 162 | - | |||||||||||||||||||||||||
| 163 | if (!((mdleni >= 0) != 0)
| 0-4462 | ||||||||||||||||||||||||
| 164 | ossl_statem_fatal((s), (80), (591), ((4|64)), | - | ||||||||||||||||||||||||
| 165 | __FILE__ | - | ||||||||||||||||||||||||
| 166 | , | - | ||||||||||||||||||||||||
| 167 | 148 | - | ||||||||||||||||||||||||
| 168 | ) | - | ||||||||||||||||||||||||
| 169 | ; | - | ||||||||||||||||||||||||
| 170 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 171 | } | - | ||||||||||||||||||||||||
| 172 | mdlen = (size_t)mdleni; | - | ||||||||||||||||||||||||
| 173 | - | |||||||||||||||||||||||||
| 174 | if (insecret ==
| 1776-2686 | ||||||||||||||||||||||||
| 175 | ((void *)0)
| 1776-2686 | ||||||||||||||||||||||||
| 176 | ) { | - | ||||||||||||||||||||||||
| 177 | insecret = default_zeros; | - | ||||||||||||||||||||||||
| 178 | insecretlen = mdlen; | - | ||||||||||||||||||||||||
| 179 | } executed 2686 times by 2 tests: end of blockExecuted by:
| 2686 | ||||||||||||||||||||||||
| 180 | if (prevsecret ==
| 1561-2901 | ||||||||||||||||||||||||
| 181 | ((void *)0)
| 1561-2901 | ||||||||||||||||||||||||
| 182 | ) { | - | ||||||||||||||||||||||||
| 183 | prevsecret = default_zeros; | - | ||||||||||||||||||||||||
| 184 | prevsecretlen = 0; | - | ||||||||||||||||||||||||
| 185 | } executed 1561 times by 2 tests: else {end of blockExecuted by:
| 1561 | ||||||||||||||||||||||||
| 186 | EVP_MD_CTX *mctx = EVP_MD_CTX_new(); | - | ||||||||||||||||||||||||
| 187 | unsigned char hash[64]; | - | ||||||||||||||||||||||||
| 188 | - | |||||||||||||||||||||||||
| 189 | - | |||||||||||||||||||||||||
| 190 | if (mctx ==
| 0-2901 | ||||||||||||||||||||||||
| 191 | ((void *)0)
| 0-2901 | ||||||||||||||||||||||||
| 192 | - | |||||||||||||||||||||||||
| 193 | || EVP_DigestInit_ex(mctx, md,
| 0-2901 | ||||||||||||||||||||||||
| 194 | ((void *)0)
| 0-2901 | ||||||||||||||||||||||||
| 195 | ) <= 0
| 0-2901 | ||||||||||||||||||||||||
| 196 | || EVP_DigestFinal_ex(mctx, hash,
| 0-2901 | ||||||||||||||||||||||||
| 197 | ((void *)0)
| 0-2901 | ||||||||||||||||||||||||
| 198 | ) <= 0
| 0-2901 | ||||||||||||||||||||||||
| 199 | ossl_statem_fatal((s), (80), (591), ((4|64)), | - | ||||||||||||||||||||||||
| 200 | __FILE__ | - | ||||||||||||||||||||||||
| 201 | , | - | ||||||||||||||||||||||||
| 202 | 169 | - | ||||||||||||||||||||||||
| 203 | ) | - | ||||||||||||||||||||||||
| 204 | ; | - | ||||||||||||||||||||||||
| 205 | EVP_MD_CTX_free(mctx); | - | ||||||||||||||||||||||||
| 206 | EVP_PKEY_CTX_free(pctx); | - | ||||||||||||||||||||||||
| 207 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 208 | } | - | ||||||||||||||||||||||||
| 209 | EVP_MD_CTX_free(mctx); | - | ||||||||||||||||||||||||
| 210 | - | |||||||||||||||||||||||||
| 211 | - | |||||||||||||||||||||||||
| 212 | if (!tls13_hkdf_expand(s, md, prevsecret,
| 0-2901 | ||||||||||||||||||||||||
| 213 | (unsigned char *)derived_secret_label,
| 0-2901 | ||||||||||||||||||||||||
| 214 | sizeof(derived_secret_label) - 1, hash, mdlen,
| 0-2901 | ||||||||||||||||||||||||
| 215 | preextractsec, mdlen)
| 0-2901 | ||||||||||||||||||||||||
| 216 | - | |||||||||||||||||||||||||
| 217 | EVP_PKEY_CTX_free(pctx); | - | ||||||||||||||||||||||||
| 218 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 219 | } | - | ||||||||||||||||||||||||
| 220 | - | |||||||||||||||||||||||||
| 221 | prevsecret = preextractsec; | - | ||||||||||||||||||||||||
| 222 | prevsecretlen = mdlen; | - | ||||||||||||||||||||||||
| 223 | } executed 2901 times by 2 tests: end of blockExecuted by:
| 2901 | ||||||||||||||||||||||||
| 224 | - | |||||||||||||||||||||||||
| 225 | ret = EVP_PKEY_derive_init(pctx) <= 0
| 0-4462 | ||||||||||||||||||||||||
| 226 | || EVP_PKEY_CTX_ctrl(pctx, -1, (1<<10), (0x1000 + 7), 1,
| 0-4462 | ||||||||||||||||||||||||
| 227 | ((void *)0)
| 0-4462 | ||||||||||||||||||||||||
| 228 | )
| 0-4462 | ||||||||||||||||||||||||
| 229 | <= 0
| 0-4462 | ||||||||||||||||||||||||
| 230 | || EVP_PKEY_CTX_ctrl(pctx, -1, (1<<10), (0x1000 + 3), 0, (void *)(md)) <= 0
| 0-4462 | ||||||||||||||||||||||||
| 231 | || EVP_PKEY_CTX_ctrl(pctx, -1, (1<<10), (0x1000 + 5), insecretlen, (void *)(insecret)) <= 0
| 0-4462 | ||||||||||||||||||||||||
| 232 | || EVP_PKEY_CTX_ctrl(pctx, -1, (1<<10), (0x1000 + 4), prevsecretlen, (void *)(prevsecret))
| 0-4462 | ||||||||||||||||||||||||
| 233 | <= 0
| 0-4462 | ||||||||||||||||||||||||
| 234 | || EVP_PKEY_derive(pctx, outsecret, &mdlen)
| 0-4462 | ||||||||||||||||||||||||
| 235 | <= 0
| 0-4462 | ||||||||||||||||||||||||
| 236 | - | |||||||||||||||||||||||||
| 237 | if (ret != 0
| 0-4462 | ||||||||||||||||||||||||
| 238 | ossl_statem_fatal((s), (80), (591), ((4|64)), never executed: ossl_statem_fatal((s), (80), (591), ((4|64)), __FILE__ , 202 ) ; | 0 | ||||||||||||||||||||||||
| 239 | __FILE__ never executed: ossl_statem_fatal((s), (80), (591), ((4|64)), __FILE__ , 202 ) ; | 0 | ||||||||||||||||||||||||
| 240 | , never executed: ossl_statem_fatal((s), (80), (591), ((4|64)), __FILE__ , 202 ) ; | 0 | ||||||||||||||||||||||||
| 241 | 202 never executed: ossl_statem_fatal((s), (80), (591), ((4|64)), __FILE__ , 202 ) ; | 0 | ||||||||||||||||||||||||
| 242 | ) never executed: ossl_statem_fatal((s), (80), (591), ((4|64)), __FILE__ , 202 ) ; | 0 | ||||||||||||||||||||||||
| 243 | ; never executed: ossl_statem_fatal((s), (80), (591), ((4|64)), __FILE__ , 202 ) ; | 0 | ||||||||||||||||||||||||
| 244 | - | |||||||||||||||||||||||||
| 245 | EVP_PKEY_CTX_free(pctx); | - | ||||||||||||||||||||||||
| 246 | if (prevsecret == preextractsec
| 1561-2901 | ||||||||||||||||||||||||
| 247 | OPENSSL_cleanse(preextractsec, mdlen); executed 2901 times by 2 tests: OPENSSL_cleanse(preextractsec, mdlen);Executed by:
| 2901 | ||||||||||||||||||||||||
| 248 | return executed 4462 times by 2 tests: ret == 0;return ret == 0;Executed by:
executed 4462 times by 2 tests: return ret == 0;Executed by:
| 4462 | ||||||||||||||||||||||||
| 249 | } | - | ||||||||||||||||||||||||
| 250 | - | |||||||||||||||||||||||||
| 251 | - | |||||||||||||||||||||||||
| 252 | - | |||||||||||||||||||||||||
| 253 | - | |||||||||||||||||||||||||
| 254 | - | |||||||||||||||||||||||||
| 255 | - | |||||||||||||||||||||||||
| 256 | int tls13_generate_handshake_secret(SSL *s, const unsigned char *insecret, | - | ||||||||||||||||||||||||
| 257 | size_t insecretlen) | - | ||||||||||||||||||||||||
| 258 | { | - | ||||||||||||||||||||||||
| 259 | - | |||||||||||||||||||||||||
| 260 | return executed 1472 times by 2 tests: tls13_generate_secret(s, ssl_handshake_md(s), s->early_secret,return tls13_generate_secret(s, ssl_handshake_md(s), s->early_secret, insecret, insecretlen, (unsigned char *)&s->handshake_secret);Executed by:
executed 1472 times by 2 tests: return tls13_generate_secret(s, ssl_handshake_md(s), s->early_secret, insecret, insecretlen, (unsigned char *)&s->handshake_secret);Executed by:
| 1472 | ||||||||||||||||||||||||
| 261 | insecret, insecretlen, executed 1472 times by 2 tests: return tls13_generate_secret(s, ssl_handshake_md(s), s->early_secret, insecret, insecretlen, (unsigned char *)&s->handshake_secret);Executed by:
| 1472 | ||||||||||||||||||||||||
| 262 | (unsigned char *)&s->handshake_secret); executed 1472 times by 2 tests: return tls13_generate_secret(s, ssl_handshake_md(s), s->early_secret, insecret, insecretlen, (unsigned char *)&s->handshake_secret);Executed by:
| 1472 | ||||||||||||||||||||||||
| 263 | } | - | ||||||||||||||||||||||||
| 264 | - | |||||||||||||||||||||||||
| 265 | - | |||||||||||||||||||||||||
| 266 | - | |||||||||||||||||||||||||
| 267 | - | |||||||||||||||||||||||||
| 268 | - | |||||||||||||||||||||||||
| 269 | - | |||||||||||||||||||||||||
| 270 | int tls13_generate_master_secret(SSL *s, unsigned char *out, | - | ||||||||||||||||||||||||
| 271 | unsigned char *prev, size_t prevlen, | - | ||||||||||||||||||||||||
| 272 | size_t *secret_size) | - | ||||||||||||||||||||||||
| 273 | { | - | ||||||||||||||||||||||||
| 274 | const EVP_MD *md = ssl_handshake_md(s); | - | ||||||||||||||||||||||||
| 275 | - | |||||||||||||||||||||||||
| 276 | *secret_size = EVP_MD_size(md); | - | ||||||||||||||||||||||||
| 277 | - | |||||||||||||||||||||||||
| 278 | return executed 1429 times by 2 tests: tls13_generate_secret(s, md, prev, return tls13_generate_secret(s, md, prev, ((void *)0) , 0, out);Executed by:
executed 1429 times by 2 tests: return tls13_generate_secret(s, md, prev, ((void *)0) , 0, out);Executed by:
| 1429 | ||||||||||||||||||||||||
| 279 | ((void *)0) executed 1429 times by 2 tests: return tls13_generate_secret(s, md, prev, ((void *)0) , 0, out);Executed by:
| 1429 | ||||||||||||||||||||||||
| 280 | , 0, out); executed 1429 times by 2 tests: return tls13_generate_secret(s, md, prev, ((void *)0) , 0, out);Executed by:
| 1429 | ||||||||||||||||||||||||
| 281 | } | - | ||||||||||||||||||||||||
| 282 | - | |||||||||||||||||||||||||
| 283 | - | |||||||||||||||||||||||||
| 284 | - | |||||||||||||||||||||||||
| 285 | - | |||||||||||||||||||||||||
| 286 | - | |||||||||||||||||||||||||
| 287 | size_t tls13_final_finish_mac(SSL *s, const char *str, size_t slen, | - | ||||||||||||||||||||||||
| 288 | unsigned char *out) | - | ||||||||||||||||||||||||
| 289 | { | - | ||||||||||||||||||||||||
| 290 | const EVP_MD *md = ssl_handshake_md(s); | - | ||||||||||||||||||||||||
| 291 | unsigned char hash[64]; | - | ||||||||||||||||||||||||
| 292 | size_t hashlen, ret = 0; | - | ||||||||||||||||||||||||
| 293 | EVP_PKEY *key = | - | ||||||||||||||||||||||||
| 294 | ((void *)0) | - | ||||||||||||||||||||||||
| 295 | ; | - | ||||||||||||||||||||||||
| 296 | EVP_MD_CTX *ctx = EVP_MD_CTX_new(); | - | ||||||||||||||||||||||||
| 297 | - | |||||||||||||||||||||||||
| 298 | if (!ssl_handshake_hash(s, hash, sizeof(hash), &hashlen)
| 0-2614 | ||||||||||||||||||||||||
| 299 | - | |||||||||||||||||||||||||
| 300 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 301 | } | - | ||||||||||||||||||||||||
| 302 | - | |||||||||||||||||||||||||
| 303 | if (str == s->method->ssl3_enc->server_finished_label
| 1185-1429 | ||||||||||||||||||||||||
| 304 | key = EVP_PKEY_new_raw_private_key(855, | - | ||||||||||||||||||||||||
| 305 | ((void *)0) | - | ||||||||||||||||||||||||
| 306 | , | - | ||||||||||||||||||||||||
| 307 | s->server_finished_secret, hashlen); | - | ||||||||||||||||||||||||
| 308 | } executed 1429 times by 1 test: else if (((end of blockExecuted by:
| 47-1429 | ||||||||||||||||||||||||
| 309 | key = EVP_PKEY_new_raw_private_key(855, | - | ||||||||||||||||||||||||
| 310 | ((void *)0) | - | ||||||||||||||||||||||||
| 311 | , | - | ||||||||||||||||||||||||
| 312 | s->client_finished_secret, hashlen); | - | ||||||||||||||||||||||||
| 313 | } executed 1138 times by 1 test: else {end of blockExecuted by:
| 1138 | ||||||||||||||||||||||||
| 314 | unsigned char finsecret[64]; | - | ||||||||||||||||||||||||
| 315 | - | |||||||||||||||||||||||||
| 316 | if (!tls13_derive_finishedkey(s, ssl_handshake_md(s),
| 0-47 | ||||||||||||||||||||||||
| 317 | s->client_app_traffic_secret,
| 0-47 | ||||||||||||||||||||||||
| 318 | finsecret, hashlen)
| 0-47 | ||||||||||||||||||||||||
| 319 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 320 | - | |||||||||||||||||||||||||
| 321 | key = EVP_PKEY_new_raw_private_key(855, | - | ||||||||||||||||||||||||
| 322 | ((void *)0) | - | ||||||||||||||||||||||||
| 323 | , finsecret, | - | ||||||||||||||||||||||||
| 324 | hashlen); | - | ||||||||||||||||||||||||
| 325 | OPENSSL_cleanse(finsecret, sizeof(finsecret)); | - | ||||||||||||||||||||||||
| 326 | } executed 47 times by 1 test: end of blockExecuted by:
| 47 | ||||||||||||||||||||||||
| 327 | - | |||||||||||||||||||||||||
| 328 | if (key ==
| 0-2614 | ||||||||||||||||||||||||
| 329 | ((void *)0)
| 0-2614 | ||||||||||||||||||||||||
| 330 | - | |||||||||||||||||||||||||
| 331 | || ctx ==
| 0-2614 | ||||||||||||||||||||||||
| 332 | ((void *)0)
| 0-2614 | ||||||||||||||||||||||||
| 333 | - | |||||||||||||||||||||||||
| 334 | || EVP_DigestSignInit(ctx,
| 0-2614 | ||||||||||||||||||||||||
| 335 | ((void *)0)
| 0-2614 | ||||||||||||||||||||||||
| 336 | , md,
| 0-2614 | ||||||||||||||||||||||||
| 337 | ((void *)0)
| 0-2614 | ||||||||||||||||||||||||
| 338 | , key) <= 0
| 0-2614 | ||||||||||||||||||||||||
| 339 | || EVP_DigestUpdate(ctx,hash,hashlen) <= 0
| 0-2614 | ||||||||||||||||||||||||
| 340 | || EVP_DigestSignFinal(ctx, out, &hashlen) <= 0
| 0-2614 | ||||||||||||||||||||||||
| 341 | ossl_statem_fatal((s), (80), (605), ((4|64)), | - | ||||||||||||||||||||||||
| 342 | __FILE__ | - | ||||||||||||||||||||||||
| 343 | , | - | ||||||||||||||||||||||||
| 344 | 283 | - | ||||||||||||||||||||||||
| 345 | ) | - | ||||||||||||||||||||||||
| 346 | ; | - | ||||||||||||||||||||||||
| 347 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 348 | } | - | ||||||||||||||||||||||||
| 349 | - | |||||||||||||||||||||||||
| 350 | ret = hashlen; | - | ||||||||||||||||||||||||
| 351 | err: code before this statement executed 2614 times by 1 test: err:Executed by:
| 2614 | ||||||||||||||||||||||||
| 352 | EVP_PKEY_free(key); | - | ||||||||||||||||||||||||
| 353 | EVP_MD_CTX_free(ctx); | - | ||||||||||||||||||||||||
| 354 | return executed 2614 times by 1 test: ret;return ret;Executed by:
executed 2614 times by 1 test: return ret;Executed by:
| 2614 | ||||||||||||||||||||||||
| 355 | } | - | ||||||||||||||||||||||||
| 356 | - | |||||||||||||||||||||||||
| 357 | - | |||||||||||||||||||||||||
| 358 | - | |||||||||||||||||||||||||
| 359 | - | |||||||||||||||||||||||||
| 360 | - | |||||||||||||||||||||||||
| 361 | int tls13_setup_key_block(SSL *s) | - | ||||||||||||||||||||||||
| 362 | { | - | ||||||||||||||||||||||||
| 363 | const EVP_CIPHER *c; | - | ||||||||||||||||||||||||
| 364 | const EVP_MD *hash; | - | ||||||||||||||||||||||||
| 365 | int mac_type = 0; | - | ||||||||||||||||||||||||
| 366 | - | |||||||||||||||||||||||||
| 367 | s->session->cipher = s->s3->tmp.new_cipher; | - | ||||||||||||||||||||||||
| 368 | if (!ssl_cipher_get_evp
| 0-1471 | ||||||||||||||||||||||||
| 369 | (s->session, &c, &hash, &mac_type,
| 0-1471 | ||||||||||||||||||||||||
| 370 | ((void *)0)
| 0-1471 | ||||||||||||||||||||||||
| 371 | ,
| 0-1471 | ||||||||||||||||||||||||
| 372 | ((void *)0)
| 0-1471 | ||||||||||||||||||||||||
| 373 | , 0)
| 0-1471 | ||||||||||||||||||||||||
| 374 | ossl_statem_fatal((s), (80), (441), (138), | - | ||||||||||||||||||||||||
| 375 | __FILE__ | - | ||||||||||||||||||||||||
| 376 | , | - | ||||||||||||||||||||||||
| 377 | 308 | - | ||||||||||||||||||||||||
| 378 | ) | - | ||||||||||||||||||||||||
| 379 | ; | - | ||||||||||||||||||||||||
| 380 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 381 | } | - | ||||||||||||||||||||||||
| 382 | - | |||||||||||||||||||||||||
| 383 | s->s3->tmp.new_sym_enc = c; | - | ||||||||||||||||||||||||
| 384 | s->s3->tmp.new_hash = hash; | - | ||||||||||||||||||||||||
| 385 | - | |||||||||||||||||||||||||
| 386 | return executed 1471 times by 1 test: 1;return 1;Executed by:
executed 1471 times by 1 test: return 1;Executed by:
| 1471 | ||||||||||||||||||||||||
| 387 | } | - | ||||||||||||||||||||||||
| 388 | - | |||||||||||||||||||||||||
| 389 | static int derive_secret_key_and_iv(SSL *s, int sending, const EVP_MD *md, | - | ||||||||||||||||||||||||
| 390 | const EVP_CIPHER *ciph, | - | ||||||||||||||||||||||||
| 391 | const unsigned char *insecret, | - | ||||||||||||||||||||||||
| 392 | const unsigned char *hash, | - | ||||||||||||||||||||||||
| 393 | const unsigned char *label, | - | ||||||||||||||||||||||||
| 394 | size_t labellen, unsigned char *secret, | - | ||||||||||||||||||||||||
| 395 | unsigned char *iv, EVP_CIPHER_CTX *ciph_ctx) | - | ||||||||||||||||||||||||
| 396 | { | - | ||||||||||||||||||||||||
| 397 | unsigned char key[64]; | - | ||||||||||||||||||||||||
| 398 | size_t ivlen, keylen, taglen; | - | ||||||||||||||||||||||||
| 399 | int hashleni = EVP_MD_size(md); | - | ||||||||||||||||||||||||
| 400 | size_t hashlen; | - | ||||||||||||||||||||||||
| 401 | - | |||||||||||||||||||||||||
| 402 | - | |||||||||||||||||||||||||
| 403 | if (!((hashleni >= 0) != 0)
| 0-5546 | ||||||||||||||||||||||||
| 404 | ossl_statem_fatal((s), (80), (514), (6), | - | ||||||||||||||||||||||||
| 405 | __FILE__ | - | ||||||||||||||||||||||||
| 406 | , | - | ||||||||||||||||||||||||
| 407 | 334 | - | ||||||||||||||||||||||||
| 408 | ) | - | ||||||||||||||||||||||||
| 409 | ; | - | ||||||||||||||||||||||||
| 410 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 411 | } | - | ||||||||||||||||||||||||
| 412 | hashlen = (size_t)hashleni; | - | ||||||||||||||||||||||||
| 413 | - | |||||||||||||||||||||||||
| 414 | if (!tls13_hkdf_expand(s, md, insecret, label, labellen, hash, hashlen,
| 0-5546 | ||||||||||||||||||||||||
| 415 | secret, hashlen)
| 0-5546 | ||||||||||||||||||||||||
| 416 | - | |||||||||||||||||||||||||
| 417 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 418 | } | - | ||||||||||||||||||||||||
| 419 | - | |||||||||||||||||||||||||
| 420 | - | |||||||||||||||||||||||||
| 421 | keylen = EVP_CIPHER_key_length(ciph); | - | ||||||||||||||||||||||||
| 422 | if ((
| 24-5522 | ||||||||||||||||||||||||
| 423 | uint32_t algenc; | - | ||||||||||||||||||||||||
| 424 | - | |||||||||||||||||||||||||
| 425 | ivlen = 12; | - | ||||||||||||||||||||||||
| 426 | if (s->s3->tmp.new_cipher ==
| 0-24 | ||||||||||||||||||||||||
| 427 | ((void *)0)
| 0-24 | ||||||||||||||||||||||||
| 428 | ) { | - | ||||||||||||||||||||||||
| 429 | - | |||||||||||||||||||||||||
| 430 | algenc = s->session->cipher->algorithm_enc; | - | ||||||||||||||||||||||||
| 431 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 432 | algenc = s->s3->tmp.new_cipher->algorithm_enc; | - | ||||||||||||||||||||||||
| 433 | } executed 24 times by 1 test: end of blockExecuted by:
| 24 | ||||||||||||||||||||||||
| 434 | if (algenc & (0x00010000U | 0x00020000U)
| 0-24 | ||||||||||||||||||||||||
| 435 | taglen = 8; never executed: taglen = 8; | 0 | ||||||||||||||||||||||||
| 436 | else | - | ||||||||||||||||||||||||
| 437 | taglen = 16; executed 24 times by 1 test: taglen = 16;Executed by:
| 24 | ||||||||||||||||||||||||
| 438 | } else { | - | ||||||||||||||||||||||||
| 439 | ivlen = EVP_CIPHER_iv_length(ciph); | - | ||||||||||||||||||||||||
| 440 | taglen = 0; | - | ||||||||||||||||||||||||
| 441 | } executed 5522 times by 1 test: end of blockExecuted by:
| 5522 | ||||||||||||||||||||||||
| 442 | - | |||||||||||||||||||||||||
| 443 | if (!tls13_derive_key(s, md, secret, key, keylen)
| 0-5546 | ||||||||||||||||||||||||
| 444 | || !tls13_derive_iv(s, md, secret, iv, ivlen)
| 0-5546 | ||||||||||||||||||||||||
| 445 | - | |||||||||||||||||||||||||
| 446 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 447 | } | - | ||||||||||||||||||||||||
| 448 | - | |||||||||||||||||||||||||
| 449 | if (EVP_CipherInit_ex(ciph_ctx, ciph,
| 0-5546 | ||||||||||||||||||||||||
| 450 | ((void *)0)
| 0-5546 | ||||||||||||||||||||||||
| 451 | ,
| 0-5546 | ||||||||||||||||||||||||
| 452 | ((void *)0)
| 0-5546 | ||||||||||||||||||||||||
| 453 | ,
| 0-5546 | ||||||||||||||||||||||||
| 454 | ((void *)0)
| 0-5546 | ||||||||||||||||||||||||
| 455 | , sending) <= 0
| 0-5546 | ||||||||||||||||||||||||
| 456 | || !EVP_CIPHER_CTX_ctrl(ciph_ctx, 0x9, ivlen,
| 0-5546 | ||||||||||||||||||||||||
| 457 | ((void *)0)
| 0-5546 | ||||||||||||||||||||||||
| 458 | )
| 0-5546 | ||||||||||||||||||||||||
| 459 | || (taglen != 0
| 0-5522 | ||||||||||||||||||||||||
| 460 | taglen,
| 0-24 | ||||||||||||||||||||||||
| 461 | ((void *)0)
| 0-24 | ||||||||||||||||||||||||
| 462 | )
| 0-24 | ||||||||||||||||||||||||
| 463 | || EVP_CipherInit_ex(ciph_ctx,
| 0-5546 | ||||||||||||||||||||||||
| 464 | ((void *)0)
| 0-5546 | ||||||||||||||||||||||||
| 465 | ,
| 0-5546 | ||||||||||||||||||||||||
| 466 | ((void *)0)
| 0-5546 | ||||||||||||||||||||||||
| 467 | , key,
| 0-5546 | ||||||||||||||||||||||||
| 468 | ((void *)0)
| 0-5546 | ||||||||||||||||||||||||
| 469 | , -1) <= 0
| 0-5546 | ||||||||||||||||||||||||
| 470 | ossl_statem_fatal((s), (80), (514), (6), | - | ||||||||||||||||||||||||
| 471 | __FILE__ | - | ||||||||||||||||||||||||
| 472 | , | - | ||||||||||||||||||||||||
| 473 | 378 | - | ||||||||||||||||||||||||
| 474 | ) | - | ||||||||||||||||||||||||
| 475 | ; | - | ||||||||||||||||||||||||
| 476 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 477 | } | - | ||||||||||||||||||||||||
| 478 | - | |||||||||||||||||||||||||
| 479 | return executed 5546 times by 1 test: 1;return 1;Executed by:
executed 5546 times by 1 test: return 1;Executed by:
| 5546 | ||||||||||||||||||||||||
| 480 | err: | - | ||||||||||||||||||||||||
| 481 | OPENSSL_cleanse(key, sizeof(key)); | - | ||||||||||||||||||||||||
| 482 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 483 | } | - | ||||||||||||||||||||||||
| 484 | - | |||||||||||||||||||||||||
| 485 | int tls13_change_cipher_state(SSL *s, int which) | - | ||||||||||||||||||||||||
| 486 | { | - | ||||||||||||||||||||||||
| 487 | static const unsigned char client_early_traffic[] = "c e traffic"; | - | ||||||||||||||||||||||||
| 488 | static const unsigned char client_handshake_traffic[] = "c hs traffic"; | - | ||||||||||||||||||||||||
| 489 | static const unsigned char client_application_traffic[] = "c ap traffic"; | - | ||||||||||||||||||||||||
| 490 | static const unsigned char server_handshake_traffic[] = "s hs traffic"; | - | ||||||||||||||||||||||||
| 491 | static const unsigned char server_application_traffic[] = "s ap traffic"; | - | ||||||||||||||||||||||||
| 492 | static const unsigned char exporter_master_secret[] = "exp master"; | - | ||||||||||||||||||||||||
| 493 | static const unsigned char resumption_master_secret[] = "res master"; | - | ||||||||||||||||||||||||
| 494 | static const unsigned char early_exporter_master_secret[] = "e exp master"; | - | ||||||||||||||||||||||||
| 495 | unsigned char *iv; | - | ||||||||||||||||||||||||
| 496 | unsigned char secret[64]; | - | ||||||||||||||||||||||||
| 497 | unsigned char hashval[64]; | - | ||||||||||||||||||||||||
| 498 | unsigned char *hash = hashval; | - | ||||||||||||||||||||||||
| 499 | unsigned char *insecret; | - | ||||||||||||||||||||||||
| 500 | unsigned char *finsecret = | - | ||||||||||||||||||||||||
| 501 | ((void *)0) | - | ||||||||||||||||||||||||
| 502 | ; | - | ||||||||||||||||||||||||
| 503 | const char *log_label = | - | ||||||||||||||||||||||||
| 504 | ((void *)0) | - | ||||||||||||||||||||||||
| 505 | ; | - | ||||||||||||||||||||||||
| 506 | EVP_CIPHER_CTX *ciph_ctx; | - | ||||||||||||||||||||||||
| 507 | size_t finsecretlen = 0; | - | ||||||||||||||||||||||||
| 508 | const unsigned char *label; | - | ||||||||||||||||||||||||
| 509 | size_t labellen, hashlen = 0; | - | ||||||||||||||||||||||||
| 510 | int ret = 0; | - | ||||||||||||||||||||||||
| 511 | const EVP_MD *md = | - | ||||||||||||||||||||||||
| 512 | ((void *)0) | - | ||||||||||||||||||||||||
| 513 | ; | - | ||||||||||||||||||||||||
| 514 | const EVP_CIPHER *cipher = | - | ||||||||||||||||||||||||
| 515 | ((void *)0) | - | ||||||||||||||||||||||||
| 516 | ; | - | ||||||||||||||||||||||||
| 517 | - | |||||||||||||||||||||||||
| 518 | if (which & 0x001
| 2627-2904 | ||||||||||||||||||||||||
| 519 | if (s->enc_read_ctx !=
| 1156-1471 | ||||||||||||||||||||||||
| 520 | ((void *)0)
| 1156-1471 | ||||||||||||||||||||||||
| 521 | ) { | - | ||||||||||||||||||||||||
| 522 | EVP_CIPHER_CTX_reset(s->enc_read_ctx); | - | ||||||||||||||||||||||||
| 523 | } executed 1156 times by 1 test: else {end of blockExecuted by:
| 1156 | ||||||||||||||||||||||||
| 524 | s->enc_read_ctx = EVP_CIPHER_CTX_new(); | - | ||||||||||||||||||||||||
| 525 | if (s->enc_read_ctx ==
| 0-1471 | ||||||||||||||||||||||||
| 526 | ((void *)0)
| 0-1471 | ||||||||||||||||||||||||
| 527 | ) { | - | ||||||||||||||||||||||||
| 528 | ossl_statem_fatal((s), (80), (440), ((1|64)), | - | ||||||||||||||||||||||||
| 529 | __FILE__ | - | ||||||||||||||||||||||||
| 530 | , | - | ||||||||||||||||||||||||
| 531 | 420 | - | ||||||||||||||||||||||||
| 532 | ) | - | ||||||||||||||||||||||||
| 533 | ; | - | ||||||||||||||||||||||||
| 534 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 535 | } | - | ||||||||||||||||||||||||
| 536 | } executed 1471 times by 1 test: end of blockExecuted by:
| 1471 | ||||||||||||||||||||||||
| 537 | ciph_ctx = s->enc_read_ctx; | - | ||||||||||||||||||||||||
| 538 | iv = s->read_iv; | - | ||||||||||||||||||||||||
| 539 | - | |||||||||||||||||||||||||
| 540 | RECORD_LAYER_reset_read_sequence(&s->rlayer); | - | ||||||||||||||||||||||||
| 541 | } executed 2627 times by 1 test: else {end of blockExecuted by:
| 2627 | ||||||||||||||||||||||||
| 542 | s->statem.enc_write_state = ENC_WRITE_STATE_INVALID; | - | ||||||||||||||||||||||||
| 543 | if (s->enc_write_ctx !=
| 1443-1461 | ||||||||||||||||||||||||
| 544 | ((void *)0)
| 1443-1461 | ||||||||||||||||||||||||
| 545 | ) { | - | ||||||||||||||||||||||||
| 546 | EVP_CIPHER_CTX_reset(s->enc_write_ctx); | - | ||||||||||||||||||||||||
| 547 | } executed 1443 times by 1 test: else {end of blockExecuted by:
| 1443 | ||||||||||||||||||||||||
| 548 | s->enc_write_ctx = EVP_CIPHER_CTX_new(); | - | ||||||||||||||||||||||||
| 549 | if (s->enc_write_ctx ==
| 0-1461 | ||||||||||||||||||||||||
| 550 | ((void *)0)
| 0-1461 | ||||||||||||||||||||||||
| 551 | ) { | - | ||||||||||||||||||||||||
| 552 | ossl_statem_fatal((s), (80), (440), ((1|64)), | - | ||||||||||||||||||||||||
| 553 | __FILE__ | - | ||||||||||||||||||||||||
| 554 | , | - | ||||||||||||||||||||||||
| 555 | 436 | - | ||||||||||||||||||||||||
| 556 | ) | - | ||||||||||||||||||||||||
| 557 | ; | - | ||||||||||||||||||||||||
| 558 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 559 | } | - | ||||||||||||||||||||||||
| 560 | } executed 1461 times by 1 test: end of blockExecuted by:
| 1461 | ||||||||||||||||||||||||
| 561 | ciph_ctx = s->enc_write_ctx; | - | ||||||||||||||||||||||||
| 562 | iv = s->write_iv; | - | ||||||||||||||||||||||||
| 563 | - | |||||||||||||||||||||||||
| 564 | RECORD_LAYER_reset_write_sequence(&s->rlayer); | - | ||||||||||||||||||||||||
| 565 | } executed 2904 times by 1 test: end of blockExecuted by:
| 2904 | ||||||||||||||||||||||||
| 566 | - | |||||||||||||||||||||||||
| 567 | if (((
| 1192-3142 | ||||||||||||||||||||||||
| 568 | || ((
| 1192-3142 | ||||||||||||||||||||||||
| 569 | if (which & 0x040
| 72-2560 | ||||||||||||||||||||||||
| 570 | EVP_MD_CTX *mdctx = | - | ||||||||||||||||||||||||
| 571 | ((void *)0) | - | ||||||||||||||||||||||||
| 572 | ; | - | ||||||||||||||||||||||||
| 573 | long handlen; | - | ||||||||||||||||||||||||
| 574 | void *hdata; | - | ||||||||||||||||||||||||
| 575 | unsigned int hashlenui; | - | ||||||||||||||||||||||||
| 576 | const SSL_CIPHER *sslcipher = SSL_SESSION_get0_cipher(s->session); | - | ||||||||||||||||||||||||
| 577 | - | |||||||||||||||||||||||||
| 578 | insecret = s->early_secret; | - | ||||||||||||||||||||||||
| 579 | label = client_early_traffic; | - | ||||||||||||||||||||||||
| 580 | labellen = sizeof(client_early_traffic) - 1; | - | ||||||||||||||||||||||||
| 581 | log_label = "CLIENT_EARLY_TRAFFIC_SECRET"; | - | ||||||||||||||||||||||||
| 582 | - | |||||||||||||||||||||||||
| 583 | handlen = BIO_ctrl(s->s3->handshake_buffer,3,0,(char *)(&hdata)); | - | ||||||||||||||||||||||||
| 584 | if (handlen <= 0
| 0-72 | ||||||||||||||||||||||||
| 585 | ossl_statem_fatal((s), (80), (440), (332), | - | ||||||||||||||||||||||||
| 586 | - | |||||||||||||||||||||||||
| 587 | __FILE__ | - | ||||||||||||||||||||||||
| 588 | , | - | ||||||||||||||||||||||||
| 589 | - | |||||||||||||||||||||||||
| 590 | 464 | - | ||||||||||||||||||||||||
| 591 | ) | - | ||||||||||||||||||||||||
| 592 | - | |||||||||||||||||||||||||
| 593 | ; | - | ||||||||||||||||||||||||
| 594 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 595 | } | - | ||||||||||||||||||||||||
| 596 | - | |||||||||||||||||||||||||
| 597 | if (s->early_data_state == SSL_EARLY_DATA_CONNECTING
| 22-50 | ||||||||||||||||||||||||
| 598 | && s->max_early_data > 0
| 0-50 | ||||||||||||||||||||||||
| 599 | && s->session->ext.max_early_data == 0
| 12-38 | ||||||||||||||||||||||||
| 600 | - | |||||||||||||||||||||||||
| 601 | - | |||||||||||||||||||||||||
| 602 | - | |||||||||||||||||||||||||
| 603 | - | |||||||||||||||||||||||||
| 604 | - | |||||||||||||||||||||||||
| 605 | if (!((s->psksession !=
| 0-12 | ||||||||||||||||||||||||
| 606 | ((void *)0)
| 0-12 | ||||||||||||||||||||||||
| 607 | && s->max_early_data == s->psksession->ext.max_early_data
| 0-12 | ||||||||||||||||||||||||
| 608 | - | |||||||||||||||||||||||||
| 609 | ) { | - | ||||||||||||||||||||||||
| 610 | ossl_statem_fatal((s), (80), (440), ((4|64)), | - | ||||||||||||||||||||||||
| 611 | - | |||||||||||||||||||||||||
| 612 | __FILE__ | - | ||||||||||||||||||||||||
| 613 | , | - | ||||||||||||||||||||||||
| 614 | - | |||||||||||||||||||||||||
| 615 | 481 | - | ||||||||||||||||||||||||
| 616 | ) | - | ||||||||||||||||||||||||
| 617 | - | |||||||||||||||||||||||||
| 618 | ; | - | ||||||||||||||||||||||||
| 619 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 620 | } | - | ||||||||||||||||||||||||
| 621 | sslcipher = SSL_SESSION_get0_cipher(s->psksession); | - | ||||||||||||||||||||||||
| 622 | } executed 12 times by 1 test: end of blockExecuted by:
| 12 | ||||||||||||||||||||||||
| 623 | if (sslcipher ==
| 0-72 | ||||||||||||||||||||||||
| 624 | ((void *)0)
| 0-72 | ||||||||||||||||||||||||
| 625 | ) { | - | ||||||||||||||||||||||||
| 626 | ossl_statem_fatal((s), (80), (440), (219), | - | ||||||||||||||||||||||||
| 627 | __FILE__ | - | ||||||||||||||||||||||||
| 628 | , | - | ||||||||||||||||||||||||
| 629 | 488 | - | ||||||||||||||||||||||||
| 630 | ) | - | ||||||||||||||||||||||||
| 631 | ; | - | ||||||||||||||||||||||||
| 632 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 633 | } | - | ||||||||||||||||||||||||
| 634 | - | |||||||||||||||||||||||||
| 635 | - | |||||||||||||||||||||||||
| 636 | - | |||||||||||||||||||||||||
| 637 | - | |||||||||||||||||||||||||
| 638 | - | |||||||||||||||||||||||||
| 639 | - | |||||||||||||||||||||||||
| 640 | mdctx = EVP_MD_CTX_new(); | - | ||||||||||||||||||||||||
| 641 | if (mdctx ==
| 0-72 | ||||||||||||||||||||||||
| 642 | ((void *)0)
| 0-72 | ||||||||||||||||||||||||
| 643 | ) { | - | ||||||||||||||||||||||||
| 644 | ossl_statem_fatal((s), (80), (440), ((1|64)), | - | ||||||||||||||||||||||||
| 645 | __FILE__ | - | ||||||||||||||||||||||||
| 646 | , | - | ||||||||||||||||||||||||
| 647 | 500 | - | ||||||||||||||||||||||||
| 648 | ) | - | ||||||||||||||||||||||||
| 649 | ; | - | ||||||||||||||||||||||||
| 650 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 651 | } | - | ||||||||||||||||||||||||
| 652 | cipher = EVP_get_cipherbyname(OBJ_nid2sn(SSL_CIPHER_get_cipher_nid(sslcipher))); | - | ||||||||||||||||||||||||
| 653 | md = ssl_md(sslcipher->algorithm2); | - | ||||||||||||||||||||||||
| 654 | if (md ==
| 0-72 | ||||||||||||||||||||||||
| 655 | ((void *)0)
| 0-72 | ||||||||||||||||||||||||
| 656 | || !EVP_DigestInit_ex(mdctx, md,
| 0-72 | ||||||||||||||||||||||||
| 657 | ((void *)0)
| 0-72 | ||||||||||||||||||||||||
| 658 | )
| 0-72 | ||||||||||||||||||||||||
| 659 | || !EVP_DigestUpdate(mdctx, hdata, handlen)
| 0-72 | ||||||||||||||||||||||||
| 660 | || !EVP_DigestFinal_ex(mdctx, hashval, &hashlenui)
| 0-72 | ||||||||||||||||||||||||
| 661 | ossl_statem_fatal((s), (80), (440), ((4|64)), | - | ||||||||||||||||||||||||
| 662 | __FILE__ | - | ||||||||||||||||||||||||
| 663 | , | - | ||||||||||||||||||||||||
| 664 | 509 | - | ||||||||||||||||||||||||
| 665 | ) | - | ||||||||||||||||||||||||
| 666 | ; | - | ||||||||||||||||||||||||
| 667 | EVP_MD_CTX_free(mdctx); | - | ||||||||||||||||||||||||
| 668 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 669 | } | - | ||||||||||||||||||||||||
| 670 | hashlen = hashlenui; | - | ||||||||||||||||||||||||
| 671 | EVP_MD_CTX_free(mdctx); | - | ||||||||||||||||||||||||
| 672 | - | |||||||||||||||||||||||||
| 673 | if (!tls13_hkdf_expand(s, md, insecret,
| 0-72 | ||||||||||||||||||||||||
| 674 | early_exporter_master_secret,
| 0-72 | ||||||||||||||||||||||||
| 675 | sizeof(early_exporter_master_secret) - 1,
| 0-72 | ||||||||||||||||||||||||
| 676 | hashval, hashlen,
| 0-72 | ||||||||||||||||||||||||
| 677 | s->early_exporter_master_secret, hashlen)
| 0-72 | ||||||||||||||||||||||||
| 678 | ossl_statem_fatal((s), (80), (440), ((4|64)), | - | ||||||||||||||||||||||||
| 679 | __FILE__ | - | ||||||||||||||||||||||||
| 680 | , | - | ||||||||||||||||||||||||
| 681 | 522 | - | ||||||||||||||||||||||||
| 682 | ) | - | ||||||||||||||||||||||||
| 683 | ; | - | ||||||||||||||||||||||||
| 684 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 685 | } | - | ||||||||||||||||||||||||
| 686 | - | |||||||||||||||||||||||||
| 687 | if (!ssl_log_secret(s, "EARLY_EXPORTER_SECRET",
| 0-72 | ||||||||||||||||||||||||
| 688 | s->early_exporter_master_secret, hashlen)
| 0-72 | ||||||||||||||||||||||||
| 689 | - | |||||||||||||||||||||||||
| 690 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 691 | } | - | ||||||||||||||||||||||||
| 692 | } executed 72 times by 1 test: else if (which & 0x080end of blockExecuted by:
| 72-1422 | ||||||||||||||||||||||||
| 693 | insecret = s->handshake_secret; | - | ||||||||||||||||||||||||
| 694 | finsecret = s->client_finished_secret; | - | ||||||||||||||||||||||||
| 695 | finsecretlen = EVP_MD_size(ssl_handshake_md(s)); | - | ||||||||||||||||||||||||
| 696 | label = client_handshake_traffic; | - | ||||||||||||||||||||||||
| 697 | labellen = sizeof(client_handshake_traffic) - 1; | - | ||||||||||||||||||||||||
| 698 | log_label = "CLIENT_HANDSHAKE_TRAFFIC_SECRET"; | - | ||||||||||||||||||||||||
| 699 | hash = s->handshake_traffic_hash; | - | ||||||||||||||||||||||||
| 700 | } executed 1422 times by 1 test: else {end of blockExecuted by:
| 1422 | ||||||||||||||||||||||||
| 701 | insecret = s->master_secret; | - | ||||||||||||||||||||||||
| 702 | label = client_application_traffic; | - | ||||||||||||||||||||||||
| 703 | labellen = sizeof(client_application_traffic) - 1; | - | ||||||||||||||||||||||||
| 704 | log_label = "CLIENT_TRAFFIC_SECRET_0"; | - | ||||||||||||||||||||||||
| 705 | - | |||||||||||||||||||||||||
| 706 | - | |||||||||||||||||||||||||
| 707 | - | |||||||||||||||||||||||||
| 708 | - | |||||||||||||||||||||||||
| 709 | - | |||||||||||||||||||||||||
| 710 | - | |||||||||||||||||||||||||
| 711 | hash = s->server_finished_hash; | - | ||||||||||||||||||||||||
| 712 | } executed 1138 times by 1 test: end of blockExecuted by:
| 1138 | ||||||||||||||||||||||||
| 713 | } else { | - | ||||||||||||||||||||||||
| 714 | - | |||||||||||||||||||||||||
| 715 | if (which & 0x080
| 1428-1471 | ||||||||||||||||||||||||
| 716 | insecret = s->handshake_secret; | - | ||||||||||||||||||||||||
| 717 | finsecret = s->server_finished_secret; | - | ||||||||||||||||||||||||
| 718 | finsecretlen = EVP_MD_size(ssl_handshake_md(s)); | - | ||||||||||||||||||||||||
| 719 | label = server_handshake_traffic; | - | ||||||||||||||||||||||||
| 720 | labellen = sizeof(server_handshake_traffic) - 1; | - | ||||||||||||||||||||||||
| 721 | log_label = "SERVER_HANDSHAKE_TRAFFIC_SECRET"; | - | ||||||||||||||||||||||||
| 722 | } executed 1471 times by 1 test: else {end of blockExecuted by:
| 1471 | ||||||||||||||||||||||||
| 723 | insecret = s->master_secret; | - | ||||||||||||||||||||||||
| 724 | label = server_application_traffic; | - | ||||||||||||||||||||||||
| 725 | labellen = sizeof(server_application_traffic) - 1; | - | ||||||||||||||||||||||||
| 726 | log_label = "SERVER_TRAFFIC_SECRET_0"; | - | ||||||||||||||||||||||||
| 727 | } executed 1428 times by 1 test: end of blockExecuted by:
| 1428 | ||||||||||||||||||||||||
| 728 | } | - | ||||||||||||||||||||||||
| 729 | - | |||||||||||||||||||||||||
| 730 | if (!(which & 0x040)
| 72-5459 | ||||||||||||||||||||||||
| 731 | md = ssl_handshake_md(s); | - | ||||||||||||||||||||||||
| 732 | cipher = s->s3->tmp.new_sym_enc; | - | ||||||||||||||||||||||||
| 733 | if (!ssl3_digest_cached_records(s, 1)
| 0-5459 | ||||||||||||||||||||||||
| 734 | || !ssl_handshake_hash(s, hashval, sizeof(hashval), &hashlen)
| 0-5459 | ||||||||||||||||||||||||
| 735 | ; | - | ||||||||||||||||||||||||
| 736 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 737 | } | - | ||||||||||||||||||||||||
| 738 | } executed 5459 times by 1 test: end of blockExecuted by:
| 5459 | ||||||||||||||||||||||||
| 739 | - | |||||||||||||||||||||||||
| 740 | - | |||||||||||||||||||||||||
| 741 | - | |||||||||||||||||||||||||
| 742 | - | |||||||||||||||||||||||||
| 743 | - | |||||||||||||||||||||||||
| 744 | if (label == server_application_traffic
| 1428-4103 | ||||||||||||||||||||||||
| 745 | memcpy(s->server_finished_hash, hashval, hashlen); executed 1428 times by 1 test: memcpy(s->server_finished_hash, hashval, hashlen);Executed by:
| 1428 | ||||||||||||||||||||||||
| 746 | - | |||||||||||||||||||||||||
| 747 | if (label == server_handshake_traffic
| 1471-4060 | ||||||||||||||||||||||||
| 748 | memcpy(s->handshake_traffic_hash, hashval, hashlen); executed 1471 times by 1 test: memcpy(s->handshake_traffic_hash, hashval, hashlen);Executed by:
| 1471 | ||||||||||||||||||||||||
| 749 | - | |||||||||||||||||||||||||
| 750 | if (label == client_application_traffic
| 1138-4393 | ||||||||||||||||||||||||
| 751 | - | |||||||||||||||||||||||||
| 752 | - | |||||||||||||||||||||||||
| 753 | - | |||||||||||||||||||||||||
| 754 | - | |||||||||||||||||||||||||
| 755 | if (!tls13_hkdf_expand(s, ssl_handshake_md(s), insecret,
| 0-1138 | ||||||||||||||||||||||||
| 756 | resumption_master_secret,
| 0-1138 | ||||||||||||||||||||||||
| 757 | sizeof(resumption_master_secret) - 1,
| 0-1138 | ||||||||||||||||||||||||
| 758 | hashval, hashlen, s->resumption_master_secret,
| 0-1138 | ||||||||||||||||||||||||
| 759 | hashlen)
| 0-1138 | ||||||||||||||||||||||||
| 760 | - | |||||||||||||||||||||||||
| 761 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 762 | } | - | ||||||||||||||||||||||||
| 763 | } executed 1138 times by 1 test: end of blockExecuted by:
| 1138 | ||||||||||||||||||||||||
| 764 | - | |||||||||||||||||||||||||
| 765 | if (!derive_secret_key_and_iv(s, which & 0x002, md, cipher,
| 0-5531 | ||||||||||||||||||||||||
| 766 | insecret, hash, label, labellen, secret, iv,
| 0-5531 | ||||||||||||||||||||||||
| 767 | ciph_ctx)
| 0-5531 | ||||||||||||||||||||||||
| 768 | - | |||||||||||||||||||||||||
| 769 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 770 | } | - | ||||||||||||||||||||||||
| 771 | - | |||||||||||||||||||||||||
| 772 | if (label == server_application_traffic
| 1428-4103 | ||||||||||||||||||||||||
| 773 | memcpy(s->server_app_traffic_secret, secret, hashlen); | - | ||||||||||||||||||||||||
| 774 | - | |||||||||||||||||||||||||
| 775 | if (!tls13_hkdf_expand(s, ssl_handshake_md(s), insecret,
| 0-1428 | ||||||||||||||||||||||||
| 776 | exporter_master_secret,
| 0-1428 | ||||||||||||||||||||||||
| 777 | sizeof(exporter_master_secret) - 1,
| 0-1428 | ||||||||||||||||||||||||
| 778 | hash, hashlen, s->exporter_master_secret,
| 0-1428 | ||||||||||||||||||||||||
| 779 | hashlen)
| 0-1428 | ||||||||||||||||||||||||
| 780 | - | |||||||||||||||||||||||||
| 781 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 782 | } | - | ||||||||||||||||||||||||
| 783 | - | |||||||||||||||||||||||||
| 784 | if (!ssl_log_secret(s, "EXPORTER_SECRET", s->exporter_master_secret,
| 0-1428 | ||||||||||||||||||||||||
| 785 | hashlen)
| 0-1428 | ||||||||||||||||||||||||
| 786 | - | |||||||||||||||||||||||||
| 787 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 788 | } | - | ||||||||||||||||||||||||
| 789 | } executed 1428 times by 1 test: else if (label == client_application_trafficend of blockExecuted by:
| 1138-2965 | ||||||||||||||||||||||||
| 790 | memcpy(s->client_app_traffic_secret, secret, hashlen); executed 1138 times by 1 test: memcpy(s->client_app_traffic_secret, secret, hashlen);Executed by:
| 1138 | ||||||||||||||||||||||||
| 791 | - | |||||||||||||||||||||||||
| 792 | if (!ssl_log_secret(s, log_label, secret, hashlen)
| 0-5531 | ||||||||||||||||||||||||
| 793 | - | |||||||||||||||||||||||||
| 794 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 795 | } | - | ||||||||||||||||||||||||
| 796 | - | |||||||||||||||||||||||||
| 797 | if (finsecret !=
| 2638-2893 | ||||||||||||||||||||||||
| 798 | ((void *)0)
| 2638-2893 | ||||||||||||||||||||||||
| 799 | - | |||||||||||||||||||||||||
| 800 | && !tls13_derive_finishedkey(s, ssl_handshake_md(s), secret,
| 0-2893 | ||||||||||||||||||||||||
| 801 | finsecret, finsecretlen)
| 0-2893 | ||||||||||||||||||||||||
| 802 | - | |||||||||||||||||||||||||
| 803 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 804 | } | - | ||||||||||||||||||||||||
| 805 | - | |||||||||||||||||||||||||
| 806 | if (!s->server
| 50-3142 | ||||||||||||||||||||||||
| 807 | s->statem.enc_write_state = ENC_WRITE_STATE_WRITE_PLAIN_ALERTS; executed 50 times by 1 test: s->statem.enc_write_state = ENC_WRITE_STATE_WRITE_PLAIN_ALERTS;Executed by:
| 50 | ||||||||||||||||||||||||
| 808 | else | - | ||||||||||||||||||||||||
| 809 | s->statem.enc_write_state = ENC_WRITE_STATE_VALID; executed 5481 times by 1 test: s->statem.enc_write_state = ENC_WRITE_STATE_VALID;Executed by:
| 5481 | ||||||||||||||||||||||||
| 810 | ret = 1; | - | ||||||||||||||||||||||||
| 811 | err: code before this statement executed 5531 times by 1 test: err:Executed by:
| 5531 | ||||||||||||||||||||||||
| 812 | OPENSSL_cleanse(secret, sizeof(secret)); | - | ||||||||||||||||||||||||
| 813 | return executed 5531 times by 1 test: ret;return ret;Executed by:
executed 5531 times by 1 test: return ret;Executed by:
| 5531 | ||||||||||||||||||||||||
| 814 | } | - | ||||||||||||||||||||||||
| 815 | - | |||||||||||||||||||||||||
| 816 | int tls13_update_key(SSL *s, int sending) | - | ||||||||||||||||||||||||
| 817 | { | - | ||||||||||||||||||||||||
| 818 | static const unsigned char application_traffic[] = "traffic upd"; | - | ||||||||||||||||||||||||
| 819 | const EVP_MD *md = ssl_handshake_md(s); | - | ||||||||||||||||||||||||
| 820 | size_t hashlen = EVP_MD_size(md); | - | ||||||||||||||||||||||||
| 821 | unsigned char *insecret, *iv; | - | ||||||||||||||||||||||||
| 822 | unsigned char secret[64]; | - | ||||||||||||||||||||||||
| 823 | EVP_CIPHER_CTX *ciph_ctx; | - | ||||||||||||||||||||||||
| 824 | int ret = 0; | - | ||||||||||||||||||||||||
| 825 | - | |||||||||||||||||||||||||
| 826 | if (s->server == sending
| 7-8 | ||||||||||||||||||||||||
| 827 | insecret = s->server_app_traffic_secret; executed 8 times by 1 test: insecret = s->server_app_traffic_secret;Executed by:
| 8 | ||||||||||||||||||||||||
| 828 | else | - | ||||||||||||||||||||||||
| 829 | insecret = s->client_app_traffic_secret; executed 7 times by 1 test: insecret = s->client_app_traffic_secret;Executed by:
| 7 | ||||||||||||||||||||||||
| 830 | - | |||||||||||||||||||||||||
| 831 | if (sending
| 7-8 | ||||||||||||||||||||||||
| 832 | s->statem.enc_write_state = ENC_WRITE_STATE_INVALID; | - | ||||||||||||||||||||||||
| 833 | iv = s->write_iv; | - | ||||||||||||||||||||||||
| 834 | ciph_ctx = s->enc_write_ctx; | - | ||||||||||||||||||||||||
| 835 | RECORD_LAYER_reset_write_sequence(&s->rlayer); | - | ||||||||||||||||||||||||
| 836 | } executed 8 times by 1 test: else {end of blockExecuted by:
| 8 | ||||||||||||||||||||||||
| 837 | iv = s->read_iv; | - | ||||||||||||||||||||||||
| 838 | ciph_ctx = s->enc_read_ctx; | - | ||||||||||||||||||||||||
| 839 | RECORD_LAYER_reset_read_sequence(&s->rlayer); | - | ||||||||||||||||||||||||
| 840 | } executed 7 times by 1 test: end of blockExecuted by:
| 7 | ||||||||||||||||||||||||
| 841 | - | |||||||||||||||||||||||||
| 842 | if (!derive_secret_key_and_iv(s, sending, ssl_handshake_md(s),
| 0-15 | ||||||||||||||||||||||||
| 843 | s->s3->tmp.new_sym_enc, insecret,
| 0-15 | ||||||||||||||||||||||||
| 844 | ((void *)0)
| 0-15 | ||||||||||||||||||||||||
| 845 | ,
| 0-15 | ||||||||||||||||||||||||
| 846 | application_traffic,
| 0-15 | ||||||||||||||||||||||||
| 847 | sizeof(application_traffic) - 1, secret, iv,
| 0-15 | ||||||||||||||||||||||||
| 848 | ciph_ctx)
| 0-15 | ||||||||||||||||||||||||
| 849 | - | |||||||||||||||||||||||||
| 850 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 851 | } | - | ||||||||||||||||||||||||
| 852 | - | |||||||||||||||||||||||||
| 853 | memcpy(insecret, secret, hashlen); | - | ||||||||||||||||||||||||
| 854 | - | |||||||||||||||||||||||||
| 855 | s->statem.enc_write_state = ENC_WRITE_STATE_VALID; | - | ||||||||||||||||||||||||
| 856 | ret = 1; | - | ||||||||||||||||||||||||
| 857 | err: code before this statement executed 15 times by 1 test: err:Executed by:
| 15 | ||||||||||||||||||||||||
| 858 | OPENSSL_cleanse(secret, sizeof(secret)); | - | ||||||||||||||||||||||||
| 859 | return executed 15 times by 1 test: ret;return ret;Executed by:
executed 15 times by 1 test: return ret;Executed by:
| 15 | ||||||||||||||||||||||||
| 860 | } | - | ||||||||||||||||||||||||
| 861 | - | |||||||||||||||||||||||||
| 862 | int tls13_alert_code(int code) | - | ||||||||||||||||||||||||
| 863 | { | - | ||||||||||||||||||||||||
| 864 | - | |||||||||||||||||||||||||
| 865 | if (code == 109
| 2-1320 | ||||||||||||||||||||||||
| 866 | return executed 24 times by 1 test: code;return code;Executed by:
executed 24 times by 1 test: return code;Executed by:
| 24 | ||||||||||||||||||||||||
| 867 | - | |||||||||||||||||||||||||
| 868 | return executed 1318 times by 1 test: tls1_alert_code(code);return tls1_alert_code(code);Executed by:
executed 1318 times by 1 test: return tls1_alert_code(code);Executed by:
| 1318 | ||||||||||||||||||||||||
| 869 | } | - | ||||||||||||||||||||||||
| 870 | - | |||||||||||||||||||||||||
| 871 | int tls13_export_keying_material(SSL *s, unsigned char *out, size_t olen, | - | ||||||||||||||||||||||||
| 872 | const char *label, size_t llen, | - | ||||||||||||||||||||||||
| 873 | const unsigned char *context, | - | ||||||||||||||||||||||||
| 874 | size_t contextlen, int use_context) | - | ||||||||||||||||||||||||
| 875 | { | - | ||||||||||||||||||||||||
| 876 | unsigned char exportsecret[64]; | - | ||||||||||||||||||||||||
| 877 | static const unsigned char exporterlabel[] = "exporter"; | - | ||||||||||||||||||||||||
| 878 | unsigned char hash[64], data[64]; | - | ||||||||||||||||||||||||
| 879 | const EVP_MD *md = ssl_handshake_md(s); | - | ||||||||||||||||||||||||
| 880 | EVP_MD_CTX *ctx = EVP_MD_CTX_new(); | - | ||||||||||||||||||||||||
| 881 | unsigned int hashsize, datalen; | - | ||||||||||||||||||||||||
| 882 | int ret = 0; | - | ||||||||||||||||||||||||
| 883 | - | |||||||||||||||||||||||||
| 884 | if (ctx ==
| 0-6 | ||||||||||||||||||||||||
| 885 | ((void *)0)
| 0-6 | ||||||||||||||||||||||||
| 886 | || !ossl_statem_export_allowed(s)
| 0-6 | ||||||||||||||||||||||||
| 887 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 888 | - | |||||||||||||||||||||||||
| 889 | if (!use_context
| 2-4 | ||||||||||||||||||||||||
| 890 | contextlen = 0; executed 2 times by 1 test: contextlen = 0;Executed by:
| 2 | ||||||||||||||||||||||||
| 891 | - | |||||||||||||||||||||||||
| 892 | if (EVP_DigestInit_ex(ctx, md,
| 0-6 | ||||||||||||||||||||||||
| 893 | ((void *)0)
| 0-6 | ||||||||||||||||||||||||
| 894 | ) <= 0
| 0-6 | ||||||||||||||||||||||||
| 895 | || EVP_DigestUpdate(ctx, context, contextlen) <= 0
| 0-6 | ||||||||||||||||||||||||
| 896 | || EVP_DigestFinal_ex(ctx, hash, &hashsize) <= 0
| 0-6 | ||||||||||||||||||||||||
| 897 | || EVP_DigestInit_ex(ctx, md,
| 0-6 | ||||||||||||||||||||||||
| 898 | ((void *)0)
| 0-6 | ||||||||||||||||||||||||
| 899 | ) <= 0
| 0-6 | ||||||||||||||||||||||||
| 900 | || EVP_DigestFinal_ex(ctx, data, &datalen) <= 0
| 0-6 | ||||||||||||||||||||||||
| 901 | || !tls13_hkdf_expand(s, md, s->exporter_master_secret,
| 0-6 | ||||||||||||||||||||||||
| 902 | (const unsigned char *)label, llen,
| 0-6 | ||||||||||||||||||||||||
| 903 | data, datalen, exportsecret, hashsize)
| 0-6 | ||||||||||||||||||||||||
| 904 | || !tls13_hkdf_expand(s, md, exportsecret, exporterlabel,
| 0-6 | ||||||||||||||||||||||||
| 905 | sizeof(exporterlabel) - 1, hash, hashsize,
| 0-6 | ||||||||||||||||||||||||
| 906 | out, olen)
| 0-6 | ||||||||||||||||||||||||
| 907 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 908 | - | |||||||||||||||||||||||||
| 909 | ret = 1; | - | ||||||||||||||||||||||||
| 910 | err: code before this statement executed 6 times by 1 test: err:Executed by:
| 6 | ||||||||||||||||||||||||
| 911 | EVP_MD_CTX_free(ctx); | - | ||||||||||||||||||||||||
| 912 | return executed 6 times by 1 test: ret;return ret;Executed by:
executed 6 times by 1 test: return ret;Executed by:
| 6 | ||||||||||||||||||||||||
| 913 | } | - | ||||||||||||||||||||||||
| 914 | - | |||||||||||||||||||||||||
| 915 | int tls13_export_keying_material_early(SSL *s, unsigned char *out, size_t olen, | - | ||||||||||||||||||||||||
| 916 | const char *label, size_t llen, | - | ||||||||||||||||||||||||
| 917 | const unsigned char *context, | - | ||||||||||||||||||||||||
| 918 | size_t contextlen) | - | ||||||||||||||||||||||||
| 919 | { | - | ||||||||||||||||||||||||
| 920 | static const unsigned char exporterlabel[] = "exporter"; | - | ||||||||||||||||||||||||
| 921 | unsigned char exportsecret[64]; | - | ||||||||||||||||||||||||
| 922 | unsigned char hash[64], data[64]; | - | ||||||||||||||||||||||||
| 923 | const EVP_MD *md; | - | ||||||||||||||||||||||||
| 924 | EVP_MD_CTX *ctx = EVP_MD_CTX_new(); | - | ||||||||||||||||||||||||
| 925 | unsigned int hashsize, datalen; | - | ||||||||||||||||||||||||
| 926 | int ret = 0; | - | ||||||||||||||||||||||||
| 927 | const SSL_CIPHER *sslcipher; | - | ||||||||||||||||||||||||
| 928 | - | |||||||||||||||||||||||||
| 929 | if (ctx ==
| 0-12 | ||||||||||||||||||||||||
| 930 | ((void *)0)
| 0-12 | ||||||||||||||||||||||||
| 931 | || !ossl_statem_export_early_allowed(s)
| 0-12 | ||||||||||||||||||||||||
| 932 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 933 | - | |||||||||||||||||||||||||
| 934 | if (!s->server
| 0-6 | ||||||||||||||||||||||||
| 935 | && s->session->ext.max_early_data == 0
| 2-4 | ||||||||||||||||||||||||
| 936 | sslcipher = SSL_SESSION_get0_cipher(s->psksession); executed 2 times by 1 test: sslcipher = SSL_SESSION_get0_cipher(s->psksession);Executed by:
| 2 | ||||||||||||||||||||||||
| 937 | else | - | ||||||||||||||||||||||||
| 938 | sslcipher = SSL_SESSION_get0_cipher(s->session); executed 10 times by 1 test: sslcipher = SSL_SESSION_get0_cipher(s->session);Executed by:
| 10 | ||||||||||||||||||||||||
| 939 | - | |||||||||||||||||||||||||
| 940 | md = ssl_md(sslcipher->algorithm2); | - | ||||||||||||||||||||||||
| 941 | if (EVP_DigestInit_ex(ctx, md,
| 0-12 | ||||||||||||||||||||||||
| 942 | ((void *)0)
| 0-12 | ||||||||||||||||||||||||
| 943 | ) <= 0
| 0-12 | ||||||||||||||||||||||||
| 944 | || EVP_DigestUpdate(ctx, context, contextlen) <= 0
| 0-12 | ||||||||||||||||||||||||
| 945 | || EVP_DigestFinal_ex(ctx, hash, &hashsize) <= 0
| 0-12 | ||||||||||||||||||||||||
| 946 | || EVP_DigestInit_ex(ctx, md,
| 0-12 | ||||||||||||||||||||||||
| 947 | ((void *)0)
| 0-12 | ||||||||||||||||||||||||
| 948 | ) <= 0
| 0-12 | ||||||||||||||||||||||||
| 949 | || EVP_DigestFinal_ex(ctx, data, &datalen) <= 0
| 0-12 | ||||||||||||||||||||||||
| 950 | || !tls13_hkdf_expand(s, md, s->early_exporter_master_secret,
| 0-12 | ||||||||||||||||||||||||
| 951 | (const unsigned char *)label, llen,
| 0-12 | ||||||||||||||||||||||||
| 952 | data, datalen, exportsecret, hashsize)
| 0-12 | ||||||||||||||||||||||||
| 953 | || !tls13_hkdf_expand(s, md, exportsecret, exporterlabel,
| 0-12 | ||||||||||||||||||||||||
| 954 | sizeof(exporterlabel) - 1, hash, hashsize,
| 0-12 | ||||||||||||||||||||||||
| 955 | out, olen)
| 0-12 | ||||||||||||||||||||||||
| 956 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 957 | - | |||||||||||||||||||||||||
| 958 | ret = 1; | - | ||||||||||||||||||||||||
| 959 | err: code before this statement executed 12 times by 1 test: err:Executed by:
| 12 | ||||||||||||||||||||||||
| 960 | EVP_MD_CTX_free(ctx); | - | ||||||||||||||||||||||||
| 961 | return executed 12 times by 1 test: ret;return ret;Executed by:
executed 12 times by 1 test: return ret;Executed by:
| 12 | ||||||||||||||||||||||||
| 962 | } | - | ||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |