| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/evp/e_chacha20_poly1305.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||
| 2 | - | |||||||||||||||||||
| 3 | - | |||||||||||||||||||
| 4 | - | |||||||||||||||||||
| 5 | - | |||||||||||||||||||
| 6 | typedef struct { | - | ||||||||||||||||||
| 7 | union { | - | ||||||||||||||||||
| 8 | double align; | - | ||||||||||||||||||
| 9 | unsigned int d[32 / 4]; | - | ||||||||||||||||||
| 10 | } key; | - | ||||||||||||||||||
| 11 | unsigned int counter[16 / 4]; | - | ||||||||||||||||||
| 12 | unsigned char buf[64]; | - | ||||||||||||||||||
| 13 | unsigned int partial_len; | - | ||||||||||||||||||
| 14 | } EVP_CHACHA_KEY; | - | ||||||||||||||||||
| 15 | - | |||||||||||||||||||
| 16 | - | |||||||||||||||||||
| 17 | - | |||||||||||||||||||
| 18 | static int chacha_init_key(EVP_CIPHER_CTX *ctx, | - | ||||||||||||||||||
| 19 | const unsigned char user_key[32], | - | ||||||||||||||||||
| 20 | const unsigned char iv[16], int enc) | - | ||||||||||||||||||
| 21 | { | - | ||||||||||||||||||
| 22 | EVP_CHACHA_KEY *key = ((EVP_CHACHA_KEY *)(ctx)->cipher_data); | - | ||||||||||||||||||
| 23 | unsigned int i; | - | ||||||||||||||||||
| 24 | - | |||||||||||||||||||
| 25 | if (user_key
| 8866-13171 | ||||||||||||||||||
| 26 | for (i = 0; i < 32
| 13171-105368 | ||||||||||||||||||
| 27 | key->key.d[i/4] = ( ((unsigned int)(user_key+i)[0]) | ((unsigned int)(user_key+i)[1]<<8) | ((unsigned int)(user_key+i)[2]<<16) | ((unsigned int)(user_key+i)[3]<<24) ); | - | ||||||||||||||||||
| 28 | } executed 105368 times by 1 test: end of blockExecuted by:
| 105368 | ||||||||||||||||||
| 29 | - | |||||||||||||||||||
| 30 | if (iv
| 6861-15176 | ||||||||||||||||||
| 31 | for (i = 0; i < 16
| 15176-60704 | ||||||||||||||||||
| 32 | key->counter[i/4] = ( ((unsigned int)(iv+i)[0]) | ((unsigned int)(iv+i)[1]<<8) | ((unsigned int)(iv+i)[2]<<16) | ((unsigned int)(iv+i)[3]<<24) ); | - | ||||||||||||||||||
| 33 | } executed 60704 times by 1 test: end of blockExecuted by:
| 60704 | ||||||||||||||||||
| 34 | - | |||||||||||||||||||
| 35 | key->partial_len = 0; | - | ||||||||||||||||||
| 36 | - | |||||||||||||||||||
| 37 | return executed 22037 times by 1 test: 1;return 1;Executed by:
executed 22037 times by 1 test: return 1;Executed by:
| 22037 | ||||||||||||||||||
| 38 | } | - | ||||||||||||||||||
| 39 | - | |||||||||||||||||||
| 40 | static int chacha_cipher(EVP_CIPHER_CTX * ctx, unsigned char *out, | - | ||||||||||||||||||
| 41 | const unsigned char *inp, size_t len) | - | ||||||||||||||||||
| 42 | { | - | ||||||||||||||||||
| 43 | EVP_CHACHA_KEY *key = ((EVP_CHACHA_KEY *)(ctx)->cipher_data); | - | ||||||||||||||||||
| 44 | unsigned int n, rem, ctr32; | - | ||||||||||||||||||
| 45 | - | |||||||||||||||||||
| 46 | if ((
| 16632-29675 | ||||||||||||||||||
| 47 | while (len
| 1812-546996 | ||||||||||||||||||
| 48 | *out++ = *inp++ ^ key->buf[n++]; | - | ||||||||||||||||||
| 49 | len--; | - | ||||||||||||||||||
| 50 | } executed 532176 times by 1 test: end of blockExecuted by:
| 532176 | ||||||||||||||||||
| 51 | key->partial_len = n; | - | ||||||||||||||||||
| 52 | - | |||||||||||||||||||
| 53 | if (len == 0
| 1812-14820 | ||||||||||||||||||
| 54 | return executed 1812 times by 1 test: 1;return 1;Executed by:
executed 1812 times by 1 test: return 1;Executed by:
| 1812 | ||||||||||||||||||
| 55 | - | |||||||||||||||||||
| 56 | if (n == 64
| 0-14820 | ||||||||||||||||||
| 57 | key->partial_len = 0; | - | ||||||||||||||||||
| 58 | key->counter[0]++; | - | ||||||||||||||||||
| 59 | if (key->counter[0] == 0
| 0-14820 | ||||||||||||||||||
| 60 | key->counter[1]++; never executed: key->counter[1]++; | 0 | ||||||||||||||||||
| 61 | } executed 14820 times by 1 test: end of blockExecuted by:
| 14820 | ||||||||||||||||||
| 62 | } executed 14820 times by 1 test: end of blockExecuted by:
| 14820 | ||||||||||||||||||
| 63 | - | |||||||||||||||||||
| 64 | rem = (unsigned int)(len % 64); | - | ||||||||||||||||||
| 65 | len -= rem; | - | ||||||||||||||||||
| 66 | ctr32 = key->counter[0]; | - | ||||||||||||||||||
| 67 | while (len >= 64
| 36005-44495 | ||||||||||||||||||
| 68 | size_t blocks = len / 64; | - | ||||||||||||||||||
| 69 | - | |||||||||||||||||||
| 70 | - | |||||||||||||||||||
| 71 | - | |||||||||||||||||||
| 72 | - | |||||||||||||||||||
| 73 | - | |||||||||||||||||||
| 74 | if (sizeof(size_t)>sizeof(unsigned int)
| 0-36005 | ||||||||||||||||||
| 75 | blocks = (1U<<28); never executed: blocks = (1U<<28); | 0 | ||||||||||||||||||
| 76 | - | |||||||||||||||||||
| 77 | - | |||||||||||||||||||
| 78 | - | |||||||||||||||||||
| 79 | - | |||||||||||||||||||
| 80 | - | |||||||||||||||||||
| 81 | - | |||||||||||||||||||
| 82 | - | |||||||||||||||||||
| 83 | ctr32 += (unsigned int)blocks; | - | ||||||||||||||||||
| 84 | if (ctr32 < blocks
| 0-36005 | ||||||||||||||||||
| 85 | blocks -= ctr32; | - | ||||||||||||||||||
| 86 | ctr32 = 0; | - | ||||||||||||||||||
| 87 | } never executed: end of block | 0 | ||||||||||||||||||
| 88 | blocks *= 64; | - | ||||||||||||||||||
| 89 | ChaCha20_ctr32(out, inp, blocks, key->key.d, key->counter); | - | ||||||||||||||||||
| 90 | len -= blocks; | - | ||||||||||||||||||
| 91 | inp += blocks; | - | ||||||||||||||||||
| 92 | out += blocks; | - | ||||||||||||||||||
| 93 | - | |||||||||||||||||||
| 94 | key->counter[0] = ctr32; | - | ||||||||||||||||||
| 95 | if (ctr32 == 0
never executed: key->counter[1]++; | 0-36005 | ||||||||||||||||||
| 96 | } executed 36005 times by 1 test: end of blockExecuted by:
| 36005 | ||||||||||||||||||
| 97 | - | |||||||||||||||||||
| 98 | if (rem
| 19403-25092 | ||||||||||||||||||
| 99 | memset(key->buf, 0, sizeof(key->buf)); | - | ||||||||||||||||||
| 100 | ChaCha20_ctr32(key->buf, key->buf, 64, | - | ||||||||||||||||||
| 101 | key->key.d, key->counter); | - | ||||||||||||||||||
| 102 | for (n = 0; n < rem
| 25092-661326 | ||||||||||||||||||
| 103 | out[n] = inp[n] ^ key->buf[n]; executed 661326 times by 1 test: out[n] = inp[n] ^ key->buf[n];Executed by:
| 661326 | ||||||||||||||||||
| 104 | key->partial_len = rem; | - | ||||||||||||||||||
| 105 | } executed 25092 times by 1 test: end of blockExecuted by:
| 25092 | ||||||||||||||||||
| 106 | - | |||||||||||||||||||
| 107 | return executed 44495 times by 1 test: 1;return 1;Executed by:
executed 44495 times by 1 test: return 1;Executed by:
| 44495 | ||||||||||||||||||
| 108 | } | - | ||||||||||||||||||
| 109 | - | |||||||||||||||||||
| 110 | static const EVP_CIPHER chacha20 = { | - | ||||||||||||||||||
| 111 | 1019, | - | ||||||||||||||||||
| 112 | 1, | - | ||||||||||||||||||
| 113 | 32, | - | ||||||||||||||||||
| 114 | 16, | - | ||||||||||||||||||
| 115 | 0x10 | 0x20, | - | ||||||||||||||||||
| 116 | chacha_init_key, | - | ||||||||||||||||||
| 117 | chacha_cipher, | - | ||||||||||||||||||
| 118 | - | |||||||||||||||||||
| 119 | ((void *)0) | - | ||||||||||||||||||
| 120 | , | - | ||||||||||||||||||
| 121 | sizeof(EVP_CHACHA_KEY), | - | ||||||||||||||||||
| 122 | - | |||||||||||||||||||
| 123 | ((void *)0) | - | ||||||||||||||||||
| 124 | , | - | ||||||||||||||||||
| 125 | - | |||||||||||||||||||
| 126 | ((void *)0) | - | ||||||||||||||||||
| 127 | , | - | ||||||||||||||||||
| 128 | - | |||||||||||||||||||
| 129 | ((void *)0) | - | ||||||||||||||||||
| 130 | , | - | ||||||||||||||||||
| 131 | - | |||||||||||||||||||
| 132 | ((void *)0) | - | ||||||||||||||||||
| 133 | - | |||||||||||||||||||
| 134 | }; | - | ||||||||||||||||||
| 135 | - | |||||||||||||||||||
| 136 | const EVP_CIPHER *EVP_chacha20(void) | - | ||||||||||||||||||
| 137 | { | - | ||||||||||||||||||
| 138 | return executed 1964 times by 1 test: &chacha20;return &chacha20;Executed by:
executed 1964 times by 1 test: return &chacha20;Executed by:
| 1964 | ||||||||||||||||||
| 139 | } | - | ||||||||||||||||||
| 140 | - | |||||||||||||||||||
| 141 | - | |||||||||||||||||||
| 142 | - | |||||||||||||||||||
| 143 | typedef struct { | - | ||||||||||||||||||
| 144 | EVP_CHACHA_KEY key; | - | ||||||||||||||||||
| 145 | unsigned int nonce[12/4]; | - | ||||||||||||||||||
| 146 | unsigned char tag[16]; | - | ||||||||||||||||||
| 147 | unsigned char tls_aad[16]; | - | ||||||||||||||||||
| 148 | struct { uint64_t aad, text; } len; | - | ||||||||||||||||||
| 149 | int aad, mac_inited, tag_len, nonce_len; | - | ||||||||||||||||||
| 150 | size_t tls_payload_length; | - | ||||||||||||||||||
| 151 | } EVP_CHACHA_AEAD_CTX; | - | ||||||||||||||||||
| 152 | - | |||||||||||||||||||
| 153 | - | |||||||||||||||||||
| 154 | - | |||||||||||||||||||
| 155 | - | |||||||||||||||||||
| 156 | - | |||||||||||||||||||
| 157 | static int chacha20_poly1305_init_key(EVP_CIPHER_CTX *ctx, | - | ||||||||||||||||||
| 158 | const unsigned char *inkey, | - | ||||||||||||||||||
| 159 | const unsigned char *iv, int enc) | - | ||||||||||||||||||
| 160 | { | - | ||||||||||||||||||
| 161 | EVP_CHACHA_AEAD_CTX *actx = ((EVP_CHACHA_AEAD_CTX *)(ctx)->cipher_data); | - | ||||||||||||||||||
| 162 | - | |||||||||||||||||||
| 163 | if (!inkey
| 456-8936 | ||||||||||||||||||
| 164 | return executed 456 times by 1 test: 1;return 1;Executed by:
executed 456 times by 1 test: return 1;Executed by:
| 456 | ||||||||||||||||||
| 165 | - | |||||||||||||||||||
| 166 | actx->len.aad = 0; | - | ||||||||||||||||||
| 167 | actx->len.text = 0; | - | ||||||||||||||||||
| 168 | actx->aad = 0; | - | ||||||||||||||||||
| 169 | actx->mac_inited = 0; | - | ||||||||||||||||||
| 170 | actx->tls_payload_length = ((size_t)-1); | - | ||||||||||||||||||
| 171 | - | |||||||||||||||||||
| 172 | if (iv !=
| 3405-11720 | ||||||||||||||||||
| 173 | ((void *)0)
| 3405-11720 | ||||||||||||||||||
| 174 | ) { | - | ||||||||||||||||||
| 175 | unsigned char temp[16] = { 0 }; | - | ||||||||||||||||||
| 176 | - | |||||||||||||||||||
| 177 | - | |||||||||||||||||||
| 178 | if (actx->nonce_len <= 16
| 0-11720 | ||||||||||||||||||
| 179 | memcpy(temp + 16 - actx->nonce_len, iv, executed 11720 times by 1 test: memcpy(temp + 16 - actx->nonce_len, iv, actx->nonce_len);Executed by:
| 11720 | ||||||||||||||||||
| 180 | actx->nonce_len); executed 11720 times by 1 test: memcpy(temp + 16 - actx->nonce_len, iv, actx->nonce_len);Executed by:
| 11720 | ||||||||||||||||||
| 181 | - | |||||||||||||||||||
| 182 | chacha_init_key(ctx, inkey, temp, enc); | - | ||||||||||||||||||
| 183 | - | |||||||||||||||||||
| 184 | actx->nonce[0] = actx->key.counter[1]; | - | ||||||||||||||||||
| 185 | actx->nonce[1] = actx->key.counter[2]; | - | ||||||||||||||||||
| 186 | actx->nonce[2] = actx->key.counter[3]; | - | ||||||||||||||||||
| 187 | } executed 11720 times by 1 test: else {end of blockExecuted by:
| 11720 | ||||||||||||||||||
| 188 | chacha_init_key(ctx, inkey, | - | ||||||||||||||||||
| 189 | ((void *)0) | - | ||||||||||||||||||
| 190 | , enc); | - | ||||||||||||||||||
| 191 | } executed 3405 times by 1 test: end of blockExecuted by:
| 3405 | ||||||||||||||||||
| 192 | - | |||||||||||||||||||
| 193 | return executed 15125 times by 1 test: 1;return 1;Executed by:
executed 15125 times by 1 test: return 1;Executed by:
| 15125 | ||||||||||||||||||
| 194 | } | - | ||||||||||||||||||
| 195 | - | |||||||||||||||||||
| 196 | - | |||||||||||||||||||
| 197 | - | |||||||||||||||||||
| 198 | - | |||||||||||||||||||
| 199 | - | |||||||||||||||||||
| 200 | - | |||||||||||||||||||
| 201 | void *xor128_encrypt_n_pad(void *out, const void *inp, void *otp, size_t len); | - | ||||||||||||||||||
| 202 | void *xor128_decrypt_n_pad(void *out, const void *inp, void *otp, size_t len); | - | ||||||||||||||||||
| 203 | static const unsigned char zero[4 * 64] = { 0 }; | - | ||||||||||||||||||
| 204 | - | |||||||||||||||||||
| 205 | - | |||||||||||||||||||
| 206 | - | |||||||||||||||||||
| 207 | - | |||||||||||||||||||
| 208 | static int chacha20_poly1305_tls_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | - | ||||||||||||||||||
| 209 | const unsigned char *in, size_t len) | - | ||||||||||||||||||
| 210 | { | - | ||||||||||||||||||
| 211 | EVP_CHACHA_AEAD_CTX *actx = ((EVP_CHACHA_AEAD_CTX *)(ctx)->cipher_data); | - | ||||||||||||||||||
| 212 | size_t tail, tohash_len, buf_len, plen = actx->tls_payload_length; | - | ||||||||||||||||||
| 213 | unsigned char *buf, *tohash, *ctr, storage[sizeof(zero) + 32]; | - | ||||||||||||||||||
| 214 | - | |||||||||||||||||||
| 215 | if (len != plen + 16
| 0-110 | ||||||||||||||||||
| 216 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||
| 217 | - | |||||||||||||||||||
| 218 | buf = storage + ((0 - (size_t)storage) & 15); | - | ||||||||||||||||||
| 219 | ctr = buf + 64; | - | ||||||||||||||||||
| 220 | tohash = buf + 64 - 16; | - | ||||||||||||||||||
| 221 | - | |||||||||||||||||||
| 222 | - | |||||||||||||||||||
| 223 | if (plen <= 3 * 64
| 53-57 | ||||||||||||||||||
| 224 | actx->key.counter[0] = 0; | - | ||||||||||||||||||
| 225 | buf_len = (plen + 2 * 64 - 1) & (0 - 64); | - | ||||||||||||||||||
| 226 | ChaCha20_ctr32(buf, zero, buf_len, actx->key.key.d, | - | ||||||||||||||||||
| 227 | actx->key.counter); | - | ||||||||||||||||||
| 228 | Poly1305_Init(((POLY1305 *)(actx + 1)), buf); | - | ||||||||||||||||||
| 229 | actx->key.partial_len = 0; | - | ||||||||||||||||||
| 230 | memcpy(tohash, actx->tls_aad, 16); | - | ||||||||||||||||||
| 231 | tohash_len = 16; | - | ||||||||||||||||||
| 232 | actx->len.aad = 13; | - | ||||||||||||||||||
| 233 | actx->len.text = plen; | - | ||||||||||||||||||
| 234 | - | |||||||||||||||||||
| 235 | if (plen
| 1-56 | ||||||||||||||||||
| 236 | if (ctx->encrypt
| 25-31 | ||||||||||||||||||
| 237 | ctr = xor128_encrypt_n_pad(out, in, ctr, plen); executed 25 times by 1 test: ctr = xor128_encrypt_n_pad(out, in, ctr, plen);Executed by:
| 25 | ||||||||||||||||||
| 238 | else | - | ||||||||||||||||||
| 239 | ctr = xor128_decrypt_n_pad(out, in, ctr, plen); executed 31 times by 1 test: ctr = xor128_decrypt_n_pad(out, in, ctr, plen);Executed by:
| 31 | ||||||||||||||||||
| 240 | - | |||||||||||||||||||
| 241 | in += plen; | - | ||||||||||||||||||
| 242 | out += plen; | - | ||||||||||||||||||
| 243 | tohash_len = (size_t)(ctr - tohash); | - | ||||||||||||||||||
| 244 | } executed 56 times by 1 test: end of blockExecuted by:
| 56 | ||||||||||||||||||
| 245 | } executed 57 times by 1 test: end of blockExecuted by:
| 57 | ||||||||||||||||||
| 246 | else { | - | ||||||||||||||||||
| 247 | actx->key.counter[0] = 0; | - | ||||||||||||||||||
| 248 | ChaCha20_ctr32(buf, zero, (buf_len = 64), | - | ||||||||||||||||||
| 249 | actx->key.key.d, actx->key.counter); | - | ||||||||||||||||||
| 250 | Poly1305_Init(((POLY1305 *)(actx + 1)), buf); | - | ||||||||||||||||||
| 251 | actx->key.counter[0] = 1; | - | ||||||||||||||||||
| 252 | actx->key.partial_len = 0; | - | ||||||||||||||||||
| 253 | Poly1305_Update(((POLY1305 *)(actx + 1)), actx->tls_aad, 16); | - | ||||||||||||||||||
| 254 | tohash = ctr; | - | ||||||||||||||||||
| 255 | tohash_len = 0; | - | ||||||||||||||||||
| 256 | actx->len.aad = 13; | - | ||||||||||||||||||
| 257 | actx->len.text = plen; | - | ||||||||||||||||||
| 258 | - | |||||||||||||||||||
| 259 | if (ctx->encrypt
| 13-40 | ||||||||||||||||||
| 260 | ChaCha20_ctr32(out, in, plen, actx->key.key.d, actx->key.counter); | - | ||||||||||||||||||
| 261 | Poly1305_Update(((POLY1305 *)(actx + 1)), out, plen); | - | ||||||||||||||||||
| 262 | } executed 40 times by 1 test: else {end of blockExecuted by:
| 40 | ||||||||||||||||||
| 263 | Poly1305_Update(((POLY1305 *)(actx + 1)), in, plen); | - | ||||||||||||||||||
| 264 | ChaCha20_ctr32(out, in, plen, actx->key.key.d, actx->key.counter); | - | ||||||||||||||||||
| 265 | } executed 13 times by 1 test: end of blockExecuted by:
| 13 | ||||||||||||||||||
| 266 | - | |||||||||||||||||||
| 267 | in += plen; | - | ||||||||||||||||||
| 268 | out += plen; | - | ||||||||||||||||||
| 269 | tail = (0 - plen) & (16 - 1); | - | ||||||||||||||||||
| 270 | Poly1305_Update(((POLY1305 *)(actx + 1)), zero, tail); | - | ||||||||||||||||||
| 271 | } executed 53 times by 1 test: end of blockExecuted by:
| 53 | ||||||||||||||||||
| 272 | - | |||||||||||||||||||
| 273 | { | - | ||||||||||||||||||
| 274 | const union { | - | ||||||||||||||||||
| 275 | long one; | - | ||||||||||||||||||
| 276 | char little; | - | ||||||||||||||||||
| 277 | } is_endian = { 1 }; | - | ||||||||||||||||||
| 278 | - | |||||||||||||||||||
| 279 | if (is_endian.little
| 0-110 | ||||||||||||||||||
| 280 | memcpy(ctr, (unsigned char *)&actx->len, 16); | - | ||||||||||||||||||
| 281 | } executed 110 times by 1 test: else {end of blockExecuted by:
| 110 | ||||||||||||||||||
| 282 | ctr[0] = (unsigned char)(actx->len.aad); | - | ||||||||||||||||||
| 283 | ctr[1] = (unsigned char)(actx->len.aad>>8); | - | ||||||||||||||||||
| 284 | ctr[2] = (unsigned char)(actx->len.aad>>16); | - | ||||||||||||||||||
| 285 | ctr[3] = (unsigned char)(actx->len.aad>>24); | - | ||||||||||||||||||
| 286 | ctr[4] = (unsigned char)(actx->len.aad>>32); | - | ||||||||||||||||||
| 287 | ctr[5] = (unsigned char)(actx->len.aad>>40); | - | ||||||||||||||||||
| 288 | ctr[6] = (unsigned char)(actx->len.aad>>48); | - | ||||||||||||||||||
| 289 | ctr[7] = (unsigned char)(actx->len.aad>>56); | - | ||||||||||||||||||
| 290 | - | |||||||||||||||||||
| 291 | ctr[8] = (unsigned char)(actx->len.text); | - | ||||||||||||||||||
| 292 | ctr[9] = (unsigned char)(actx->len.text>>8); | - | ||||||||||||||||||
| 293 | ctr[10] = (unsigned char)(actx->len.text>>16); | - | ||||||||||||||||||
| 294 | ctr[11] = (unsigned char)(actx->len.text>>24); | - | ||||||||||||||||||
| 295 | ctr[12] = (unsigned char)(actx->len.text>>32); | - | ||||||||||||||||||
| 296 | ctr[13] = (unsigned char)(actx->len.text>>40); | - | ||||||||||||||||||
| 297 | ctr[14] = (unsigned char)(actx->len.text>>48); | - | ||||||||||||||||||
| 298 | ctr[15] = (unsigned char)(actx->len.text>>56); | - | ||||||||||||||||||
| 299 | } never executed: end of block | 0 | ||||||||||||||||||
| 300 | tohash_len += 16; | - | ||||||||||||||||||
| 301 | } | - | ||||||||||||||||||
| 302 | - | |||||||||||||||||||
| 303 | Poly1305_Update(((POLY1305 *)(actx + 1)), tohash, tohash_len); | - | ||||||||||||||||||
| 304 | OPENSSL_cleanse(buf, buf_len); | - | ||||||||||||||||||
| 305 | Poly1305_Final(((POLY1305 *)(actx + 1)), ctx->encrypt ? actx->tag | - | ||||||||||||||||||
| 306 | : tohash); | - | ||||||||||||||||||
| 307 | - | |||||||||||||||||||
| 308 | actx->tls_payload_length = ((size_t)-1); | - | ||||||||||||||||||
| 309 | - | |||||||||||||||||||
| 310 | if (ctx->encrypt
| 45-65 | ||||||||||||||||||
| 311 | memcpy(out, actx->tag, 16); | - | ||||||||||||||||||
| 312 | } executed 65 times by 1 test: else {end of blockExecuted by:
| 65 | ||||||||||||||||||
| 313 | if (CRYPTO_memcmp(tohash, in, 16)
| 20-25 | ||||||||||||||||||
| 314 | memset(out - (len - 16), 0, | - | ||||||||||||||||||
| 315 | len - 16); | - | ||||||||||||||||||
| 316 | return executed 20 times by 1 test: -1;return -1;Executed by:
executed 20 times by 1 test: return -1;Executed by:
| 20 | ||||||||||||||||||
| 317 | } | - | ||||||||||||||||||
| 318 | } executed 25 times by 1 test: end of blockExecuted by:
| 25 | ||||||||||||||||||
| 319 | - | |||||||||||||||||||
| 320 | return executed 90 times by 1 test: len;return len;Executed by:
executed 90 times by 1 test: return len;Executed by:
| 90 | ||||||||||||||||||
| 321 | } | - | ||||||||||||||||||
| 322 | - | |||||||||||||||||||
| 323 | - | |||||||||||||||||||
| 324 | - | |||||||||||||||||||
| 325 | - | |||||||||||||||||||
| 326 | static int chacha20_poly1305_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | - | ||||||||||||||||||
| 327 | const unsigned char *in, size_t len) | - | ||||||||||||||||||
| 328 | { | - | ||||||||||||||||||
| 329 | EVP_CHACHA_AEAD_CTX *actx = ((EVP_CHACHA_AEAD_CTX *)(ctx)->cipher_data); | - | ||||||||||||||||||
| 330 | size_t rem, plen = actx->tls_payload_length; | - | ||||||||||||||||||
| 331 | - | |||||||||||||||||||
| 332 | if (!actx->mac_inited
| 14853-35850 | ||||||||||||||||||
| 333 | - | |||||||||||||||||||
| 334 | if (plen != ((size_t)-1)
| 0-14743 | ||||||||||||||||||
| 335 | ((void *)0)
| 0-110 | ||||||||||||||||||
| 336 | ) | - | ||||||||||||||||||
| 337 | return executed 110 times by 1 test: chacha20_poly1305_tls_cipher(ctx, out, in, len);return chacha20_poly1305_tls_cipher(ctx, out, in, len);Executed by:
executed 110 times by 1 test: return chacha20_poly1305_tls_cipher(ctx, out, in, len);Executed by:
| 110 | ||||||||||||||||||
| 338 | - | |||||||||||||||||||
| 339 | actx->key.counter[0] = 0; | - | ||||||||||||||||||
| 340 | ChaCha20_ctr32(actx->key.buf, zero, 64, | - | ||||||||||||||||||
| 341 | actx->key.key.d, actx->key.counter); | - | ||||||||||||||||||
| 342 | Poly1305_Init(((POLY1305 *)(actx + 1)), actx->key.buf); | - | ||||||||||||||||||
| 343 | actx->key.counter[0] = 1; | - | ||||||||||||||||||
| 344 | actx->key.partial_len = 0; | - | ||||||||||||||||||
| 345 | actx->len.aad = actx->len.text = 0; | - | ||||||||||||||||||
| 346 | actx->mac_inited = 1; | - | ||||||||||||||||||
| 347 | if (plen != ((size_t)-1)
| 0-14743 | ||||||||||||||||||
| 348 | Poly1305_Update(((POLY1305 *)(actx + 1)), actx->tls_aad, | - | ||||||||||||||||||
| 349 | 13); | - | ||||||||||||||||||
| 350 | actx->len.aad = 13; | - | ||||||||||||||||||
| 351 | actx->aad = 1; | - | ||||||||||||||||||
| 352 | } never executed: end of block | 0 | ||||||||||||||||||
| 353 | } executed 14743 times by 1 test: end of blockExecuted by:
| 14743 | ||||||||||||||||||
| 354 | - | |||||||||||||||||||
| 355 | if (in
| 14743-35850 | ||||||||||||||||||
| 356 | if (out ==
| 8721-27129 | ||||||||||||||||||
| 357 | ((void *)0)
| 8721-27129 | ||||||||||||||||||
| 358 | ) { | - | ||||||||||||||||||
| 359 | Poly1305_Update(((POLY1305 *)(actx + 1)), in, len); | - | ||||||||||||||||||
| 360 | actx->len.aad += len; | - | ||||||||||||||||||
| 361 | actx->aad = 1; | - | ||||||||||||||||||
| 362 | return executed 8721 times by 1 test: len;return len;Executed by:
executed 8721 times by 1 test: return len;Executed by:
| 8721 | ||||||||||||||||||
| 363 | } else { | - | ||||||||||||||||||
| 364 | if (actx->aad
| 8601-18528 | ||||||||||||||||||
| 365 | if ((
| 0-8601 | ||||||||||||||||||
| 366 | Poly1305_Update(((POLY1305 *)(actx + 1)), zero, executed 8601 times by 1 test: Poly1305_Update(((POLY1305 *)(actx + 1)), zero, 16 - rem);Executed by:
| 8601 | ||||||||||||||||||
| 367 | 16 - rem); executed 8601 times by 1 test: Poly1305_Update(((POLY1305 *)(actx + 1)), zero, 16 - rem);Executed by:
| 8601 | ||||||||||||||||||
| 368 | actx->aad = 0; | - | ||||||||||||||||||
| 369 | } executed 8601 times by 1 test: end of blockExecuted by:
| 8601 | ||||||||||||||||||
| 370 | - | |||||||||||||||||||
| 371 | actx->tls_payload_length = ((size_t)-1); | - | ||||||||||||||||||
| 372 | if (plen == ((size_t)-1)
| 0-27129 | ||||||||||||||||||
| 373 | plen = len; executed 27129 times by 1 test: plen = len;Executed by:
| 27129 | ||||||||||||||||||
| 374 | else if (len != plen + 16
| 0 | ||||||||||||||||||
| 375 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||
| 376 | - | |||||||||||||||||||
| 377 | if (ctx->encrypt
| 9791-17338 | ||||||||||||||||||
| 378 | chacha_cipher(ctx, out, in, plen); | - | ||||||||||||||||||
| 379 | Poly1305_Update(((POLY1305 *)(actx + 1)), out, plen); | - | ||||||||||||||||||
| 380 | in += plen; | - | ||||||||||||||||||
| 381 | out += plen; | - | ||||||||||||||||||
| 382 | actx->len.text += plen; | - | ||||||||||||||||||
| 383 | } executed 9791 times by 1 test: else {end of blockExecuted by:
| 9791 | ||||||||||||||||||
| 384 | Poly1305_Update(((POLY1305 *)(actx + 1)), in, plen); | - | ||||||||||||||||||
| 385 | chacha_cipher(ctx, out, in, plen); | - | ||||||||||||||||||
| 386 | in += plen; | - | ||||||||||||||||||
| 387 | out += plen; | - | ||||||||||||||||||
| 388 | actx->len.text += plen; | - | ||||||||||||||||||
| 389 | } executed 17338 times by 1 test: end of blockExecuted by:
| 17338 | ||||||||||||||||||
| 390 | } | - | ||||||||||||||||||
| 391 | } | - | ||||||||||||||||||
| 392 | if (in ==
| 14743-27129 | ||||||||||||||||||
| 393 | ((void *)0)
| 14743-27129 | ||||||||||||||||||
| 394 | - | |||||||||||||||||||
| 395 | || plen != len
| 0-27129 | ||||||||||||||||||
| 396 | const union { | - | ||||||||||||||||||
| 397 | long one; | - | ||||||||||||||||||
| 398 | char little; | - | ||||||||||||||||||
| 399 | } is_endian = { 1 }; | - | ||||||||||||||||||
| 400 | unsigned char temp[16]; | - | ||||||||||||||||||
| 401 | - | |||||||||||||||||||
| 402 | if (actx->aad
| 0-14743 | ||||||||||||||||||
| 403 | if ((
| 0 | ||||||||||||||||||
| 404 | Poly1305_Update(((POLY1305 *)(actx + 1)), zero, never executed: Poly1305_Update(((POLY1305 *)(actx + 1)), zero, 16 - rem); | 0 | ||||||||||||||||||
| 405 | 16 - rem); never executed: Poly1305_Update(((POLY1305 *)(actx + 1)), zero, 16 - rem); | 0 | ||||||||||||||||||
| 406 | actx->aad = 0; | - | ||||||||||||||||||
| 407 | } never executed: end of block | 0 | ||||||||||||||||||
| 408 | - | |||||||||||||||||||
| 409 | if ((
| 6347-8396 | ||||||||||||||||||
| 410 | Poly1305_Update(((POLY1305 *)(actx + 1)), zero, executed 8396 times by 1 test: Poly1305_Update(((POLY1305 *)(actx + 1)), zero, 16 - rem);Executed by:
| 8396 | ||||||||||||||||||
| 411 | 16 - rem); executed 8396 times by 1 test: Poly1305_Update(((POLY1305 *)(actx + 1)), zero, 16 - rem);Executed by:
| 8396 | ||||||||||||||||||
| 412 | - | |||||||||||||||||||
| 413 | if (is_endian.little
| 0-14743 | ||||||||||||||||||
| 414 | Poly1305_Update(((POLY1305 *)(actx + 1)), | - | ||||||||||||||||||
| 415 | (unsigned char *)&actx->len, 16); | - | ||||||||||||||||||
| 416 | } executed 14743 times by 1 test: else {end of blockExecuted by:
| 14743 | ||||||||||||||||||
| 417 | temp[0] = (unsigned char)(actx->len.aad); | - | ||||||||||||||||||
| 418 | temp[1] = (unsigned char)(actx->len.aad>>8); | - | ||||||||||||||||||
| 419 | temp[2] = (unsigned char)(actx->len.aad>>16); | - | ||||||||||||||||||
| 420 | temp[3] = (unsigned char)(actx->len.aad>>24); | - | ||||||||||||||||||
| 421 | temp[4] = (unsigned char)(actx->len.aad>>32); | - | ||||||||||||||||||
| 422 | temp[5] = (unsigned char)(actx->len.aad>>40); | - | ||||||||||||||||||
| 423 | temp[6] = (unsigned char)(actx->len.aad>>48); | - | ||||||||||||||||||
| 424 | temp[7] = (unsigned char)(actx->len.aad>>56); | - | ||||||||||||||||||
| 425 | - | |||||||||||||||||||
| 426 | temp[8] = (unsigned char)(actx->len.text); | - | ||||||||||||||||||
| 427 | temp[9] = (unsigned char)(actx->len.text>>8); | - | ||||||||||||||||||
| 428 | temp[10] = (unsigned char)(actx->len.text>>16); | - | ||||||||||||||||||
| 429 | temp[11] = (unsigned char)(actx->len.text>>24); | - | ||||||||||||||||||
| 430 | temp[12] = (unsigned char)(actx->len.text>>32); | - | ||||||||||||||||||
| 431 | temp[13] = (unsigned char)(actx->len.text>>40); | - | ||||||||||||||||||
| 432 | temp[14] = (unsigned char)(actx->len.text>>48); | - | ||||||||||||||||||
| 433 | temp[15] = (unsigned char)(actx->len.text>>56); | - | ||||||||||||||||||
| 434 | - | |||||||||||||||||||
| 435 | Poly1305_Update(((POLY1305 *)(actx + 1)), temp, 16); | - | ||||||||||||||||||
| 436 | } never executed: end of block | 0 | ||||||||||||||||||
| 437 | Poly1305_Final(((POLY1305 *)(actx + 1)), ctx->encrypt ? actx->tag | - | ||||||||||||||||||
| 438 | : temp); | - | ||||||||||||||||||
| 439 | actx->mac_inited = 0; | - | ||||||||||||||||||
| 440 | - | |||||||||||||||||||
| 441 | if (in !=
| 0-14743 | ||||||||||||||||||
| 442 | ((void *)0)
| 0-14743 | ||||||||||||||||||
| 443 | && len != plen
| 0 | ||||||||||||||||||
| 444 | if (ctx->encrypt
| 0 | ||||||||||||||||||
| 445 | memcpy(out, actx->tag, 16); | - | ||||||||||||||||||
| 446 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 447 | if (CRYPTO_memcmp(temp, in, 16)
| 0 | ||||||||||||||||||
| 448 | memset(out - plen, 0, plen); | - | ||||||||||||||||||
| 449 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||
| 450 | } | - | ||||||||||||||||||
| 451 | } never executed: end of block | 0 | ||||||||||||||||||
| 452 | } | - | ||||||||||||||||||
| 453 | else if (!ctx->encrypt
| 3597-11146 | ||||||||||||||||||
| 454 | if (CRYPTO_memcmp(temp, actx->tag, actx->tag_len)
| 3153-7993 | ||||||||||||||||||
| 455 | return executed 7993 times by 1 test: -1;return -1;Executed by:
executed 7993 times by 1 test: return -1;Executed by:
| 7993 | ||||||||||||||||||
| 456 | } executed 3153 times by 1 test: end of blockExecuted by:
| 3153 | ||||||||||||||||||
| 457 | } executed 6750 times by 1 test: end of blockExecuted by:
| 6750 | ||||||||||||||||||
| 458 | return executed 33879 times by 1 test: len;return len;Executed by:
executed 33879 times by 1 test: return len;Executed by:
| 33879 | ||||||||||||||||||
| 459 | } | - | ||||||||||||||||||
| 460 | - | |||||||||||||||||||
| 461 | static int chacha20_poly1305_cleanup(EVP_CIPHER_CTX *ctx) | - | ||||||||||||||||||
| 462 | { | - | ||||||||||||||||||
| 463 | EVP_CHACHA_AEAD_CTX *actx = ((EVP_CHACHA_AEAD_CTX *)(ctx)->cipher_data); | - | ||||||||||||||||||
| 464 | if (actx
| 0-6645 | ||||||||||||||||||
| 465 | OPENSSL_cleanse(ctx->cipher_data, sizeof(*actx) + Poly1305_ctx_size()); executed 6645 times by 1 test: OPENSSL_cleanse(ctx->cipher_data, sizeof(*actx) + Poly1305_ctx_size());Executed by:
| 6645 | ||||||||||||||||||
| 466 | return executed 6645 times by 1 test: 1;return 1;Executed by:
executed 6645 times by 1 test: return 1;Executed by:
| 6645 | ||||||||||||||||||
| 467 | } | - | ||||||||||||||||||
| 468 | - | |||||||||||||||||||
| 469 | static int chacha20_poly1305_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, | - | ||||||||||||||||||
| 470 | void *ptr) | - | ||||||||||||||||||
| 471 | { | - | ||||||||||||||||||
| 472 | EVP_CHACHA_AEAD_CTX *actx = ((EVP_CHACHA_AEAD_CTX *)(ctx)->cipher_data); | - | ||||||||||||||||||
| 473 | - | |||||||||||||||||||
| 474 | switch(type) { | - | ||||||||||||||||||
| 475 | case executed 6645 times by 1 test: 0x0:case 0x0:Executed by:
executed 6645 times by 1 test: case 0x0:Executed by:
| 6645 | ||||||||||||||||||
| 476 | if (actx ==
| 0-6645 | ||||||||||||||||||
| 477 | ((void *)0)
| 0-6645 | ||||||||||||||||||
| 478 | ) | - | ||||||||||||||||||
| 479 | actx = ctx->cipher_data executed 6645 times by 1 test: actx = ctx->cipher_data = CRYPTO_zalloc(sizeof(*actx) + Poly1305_ctx_size(), __FILE__, 507);Executed by:
| 6645 | ||||||||||||||||||
| 480 | = CRYPTO_zalloc(sizeof(*actx) + Poly1305_ctx_size(), __FILE__, 507); executed 6645 times by 1 test: actx = ctx->cipher_data = CRYPTO_zalloc(sizeof(*actx) + Poly1305_ctx_size(), __FILE__, 507);Executed by:
| 6645 | ||||||||||||||||||
| 481 | if (actx ==
| 0-6645 | ||||||||||||||||||
| 482 | ((void *)0)
| 0-6645 | ||||||||||||||||||
| 483 | ) { | - | ||||||||||||||||||
| 484 | ERR_put_error(6,(182),(134),__FILE__,509); | - | ||||||||||||||||||
| 485 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 486 | } | - | ||||||||||||||||||
| 487 | actx->len.aad = 0; | - | ||||||||||||||||||
| 488 | actx->len.text = 0; | - | ||||||||||||||||||
| 489 | actx->aad = 0; | - | ||||||||||||||||||
| 490 | actx->mac_inited = 0; | - | ||||||||||||||||||
| 491 | actx->tag_len = 0; | - | ||||||||||||||||||
| 492 | actx->nonce_len = 12; | - | ||||||||||||||||||
| 493 | actx->tls_payload_length = ((size_t)-1); | - | ||||||||||||||||||
| 494 | memset(actx->tls_aad, 0, 16); | - | ||||||||||||||||||
| 495 | return executed 6645 times by 1 test: 1;return 1;Executed by:
executed 6645 times by 1 test: return 1;Executed by:
| 6645 | ||||||||||||||||||
| 496 | - | |||||||||||||||||||
| 497 | case never executed: 0x8:case 0x8:never executed: case 0x8: | 0 | ||||||||||||||||||
| 498 | if (actx
| 0 | ||||||||||||||||||
| 499 | EVP_CIPHER_CTX *dst = (EVP_CIPHER_CTX *)ptr; | - | ||||||||||||||||||
| 500 | - | |||||||||||||||||||
| 501 | dst->cipher_data = | - | ||||||||||||||||||
| 502 | CRYPTO_memdup((actx), sizeof(*actx) + Poly1305_ctx_size(), __FILE__, 527); | - | ||||||||||||||||||
| 503 | if (dst->cipher_data ==
| 0 | ||||||||||||||||||
| 504 | ((void *)0)
| 0 | ||||||||||||||||||
| 505 | ) { | - | ||||||||||||||||||
| 506 | ERR_put_error(6,(182),(173),__FILE__,529); | - | ||||||||||||||||||
| 507 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 508 | } | - | ||||||||||||||||||
| 509 | } never executed: end of block | 0 | ||||||||||||||||||
| 510 | return never executed: 1;return 1;never executed: return 1; | 0 | ||||||||||||||||||
| 511 | - | |||||||||||||||||||
| 512 | case executed 456 times by 1 test: 0x9:case 0x9:Executed by:
executed 456 times by 1 test: case 0x9:Executed by:
| 456 | ||||||||||||||||||
| 513 | if (arg <= 0
| 0-456 | ||||||||||||||||||
| 514 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 515 | actx->nonce_len = arg; | - | ||||||||||||||||||
| 516 | return executed 456 times by 1 test: 1;return 1;Executed by:
executed 456 times by 1 test: return 1;Executed by:
| 456 | ||||||||||||||||||
| 517 | - | |||||||||||||||||||
| 518 | case never executed: 0x12:case 0x12:never executed: case 0x12: | 0 | ||||||||||||||||||
| 519 | if (arg != 12
| 0 | ||||||||||||||||||
| 520 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 521 | actx->nonce[0] = actx->key.counter[1] | - | ||||||||||||||||||
| 522 | = ( ((unsigned int)((unsigned char *)ptr)[0]) | ((unsigned int)((unsigned char *)ptr)[1]<<8) | ((unsigned int)((unsigned char *)ptr)[2]<<16) | ((unsigned int)((unsigned char *)ptr)[3]<<24) ); | - | ||||||||||||||||||
| 523 | actx->nonce[1] = actx->key.counter[2] | - | ||||||||||||||||||
| 524 | = ( ((unsigned int)((unsigned char *)ptr+4)[0]) | ((unsigned int)((unsigned char *)ptr+4)[1]<<8) | ((unsigned int)((unsigned char *)ptr+4)[2]<<16) | ((unsigned int)((unsigned char *)ptr+4)[3]<<24) ); | - | ||||||||||||||||||
| 525 | actx->nonce[2] = actx->key.counter[3] | - | ||||||||||||||||||
| 526 | = ( ((unsigned int)((unsigned char *)ptr+8)[0]) | ((unsigned int)((unsigned char *)ptr+8)[1]<<8) | ((unsigned int)((unsigned char *)ptr+8)[2]<<16) | ((unsigned int)((unsigned char *)ptr+8)[3]<<24) ); | - | ||||||||||||||||||
| 527 | return never executed: 1;return 1;never executed: return 1; | 0 | ||||||||||||||||||
| 528 | - | |||||||||||||||||||
| 529 | case executed 8134 times by 1 test: 0x11:case 0x11:Executed by:
executed 8134 times by 1 test: case 0x11:Executed by:
| 8134 | ||||||||||||||||||
| 530 | if (arg <= 0
| 0-8134 | ||||||||||||||||||
| 531 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 532 | if (ptr !=
| 60-8074 | ||||||||||||||||||
| 533 | ((void *)0)
| 60-8074 | ||||||||||||||||||
| 534 | ) { | - | ||||||||||||||||||
| 535 | memcpy(actx->tag, ptr, arg); | - | ||||||||||||||||||
| 536 | actx->tag_len = arg; | - | ||||||||||||||||||
| 537 | } executed 8074 times by 1 test: end of blockExecuted by:
| 8074 | ||||||||||||||||||
| 538 | return executed 8134 times by 1 test: 1;return 1;Executed by:
executed 8134 times by 1 test: return 1;Executed by:
| 8134 | ||||||||||||||||||
| 539 | - | |||||||||||||||||||
| 540 | case executed 527 times by 1 test: 0x10:case 0x10:Executed by:
executed 527 times by 1 test: case 0x10:Executed by:
| 527 | ||||||||||||||||||
| 541 | if (arg <= 0
| 0-527 | ||||||||||||||||||
| 542 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 543 | memcpy(ptr, actx->tag, arg); | - | ||||||||||||||||||
| 544 | return executed 527 times by 1 test: 1;return 1;Executed by:
executed 527 times by 1 test: return 1;Executed by:
| 527 | ||||||||||||||||||
| 545 | - | |||||||||||||||||||
| 546 | case executed 111 times by 1 test: 0x16:case 0x16:Executed by:
executed 111 times by 1 test: case 0x16:Executed by:
| 111 | ||||||||||||||||||
| 547 | if (arg != 13
| 0-111 | ||||||||||||||||||
| 548 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 549 | { | - | ||||||||||||||||||
| 550 | unsigned int len; | - | ||||||||||||||||||
| 551 | unsigned char *aad = ptr; | - | ||||||||||||||||||
| 552 | - | |||||||||||||||||||
| 553 | memcpy(actx->tls_aad, ptr, 13); | - | ||||||||||||||||||
| 554 | len = aad[13 - 2] << 8 | | - | ||||||||||||||||||
| 555 | aad[13 - 1]; | - | ||||||||||||||||||
| 556 | aad = actx->tls_aad; | - | ||||||||||||||||||
| 557 | if (!ctx->encrypt
| 46-65 | ||||||||||||||||||
| 558 | if (len < 16
| 1-45 | ||||||||||||||||||
| 559 | return executed 1 time by 1 test: 0;return 0;Executed by:
executed 1 time by 1 test: return 0;Executed by:
| 1 | ||||||||||||||||||
| 560 | len -= 16; | - | ||||||||||||||||||
| 561 | aad[13 - 2] = (unsigned char)(len >> 8); | - | ||||||||||||||||||
| 562 | aad[13 - 1] = (unsigned char)len; | - | ||||||||||||||||||
| 563 | } executed 45 times by 1 test: end of blockExecuted by:
| 45 | ||||||||||||||||||
| 564 | actx->tls_payload_length = len; | - | ||||||||||||||||||
| 565 | - | |||||||||||||||||||
| 566 | - | |||||||||||||||||||
| 567 | - | |||||||||||||||||||
| 568 | - | |||||||||||||||||||
| 569 | actx->key.counter[1] = actx->nonce[0]; | - | ||||||||||||||||||
| 570 | actx->key.counter[2] = actx->nonce[1] ^ ( ((unsigned int)(aad)[0]) | ((unsigned int)(aad)[1]<<8) | ((unsigned int)(aad)[2]<<16) | ((unsigned int)(aad)[3]<<24) ); | - | ||||||||||||||||||
| 571 | actx->key.counter[3] = actx->nonce[2] ^ ( ((unsigned int)(aad+4)[0]) | ((unsigned int)(aad+4)[1]<<8) | ((unsigned int)(aad+4)[2]<<16) | ((unsigned int)(aad+4)[3]<<24) ); | - | ||||||||||||||||||
| 572 | actx->mac_inited = 0; | - | ||||||||||||||||||
| 573 | - | |||||||||||||||||||
| 574 | return executed 110 times by 1 test: 16;return 16;Executed by:
executed 110 times by 1 test: return 16;Executed by:
| 110 | ||||||||||||||||||
| 575 | } | - | ||||||||||||||||||
| 576 | - | |||||||||||||||||||
| 577 | case never executed: 0x17:case 0x17:never executed: case 0x17: | 0 | ||||||||||||||||||
| 578 | - | |||||||||||||||||||
| 579 | return never executed: 1;return 1;never executed: return 1; | 0 | ||||||||||||||||||
| 580 | - | |||||||||||||||||||
| 581 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||
| 582 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||
| 583 | } | - | ||||||||||||||||||
| 584 | } | - | ||||||||||||||||||
| 585 | - | |||||||||||||||||||
| 586 | static EVP_CIPHER chacha20_poly1305 = { | - | ||||||||||||||||||
| 587 | 1018, | - | ||||||||||||||||||
| 588 | 1, | - | ||||||||||||||||||
| 589 | 32, | - | ||||||||||||||||||
| 590 | 12, | - | ||||||||||||||||||
| 591 | 0x200000 | 0x10 | | - | ||||||||||||||||||
| 592 | 0x20 | 0x40 | | - | ||||||||||||||||||
| 593 | 0x400 | 0x100000, | - | ||||||||||||||||||
| 594 | chacha20_poly1305_init_key, | - | ||||||||||||||||||
| 595 | chacha20_poly1305_cipher, | - | ||||||||||||||||||
| 596 | chacha20_poly1305_cleanup, | - | ||||||||||||||||||
| 597 | 0, | - | ||||||||||||||||||
| 598 | - | |||||||||||||||||||
| 599 | ((void *)0) | - | ||||||||||||||||||
| 600 | , | - | ||||||||||||||||||
| 601 | - | |||||||||||||||||||
| 602 | ((void *)0) | - | ||||||||||||||||||
| 603 | , | - | ||||||||||||||||||
| 604 | chacha20_poly1305_ctrl, | - | ||||||||||||||||||
| 605 | - | |||||||||||||||||||
| 606 | ((void *)0) | - | ||||||||||||||||||
| 607 | - | |||||||||||||||||||
| 608 | }; | - | ||||||||||||||||||
| 609 | - | |||||||||||||||||||
| 610 | const EVP_CIPHER *EVP_chacha20_poly1305(void) | - | ||||||||||||||||||
| 611 | { | - | ||||||||||||||||||
| 612 | return executed 3922 times by 1 test: (&chacha20_poly1305);return(&chacha20_poly1305);Executed by:
executed 3922 times by 1 test: return(&chacha20_poly1305);Executed by:
| 3922 | ||||||||||||||||||
| 613 | } | - | ||||||||||||||||||
| Switch to Source code | Preprocessed file |