| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/ssl/s3_cbc.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||
| 2 | static void tls1_md5_final_raw(void *ctx, unsigned char *md_out) | - | ||||||||||||
| 3 | { | - | ||||||||||||
| 4 | MD5_CTX *md5 = ctx; | - | ||||||||||||
| 5 | (*((md_out)++)=(unsigned char)(md5->A), *((md_out)++)=(unsigned char)(md5->A>>8), *((md_out)++)=(unsigned char)(md5->A>>16), *((md_out)++)=(unsigned char)(md5->A>>24)); | - | ||||||||||||
| 6 | (*((md_out)++)=(unsigned char)(md5->B), *((md_out)++)=(unsigned char)(md5->B>>8), *((md_out)++)=(unsigned char)(md5->B>>16), *((md_out)++)=(unsigned char)(md5->B>>24)); | - | ||||||||||||
| 7 | (*((md_out)++)=(unsigned char)(md5->C), *((md_out)++)=(unsigned char)(md5->C>>8), *((md_out)++)=(unsigned char)(md5->C>>16), *((md_out)++)=(unsigned char)(md5->C>>24)); | - | ||||||||||||
| 8 | (*((md_out)++)=(unsigned char)(md5->D), *((md_out)++)=(unsigned char)(md5->D>>8), *((md_out)++)=(unsigned char)(md5->D>>16), *((md_out)++)=(unsigned char)(md5->D>>24)); | - | ||||||||||||
| 9 | } never executed: end of block | 0 | ||||||||||||
| 10 | - | |||||||||||||
| 11 | static void tls1_sha1_final_raw(void *ctx, unsigned char *md_out) | - | ||||||||||||
| 12 | { | - | ||||||||||||
| 13 | SHA_CTX *sha1 = ctx; | - | ||||||||||||
| 14 | (*((md_out)++)=(unsigned char)(((sha1->h0)>>24)&0xff), *((md_out)++)=(unsigned char)(((sha1->h0)>>16)&0xff), *((md_out)++)=(unsigned char)(((sha1->h0)>> 8)&0xff), *((md_out)++)=(unsigned char)(((sha1->h0) )&0xff)); | - | ||||||||||||
| 15 | (*((md_out)++)=(unsigned char)(((sha1->h1)>>24)&0xff), *((md_out)++)=(unsigned char)(((sha1->h1)>>16)&0xff), *((md_out)++)=(unsigned char)(((sha1->h1)>> 8)&0xff), *((md_out)++)=(unsigned char)(((sha1->h1) )&0xff)); | - | ||||||||||||
| 16 | (*((md_out)++)=(unsigned char)(((sha1->h2)>>24)&0xff), *((md_out)++)=(unsigned char)(((sha1->h2)>>16)&0xff), *((md_out)++)=(unsigned char)(((sha1->h2)>> 8)&0xff), *((md_out)++)=(unsigned char)(((sha1->h2) )&0xff)); | - | ||||||||||||
| 17 | (*((md_out)++)=(unsigned char)(((sha1->h3)>>24)&0xff), *((md_out)++)=(unsigned char)(((sha1->h3)>>16)&0xff), *((md_out)++)=(unsigned char)(((sha1->h3)>> 8)&0xff), *((md_out)++)=(unsigned char)(((sha1->h3) )&0xff)); | - | ||||||||||||
| 18 | (*((md_out)++)=(unsigned char)(((sha1->h4)>>24)&0xff), *((md_out)++)=(unsigned char)(((sha1->h4)>>16)&0xff), *((md_out)++)=(unsigned char)(((sha1->h4)>> 8)&0xff), *((md_out)++)=(unsigned char)(((sha1->h4) )&0xff)); | - | ||||||||||||
| 19 | } executed 1078 times by 1 test: end of blockExecuted by:
| 1078 | ||||||||||||
| 20 | - | |||||||||||||
| 21 | static void tls1_sha256_final_raw(void *ctx, unsigned char *md_out) | - | ||||||||||||
| 22 | { | - | ||||||||||||
| 23 | SHA256_CTX *sha256 = ctx; | - | ||||||||||||
| 24 | unsigned i; | - | ||||||||||||
| 25 | - | |||||||||||||
| 26 | for (i = 0; i < 8
| 364-2912 | ||||||||||||
| 27 | (*((md_out)++)=(unsigned char)(((sha256->h[i])>>24)&0xff), *((md_out)++)=(unsigned char)(((sha256->h[i])>>16)&0xff), *((md_out)++)=(unsigned char)(((sha256->h[i])>> 8)&0xff), *((md_out)++)=(unsigned char)(((sha256->h[i]) )&0xff)); | - | ||||||||||||
| 28 | } executed 2912 times by 1 test: end of blockExecuted by:
| 2912 | ||||||||||||
| 29 | } executed 364 times by 1 test: end of blockExecuted by:
| 364 | ||||||||||||
| 30 | - | |||||||||||||
| 31 | static void tls1_sha512_final_raw(void *ctx, unsigned char *md_out) | - | ||||||||||||
| 32 | { | - | ||||||||||||
| 33 | SHA512_CTX *sha512 = ctx; | - | ||||||||||||
| 34 | unsigned i; | - | ||||||||||||
| 35 | - | |||||||||||||
| 36 | for (i = 0; i < 8
| 105-840 | ||||||||||||
| 37 | (*((md_out)++)=(unsigned char)(((sha512->h[i])>>56)&0xff), *((md_out)++)=(unsigned char)(((sha512->h[i])>>48)&0xff), *((md_out)++)=(unsigned char)(((sha512->h[i])>>40)&0xff), *((md_out)++)=(unsigned char)(((sha512->h[i])>>32)&0xff), *((md_out)++)=(unsigned char)(((sha512->h[i])>>24)&0xff), *((md_out)++)=(unsigned char)(((sha512->h[i])>>16)&0xff), *((md_out)++)=(unsigned char)(((sha512->h[i])>> 8)&0xff), *((md_out)++)=(unsigned char)(((sha512->h[i]) )&0xff)); | - | ||||||||||||
| 38 | } executed 840 times by 1 test: end of blockExecuted by:
| 840 | ||||||||||||
| 39 | } executed 105 times by 1 test: end of blockExecuted by:
| 105 | ||||||||||||
| 40 | char ssl3_cbc_record_digest_supported(const EVP_MD_CTX *ctx) | - | ||||||||||||
| 41 | { | - | ||||||||||||
| 42 | switch (EVP_MD_type(EVP_MD_CTX_md(ctx))) { | - | ||||||||||||
| 43 | case never executed: 4:case 4:never executed: case 4: | 0 | ||||||||||||
| 44 | case executed 154 times by 1 test: 64:case 64:Executed by:
executed 154 times by 1 test: case 64:Executed by:
| 154 | ||||||||||||
| 45 | case never executed: 675:case 675:never executed: case 675: | 0 | ||||||||||||
| 46 | case executed 52 times by 1 test: 672:case 672:Executed by:
executed 52 times by 1 test: case 672:Executed by:
| 52 | ||||||||||||
| 47 | case executed 15 times by 1 test: 673:case 673:Executed by:
executed 15 times by 1 test: case 673:Executed by:
| 15 | ||||||||||||
| 48 | case never executed: 674:case 674:never executed: case 674: | 0 | ||||||||||||
| 49 | return executed 221 times by 1 test: 1;return 1;Executed by:
executed 221 times by 1 test: return 1;Executed by:
| 221 | ||||||||||||
| 50 | default never executed: :default:never executed: default: | 0 | ||||||||||||
| 51 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 52 | } | - | ||||||||||||
| 53 | } | - | ||||||||||||
| 54 | int ssl3_cbc_digest_record(const EVP_MD_CTX *ctx, | - | ||||||||||||
| 55 | unsigned char *md_out, | - | ||||||||||||
| 56 | size_t *md_out_size, | - | ||||||||||||
| 57 | const unsigned char header[13], | - | ||||||||||||
| 58 | const unsigned char *data, | - | ||||||||||||
| 59 | size_t data_plus_mac_size, | - | ||||||||||||
| 60 | size_t data_plus_mac_plus_padding_size, | - | ||||||||||||
| 61 | const unsigned char *mac_secret, | - | ||||||||||||
| 62 | size_t mac_secret_length, char is_sslv3) | - | ||||||||||||
| 63 | { | - | ||||||||||||
| 64 | union { | - | ||||||||||||
| 65 | double align; | - | ||||||||||||
| 66 | unsigned char c[sizeof(SHA512_CTX)]; | - | ||||||||||||
| 67 | } md_state; | - | ||||||||||||
| 68 | void (*md_final_raw) (void *ctx, unsigned char *md_out); | - | ||||||||||||
| 69 | void (*md_transform) (void *ctx, const unsigned char *block); | - | ||||||||||||
| 70 | size_t md_size, md_block_size = 64; | - | ||||||||||||
| 71 | size_t sslv3_pad_length = 40, header_length, variance_blocks, | - | ||||||||||||
| 72 | len, max_mac_bytes, num_blocks, | - | ||||||||||||
| 73 | num_starting_blocks, k, mac_end_offset, c, index_a, index_b; | - | ||||||||||||
| 74 | size_t bits; | - | ||||||||||||
| 75 | unsigned char length_bytes[16]; | - | ||||||||||||
| 76 | - | |||||||||||||
| 77 | unsigned char hmac_pad[128]; | - | ||||||||||||
| 78 | unsigned char first_block[128]; | - | ||||||||||||
| 79 | unsigned char mac_out[64]; | - | ||||||||||||
| 80 | size_t i, j; | - | ||||||||||||
| 81 | unsigned md_out_size_u; | - | ||||||||||||
| 82 | EVP_MD_CTX *md_ctx = | - | ||||||||||||
| 83 | ((void *)0) | - | ||||||||||||
| 84 | ; | - | ||||||||||||
| 85 | - | |||||||||||||
| 86 | - | |||||||||||||
| 87 | - | |||||||||||||
| 88 | - | |||||||||||||
| 89 | size_t md_length_size = 8; | - | ||||||||||||
| 90 | char length_is_big_endian = 1; | - | ||||||||||||
| 91 | int ret; | - | ||||||||||||
| 92 | - | |||||||||||||
| 93 | - | |||||||||||||
| 94 | - | |||||||||||||
| 95 | - | |||||||||||||
| 96 | - | |||||||||||||
| 97 | if (!((data_plus_mac_plus_padding_size < 1024 * 1024) != 0)
| 0-221 | ||||||||||||
| 98 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 99 | - | |||||||||||||
| 100 | switch (EVP_MD_type(EVP_MD_CTX_md(ctx))) { | - | ||||||||||||
| 101 | case never executed: 4:case 4:never executed: case 4: | 0 | ||||||||||||
| 102 | if (MD5_Init((MD5_CTX *)md_state.c) <= 0
| 0 | ||||||||||||
| 103 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 104 | md_final_raw = tls1_md5_final_raw; | - | ||||||||||||
| 105 | md_transform = | - | ||||||||||||
| 106 | (void (*)(void *ctx, const unsigned char *block))MD5_Transform; | - | ||||||||||||
| 107 | md_size = 16; | - | ||||||||||||
| 108 | sslv3_pad_length = 48; | - | ||||||||||||
| 109 | length_is_big_endian = 0; | - | ||||||||||||
| 110 | break; never executed: break; | 0 | ||||||||||||
| 111 | case executed 154 times by 1 test: 64:case 64:Executed by:
executed 154 times by 1 test: case 64:Executed by:
| 154 | ||||||||||||
| 112 | if (SHA1_Init((SHA_CTX *)md_state.c) <= 0
| 0-154 | ||||||||||||
| 113 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 114 | md_final_raw = tls1_sha1_final_raw; | - | ||||||||||||
| 115 | md_transform = | - | ||||||||||||
| 116 | (void (*)(void *ctx, const unsigned char *block))SHA1_Transform; | - | ||||||||||||
| 117 | md_size = 20; | - | ||||||||||||
| 118 | break; executed 154 times by 1 test: break;Executed by:
| 154 | ||||||||||||
| 119 | case never executed: 675:case 675:never executed: case 675: | 0 | ||||||||||||
| 120 | if (SHA224_Init((SHA256_CTX *)md_state.c) <= 0
| 0 | ||||||||||||
| 121 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 122 | md_final_raw = tls1_sha256_final_raw; | - | ||||||||||||
| 123 | md_transform = | - | ||||||||||||
| 124 | (void (*)(void *ctx, const unsigned char *block))SHA256_Transform; | - | ||||||||||||
| 125 | md_size = 224 / 8; | - | ||||||||||||
| 126 | break; never executed: break; | 0 | ||||||||||||
| 127 | case executed 52 times by 1 test: 672:case 672:Executed by:
executed 52 times by 1 test: case 672:Executed by:
| 52 | ||||||||||||
| 128 | if (SHA256_Init((SHA256_CTX *)md_state.c) <= 0
| 0-52 | ||||||||||||
| 129 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 130 | md_final_raw = tls1_sha256_final_raw; | - | ||||||||||||
| 131 | md_transform = | - | ||||||||||||
| 132 | (void (*)(void *ctx, const unsigned char *block))SHA256_Transform; | - | ||||||||||||
| 133 | md_size = 32; | - | ||||||||||||
| 134 | break; executed 52 times by 1 test: break;Executed by:
| 52 | ||||||||||||
| 135 | case executed 15 times by 1 test: 673:case 673:Executed by:
executed 15 times by 1 test: case 673:Executed by:
| 15 | ||||||||||||
| 136 | if (SHA384_Init((SHA512_CTX *)md_state.c) <= 0
| 0-15 | ||||||||||||
| 137 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 138 | md_final_raw = tls1_sha512_final_raw; | - | ||||||||||||
| 139 | md_transform = | - | ||||||||||||
| 140 | (void (*)(void *ctx, const unsigned char *block))SHA512_Transform; | - | ||||||||||||
| 141 | md_size = 384 / 8; | - | ||||||||||||
| 142 | md_block_size = 128; | - | ||||||||||||
| 143 | md_length_size = 16; | - | ||||||||||||
| 144 | break; executed 15 times by 1 test: break;Executed by:
| 15 | ||||||||||||
| 145 | case never executed: 674:case 674:never executed: case 674: | 0 | ||||||||||||
| 146 | if (SHA512_Init((SHA512_CTX *)md_state.c) <= 0
| 0 | ||||||||||||
| 147 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 148 | md_final_raw = tls1_sha512_final_raw; | - | ||||||||||||
| 149 | md_transform = | - | ||||||||||||
| 150 | (void (*)(void *ctx, const unsigned char *block))SHA512_Transform; | - | ||||||||||||
| 151 | md_size = 64; | - | ||||||||||||
| 152 | md_block_size = 128; | - | ||||||||||||
| 153 | md_length_size = 16; | - | ||||||||||||
| 154 | break; never executed: break; | 0 | ||||||||||||
| 155 | default never executed: :default:never executed: default: | 0 | ||||||||||||
| 156 | - | |||||||||||||
| 157 | - | |||||||||||||
| 158 | - | |||||||||||||
| 159 | - | |||||||||||||
| 160 | if (md_out_size !=
| 0 | ||||||||||||
| 161 | ((void *)0)
| 0 | ||||||||||||
| 162 | ) | - | ||||||||||||
| 163 | * never executed: md_out_size = 0;*md_out_size = 0;never executed: *md_out_size = 0; | 0 | ||||||||||||
| 164 | return never executed: ((0) != 0);return ((0) != 0);never executed: return ((0) != 0); | 0 | ||||||||||||
| 165 | } | - | ||||||||||||
| 166 | - | |||||||||||||
| 167 | if (!((md_length_size <= 16) != 0)
| 0-221 | ||||||||||||
| 168 | || !((md_block_size <= 128) != 0)
| 0-221 | ||||||||||||
| 169 | || !((md_size <= 64) != 0)
| 0-221 | ||||||||||||
| 170 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 171 | - | |||||||||||||
| 172 | header_length = 13; | - | ||||||||||||
| 173 | if (is_sslv3
| 0-221 | ||||||||||||
| 174 | header_length = mac_secret_length + sslv3_pad_length + 8 | - | ||||||||||||
| 175 | + | - | ||||||||||||
| 176 | 1 + | - | ||||||||||||
| 177 | 2 ; | - | ||||||||||||
| 178 | } never executed: end of block | 0 | ||||||||||||
| 179 | variance_blocks = is_sslv3
| 0-221 | ||||||||||||
| 180 | - | |||||||||||||
| 181 | - | |||||||||||||
| 182 | - | |||||||||||||
| 183 | - | |||||||||||||
| 184 | - | |||||||||||||
| 185 | len = data_plus_mac_plus_padding_size + header_length; | - | ||||||||||||
| 186 | - | |||||||||||||
| 187 | - | |||||||||||||
| 188 | - | |||||||||||||
| 189 | - | |||||||||||||
| 190 | max_mac_bytes = len - md_size - 1; | - | ||||||||||||
| 191 | - | |||||||||||||
| 192 | num_blocks = | - | ||||||||||||
| 193 | (max_mac_bytes + 1 + md_length_size + md_block_size - | - | ||||||||||||
| 194 | 1) / md_block_size; | - | ||||||||||||
| 195 | num_starting_blocks = 0; | - | ||||||||||||
| 196 | - | |||||||||||||
| 197 | - | |||||||||||||
| 198 | - | |||||||||||||
| 199 | - | |||||||||||||
| 200 | k = 0; | - | ||||||||||||
| 201 | - | |||||||||||||
| 202 | - | |||||||||||||
| 203 | - | |||||||||||||
| 204 | mac_end_offset = data_plus_mac_size + header_length - md_size; | - | ||||||||||||
| 205 | - | |||||||||||||
| 206 | - | |||||||||||||
| 207 | - | |||||||||||||
| 208 | - | |||||||||||||
| 209 | c = mac_end_offset % md_block_size; | - | ||||||||||||
| 210 | - | |||||||||||||
| 211 | - | |||||||||||||
| 212 | - | |||||||||||||
| 213 | - | |||||||||||||
| 214 | index_a = mac_end_offset / md_block_size; | - | ||||||||||||
| 215 | - | |||||||||||||
| 216 | - | |||||||||||||
| 217 | - | |||||||||||||
| 218 | - | |||||||||||||
| 219 | index_b = (mac_end_offset + md_length_size) / md_block_size; | - | ||||||||||||
| 220 | if (num_blocks > variance_blocks + (is_sslv3
| 0-221 | ||||||||||||
| 221 | num_starting_blocks = num_blocks - variance_blocks; | - | ||||||||||||
| 222 | k = md_block_size * num_starting_blocks; | - | ||||||||||||
| 223 | } executed 34 times by 1 test: end of blockExecuted by:
| 34 | ||||||||||||
| 224 | - | |||||||||||||
| 225 | bits = 8 * mac_end_offset; | - | ||||||||||||
| 226 | if (!is_sslv3
| 0-221 | ||||||||||||
| 227 | - | |||||||||||||
| 228 | - | |||||||||||||
| 229 | - | |||||||||||||
| 230 | - | |||||||||||||
| 231 | - | |||||||||||||
| 232 | bits += 8 * md_block_size; | - | ||||||||||||
| 233 | memset(hmac_pad, 0, md_block_size); | - | ||||||||||||
| 234 | if (!((mac_secret_length <= sizeof(hmac_pad)) != 0)
| 0-221 | ||||||||||||
| 235 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 236 | memcpy(hmac_pad, mac_secret, mac_secret_length); | - | ||||||||||||
| 237 | for (i = 0; i < md_block_size
| 221-15104 | ||||||||||||
| 238 | hmac_pad[i] ^= 0x36; executed 15104 times by 1 test: hmac_pad[i] ^= 0x36;Executed by:
| 15104 | ||||||||||||
| 239 | - | |||||||||||||
| 240 | md_transform(md_state.c, hmac_pad); | - | ||||||||||||
| 241 | } executed 221 times by 1 test: end of blockExecuted by:
| 221 | ||||||||||||
| 242 | - | |||||||||||||
| 243 | if (length_is_big_endian
| 0-221 | ||||||||||||
| 244 | memset(length_bytes, 0, md_length_size - 4); | - | ||||||||||||
| 245 | length_bytes[md_length_size - 4] = (unsigned char)(bits >> 24); | - | ||||||||||||
| 246 | length_bytes[md_length_size - 3] = (unsigned char)(bits >> 16); | - | ||||||||||||
| 247 | length_bytes[md_length_size - 2] = (unsigned char)(bits >> 8); | - | ||||||||||||
| 248 | length_bytes[md_length_size - 1] = (unsigned char)bits; | - | ||||||||||||
| 249 | } executed 221 times by 1 test: else {end of blockExecuted by:
| 221 | ||||||||||||
| 250 | memset(length_bytes, 0, md_length_size); | - | ||||||||||||
| 251 | length_bytes[md_length_size - 5] = (unsigned char)(bits >> 24); | - | ||||||||||||
| 252 | length_bytes[md_length_size - 6] = (unsigned char)(bits >> 16); | - | ||||||||||||
| 253 | length_bytes[md_length_size - 7] = (unsigned char)(bits >> 8); | - | ||||||||||||
| 254 | length_bytes[md_length_size - 8] = (unsigned char)bits; | - | ||||||||||||
| 255 | } never executed: end of block | 0 | ||||||||||||
| 256 | - | |||||||||||||
| 257 | if (k > 0
| 34-187 | ||||||||||||
| 258 | if (is_sslv3
| 0-34 | ||||||||||||
| 259 | size_t overhang; | - | ||||||||||||
| 260 | if (header_length <= md_block_size
| 0 | ||||||||||||
| 261 | - | |||||||||||||
| 262 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 263 | } | - | ||||||||||||
| 264 | overhang = header_length - md_block_size; | - | ||||||||||||
| 265 | md_transform(md_state.c, header); | - | ||||||||||||
| 266 | memcpy(first_block, header + md_block_size, overhang); | - | ||||||||||||
| 267 | memcpy(first_block + overhang, data, md_block_size - overhang); | - | ||||||||||||
| 268 | md_transform(md_state.c, first_block); | - | ||||||||||||
| 269 | for (i = 1; i < k / md_block_size - 1
| 0 | ||||||||||||
| 270 | md_transform(md_state.c, data + md_block_size * i - overhang); never executed: md_transform(md_state.c, data + md_block_size * i - overhang); | 0 | ||||||||||||
| 271 | } never executed: else {end of block | 0 | ||||||||||||
| 272 | - | |||||||||||||
| 273 | memcpy(first_block, header, 13); | - | ||||||||||||
| 274 | memcpy(first_block + 13, data, md_block_size - 13); | - | ||||||||||||
| 275 | md_transform(md_state.c, first_block); | - | ||||||||||||
| 276 | for (i = 1; i < k / md_block_size
| 34-2730 | ||||||||||||
| 277 | md_transform(md_state.c, data + md_block_size * i - 13); executed 2730 times by 1 test: md_transform(md_state.c, data + md_block_size * i - 13);Executed by:
| 2730 | ||||||||||||
| 278 | } executed 34 times by 1 test: end of blockExecuted by:
| 34 | ||||||||||||
| 279 | } | - | ||||||||||||
| 280 | - | |||||||||||||
| 281 | memset(mac_out, 0, sizeof(mac_out)); | - | ||||||||||||
| 282 | - | |||||||||||||
| 283 | - | |||||||||||||
| 284 | - | |||||||||||||
| 285 | - | |||||||||||||
| 286 | - | |||||||||||||
| 287 | - | |||||||||||||
| 288 | - | |||||||||||||
| 289 | for (i = num_starting_blocks; i <= num_starting_blocks + variance_blocks
| 221-1547 | ||||||||||||
| 290 | i++) { | - | ||||||||||||
| 291 | unsigned char block[128]; | - | ||||||||||||
| 292 | unsigned char is_block_a = constant_time_eq_8_s(i, index_a); | - | ||||||||||||
| 293 | unsigned char is_block_b = constant_time_eq_8_s(i, index_b); | - | ||||||||||||
| 294 | for (j = 0; j < md_block_size
| 1547-105728 | ||||||||||||
| 295 | unsigned char b = 0, is_past_c, is_past_cp1; | - | ||||||||||||
| 296 | if (k < header_length
| 2431-103297 | ||||||||||||
| 297 | b = header[k]; executed 2431 times by 1 test: b = header[k];Executed by:
| 2431 | ||||||||||||
| 298 | else if (k < data_plus_mac_plus_padding_size + header_length
| 36786-66511 | ||||||||||||
| 299 | b = data[k - header_length]; executed 36786 times by 1 test: b = data[k - header_length];Executed by:
| 36786 | ||||||||||||
| 300 | k++; | - | ||||||||||||
| 301 | - | |||||||||||||
| 302 | is_past_c = is_block_a & constant_time_ge_8_s(j, c); | - | ||||||||||||
| 303 | is_past_cp1 = is_block_a & constant_time_ge_8_s(j, c + 1); | - | ||||||||||||
| 304 | - | |||||||||||||
| 305 | - | |||||||||||||
| 306 | - | |||||||||||||
| 307 | - | |||||||||||||
| 308 | - | |||||||||||||
| 309 | b = constant_time_select_8(is_past_c, 0x80, b); | - | ||||||||||||
| 310 | - | |||||||||||||
| 311 | - | |||||||||||||
| 312 | - | |||||||||||||
| 313 | - | |||||||||||||
| 314 | b = b & ~is_past_cp1; | - | ||||||||||||
| 315 | - | |||||||||||||
| 316 | - | |||||||||||||
| 317 | - | |||||||||||||
| 318 | - | |||||||||||||
| 319 | - | |||||||||||||
| 320 | b &= ~is_block_b | is_block_a; | - | ||||||||||||
| 321 | - | |||||||||||||
| 322 | - | |||||||||||||
| 323 | - | |||||||||||||
| 324 | - | |||||||||||||
| 325 | if (j >= md_block_size - md_length_size
| 13216-92512 | ||||||||||||
| 326 | - | |||||||||||||
| 327 | b = constant_time_select_8(is_block_b, | - | ||||||||||||
| 328 | length_bytes[j - | - | ||||||||||||
| 329 | (md_block_size - | - | ||||||||||||
| 330 | md_length_size)], b); | - | ||||||||||||
| 331 | } executed 13216 times by 1 test: end of blockExecuted by:
| 13216 | ||||||||||||
| 332 | block[j] = b; | - | ||||||||||||
| 333 | } executed 105728 times by 1 test: end of blockExecuted by:
| 105728 | ||||||||||||
| 334 | - | |||||||||||||
| 335 | md_transform(md_state.c, block); | - | ||||||||||||
| 336 | md_final_raw(md_state.c, block); | - | ||||||||||||
| 337 | - | |||||||||||||
| 338 | for (j = 0; j < md_size
| 1547-38248 | ||||||||||||
| 339 | mac_out[j] |= block[j] & is_block_b; executed 38248 times by 1 test: mac_out[j] |= block[j] & is_block_b;Executed by:
| 38248 | ||||||||||||
| 340 | } executed 1547 times by 1 test: end of blockExecuted by:
| 1547 | ||||||||||||
| 341 | - | |||||||||||||
| 342 | md_ctx = EVP_MD_CTX_new(); | - | ||||||||||||
| 343 | if (md_ctx ==
| 0-221 | ||||||||||||
| 344 | ((void *)0)
| 0-221 | ||||||||||||
| 345 | ) | - | ||||||||||||
| 346 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||
| 347 | if (EVP_DigestInit_ex(md_ctx, EVP_MD_CTX_md(ctx),
| 0-221 | ||||||||||||
| 348 | ((void *)0)
| 0-221 | ||||||||||||
| 349 | ) <= 0
| 0-221 | ||||||||||||
| 350 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||
| 351 | if (is_sslv3
| 0-221 | ||||||||||||
| 352 | - | |||||||||||||
| 353 | memset(hmac_pad, 0x5c, sslv3_pad_length); | - | ||||||||||||
| 354 | - | |||||||||||||
| 355 | if (EVP_DigestUpdate(md_ctx, mac_secret, mac_secret_length) <= 0
| 0 | ||||||||||||
| 356 | || EVP_DigestUpdate(md_ctx, hmac_pad, sslv3_pad_length) <= 0
| 0 | ||||||||||||
| 357 | || EVP_DigestUpdate(md_ctx, mac_out, md_size) <= 0
| 0 | ||||||||||||
| 358 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||
| 359 | } never executed: else {end of block | 0 | ||||||||||||
| 360 | - | |||||||||||||
| 361 | for (i = 0; i < md_block_size
| 221-15104 | ||||||||||||
| 362 | hmac_pad[i] ^= 0x6a; executed 15104 times by 1 test: hmac_pad[i] ^= 0x6a;Executed by:
| 15104 | ||||||||||||
| 363 | - | |||||||||||||
| 364 | if (EVP_DigestUpdate(md_ctx, hmac_pad, md_block_size) <= 0
| 0-221 | ||||||||||||
| 365 | || EVP_DigestUpdate(md_ctx, mac_out, md_size) <= 0
| 0-221 | ||||||||||||
| 366 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||
| 367 | } executed 221 times by 1 test: end of blockExecuted by:
| 221 | ||||||||||||
| 368 | - | |||||||||||||
| 369 | ret = EVP_DigestFinal(md_ctx, md_out, &md_out_size_u); | - | ||||||||||||
| 370 | if (ret
| 0-221 | ||||||||||||
| 371 | * executed 221 times by 1 test: md_out_size = md_out_size_u;*md_out_size = md_out_size_u;Executed by:
executed 221 times by 1 test: *md_out_size = md_out_size_u;Executed by:
| 221 | ||||||||||||
| 372 | EVP_MD_CTX_free(md_ctx); | - | ||||||||||||
| 373 | - | |||||||||||||
| 374 | return executed 221 times by 1 test: 1;return 1;Executed by:
executed 221 times by 1 test: return 1;Executed by:
| 221 | ||||||||||||
| 375 | err: | - | ||||||||||||
| 376 | EVP_MD_CTX_free(md_ctx); | - | ||||||||||||
| 377 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 378 | } | - | ||||||||||||
| Switch to Source code | Preprocessed file |