| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/modes/ocb128.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | static u32 ocb_ntz(u64 n) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | u32 cnt = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | while (!(n & 1)
| 773-1617 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | n >>= 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | cnt++; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | } executed 773 times by 1 test: end of blockExecuted by:
| 773 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | return executed 1617 times by 1 test: cnt;return cnt;Executed by:
executed 1617 times by 1 test: return cnt;Executed by:
| 1617 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | static void ocb_block_lshift(const unsigned char *in, size_t shift, | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | unsigned char *out) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | int i; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | unsigned char carry = 0, carry_next; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | for (i = 15; i >= 0
| 3871-61936 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | carry_next = in[i] >> (8 - shift); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | out[i] = (in[i] << shift) | carry; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | carry = carry_next; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | } executed 61936 times by 1 test: end of blockExecuted by:
| 61936 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | } executed 3871 times by 1 test: end of blockExecuted by:
| 3871 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | static void ocb_double(OCB_BLOCK *in, OCB_BLOCK *out) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | unsigned char mask; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | mask = in->c[0] & 0x80; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | mask >>= 7; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | mask = (0 - mask) & 0x87; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | ocb_block_lshift(in->c, 1, out->c); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | out->c[15] ^= mask; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | } executed 3318 times by 1 test: end of blockExecuted by:
| 3318 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | static void ocb_block_xor(const unsigned char *in1, | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | const unsigned char *in2, size_t len, | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | unsigned char *out) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | size_t i; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | for (i = 0; i < len
| 866-6202 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | out[i] = in1[i] ^ in2[i]; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | } executed 6202 times by 1 test: end of blockExecuted by:
| 6202 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | } executed 866 times by 1 test: end of blockExecuted by:
| 866 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | static OCB_BLOCK *ocb_lookup_l(OCB128_CONTEXT *ctx, size_t idx) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | size_t l_index = ctx->l_index; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | if (idx <= l_index
| 0-1617 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | return executed 1617 times by 1 test: ctx->l + idx;return ctx->l + idx;Executed by:
executed 1617 times by 1 test: return ctx->l + idx;Executed by:
| 1617 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | if (idx >= ctx->max_l_index
| 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | void *tmp_ptr; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | ctx->max_l_index += (idx - ctx->max_l_index + 4) & ~3; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | tmp_ptr = CRYPTO_realloc(ctx->l, ctx->max_l_index * sizeof(OCB_BLOCK), __FILE__, 113); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | if (tmp_ptr ==
| 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | ((void *)0)
| 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | return never executed: return ((void *)0) ;never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | ctx->l = tmp_ptr; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | while (l_index < idx
| 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | ocb_double(ctx->l + l_index, ctx->l + l_index + 1); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | l_index++; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | ctx->l_index = l_index; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | return never executed: ctx->l + idx;return ctx->l + idx;never executed: return ctx->l + idx; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | OCB128_CONTEXT *CRYPTO_ocb128_new(void *keyenc, void *keydec, | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | block128_f encrypt, block128_f decrypt, | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | ocb128_f stream) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | OCB128_CONTEXT *octx; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | int ret; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | if ((
| 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | ((void *)0)
| 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | ) { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | ret = CRYPTO_ocb128_init(octx, keyenc, keydec, encrypt, decrypt, | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | stream); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | if (ret
| 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | return never executed: octx;return octx;never executed: return octx; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | CRYPTO_free(octx, __FILE__, 142); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | return never executed: return ((void *)0) ;never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | int CRYPTO_ocb128_init(OCB128_CONTEXT *ctx, void *keyenc, void *keydec, | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | block128_f encrypt, block128_f decrypt, | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | ocb128_f stream) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | memset(ctx, 0, sizeof(*ctx)); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | ctx->l_index = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | ctx->max_l_index = 5; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | if ((
| 0-553 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | ((void *)0)
| 0-553 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | ) { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | ERR_put_error(15,(122),((1|64)),__FILE__,159); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | ctx->encrypt = encrypt; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | ctx->decrypt = decrypt; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | ctx->stream = stream; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | ctx->keyenc = keyenc; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | ctx->keydec = keydec; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | ctx->encrypt(ctx->l_star.c, ctx->l_star.c, ctx->keyenc); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | ocb_double(&ctx->l_star, &ctx->l_dollar); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | ocb_double(&ctx->l_dollar, ctx->l); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | ocb_double(ctx->l, ctx->l+1); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | ocb_double(ctx->l+1, ctx->l+2); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | ocb_double(ctx->l+2, ctx->l+3); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | ocb_double(ctx->l+3, ctx->l+4); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | ctx->l_index = 4; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | return executed 553 times by 1 test: 1;return 1;Executed by:
executed 553 times by 1 test: return 1;Executed by:
| 553 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | int CRYPTO_ocb128_copy_ctx(OCB128_CONTEXT *dest, OCB128_CONTEXT *src, | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | void *keyenc, void *keydec) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | memcpy(dest, src, sizeof(OCB128_CONTEXT)); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | if (keyenc
| 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | dest->keyenc = keyenc; never executed: dest->keyenc = keyenc; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | if (keydec
| 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | dest->keydec = keydec; never executed: dest->keydec = keydec; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | if (src->l
| 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | if ((
| 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | ((void *)0)
| 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | ) { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | ERR_put_error(15,(121),((1|64)),__FILE__,206); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | memcpy(dest->l, src->l, (src->l_index + 1) * 16); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | return never executed: 1;return 1;never executed: return 1; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | int CRYPTO_ocb128_setiv(OCB128_CONTEXT *ctx, const unsigned char *iv, | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | size_t len, size_t taglen) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | unsigned char ktop[16], tmp[16], mask; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | unsigned char stretch[24], nonce[16]; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | size_t bottom, shift; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | if ((
| 0-553 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | memset(&ctx->sess, 0, sizeof(ctx->sess)); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | nonce[0] = ((taglen * 8) % 128) << 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | memset(nonce + 1, 0, 15); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | memcpy(nonce + 16 - len, iv, len); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | nonce[15 - len] |= 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | memcpy(tmp, nonce, 16); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | tmp[15] &= 0xc0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | ctx->encrypt(tmp, ktop, ctx->keyenc); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | memcpy(stretch, ktop, 16); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | ocb_block_xor(ktop, ktop + 1, 8, stretch + 16); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | bottom = nonce[15] & 0x3f; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | shift = bottom % 8; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | ocb_block_lshift(stretch + (bottom / 8), shift, ctx->sess.offset.c); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | mask = 0xff; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | mask <<= 8 - shift; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | ctx->sess.offset.c[15] |= | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | (*(stretch + (bottom / 8) + 16) & mask) >> (8 - shift); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | return executed 553 times by 1 test: 1;return 1;Executed by:
executed 553 times by 1 test: return 1;Executed by:
| 553 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | int CRYPTO_ocb128_aad(OCB128_CONTEXT *ctx, const unsigned char *aad, | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | size_t len) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | u64 i, all_num_blocks; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | size_t num_blocks, last_len; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | OCB_BLOCK tmp; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | num_blocks = len / 16; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | all_num_blocks = num_blocks + ctx->sess.blocks_hashed; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | for (i = ctx->sess.blocks_hashed + 1; i <= all_num_blocks
| 626-806 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | OCB_BLOCK *lookup; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | lookup = ocb_lookup_l(ctx, ocb_ntz(i)); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | if (lookup ==
| 0-626 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | ((void *)0)
| 0-626 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | ( (&ctx->sess.offset_aad)->a[0]=(&ctx->sess.offset_aad)->a[0]^(lookup)->a[0], (&ctx->sess.offset_aad)->a[1]=(&ctx->sess.offset_aad)->a[1]^(lookup)->a[1] ); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | memcpy(tmp.c, aad, 16); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | aad += 16; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | ( (&tmp)->a[0]=(&ctx->sess.offset_aad)->a[0]^(&tmp)->a[0], (&tmp)->a[1]=(&ctx->sess.offset_aad)->a[1]^(&tmp)->a[1] ); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | ctx->encrypt(tmp.c, tmp.c, ctx->keyenc); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | ( (&ctx->sess.sum)->a[0]=(&tmp)->a[0]^(&ctx->sess.sum)->a[0], (&ctx->sess.sum)->a[1]=(&tmp)->a[1]^(&ctx->sess.sum)->a[1] ); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | } executed 626 times by 1 test: end of blockExecuted by:
| 626 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | last_len = len % 16; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | if (last_len > 0
| 313-493 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | ( (&ctx->sess.offset_aad)->a[0]=(&ctx->sess.offset_aad)->a[0]^(&ctx->l_star)->a[0], (&ctx->sess.offset_aad)->a[1]=(&ctx->sess.offset_aad)->a[1]^(&ctx->l_star)->a[1] ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | memset(tmp.c, 0, 16); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | memcpy(tmp.c, aad, last_len); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | tmp.c[last_len] = 0x80; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | ( (&tmp)->a[0]=(&ctx->sess.offset_aad)->a[0]^(&tmp)->a[0], (&tmp)->a[1]=(&ctx->sess.offset_aad)->a[1]^(&tmp)->a[1] ); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | ctx->encrypt(tmp.c, tmp.c, ctx->keyenc); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | ( (&ctx->sess.sum)->a[0]=(&tmp)->a[0]^(&ctx->sess.sum)->a[0], (&ctx->sess.sum)->a[1]=(&tmp)->a[1]^(&ctx->sess.sum)->a[1] ); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | } executed 313 times by 1 test: end of blockExecuted by:
| 313 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | ctx->sess.blocks_hashed = all_num_blocks; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | return executed 806 times by 1 test: 1;return 1;Executed by:
executed 806 times by 1 test: return 1;Executed by:
| 806 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | int CRYPTO_ocb128_encrypt(OCB128_CONTEXT *ctx, | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | const unsigned char *in, unsigned char *out, | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | size_t len) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | u64 i, all_num_blocks; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | size_t num_blocks, last_len; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | num_blocks = len / 16; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | all_num_blocks = num_blocks + ctx->sess.blocks_processed; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | if (num_blocks
| 0-246 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | && ctx->stream !=
| 0-246 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | ((void *)0)
| 0-246 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | ) { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | size_t max_idx = 0, top = (size_t)all_num_blocks; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | while (top >>= 1
| 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | max_idx++; never executed: max_idx++; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | if (ocb_lookup_l(ctx, max_idx) ==
| 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | ((void *)0)
| 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | ctx->stream(in, out, num_blocks, ctx->keyenc, | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | (size_t)ctx->sess.blocks_processed + 1, ctx->sess.offset.c, | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | (const unsigned char (*)[16])ctx->l, ctx->sess.checksum.c); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | for (i = ctx->sess.blocks_processed + 1; i <= all_num_blocks
| 402-492 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | OCB_BLOCK *lookup; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | OCB_BLOCK tmp; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | lookup = ocb_lookup_l(ctx, ocb_ntz(i)); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | if (lookup ==
| 0-492 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | ((void *)0)
| 0-492 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | ( (&ctx->sess.offset)->a[0]=(&ctx->sess.offset)->a[0]^(lookup)->a[0], (&ctx->sess.offset)->a[1]=(&ctx->sess.offset)->a[1]^(lookup)->a[1] ); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | memcpy(tmp.c, in, 16); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | in += 16; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | ( (&ctx->sess.checksum)->a[0]=(&tmp)->a[0]^(&ctx->sess.checksum)->a[0], (&ctx->sess.checksum)->a[1]=(&tmp)->a[1]^(&ctx->sess.checksum)->a[1] ); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | ( (&tmp)->a[0]=(&ctx->sess.offset)->a[0]^(&tmp)->a[0], (&tmp)->a[1]=(&ctx->sess.offset)->a[1]^(&tmp)->a[1] ); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | ctx->encrypt(tmp.c, tmp.c, ctx->keyenc); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | ( (&tmp)->a[0]=(&ctx->sess.offset)->a[0]^(&tmp)->a[0], (&tmp)->a[1]=(&ctx->sess.offset)->a[1]^(&tmp)->a[1] ); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | memcpy(out, tmp.c, 16); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | out += 16; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | } executed 492 times by 1 test: end of blockExecuted by:
| 492 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | } executed 402 times by 1 test: end of blockExecuted by:
| 402 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | last_len = len % 16; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | if (last_len > 0
| 156-246 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | OCB_BLOCK pad; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | ( (&ctx->sess.offset)->a[0]=(&ctx->sess.offset)->a[0]^(&ctx->l_star)->a[0], (&ctx->sess.offset)->a[1]=(&ctx->sess.offset)->a[1]^(&ctx->l_star)->a[1] ); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | ctx->encrypt(ctx->sess.offset.c, pad.c, ctx->keyenc); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | ocb_block_xor(in, pad.c, last_len, out); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | memset(pad.c, 0, 16); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | memcpy(pad.c, in, last_len); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | pad.c[last_len] = 0x80; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | ( (&ctx->sess.checksum)->a[0]=(&pad)->a[0]^(&ctx->sess.checksum)->a[0], (&ctx->sess.checksum)->a[1]=(&pad)->a[1]^(&ctx->sess.checksum)->a[1] ); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | } executed 156 times by 1 test: end of blockExecuted by:
| 156 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | ctx->sess.blocks_processed = all_num_blocks; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | return executed 402 times by 1 test: 1;return 1;Executed by:
executed 402 times by 1 test: return 1;Executed by:
| 402 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | int CRYPTO_ocb128_decrypt(OCB128_CONTEXT *ctx, | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | const unsigned char *in, unsigned char *out, | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | size_t len) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | u64 i, all_num_blocks; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | size_t num_blocks, last_len; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | num_blocks = len / 16; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | all_num_blocks = num_blocks + ctx->sess.blocks_processed; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | if (num_blocks
| 0-247 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | && ctx->stream !=
| 0-247 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | ((void *)0)
| 0-247 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | ) { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | size_t max_idx = 0, top = (size_t)all_num_blocks; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | while (top >>= 1
| 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | max_idx++; never executed: max_idx++; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | if (ocb_lookup_l(ctx, max_idx) ==
| 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | ((void *)0)
| 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | ctx->stream(in, out, num_blocks, ctx->keydec, | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | (size_t)ctx->sess.blocks_processed + 1, ctx->sess.offset.c, | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | (const unsigned char (*)[16])ctx->l, ctx->sess.checksum.c); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | OCB_BLOCK tmp; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | for (i = ctx->sess.blocks_processed + 1; i <= all_num_blocks
| 404-499 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | OCB_BLOCK *lookup = ocb_lookup_l(ctx, ocb_ntz(i)); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | if (lookup ==
| 0-499 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | ((void *)0)
| 0-499 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | ( (&ctx->sess.offset)->a[0]=(&ctx->sess.offset)->a[0]^(lookup)->a[0], (&ctx->sess.offset)->a[1]=(&ctx->sess.offset)->a[1]^(lookup)->a[1] ); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | memcpy(tmp.c, in, 16); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | in += 16; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | ( (&tmp)->a[0]=(&ctx->sess.offset)->a[0]^(&tmp)->a[0], (&tmp)->a[1]=(&ctx->sess.offset)->a[1]^(&tmp)->a[1] ); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | ctx->decrypt(tmp.c, tmp.c, ctx->keydec); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | ( (&tmp)->a[0]=(&ctx->sess.offset)->a[0]^(&tmp)->a[0], (&tmp)->a[1]=(&ctx->sess.offset)->a[1]^(&tmp)->a[1] ); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | ( (&ctx->sess.checksum)->a[0]=(&tmp)->a[0]^(&ctx->sess.checksum)->a[0], (&ctx->sess.checksum)->a[1]=(&tmp)->a[1]^(&ctx->sess.checksum)->a[1] ); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | memcpy(out, tmp.c, 16); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | out += 16; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | } executed 499 times by 1 test: end of blockExecuted by:
| 499 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | } executed 404 times by 1 test: end of blockExecuted by:
| 404 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | last_len = len % 16; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | if (last_len > 0
| 157-247 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | OCB_BLOCK pad; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | ( (&ctx->sess.offset)->a[0]=(&ctx->sess.offset)->a[0]^(&ctx->l_star)->a[0], (&ctx->sess.offset)->a[1]=(&ctx->sess.offset)->a[1]^(&ctx->l_star)->a[1] ); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | ctx->encrypt(ctx->sess.offset.c, pad.c, ctx->keyenc); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | ocb_block_xor(in, pad.c, last_len, out); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | memset(pad.c, 0, 16); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | memcpy(pad.c, out, last_len); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | pad.c[last_len] = 0x80; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | ( (&ctx->sess.checksum)->a[0]=(&pad)->a[0]^(&ctx->sess.checksum)->a[0], (&ctx->sess.checksum)->a[1]=(&pad)->a[1]^(&ctx->sess.checksum)->a[1] ); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | } executed 157 times by 1 test: end of blockExecuted by:
| 157 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | ctx->sess.blocks_processed = all_num_blocks; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | return executed 404 times by 1 test: 1;return 1;Executed by:
executed 404 times by 1 test: return 1;Executed by:
| 404 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | static int ocb_finish(OCB128_CONTEXT *ctx, unsigned char *tag, size_t len, | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | int write) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | OCB_BLOCK tmp; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | if (len > 16
| 0-553 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | ( (&tmp)->a[0]=(&ctx->sess.checksum)->a[0]^(&ctx->sess.offset)->a[0], (&tmp)->a[1]=(&ctx->sess.checksum)->a[1]^(&ctx->sess.offset)->a[1] ); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | ( (&tmp)->a[0]=(&ctx->l_dollar)->a[0]^(&tmp)->a[0], (&tmp)->a[1]=(&ctx->l_dollar)->a[1]^(&tmp)->a[1] ); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | ctx->encrypt(tmp.c, tmp.c, ctx->keyenc); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | ( (&tmp)->a[0]=(&tmp)->a[0]^(&ctx->sess.sum)->a[0], (&tmp)->a[1]=(&tmp)->a[1]^(&ctx->sess.sum)->a[1] ); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | if (write
| 276-277 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | memcpy(tag, &tmp, len); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | return executed 276 times by 1 test: 1;return 1;Executed by:
executed 276 times by 1 test: return 1;Executed by:
| 276 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | } else { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | return executed 277 times by 1 test: CRYPTO_memcmp(&tmp, tag, len);return CRYPTO_memcmp(&tmp, tag, len);Executed by:
executed 277 times by 1 test: return CRYPTO_memcmp(&tmp, tag, len);Executed by:
| 277 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | int CRYPTO_ocb128_finish(OCB128_CONTEXT *ctx, const unsigned char *tag, | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | size_t len) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | return executed 277 times by 1 test: ocb_finish(ctx, (unsigned char*)tag, len, 0);return ocb_finish(ctx, (unsigned char*)tag, len, 0);Executed by:
executed 277 times by 1 test: return ocb_finish(ctx, (unsigned char*)tag, len, 0);Executed by:
| 277 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | int CRYPTO_ocb128_tag(OCB128_CONTEXT *ctx, unsigned char *tag, size_t len) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | return executed 276 times by 1 test: ocb_finish(ctx, tag, len, 1);return ocb_finish(ctx, tag, len, 1);Executed by:
executed 276 times by 1 test: return ocb_finish(ctx, tag, len, 1);Executed by:
| 276 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | void CRYPTO_ocb128_cleanup(OCB128_CONTEXT *ctx) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | if (ctx
| 0-553 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | CRYPTO_clear_free(ctx->l, ctx->max_l_index * 16, __FILE__, 557); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | OPENSSL_cleanse(ctx, sizeof(*ctx)); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | } executed 553 times by 1 test: end of blockExecuted by:
| 553 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | } executed 553 times by 1 test: end of blockExecuted by:
| 553 | ||||||||||||||||||||||||||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |