OpenCoverage

ofb128.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/modes/ofb128.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/*-
2 * Copyright 2008-2016 The OpenSSL Project Authors. All Rights Reserved.-
3 *-
4 * Licensed under the OpenSSL license (the "License"). You may not use-
5 * this file except in compliance with the License. You can obtain a copy-
6 * in the file LICENSE in the source distribution or at-
7 * https://www.openssl.org/source/license.html-
8 */-
9-
10#include <openssl/crypto.h>-
11#include "modes_lcl.h"-
12#include <string.h>-
13-
14/*-
15 * The input and output encrypted as though 128bit ofb mode is being used.-
16 * The extra state information to record how much of the 128bit block we have-
17 * used is contained in *num;-
18 */-
19void CRYPTO_ofb128_encrypt(const unsigned char *in, unsigned char *out,-
20 size_t len, const void *key,-
21 unsigned char ivec[16], int *num, block128_f block)-
22{-
23 unsigned int n;-
24 size_t l = 0;-
25-
26 n = *num;-
27-
28#if !defined(OPENSSL_SMALL_FOOTPRINT)-
29 if (16 % sizeof(size_t) == 0) { /* always true actually */
16 % sizeof(size_t) == 0Description
TRUEevaluated 20114 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-20114
30 do {-
31 while (n && len) {
nDescription
TRUEevaluated 69406 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 19816 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
lenDescription
TRUEevaluated 69108 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 298 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
298-69406
32 *(out++) = *(in++) ^ ivec[n];-
33 --len;-
34 n = (n + 1) % 16;-
35 }
executed 69108 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
69108
36# if defined(STRICT_ALIGNMENT)-
37 if (((size_t)in | (size_t)out | (size_t)ivec) % sizeof(size_t) !=-
38 0)-
39 break;-
40# endif-
41 while (len >= 16) {
len >= 16Description
TRUEevaluated 391304 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 20114 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
20114-391304
42 (*block) (ivec, ivec, key);-
43 for (; n < 16; n += sizeof(size_t))
n < 16Description
TRUEevaluated 782608 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 391304 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
391304-782608
44 *(size_t *)(out + n) =
executed 782608 times by 1 test: *(size_t *)(out + n) = *(size_t *)(in + n) ^ *(size_t *)(ivec + n);
Executed by:
  • libcrypto.so.1.1
782608
45 *(size_t *)(in + n) ^ *(size_t *)(ivec + n);
executed 782608 times by 1 test: *(size_t *)(out + n) = *(size_t *)(in + n) ^ *(size_t *)(ivec + n);
Executed by:
  • libcrypto.so.1.1
782608
46 len -= 16;-
47 out += 16;-
48 in += 16;-
49 n = 0;-
50 }
executed 391304 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
391304
51 if (len) {
lenDescription
TRUEevaluated 8406 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 11708 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
8406-11708
52 (*block) (ivec, ivec, key);-
53 while (len--) {
len--Description
TRUEevaluated 65192 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 8406 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
8406-65192
54 out[n] = in[n] ^ ivec[n];-
55 ++n;-
56 }
executed 65192 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
65192
57 }
executed 8406 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
8406
58 *num = n;-
59 return;
executed 20114 times by 1 test: return;
Executed by:
  • libcrypto.so.1.1
20114
60 } while (0);-
61 }
never executed: end of block
0
62 /* the rest would be commonly eliminated by x86* compiler */-
63#endif-
64 while (l < len) {
l < lenDescription
TRUEnever evaluated
FALSEnever evaluated
0
65 if (n == 0) {
n == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
66 (*block) (ivec, ivec, key);-
67 }
never executed: end of block
0
68 out[l] = in[l] ^ ivec[n];-
69 ++l;-
70 n = (n + 1) % 16;-
71 }
never executed: end of block
0
72-
73 *num = n;-
74}
never executed: end of block
0
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.2