| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/modes/cfb128.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||
| 2 | - | |||||||||||||
| 3 | - | |||||||||||||
| 4 | - | |||||||||||||
| 5 | - | |||||||||||||
| 6 | - | |||||||||||||
| 7 | - | |||||||||||||
| 8 | void CRYPTO_cfb128_encrypt(const unsigned char *in, unsigned char *out, | - | ||||||||||||
| 9 | size_t len, const void *key, | - | ||||||||||||
| 10 | unsigned char ivec[16], int *num, | - | ||||||||||||
| 11 | int enc, block128_f block) | - | ||||||||||||
| 12 | { | - | ||||||||||||
| 13 | unsigned int n; | - | ||||||||||||
| 14 | size_t l = 0; | - | ||||||||||||
| 15 | - | |||||||||||||
| 16 | n = *num; | - | ||||||||||||
| 17 | - | |||||||||||||
| 18 | if (enc
| 10027-10087 | ||||||||||||
| 19 | - | |||||||||||||
| 20 | if (16 % sizeof(size_t) == 0
| 0-10087 | ||||||||||||
| 21 | do { | - | ||||||||||||
| 22 | while (n
| 154-35028 | ||||||||||||
| 23 | *(out++) = ivec[n] ^= *(in++); | - | ||||||||||||
| 24 | --len; | - | ||||||||||||
| 25 | n = (n + 1) % 16; | - | ||||||||||||
| 26 | } executed 34874 times by 1 test: end of blockExecuted by:
| 34874 | ||||||||||||
| 27 | - | |||||||||||||
| 28 | - | |||||||||||||
| 29 | - | |||||||||||||
| 30 | - | |||||||||||||
| 31 | - | |||||||||||||
| 32 | while (len >= 16
| 10087-195632 | ||||||||||||
| 33 | (*block) (ivec, ivec, key); | - | ||||||||||||
| 34 | for (; n < 16
| 195632-391264 | ||||||||||||
| 35 | *(size_t *)(out + n) = | - | ||||||||||||
| 36 | *(size_t *)(ivec + n) ^= *(size_t *)(in + n); | - | ||||||||||||
| 37 | } executed 391264 times by 1 test: end of blockExecuted by:
| 391264 | ||||||||||||
| 38 | len -= 16; | - | ||||||||||||
| 39 | out += 16; | - | ||||||||||||
| 40 | in += 16; | - | ||||||||||||
| 41 | n = 0; | - | ||||||||||||
| 42 | } executed 195632 times by 1 test: end of blockExecuted by:
| 195632 | ||||||||||||
| 43 | if (len
| 4223-5864 | ||||||||||||
| 44 | (*block) (ivec, ivec, key); | - | ||||||||||||
| 45 | while (len--
| 4223-32596 | ||||||||||||
| 46 | out[n] = ivec[n] ^= in[n]; | - | ||||||||||||
| 47 | ++n; | - | ||||||||||||
| 48 | } executed 32596 times by 1 test: end of blockExecuted by:
| 32596 | ||||||||||||
| 49 | } executed 4223 times by 1 test: end of blockExecuted by:
| 4223 | ||||||||||||
| 50 | *num = n; | - | ||||||||||||
| 51 | return; executed 10087 times by 1 test: return;Executed by:
| 10087 | ||||||||||||
| 52 | } while (0); | - | ||||||||||||
| 53 | } never executed: end of block | 0 | ||||||||||||
| 54 | - | |||||||||||||
| 55 | - | |||||||||||||
| 56 | while (l < len
| 0 | ||||||||||||
| 57 | if (n == 0
| 0 | ||||||||||||
| 58 | (*block) (ivec, ivec, key); | - | ||||||||||||
| 59 | } never executed: end of block | 0 | ||||||||||||
| 60 | out[l] = ivec[n] ^= in[l]; | - | ||||||||||||
| 61 | ++l; | - | ||||||||||||
| 62 | n = (n + 1) % 16; | - | ||||||||||||
| 63 | } never executed: end of block | 0 | ||||||||||||
| 64 | *num = n; | - | ||||||||||||
| 65 | } never executed: else {end of block | 0 | ||||||||||||
| 66 | - | |||||||||||||
| 67 | if (16 % sizeof(size_t) == 0
| 0-10027 | ||||||||||||
| 68 | do { | - | ||||||||||||
| 69 | while (n
| 144-34378 | ||||||||||||
| 70 | unsigned char c; | - | ||||||||||||
| 71 | *(out++) = ivec[n] ^ (c = *(in++)); | - | ||||||||||||
| 72 | ivec[n] = c; | - | ||||||||||||
| 73 | --len; | - | ||||||||||||
| 74 | n = (n + 1) % 16; | - | ||||||||||||
| 75 | } executed 34234 times by 1 test: end of blockExecuted by:
| 34234 | ||||||||||||
| 76 | - | |||||||||||||
| 77 | - | |||||||||||||
| 78 | - | |||||||||||||
| 79 | - | |||||||||||||
| 80 | - | |||||||||||||
| 81 | while (len >= 16
| 10027-195672 | ||||||||||||
| 82 | (*block) (ivec, ivec, key); | - | ||||||||||||
| 83 | for (; n < 16
| 195672-391344 | ||||||||||||
| 84 | size_t t = *(size_t *)(in + n); | - | ||||||||||||
| 85 | *(size_t *)(out + n) = *(size_t *)(ivec + n) ^ t; | - | ||||||||||||
| 86 | *(size_t *)(ivec + n) = t; | - | ||||||||||||
| 87 | } executed 391344 times by 1 test: end of blockExecuted by:
| 391344 | ||||||||||||
| 88 | len -= 16; | - | ||||||||||||
| 89 | out += 16; | - | ||||||||||||
| 90 | in += 16; | - | ||||||||||||
| 91 | n = 0; | - | ||||||||||||
| 92 | } executed 195672 times by 1 test: end of blockExecuted by:
| 195672 | ||||||||||||
| 93 | if (len
| 4183-5844 | ||||||||||||
| 94 | (*block) (ivec, ivec, key); | - | ||||||||||||
| 95 | while (len--
| 4183-32596 | ||||||||||||
| 96 | unsigned char c; | - | ||||||||||||
| 97 | out[n] = ivec[n] ^ (c = in[n]); | - | ||||||||||||
| 98 | ivec[n] = c; | - | ||||||||||||
| 99 | ++n; | - | ||||||||||||
| 100 | } executed 32596 times by 1 test: end of blockExecuted by:
| 32596 | ||||||||||||
| 101 | } executed 4183 times by 1 test: end of blockExecuted by:
| 4183 | ||||||||||||
| 102 | *num = n; | - | ||||||||||||
| 103 | return; executed 10027 times by 1 test: return;Executed by:
| 10027 | ||||||||||||
| 104 | } while (0); | - | ||||||||||||
| 105 | } never executed: end of block | 0 | ||||||||||||
| 106 | - | |||||||||||||
| 107 | - | |||||||||||||
| 108 | while (l < len
| 0 | ||||||||||||
| 109 | unsigned char c; | - | ||||||||||||
| 110 | if (n == 0
| 0 | ||||||||||||
| 111 | (*block) (ivec, ivec, key); | - | ||||||||||||
| 112 | } never executed: end of block | 0 | ||||||||||||
| 113 | out[l] = ivec[n] ^ (c = in[l]); | - | ||||||||||||
| 114 | ivec[n] = c; | - | ||||||||||||
| 115 | ++l; | - | ||||||||||||
| 116 | n = (n + 1) % 16; | - | ||||||||||||
| 117 | } never executed: end of block | 0 | ||||||||||||
| 118 | *num = n; | - | ||||||||||||
| 119 | } never executed: end of block | 0 | ||||||||||||
| 120 | } | - | ||||||||||||
| 121 | - | |||||||||||||
| 122 | - | |||||||||||||
| 123 | - | |||||||||||||
| 124 | - | |||||||||||||
| 125 | - | |||||||||||||
| 126 | static void cfbr_encrypt_block(const unsigned char *in, unsigned char *out, | - | ||||||||||||
| 127 | int nbits, const void *key, | - | ||||||||||||
| 128 | unsigned char ivec[16], int enc, | - | ||||||||||||
| 129 | block128_f block) | - | ||||||||||||
| 130 | { | - | ||||||||||||
| 131 | int n, rem, num; | - | ||||||||||||
| 132 | unsigned char ovec[16 * 2 + 1]; | - | ||||||||||||
| 133 | - | |||||||||||||
| 134 | - | |||||||||||||
| 135 | if (nbits <= 0
| 0-562212 | ||||||||||||
| 136 | return; never executed: return; | 0 | ||||||||||||
| 137 | - | |||||||||||||
| 138 | - | |||||||||||||
| 139 | memcpy(ovec, ivec, 16); | - | ||||||||||||
| 140 | - | |||||||||||||
| 141 | (*block) (ivec, ivec, key); | - | ||||||||||||
| 142 | num = (nbits + 7) / 8; | - | ||||||||||||
| 143 | if (enc
| 281106 | ||||||||||||
| 144 | for (n = 0; n < num
| 281106 | ||||||||||||
| 145 | out[n] = (ovec[16 + n] = in[n] ^ ivec[n]); executed 281106 times by 1 test: out[n] = (ovec[16 + n] = in[n] ^ ivec[n]);Executed by:
| 281106 | ||||||||||||
| 146 | else | - | ||||||||||||
| 147 | for (n = 0; n < num
| 281106 | ||||||||||||
| 148 | out[n] = (ovec[16 + n] = in[n]) ^ ivec[n]; executed 281106 times by 1 test: out[n] = (ovec[16 + n] = in[n]) ^ ivec[n];Executed by:
| 281106 | ||||||||||||
| 149 | - | |||||||||||||
| 150 | rem = nbits % 8; | - | ||||||||||||
| 151 | num = nbits / 8; | - | ||||||||||||
| 152 | if (rem == 0
| 72708-489504 | ||||||||||||
| 153 | memcpy(ivec, ovec + num, 16); executed 72708 times by 1 test: memcpy(ivec, ovec + num, 16);Executed by:
| 72708 | ||||||||||||
| 154 | else | - | ||||||||||||
| 155 | for (n = 0; n < 16
| 489504-7832064 | ||||||||||||
| 156 | ivec[n] = ovec[n + num] << rem | ovec[n + num + 1] >> (8 - rem); executed 7832064 times by 1 test: ivec[n] = ovec[n + num] << rem | ovec[n + num + 1] >> (8 - rem);Executed by:
| 7832064 | ||||||||||||
| 157 | - | |||||||||||||
| 158 | - | |||||||||||||
| 159 | } executed 562212 times by 1 test: end of blockExecuted by:
| 562212 | ||||||||||||
| 160 | - | |||||||||||||
| 161 | - | |||||||||||||
| 162 | void CRYPTO_cfb128_1_encrypt(const unsigned char *in, unsigned char *out, | - | ||||||||||||
| 163 | size_t bits, const void *key, | - | ||||||||||||
| 164 | unsigned char ivec[16], int *num, | - | ||||||||||||
| 165 | int enc, block128_f block) | - | ||||||||||||
| 166 | { | - | ||||||||||||
| 167 | size_t n; | - | ||||||||||||
| 168 | unsigned char c[1], d[1]; | - | ||||||||||||
| 169 | - | |||||||||||||
| 170 | for (n = 0; n < bits
| 222-489504 | ||||||||||||
| 171 | c[0] = (
| 224519-264985 | ||||||||||||
| 172 | cfbr_encrypt_block(c, d, 1, key, ivec, enc, block); | - | ||||||||||||
| 173 | out[n / 8] = (out[n / 8] & ~(1 << (unsigned int)(7 - n % 8))) | | - | ||||||||||||
| 174 | ((d[0] & 0x80) >> (unsigned int)(n % 8)); | - | ||||||||||||
| 175 | } executed 489504 times by 1 test: end of blockExecuted by:
| 489504 | ||||||||||||
| 176 | } executed 222 times by 1 test: end of blockExecuted by:
| 222 | ||||||||||||
| 177 | - | |||||||||||||
| 178 | void CRYPTO_cfb128_8_encrypt(const unsigned char *in, unsigned char *out, | - | ||||||||||||
| 179 | size_t length, const void *key, | - | ||||||||||||
| 180 | unsigned char ivec[16], int *num, | - | ||||||||||||
| 181 | int enc, block128_f block) | - | ||||||||||||
| 182 | { | - | ||||||||||||
| 183 | size_t n; | - | ||||||||||||
| 184 | - | |||||||||||||
| 185 | for (n = 0; n < length
| 366-72708 | ||||||||||||
| 186 | cfbr_encrypt_block(&in[n], &out[n], 8, key, ivec, enc, block); executed 72708 times by 1 test: cfbr_encrypt_block(&in[n], &out[n], 8, key, ivec, enc, block);Executed by:
| 72708 | ||||||||||||
| 187 | } executed 366 times by 1 test: end of blockExecuted by:
| 366 | ||||||||||||
| Switch to Source code | Preprocessed file |