| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/libressl/src/crypto/modes/cts128.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | size_t CRYPTO_cts128_encrypt_block(const unsigned char *in, unsigned char *out, | - | ||||||||||||
| 2 | size_t len, const void *key, | - | ||||||||||||
| 3 | unsigned char ivec[16], block128_f block) | - | ||||||||||||
| 4 | { size_t residue, n; | - | ||||||||||||
| 5 | - | |||||||||||||
| 6 | if (len <= 16
never executed: 0;return 0;never executed: return 0; | 0-6 | ||||||||||||
| 7 | - | |||||||||||||
| 8 | if ((
executed 3 times by 1 test: residue = 16;Executed by:
| 3 | ||||||||||||
| 9 | - | |||||||||||||
| 10 | len -= residue; | - | ||||||||||||
| 11 | - | |||||||||||||
| 12 | CRYPTO_cbc128_encrypt(in,out,len,key,ivec,block); | - | ||||||||||||
| 13 | - | |||||||||||||
| 14 | in += len; | - | ||||||||||||
| 15 | out += len; | - | ||||||||||||
| 16 | - | |||||||||||||
| 17 | for (n=0; n<residue
| 6-79 | ||||||||||||
| 18 | ivec[n] ^= in[n]; executed 79 times by 1 test: ivec[n] ^= in[n];Executed by:
| 79 | ||||||||||||
| 19 | (*block)(ivec,ivec,key); | - | ||||||||||||
| 20 | memcpy(out,out-16,residue); | - | ||||||||||||
| 21 | memcpy(out-16,ivec,16); | - | ||||||||||||
| 22 | - | |||||||||||||
| 23 | return executed 6 times by 1 test: len+residue;return len+residue;Executed by:
executed 6 times by 1 test: return len+residue;Executed by:
| 6 | ||||||||||||
| 24 | } | - | ||||||||||||
| 25 | - | |||||||||||||
| 26 | size_t CRYPTO_nistcts128_encrypt_block(const unsigned char *in, unsigned char *out, | - | ||||||||||||
| 27 | size_t len, const void *key, | - | ||||||||||||
| 28 | unsigned char ivec[16], block128_f block) | - | ||||||||||||
| 29 | { size_t residue, n; | - | ||||||||||||
| 30 | - | |||||||||||||
| 31 | if (len < 16
never executed: 0;return 0;never executed: return 0; | 0-6 | ||||||||||||
| 32 | - | |||||||||||||
| 33 | residue=len%16; | - | ||||||||||||
| 34 | - | |||||||||||||
| 35 | len -= residue; | - | ||||||||||||
| 36 | - | |||||||||||||
| 37 | CRYPTO_cbc128_encrypt(in,out,len,key,ivec,block); | - | ||||||||||||
| 38 | - | |||||||||||||
| 39 | if (residue==0
executed 3 times by 1 test: len;return len;Executed by:
executed 3 times by 1 test: return len;Executed by:
| 3 | ||||||||||||
| 40 | - | |||||||||||||
| 41 | in += len; | - | ||||||||||||
| 42 | out += len; | - | ||||||||||||
| 43 | - | |||||||||||||
| 44 | for (n=0; n<residue
| 3-31 | ||||||||||||
| 45 | ivec[n] ^= in[n]; executed 31 times by 1 test: ivec[n] ^= in[n];Executed by:
| 31 | ||||||||||||
| 46 | (*block)(ivec,ivec,key); | - | ||||||||||||
| 47 | memcpy(out-16+residue,ivec,16); | - | ||||||||||||
| 48 | - | |||||||||||||
| 49 | return executed 3 times by 1 test: len+residue;return len+residue;Executed by:
executed 3 times by 1 test: return len+residue;Executed by:
| 3 | ||||||||||||
| 50 | } | - | ||||||||||||
| 51 | - | |||||||||||||
| 52 | size_t CRYPTO_cts128_encrypt(const unsigned char *in, unsigned char *out, | - | ||||||||||||
| 53 | size_t len, const void *key, | - | ||||||||||||
| 54 | unsigned char ivec[16], cbc128_f cbc) | - | ||||||||||||
| 55 | { size_t residue; | - | ||||||||||||
| 56 | union { size_t align; unsigned char c[16]; } tmp; | - | ||||||||||||
| 57 | - | |||||||||||||
| 58 | if (len <= 16
never executed: 0;return 0;never executed: return 0; | 0-6 | ||||||||||||
| 59 | - | |||||||||||||
| 60 | if ((
executed 3 times by 1 test: residue = 16;Executed by:
| 3 | ||||||||||||
| 61 | - | |||||||||||||
| 62 | len -= residue; | - | ||||||||||||
| 63 | - | |||||||||||||
| 64 | (*cbc)(in,out,len,key,ivec,1); | - | ||||||||||||
| 65 | - | |||||||||||||
| 66 | in += len; | - | ||||||||||||
| 67 | out += len; | - | ||||||||||||
| 68 | - | |||||||||||||
| 69 | memset(tmp.c,0,sizeof(tmp)); | - | ||||||||||||
| 70 | memcpy(tmp.c,in,residue); | - | ||||||||||||
| 71 | memcpy(out,out-16,residue); | - | ||||||||||||
| 72 | (*cbc)(tmp.c,out-16,16,key,ivec,1); | - | ||||||||||||
| 73 | return executed 6 times by 1 test: len+residue;return len+residue;Executed by:
executed 6 times by 1 test: return len+residue;Executed by:
| 6 | ||||||||||||
| 74 | } | - | ||||||||||||
| 75 | - | |||||||||||||
| 76 | size_t CRYPTO_nistcts128_encrypt(const unsigned char *in, unsigned char *out, | - | ||||||||||||
| 77 | size_t len, const void *key, | - | ||||||||||||
| 78 | unsigned char ivec[16], cbc128_f cbc) | - | ||||||||||||
| 79 | { size_t residue; | - | ||||||||||||
| 80 | union { size_t align; unsigned char c[16]; } tmp; | - | ||||||||||||
| 81 | - | |||||||||||||
| 82 | if (len < 16
never executed: 0;return 0;never executed: return 0; | 0-6 | ||||||||||||
| 83 | - | |||||||||||||
| 84 | residue=len%16; | - | ||||||||||||
| 85 | - | |||||||||||||
| 86 | len -= residue; | - | ||||||||||||
| 87 | - | |||||||||||||
| 88 | (*cbc)(in,out,len,key,ivec,1); | - | ||||||||||||
| 89 | - | |||||||||||||
| 90 | if (residue==0
executed 3 times by 1 test: len;return len;Executed by:
executed 3 times by 1 test: return len;Executed by:
| 3 | ||||||||||||
| 91 | - | |||||||||||||
| 92 | in += len; | - | ||||||||||||
| 93 | out += len; | - | ||||||||||||
| 94 | - | |||||||||||||
| 95 | memset(tmp.c,0,sizeof(tmp)); | - | ||||||||||||
| 96 | memcpy(tmp.c,in,residue); | - | ||||||||||||
| 97 | (*cbc)(tmp.c,out-16+residue,16,key,ivec,1); | - | ||||||||||||
| 98 | return executed 3 times by 1 test: len+residue;return len+residue;Executed by:
executed 3 times by 1 test: return len+residue;Executed by:
| 3 | ||||||||||||
| 99 | } | - | ||||||||||||
| 100 | - | |||||||||||||
| 101 | size_t CRYPTO_cts128_decrypt_block(const unsigned char *in, unsigned char *out, | - | ||||||||||||
| 102 | size_t len, const void *key, | - | ||||||||||||
| 103 | unsigned char ivec[16], block128_f block) | - | ||||||||||||
| 104 | { size_t residue, n; | - | ||||||||||||
| 105 | union { size_t align; unsigned char c[32]; } tmp; | - | ||||||||||||
| 106 | - | |||||||||||||
| 107 | if (len<=16
never executed: 0;return 0;never executed: return 0; | 0-6 | ||||||||||||
| 108 | - | |||||||||||||
| 109 | if ((
executed 3 times by 1 test: residue = 16;Executed by:
| 3 | ||||||||||||
| 110 | - | |||||||||||||
| 111 | len -= 16+residue; | - | ||||||||||||
| 112 | - | |||||||||||||
| 113 | if (len
| 3 | ||||||||||||
| 114 | CRYPTO_cbc128_decrypt(in,out,len,key,ivec,block); | - | ||||||||||||
| 115 | in += len; | - | ||||||||||||
| 116 | out += len; | - | ||||||||||||
| 117 | } executed 3 times by 1 test: end of blockExecuted by:
| 3 | ||||||||||||
| 118 | - | |||||||||||||
| 119 | (*block)(in,tmp.c+16,key); | - | ||||||||||||
| 120 | - | |||||||||||||
| 121 | memcpy(tmp.c,tmp.c+16,16); | - | ||||||||||||
| 122 | memcpy(tmp.c,in+16,residue); | - | ||||||||||||
| 123 | (*block)(tmp.c,tmp.c,key); | - | ||||||||||||
| 124 | - | |||||||||||||
| 125 | for(n=0; n<16
| 6-96 | ||||||||||||
| 126 | unsigned char c = in[n]; | - | ||||||||||||
| 127 | out[n] = tmp.c[n] ^ ivec[n]; | - | ||||||||||||
| 128 | ivec[n] = c; | - | ||||||||||||
| 129 | } executed 96 times by 1 test: end of blockExecuted by:
| 96 | ||||||||||||
| 130 | for(residue+=16; n<residue
| 6-79 | ||||||||||||
| 131 | out[n] = tmp.c[n] ^ in[n]; executed 79 times by 1 test: out[n] = tmp.c[n] ^ in[n];Executed by:
| 79 | ||||||||||||
| 132 | - | |||||||||||||
| 133 | return executed 6 times by 1 test: 16+len+residue;return 16+len+residue;Executed by:
executed 6 times by 1 test: return 16+len+residue;Executed by:
| 6 | ||||||||||||
| 134 | } | - | ||||||||||||
| 135 | - | |||||||||||||
| 136 | size_t CRYPTO_nistcts128_decrypt_block(const unsigned char *in, unsigned char *out, | - | ||||||||||||
| 137 | size_t len, const void *key, | - | ||||||||||||
| 138 | unsigned char ivec[16], block128_f block) | - | ||||||||||||
| 139 | { size_t residue, n; | - | ||||||||||||
| 140 | union { size_t align; unsigned char c[32]; } tmp; | - | ||||||||||||
| 141 | - | |||||||||||||
| 142 | if (len<16
never executed: 0;return 0;never executed: return 0; | 0-6 | ||||||||||||
| 143 | - | |||||||||||||
| 144 | residue=len%16; | - | ||||||||||||
| 145 | - | |||||||||||||
| 146 | if (residue==0
| 3 | ||||||||||||
| 147 | CRYPTO_cbc128_decrypt(in,out,len,key,ivec,block); | - | ||||||||||||
| 148 | return executed 3 times by 1 test: len;return len;Executed by:
executed 3 times by 1 test: return len;Executed by:
| 3 | ||||||||||||
| 149 | } | - | ||||||||||||
| 150 | - | |||||||||||||
| 151 | len -= 16+residue; | - | ||||||||||||
| 152 | - | |||||||||||||
| 153 | if (len
| 1-2 | ||||||||||||
| 154 | CRYPTO_cbc128_decrypt(in,out,len,key,ivec,block); | - | ||||||||||||
| 155 | in += len; | - | ||||||||||||
| 156 | out += len; | - | ||||||||||||
| 157 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||
| 158 | - | |||||||||||||
| 159 | (*block)(in+residue,tmp.c+16,key); | - | ||||||||||||
| 160 | - | |||||||||||||
| 161 | memcpy(tmp.c,tmp.c+16,16); | - | ||||||||||||
| 162 | memcpy(tmp.c,in,residue); | - | ||||||||||||
| 163 | (*block)(tmp.c,tmp.c,key); | - | ||||||||||||
| 164 | - | |||||||||||||
| 165 | for(n=0; n<16
| 3-48 | ||||||||||||
| 166 | unsigned char c = in[n]; | - | ||||||||||||
| 167 | out[n] = tmp.c[n] ^ ivec[n]; | - | ||||||||||||
| 168 | ivec[n] = in[n+residue]; | - | ||||||||||||
| 169 | tmp.c[n] = c; | - | ||||||||||||
| 170 | } executed 48 times by 1 test: end of blockExecuted by:
| 48 | ||||||||||||
| 171 | for(residue+=16; n<residue
| 3-31 | ||||||||||||
| 172 | out[n] = tmp.c[n] ^ tmp.c[n-16]; executed 31 times by 1 test: out[n] = tmp.c[n] ^ tmp.c[n-16];Executed by:
| 31 | ||||||||||||
| 173 | - | |||||||||||||
| 174 | return executed 3 times by 1 test: 16+len+residue;return 16+len+residue;Executed by:
executed 3 times by 1 test: return 16+len+residue;Executed by:
| 3 | ||||||||||||
| 175 | } | - | ||||||||||||
| 176 | - | |||||||||||||
| 177 | size_t CRYPTO_cts128_decrypt(const unsigned char *in, unsigned char *out, | - | ||||||||||||
| 178 | size_t len, const void *key, | - | ||||||||||||
| 179 | unsigned char ivec[16], cbc128_f cbc) | - | ||||||||||||
| 180 | { size_t residue; | - | ||||||||||||
| 181 | union { size_t align; unsigned char c[32]; } tmp; | - | ||||||||||||
| 182 | - | |||||||||||||
| 183 | if (len<=16
never executed: 0;return 0;never executed: return 0; | 0-6 | ||||||||||||
| 184 | - | |||||||||||||
| 185 | if ((
executed 3 times by 1 test: residue = 16;Executed by:
| 3 | ||||||||||||
| 186 | - | |||||||||||||
| 187 | len -= 16+residue; | - | ||||||||||||
| 188 | - | |||||||||||||
| 189 | if (len
| 3 | ||||||||||||
| 190 | (*cbc)(in,out,len,key,ivec,0); | - | ||||||||||||
| 191 | in += len; | - | ||||||||||||
| 192 | out += len; | - | ||||||||||||
| 193 | } executed 3 times by 1 test: end of blockExecuted by:
| 3 | ||||||||||||
| 194 | - | |||||||||||||
| 195 | memset(tmp.c,0,sizeof(tmp)); | - | ||||||||||||
| 196 | - | |||||||||||||
| 197 | (*cbc)(in,tmp.c,16,key,tmp.c+16,0); | - | ||||||||||||
| 198 | - | |||||||||||||
| 199 | memcpy(tmp.c,in+16,residue); | - | ||||||||||||
| 200 | (*cbc)(tmp.c,tmp.c,32,key,ivec,0); | - | ||||||||||||
| 201 | memcpy(out,tmp.c,16+residue); | - | ||||||||||||
| 202 | return executed 6 times by 1 test: 16+len+residue;return 16+len+residue;Executed by:
executed 6 times by 1 test: return 16+len+residue;Executed by:
| 6 | ||||||||||||
| 203 | } | - | ||||||||||||
| 204 | - | |||||||||||||
| 205 | size_t CRYPTO_nistcts128_decrypt(const unsigned char *in, unsigned char *out, | - | ||||||||||||
| 206 | size_t len, const void *key, | - | ||||||||||||
| 207 | unsigned char ivec[16], cbc128_f cbc) | - | ||||||||||||
| 208 | { size_t residue; | - | ||||||||||||
| 209 | union { size_t align; unsigned char c[32]; } tmp; | - | ||||||||||||
| 210 | - | |||||||||||||
| 211 | if (len<16
never executed: 0;return 0;never executed: return 0; | 0-6 | ||||||||||||
| 212 | - | |||||||||||||
| 213 | residue=len%16; | - | ||||||||||||
| 214 | - | |||||||||||||
| 215 | if (residue==0
| 3 | ||||||||||||
| 216 | (*cbc)(in,out,len,key,ivec,0); | - | ||||||||||||
| 217 | return executed 3 times by 1 test: len;return len;Executed by:
executed 3 times by 1 test: return len;Executed by:
| 3 | ||||||||||||
| 218 | } | - | ||||||||||||
| 219 | - | |||||||||||||
| 220 | len -= 16+residue; | - | ||||||||||||
| 221 | - | |||||||||||||
| 222 | if (len
| 1-2 | ||||||||||||
| 223 | (*cbc)(in,out,len,key,ivec,0); | - | ||||||||||||
| 224 | in += len; | - | ||||||||||||
| 225 | out += len; | - | ||||||||||||
| 226 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||
| 227 | - | |||||||||||||
| 228 | memset(tmp.c,0,sizeof(tmp)); | - | ||||||||||||
| 229 | - | |||||||||||||
| 230 | (*cbc)(in+residue,tmp.c,16,key,tmp.c+16,0); | - | ||||||||||||
| 231 | - | |||||||||||||
| 232 | memcpy(tmp.c,in,residue); | - | ||||||||||||
| 233 | (*cbc)(tmp.c,tmp.c,32,key,ivec,0); | - | ||||||||||||
| 234 | memcpy(out,tmp.c,16+residue); | - | ||||||||||||
| 235 | return executed 3 times by 1 test: 16+len+residue;return 16+len+residue;Executed by:
executed 3 times by 1 test: return 16+len+residue;Executed by:
| 3 | ||||||||||||
| 236 | } | - | ||||||||||||
| Switch to Source code | Preprocessed file |