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