| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/libressl/src/crypto/gost/gost2814789.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||
| 2 | - | |||||||||||||||||||
| 3 | - | |||||||||||||||||||
| 4 | - | |||||||||||||||||||
| 5 | - | |||||||||||||||||||
| 6 | static inline unsigned int | - | ||||||||||||||||||
| 7 | f(const GOST2814789_KEY *c, unsigned int x) | - | ||||||||||||||||||
| 8 | { | - | ||||||||||||||||||
| 9 | return executed 55554080 times by 3 tests: c->k87[(x>>24) & 255] | c->k65[(x>>16) & 255]|return c->k87[(x>>24) & 255] | c->k65[(x>>16) & 255]| c->k43[(x>> 8) & 255] | c->k21[(x ) & 255];Executed by:
executed 55554080 times by 3 tests: return c->k87[(x>>24) & 255] | c->k65[(x>>16) & 255]| c->k43[(x>> 8) & 255] | c->k21[(x ) & 255];Executed by:
| 55554080 | ||||||||||||||||||
| 10 | c->k43[(x>> 8) & 255] | c->k21[(x ) & 255]; executed 55554080 times by 3 tests: return c->k87[(x>>24) & 255] | c->k65[(x>>16) & 255]| c->k43[(x>> 8) & 255] | c->k21[(x ) & 255];Executed by:
| 55554080 | ||||||||||||||||||
| 11 | } | - | ||||||||||||||||||
| 12 | - | |||||||||||||||||||
| 13 | void | - | ||||||||||||||||||
| 14 | Gost2814789_encrypt(const unsigned char *in, unsigned char *out, | - | ||||||||||||||||||
| 15 | const GOST2814789_KEY *key) | - | ||||||||||||||||||
| 16 | { | - | ||||||||||||||||||
| 17 | unsigned int n1, n2; | - | ||||||||||||||||||
| 18 | - | |||||||||||||||||||
| 19 | ((n1)=*((const unsigned int *)(in)), (in)+=4); | - | ||||||||||||||||||
| 20 | ((n2)=*((const unsigned int *)(in)), (in)+=4); | - | ||||||||||||||||||
| 21 | - | |||||||||||||||||||
| 22 | - | |||||||||||||||||||
| 23 | n2 ^= f(key, n1 + key->key[0]); n1 ^= f(key, n2 + key->key[1]); | - | ||||||||||||||||||
| 24 | n2 ^= f(key, n1 + key->key[2]); n1 ^= f(key, n2 + key->key[3]); | - | ||||||||||||||||||
| 25 | n2 ^= f(key, n1 + key->key[4]); n1 ^= f(key, n2 + key->key[5]); | - | ||||||||||||||||||
| 26 | n2 ^= f(key, n1 + key->key[6]); n1 ^= f(key, n2 + key->key[7]); | - | ||||||||||||||||||
| 27 | - | |||||||||||||||||||
| 28 | n2 ^= f(key, n1 + key->key[0]); n1 ^= f(key, n2 + key->key[1]); | - | ||||||||||||||||||
| 29 | n2 ^= f(key, n1 + key->key[2]); n1 ^= f(key, n2 + key->key[3]); | - | ||||||||||||||||||
| 30 | n2 ^= f(key, n1 + key->key[4]); n1 ^= f(key, n2 + key->key[5]); | - | ||||||||||||||||||
| 31 | n2 ^= f(key, n1 + key->key[6]); n1 ^= f(key, n2 + key->key[7]); | - | ||||||||||||||||||
| 32 | - | |||||||||||||||||||
| 33 | n2 ^= f(key, n1 + key->key[0]); n1 ^= f(key, n2 + key->key[1]); | - | ||||||||||||||||||
| 34 | n2 ^= f(key, n1 + key->key[2]); n1 ^= f(key, n2 + key->key[3]); | - | ||||||||||||||||||
| 35 | n2 ^= f(key, n1 + key->key[4]); n1 ^= f(key, n2 + key->key[5]); | - | ||||||||||||||||||
| 36 | n2 ^= f(key, n1 + key->key[6]); n1 ^= f(key, n2 + key->key[7]); | - | ||||||||||||||||||
| 37 | - | |||||||||||||||||||
| 38 | n2 ^= f(key, n1 + key->key[7]); n1 ^= f(key, n2 + key->key[6]); | - | ||||||||||||||||||
| 39 | n2 ^= f(key, n1 + key->key[5]); n1 ^= f(key, n2 + key->key[4]); | - | ||||||||||||||||||
| 40 | n2 ^= f(key, n1 + key->key[3]); n1 ^= f(key, n2 + key->key[2]); | - | ||||||||||||||||||
| 41 | n2 ^= f(key, n1 + key->key[1]); n1 ^= f(key, n2 + key->key[0]); | - | ||||||||||||||||||
| 42 | - | |||||||||||||||||||
| 43 | (*((unsigned int *)(out))=(n2), (out)+=4); | - | ||||||||||||||||||
| 44 | (*((unsigned int *)(out))=(n1), (out)+=4); | - | ||||||||||||||||||
| 45 | } executed 1346867 times by 3 tests: end of blockExecuted by:
| 1346867 | ||||||||||||||||||
| 46 | - | |||||||||||||||||||
| 47 | void | - | ||||||||||||||||||
| 48 | Gost2814789_decrypt(const unsigned char *in, unsigned char *out, | - | ||||||||||||||||||
| 49 | const GOST2814789_KEY *key) | - | ||||||||||||||||||
| 50 | { | - | ||||||||||||||||||
| 51 | unsigned int n1, n2; | - | ||||||||||||||||||
| 52 | - | |||||||||||||||||||
| 53 | ((n1)=*((const unsigned int *)(in)), (in)+=4); | - | ||||||||||||||||||
| 54 | ((n2)=*((const unsigned int *)(in)), (in)+=4); | - | ||||||||||||||||||
| 55 | - | |||||||||||||||||||
| 56 | - | |||||||||||||||||||
| 57 | n2 ^= f(key, n1 + key->key[0]); n1 ^= f(key, n2 + key->key[1]); | - | ||||||||||||||||||
| 58 | n2 ^= f(key, n1 + key->key[2]); n1 ^= f(key, n2 + key->key[3]); | - | ||||||||||||||||||
| 59 | n2 ^= f(key, n1 + key->key[4]); n1 ^= f(key, n2 + key->key[5]); | - | ||||||||||||||||||
| 60 | n2 ^= f(key, n1 + key->key[6]); n1 ^= f(key, n2 + key->key[7]); | - | ||||||||||||||||||
| 61 | - | |||||||||||||||||||
| 62 | n2 ^= f(key, n1 + key->key[7]); n1 ^= f(key, n2 + key->key[6]); | - | ||||||||||||||||||
| 63 | n2 ^= f(key, n1 + key->key[5]); n1 ^= f(key, n2 + key->key[4]); | - | ||||||||||||||||||
| 64 | n2 ^= f(key, n1 + key->key[3]); n1 ^= f(key, n2 + key->key[2]); | - | ||||||||||||||||||
| 65 | n2 ^= f(key, n1 + key->key[1]); n1 ^= f(key, n2 + key->key[0]); | - | ||||||||||||||||||
| 66 | - | |||||||||||||||||||
| 67 | n2 ^= f(key, n1 + key->key[7]); n1 ^= f(key, n2 + key->key[6]); | - | ||||||||||||||||||
| 68 | n2 ^= f(key, n1 + key->key[5]); n1 ^= f(key, n2 + key->key[4]); | - | ||||||||||||||||||
| 69 | n2 ^= f(key, n1 + key->key[3]); n1 ^= f(key, n2 + key->key[2]); | - | ||||||||||||||||||
| 70 | n2 ^= f(key, n1 + key->key[1]); n1 ^= f(key, n2 + key->key[0]); | - | ||||||||||||||||||
| 71 | - | |||||||||||||||||||
| 72 | n2 ^= f(key, n1 + key->key[7]); n1 ^= f(key, n2 + key->key[6]); | - | ||||||||||||||||||
| 73 | n2 ^= f(key, n1 + key->key[5]); n1 ^= f(key, n2 + key->key[4]); | - | ||||||||||||||||||
| 74 | n2 ^= f(key, n1 + key->key[3]); n1 ^= f(key, n2 + key->key[2]); | - | ||||||||||||||||||
| 75 | n2 ^= f(key, n1 + key->key[1]); n1 ^= f(key, n2 + key->key[0]); | - | ||||||||||||||||||
| 76 | - | |||||||||||||||||||
| 77 | (*((unsigned int *)(out))=(n2), (out)+=4); | - | ||||||||||||||||||
| 78 | (*((unsigned int *)(out))=(n1), (out)+=4); | - | ||||||||||||||||||
| 79 | } executed 61448 times by 1 test: end of blockExecuted by:
| 61448 | ||||||||||||||||||
| 80 | - | |||||||||||||||||||
| 81 | static void | - | ||||||||||||||||||
| 82 | Gost2814789_mac(const unsigned char *in, unsigned char *mac, | - | ||||||||||||||||||
| 83 | GOST2814789_KEY *key) | - | ||||||||||||||||||
| 84 | { | - | ||||||||||||||||||
| 85 | unsigned int n1, n2; | - | ||||||||||||||||||
| 86 | unsigned char *p; | - | ||||||||||||||||||
| 87 | int i; | - | ||||||||||||||||||
| 88 | - | |||||||||||||||||||
| 89 | for (i = 0; i < 8
| 655500-5244000 | ||||||||||||||||||
| 90 | mac[i] ^= in[i]; executed 5244000 times by 1 test: mac[i] ^= in[i];Executed by:
| 5244000 | ||||||||||||||||||
| 91 | - | |||||||||||||||||||
| 92 | p = mac; | - | ||||||||||||||||||
| 93 | ((n1)=*((const unsigned int *)(p)), (p)+=4); | - | ||||||||||||||||||
| 94 | ((n2)=*((const unsigned int *)(p)), (p)+=4); | - | ||||||||||||||||||
| 95 | - | |||||||||||||||||||
| 96 | - | |||||||||||||||||||
| 97 | n2 ^= f(key, n1 + key->key[0]); n1 ^= f(key, n2 + key->key[1]); | - | ||||||||||||||||||
| 98 | n2 ^= f(key, n1 + key->key[2]); n1 ^= f(key, n2 + key->key[3]); | - | ||||||||||||||||||
| 99 | n2 ^= f(key, n1 + key->key[4]); n1 ^= f(key, n2 + key->key[5]); | - | ||||||||||||||||||
| 100 | n2 ^= f(key, n1 + key->key[6]); n1 ^= f(key, n2 + key->key[7]); | - | ||||||||||||||||||
| 101 | - | |||||||||||||||||||
| 102 | n2 ^= f(key, n1 + key->key[0]); n1 ^= f(key, n2 + key->key[1]); | - | ||||||||||||||||||
| 103 | n2 ^= f(key, n1 + key->key[2]); n1 ^= f(key, n2 + key->key[3]); | - | ||||||||||||||||||
| 104 | n2 ^= f(key, n1 + key->key[4]); n1 ^= f(key, n2 + key->key[5]); | - | ||||||||||||||||||
| 105 | n2 ^= f(key, n1 + key->key[6]); n1 ^= f(key, n2 + key->key[7]); | - | ||||||||||||||||||
| 106 | - | |||||||||||||||||||
| 107 | p = mac; | - | ||||||||||||||||||
| 108 | (*((unsigned int *)(p))=(n1), (p)+=4); | - | ||||||||||||||||||
| 109 | (*((unsigned int *)(p))=(n2), (p)+=4); | - | ||||||||||||||||||
| 110 | } executed 655500 times by 1 test: end of blockExecuted by:
| 655500 | ||||||||||||||||||
| 111 | - | |||||||||||||||||||
| 112 | void | - | ||||||||||||||||||
| 113 | Gost2814789_ecb_encrypt(const unsigned char *in, unsigned char *out, | - | ||||||||||||||||||
| 114 | GOST2814789_KEY *key, const int enc) | - | ||||||||||||||||||
| 115 | { | - | ||||||||||||||||||
| 116 | if (key->key_meshing
| 0-3 | ||||||||||||||||||
| 117 | Gost2814789_cryptopro_key_mesh(key); | - | ||||||||||||||||||
| 118 | key->count = 0; | - | ||||||||||||||||||
| 119 | } never executed: end of block | 0 | ||||||||||||||||||
| 120 | - | |||||||||||||||||||
| 121 | if (enc
| 0-5 | ||||||||||||||||||
| 122 | Gost2814789_encrypt(in, out, key); executed 5 times by 1 test: Gost2814789_encrypt(in, out, key);Executed by:
| 5 | ||||||||||||||||||
| 123 | else | - | ||||||||||||||||||
| 124 | Gost2814789_decrypt(in, out, key); never executed: Gost2814789_decrypt(in, out, key); | 0 | ||||||||||||||||||
| 125 | } | - | ||||||||||||||||||
| 126 | - | |||||||||||||||||||
| 127 | static inline void | - | ||||||||||||||||||
| 128 | Gost2814789_encrypt_mesh(unsigned char *iv, GOST2814789_KEY *key) | - | ||||||||||||||||||
| 129 | { | - | ||||||||||||||||||
| 130 | if (key->key_meshing
| 0-655496 | ||||||||||||||||||
| 131 | Gost2814789_cryptopro_key_mesh(key); | - | ||||||||||||||||||
| 132 | Gost2814789_encrypt(iv, iv, key); | - | ||||||||||||||||||
| 133 | key->count = 0; | - | ||||||||||||||||||
| 134 | } executed 5121 times by 1 test: end of blockExecuted by:
| 5121 | ||||||||||||||||||
| 135 | Gost2814789_encrypt(iv, iv, key); | - | ||||||||||||||||||
| 136 | key->count += 8; | - | ||||||||||||||||||
| 137 | } executed 655496 times by 1 test: end of blockExecuted by:
| 655496 | ||||||||||||||||||
| 138 | - | |||||||||||||||||||
| 139 | static inline void | - | ||||||||||||||||||
| 140 | Gost2814789_mac_mesh(const unsigned char *data, unsigned char *mac, | - | ||||||||||||||||||
| 141 | GOST2814789_KEY *key) | - | ||||||||||||||||||
| 142 | { | - | ||||||||||||||||||
| 143 | if (key->key_meshing
| 0-655500 | ||||||||||||||||||
| 144 | Gost2814789_cryptopro_key_mesh(key); | - | ||||||||||||||||||
| 145 | key->count = 0; | - | ||||||||||||||||||
| 146 | } executed 5120 times by 1 test: end of blockExecuted by:
| 5120 | ||||||||||||||||||
| 147 | Gost2814789_mac(data, mac, key); | - | ||||||||||||||||||
| 148 | key->count += 8; | - | ||||||||||||||||||
| 149 | } executed 655500 times by 1 test: end of blockExecuted by:
| 655500 | ||||||||||||||||||
| 150 | - | |||||||||||||||||||
| 151 | void | - | ||||||||||||||||||
| 152 | Gost2814789_cfb64_encrypt(const unsigned char *in, unsigned char *out, | - | ||||||||||||||||||
| 153 | size_t len, GOST2814789_KEY *key, unsigned char *ivec, int *num, | - | ||||||||||||||||||
| 154 | const int enc) | - | ||||||||||||||||||
| 155 | { | - | ||||||||||||||||||
| 156 | unsigned int n; | - | ||||||||||||||||||
| 157 | size_t l = 0; | - | ||||||||||||||||||
| 158 | - | |||||||||||||||||||
| 159 | n = *num; | - | ||||||||||||||||||
| 160 | - | |||||||||||||||||||
| 161 | if (enc
| 0-5 | ||||||||||||||||||
| 162 | - | |||||||||||||||||||
| 163 | if (8 % sizeof(size_t) == 0
| 0-5 | ||||||||||||||||||
| 164 | while (n
| 0-5 | ||||||||||||||||||
| 165 | *(out++) = ivec[n] ^= *(in++); | - | ||||||||||||||||||
| 166 | --len; | - | ||||||||||||||||||
| 167 | n = (n + 1) % 8; | - | ||||||||||||||||||
| 168 | } never executed: end of block | 0 | ||||||||||||||||||
| 169 | - | |||||||||||||||||||
| 170 | - | |||||||||||||||||||
| 171 | - | |||||||||||||||||||
| 172 | - | |||||||||||||||||||
| 173 | - | |||||||||||||||||||
| 174 | while (len >= 8
| 5-655493 | ||||||||||||||||||
| 175 | Gost2814789_encrypt_mesh(ivec, key); | - | ||||||||||||||||||
| 176 | for (; n < 8
| 655493 | ||||||||||||||||||
| 177 | *(size_t*)(out + n) = | - | ||||||||||||||||||
| 178 | *(size_t*)(ivec + n) ^= | - | ||||||||||||||||||
| 179 | *(size_t*)(in + n); | - | ||||||||||||||||||
| 180 | } executed 655493 times by 1 test: end of blockExecuted by:
| 655493 | ||||||||||||||||||
| 181 | len -= 8; | - | ||||||||||||||||||
| 182 | out += 8; | - | ||||||||||||||||||
| 183 | in += 8; | - | ||||||||||||||||||
| 184 | n = 0; | - | ||||||||||||||||||
| 185 | } executed 655493 times by 1 test: end of blockExecuted by:
| 655493 | ||||||||||||||||||
| 186 | if (len
| 2-3 | ||||||||||||||||||
| 187 | Gost2814789_encrypt_mesh(ivec, key); | - | ||||||||||||||||||
| 188 | while (len--
| 3-12 | ||||||||||||||||||
| 189 | out[n] = ivec[n] ^= in[n]; | - | ||||||||||||||||||
| 190 | ++n; | - | ||||||||||||||||||
| 191 | } executed 12 times by 1 test: end of blockExecuted by:
| 12 | ||||||||||||||||||
| 192 | } executed 3 times by 1 test: end of blockExecuted by:
| 3 | ||||||||||||||||||
| 193 | *num = n; | - | ||||||||||||||||||
| 194 | return; executed 5 times by 1 test: return;Executed by:
| 5 | ||||||||||||||||||
| 195 | } never executed: while (0);end of block | 0 | ||||||||||||||||||
| 196 | - | |||||||||||||||||||
| 197 | - | |||||||||||||||||||
| 198 | while (l<len
| 0 | ||||||||||||||||||
| 199 | if (n == 0
| 0 | ||||||||||||||||||
| 200 | Gost2814789_encrypt_mesh(ivec, key); | - | ||||||||||||||||||
| 201 | } never executed: end of block | 0 | ||||||||||||||||||
| 202 | out[l] = ivec[n] ^= in[l]; | - | ||||||||||||||||||
| 203 | ++l; | - | ||||||||||||||||||
| 204 | n = (n + 1) % 8; | - | ||||||||||||||||||
| 205 | } never executed: end of block | 0 | ||||||||||||||||||
| 206 | *num = n; | - | ||||||||||||||||||
| 207 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 208 | - | |||||||||||||||||||
| 209 | if (8 % sizeof(size_t) == 0
| 0 | ||||||||||||||||||
| 210 | while (n
| 0 | ||||||||||||||||||
| 211 | unsigned char c; | - | ||||||||||||||||||
| 212 | - | |||||||||||||||||||
| 213 | *(out++) = ivec[n] ^ (c = *(in++)); | - | ||||||||||||||||||
| 214 | ivec[n] = c; | - | ||||||||||||||||||
| 215 | --len; | - | ||||||||||||||||||
| 216 | n = (n + 1) % 8; | - | ||||||||||||||||||
| 217 | } never executed: end of block | 0 | ||||||||||||||||||
| 218 | - | |||||||||||||||||||
| 219 | - | |||||||||||||||||||
| 220 | - | |||||||||||||||||||
| 221 | - | |||||||||||||||||||
| 222 | - | |||||||||||||||||||
| 223 | while (len >= 8
| 0 | ||||||||||||||||||
| 224 | Gost2814789_encrypt_mesh(ivec, key); | - | ||||||||||||||||||
| 225 | for (; n < 8
| 0 | ||||||||||||||||||
| 226 | size_t t = *(size_t*)(in + n); | - | ||||||||||||||||||
| 227 | *(size_t*)(out + n) = | - | ||||||||||||||||||
| 228 | *(size_t*)(ivec + n) ^ t; | - | ||||||||||||||||||
| 229 | *(size_t*)(ivec + n) = t; | - | ||||||||||||||||||
| 230 | } never executed: end of block | 0 | ||||||||||||||||||
| 231 | len -= 8; | - | ||||||||||||||||||
| 232 | out += 8; | - | ||||||||||||||||||
| 233 | in += 8; | - | ||||||||||||||||||
| 234 | n = 0; | - | ||||||||||||||||||
| 235 | } never executed: end of block | 0 | ||||||||||||||||||
| 236 | if (len
| 0 | ||||||||||||||||||
| 237 | Gost2814789_encrypt_mesh(ivec, key); | - | ||||||||||||||||||
| 238 | while (len--
| 0 | ||||||||||||||||||
| 239 | unsigned char c; | - | ||||||||||||||||||
| 240 | - | |||||||||||||||||||
| 241 | out[n] = ivec[n] ^ (c = in[n]); | - | ||||||||||||||||||
| 242 | ivec[n] = c; | - | ||||||||||||||||||
| 243 | ++n; | - | ||||||||||||||||||
| 244 | } never executed: end of block | 0 | ||||||||||||||||||
| 245 | } never executed: end of block | 0 | ||||||||||||||||||
| 246 | *num = n; | - | ||||||||||||||||||
| 247 | return; never executed: return; | 0 | ||||||||||||||||||
| 248 | } never executed: while (0);end of block | 0 | ||||||||||||||||||
| 249 | - | |||||||||||||||||||
| 250 | - | |||||||||||||||||||
| 251 | while (l < len
| 0 | ||||||||||||||||||
| 252 | unsigned char c; | - | ||||||||||||||||||
| 253 | - | |||||||||||||||||||
| 254 | if (n == 0
| 0 | ||||||||||||||||||
| 255 | Gost2814789_encrypt_mesh(ivec, key); | - | ||||||||||||||||||
| 256 | } never executed: end of block | 0 | ||||||||||||||||||
| 257 | out[l] = ivec[n] ^ (c = in[l]); ivec[n] = c; | - | ||||||||||||||||||
| 258 | ++l; | - | ||||||||||||||||||
| 259 | n = (n + 1) % 8; | - | ||||||||||||||||||
| 260 | } never executed: end of block | 0 | ||||||||||||||||||
| 261 | *num = n; | - | ||||||||||||||||||
| 262 | } never executed: end of block | 0 | ||||||||||||||||||
| 263 | } | - | ||||||||||||||||||
| 264 | - | |||||||||||||||||||
| 265 | static inline void | - | ||||||||||||||||||
| 266 | Gost2814789_cnt_next(unsigned char *ivec, unsigned char *out, | - | ||||||||||||||||||
| 267 | GOST2814789_KEY *key) | - | ||||||||||||||||||
| 268 | { | - | ||||||||||||||||||
| 269 | unsigned char *p = ivec, *p2 = ivec; | - | ||||||||||||||||||
| 270 | unsigned int val, val2; | - | ||||||||||||||||||
| 271 | - | |||||||||||||||||||
| 272 | if (key->count == 0
| 3-655490 | ||||||||||||||||||
| 273 | Gost2814789_encrypt(ivec, ivec, key); executed 3 times by 1 test: Gost2814789_encrypt(ivec, ivec, key);Executed by:
| 3 | ||||||||||||||||||
| 274 | - | |||||||||||||||||||
| 275 | if (key->key_meshing
| 0-655493 | ||||||||||||||||||
| 276 | Gost2814789_cryptopro_key_mesh(key); | - | ||||||||||||||||||
| 277 | Gost2814789_encrypt(ivec, ivec, key); | - | ||||||||||||||||||
| 278 | key->count = 0; | - | ||||||||||||||||||
| 279 | } executed 5121 times by 1 test: end of blockExecuted by:
| 5121 | ||||||||||||||||||
| 280 | - | |||||||||||||||||||
| 281 | ((val)=*((const unsigned int *)(p)), (p)+=4); | - | ||||||||||||||||||
| 282 | val2 = val + 0x01010101; | - | ||||||||||||||||||
| 283 | (*((unsigned int *)(p2))=(val2), (p2)+=4); | - | ||||||||||||||||||
| 284 | - | |||||||||||||||||||
| 285 | ((val)=*((const unsigned int *)(p)), (p)+=4); | - | ||||||||||||||||||
| 286 | val2 = val + 0x01010104; | - | ||||||||||||||||||
| 287 | if (val > val2
| 2558-652935 | ||||||||||||||||||
| 288 | val2++; executed 2558 times by 1 test: val2++;Executed by:
| 2558 | ||||||||||||||||||
| 289 | (*((unsigned int *)(p2))=(val2), (p2)+=4); | - | ||||||||||||||||||
| 290 | - | |||||||||||||||||||
| 291 | Gost2814789_encrypt(ivec, out, key); | - | ||||||||||||||||||
| 292 | key->count += 8; | - | ||||||||||||||||||
| 293 | } executed 655493 times by 1 test: end of blockExecuted by:
| 655493 | ||||||||||||||||||
| 294 | - | |||||||||||||||||||
| 295 | void | - | ||||||||||||||||||
| 296 | Gost2814789_cnt_encrypt(const unsigned char *in, unsigned char *out, size_t len, | - | ||||||||||||||||||
| 297 | GOST2814789_KEY *key, unsigned char *ivec, unsigned char *cnt_buf, int *num) | - | ||||||||||||||||||
| 298 | { | - | ||||||||||||||||||
| 299 | unsigned int n; | - | ||||||||||||||||||
| 300 | size_t l = 0; | - | ||||||||||||||||||
| 301 | - | |||||||||||||||||||
| 302 | n = *num; | - | ||||||||||||||||||
| 303 | - | |||||||||||||||||||
| 304 | - | |||||||||||||||||||
| 305 | if (8 % sizeof(size_t) == 0
| 0-3 | ||||||||||||||||||
| 306 | while (n
| 0-3 | ||||||||||||||||||
| 307 | *(out++) = *(in++) ^ cnt_buf[n]; | - | ||||||||||||||||||
| 308 | --len; | - | ||||||||||||||||||
| 309 | n = (n + 1) % 8; | - | ||||||||||||||||||
| 310 | } never executed: end of block | 0 | ||||||||||||||||||
| 311 | - | |||||||||||||||||||
| 312 | - | |||||||||||||||||||
| 313 | - | |||||||||||||||||||
| 314 | - | |||||||||||||||||||
| 315 | - | |||||||||||||||||||
| 316 | - | |||||||||||||||||||
| 317 | while (len >= 8
| 3-655492 | ||||||||||||||||||
| 318 | Gost2814789_cnt_next(ivec, cnt_buf, key); | - | ||||||||||||||||||
| 319 | for (; n < 8
| 655492 | ||||||||||||||||||
| 320 | *( executed 655492 times by 1 test: size_t *)(out + n) = *(size_t *)(in + n) ^*(size_t *)(out + n) = *(size_t *)(in + n) ^ *(size_t *)(cnt_buf + n);Executed by:
executed 655492 times by 1 test: *(size_t *)(out + n) = *(size_t *)(in + n) ^ *(size_t *)(cnt_buf + n);Executed by:
| 655492 | ||||||||||||||||||
| 321 | *(size_t *)(cnt_buf + n); executed 655492 times by 1 test: *(size_t *)(out + n) = *(size_t *)(in + n) ^ *(size_t *)(cnt_buf + n);Executed by:
| 655492 | ||||||||||||||||||
| 322 | len -= 8; | - | ||||||||||||||||||
| 323 | out += 8; | - | ||||||||||||||||||
| 324 | in += 8; | - | ||||||||||||||||||
| 325 | n = 0; | - | ||||||||||||||||||
| 326 | } executed 655492 times by 1 test: end of blockExecuted by:
| 655492 | ||||||||||||||||||
| 327 | if (len
| 1-2 | ||||||||||||||||||
| 328 | Gost2814789_cnt_next(ivec, cnt_buf, key); | - | ||||||||||||||||||
| 329 | while (len--
| 1-5 | ||||||||||||||||||
| 330 | out[n] = in[n] ^ cnt_buf[n]; | - | ||||||||||||||||||
| 331 | ++n; | - | ||||||||||||||||||
| 332 | } executed 5 times by 1 test: end of blockExecuted by:
| 5 | ||||||||||||||||||
| 333 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||||||||
| 334 | *num = n; | - | ||||||||||||||||||
| 335 | return; executed 3 times by 1 test: return;Executed by:
| 3 | ||||||||||||||||||
| 336 | } never executed: while(0);end of block | 0 | ||||||||||||||||||
| 337 | - | |||||||||||||||||||
| 338 | - | |||||||||||||||||||
| 339 | while (l < len
| 0 | ||||||||||||||||||
| 340 | if (n==0
| 0 | ||||||||||||||||||
| 341 | Gost2814789_cnt_next(ivec, cnt_buf, key); never executed: Gost2814789_cnt_next(ivec, cnt_buf, key); | 0 | ||||||||||||||||||
| 342 | out[l] = in[l] ^ cnt_buf[n]; | - | ||||||||||||||||||
| 343 | ++l; | - | ||||||||||||||||||
| 344 | n = (n + 1) % 8; | - | ||||||||||||||||||
| 345 | } never executed: end of block | 0 | ||||||||||||||||||
| 346 | - | |||||||||||||||||||
| 347 | *num=n; | - | ||||||||||||||||||
| 348 | } never executed: end of block | 0 | ||||||||||||||||||
| 349 | - | |||||||||||||||||||
| 350 | int | - | ||||||||||||||||||
| 351 | GOST2814789IMIT_Init(GOST2814789IMIT_CTX *c, int nid) | - | ||||||||||||||||||
| 352 | { | - | ||||||||||||||||||
| 353 | c->Nl = c->Nh = c->num = 0; | - | ||||||||||||||||||
| 354 | memset(c->mac, 0, 8); | - | ||||||||||||||||||
| 355 | return executed 8 times by 1 test: Gost2814789_set_sbox(&c->cipher, nid);return Gost2814789_set_sbox(&c->cipher, nid);Executed by:
executed 8 times by 1 test: return Gost2814789_set_sbox(&c->cipher, nid);Executed by:
| 8 | ||||||||||||||||||
| 356 | } | - | ||||||||||||||||||
| 357 | - | |||||||||||||||||||
| 358 | static void | - | ||||||||||||||||||
| 359 | GOST2814789IMIT_block_data_order(GOST2814789IMIT_CTX *ctx, | - | ||||||||||||||||||
| 360 | const unsigned char *p, size_t num) | - | ||||||||||||||||||
| 361 | { | - | ||||||||||||||||||
| 362 | int i; | - | ||||||||||||||||||
| 363 | - | |||||||||||||||||||
| 364 | for (i = 0; i < num
| 6-655495 | ||||||||||||||||||
| 365 | Gost2814789_mac_mesh(p, ctx->mac, &ctx->cipher); | - | ||||||||||||||||||
| 366 | p += 8; | - | ||||||||||||||||||
| 367 | } executed 655495 times by 1 test: end of blockExecuted by:
| 655495 | ||||||||||||||||||
| 368 | } executed 6 times by 1 test: end of blockExecuted by:
| 6 | ||||||||||||||||||
| 369 | - | |||||||||||||||||||
| 370 | int | - | ||||||||||||||||||
| 371 | GOST2814789IMIT_Final(unsigned char *md, GOST2814789IMIT_CTX *c) | - | ||||||||||||||||||
| 372 | { | - | ||||||||||||||||||
| 373 | if (c->num
| 3-5 | ||||||||||||||||||
| 374 | memset(c->data + c->num, 0, 8 - c->num); | - | ||||||||||||||||||
| 375 | Gost2814789_mac_mesh(c->data, c->mac, &c->cipher); | - | ||||||||||||||||||
| 376 | } executed 3 times by 1 test: end of blockExecuted by:
| 3 | ||||||||||||||||||
| 377 | if (c->Nl <= 8 * 8
| 0-5 | ||||||||||||||||||
| 378 | memset(c->data, 0, 8); | - | ||||||||||||||||||
| 379 | Gost2814789_mac_mesh(c->data, c->mac, &c->cipher); | - | ||||||||||||||||||
| 380 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||
| 381 | memcpy(md, c->mac, 4); | - | ||||||||||||||||||
| 382 | return executed 8 times by 1 test: 1;return 1;Executed by:
executed 8 times by 1 test: return 1;Executed by:
| 8 | ||||||||||||||||||
| 383 | } | - | ||||||||||||||||||
| 384 | - | |||||||||||||||||||
| 385 | unsigned char * | - | ||||||||||||||||||
| 386 | GOST2814789IMIT(const unsigned char *d, size_t n, unsigned char *md, int nid, | - | ||||||||||||||||||
| 387 | const unsigned char *key, const unsigned char *iv) | - | ||||||||||||||||||
| 388 | { | - | ||||||||||||||||||
| 389 | GOST2814789IMIT_CTX c; | - | ||||||||||||||||||
| 390 | static unsigned char m[4]; | - | ||||||||||||||||||
| 391 | - | |||||||||||||||||||
| 392 | if (md ==
| 0 | ||||||||||||||||||
| 393 | ((void *)0)
| 0 | ||||||||||||||||||
| 394 | ) | - | ||||||||||||||||||
| 395 | md = m; never executed: md = m; | 0 | ||||||||||||||||||
| 396 | GOST2814789IMIT_Init(&c, nid); | - | ||||||||||||||||||
| 397 | memcpy(c.mac, iv, 8); | - | ||||||||||||||||||
| 398 | Gost2814789_set_key(&c.cipher, key, 256); | - | ||||||||||||||||||
| 399 | GOST2814789IMIT_Update(&c, d, n); | - | ||||||||||||||||||
| 400 | GOST2814789IMIT_Final(md, &c); | - | ||||||||||||||||||
| 401 | explicit_bzero(&c, sizeof(c)); | - | ||||||||||||||||||
| 402 | return never executed: (md);return (md);never executed: return (md); | 0 | ||||||||||||||||||
| 403 | } | - | ||||||||||||||||||
| Switch to Source code | Preprocessed file |