xtea.h

filter: Statementstmt 100% 16 / 16 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 100% 20 / 20 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« XTEA.xs ↑ Summary
1 #include<stdint.h>
2  
3 /* take 64 bits of data in v[0] and v[1] and 128 bits of key[0] - key[3] */
4  
5 8 void xtea_encrypt(unsigned int num_rounds, uint32_t v[2], uint32_t const key[4]) {
6 unsigned int i;
7 8 uint32_t v0=v[0], v1=v[1], sum=0, delta=0x9E3779B9;
8 264 ▶ for (i=0; i < num_rounds; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i=0; i < num_rounds; i++) { 256 8 264
9 256 v0 += (((v1 << 4) ^ (v1 >> 5)) + v1) ^ (sum + key[sum & 3]);
10 256 sum += delta;
11 256 v1 += (((v0 << 4) ^ (v0 >> 5)) + v0) ^ (sum + key[(sum>>11) & 3]);
12 }
13 8 v[0]=v0; v[1]=v1;
14 8 }
15  
16 8 void xtea_decrypt(unsigned int num_rounds, uint32_t v[2], uint32_t const key[4]) {
17 unsigned int i;
18 8 uint32_t v0=v[0], v1=v[1], delta=0x9E3779B9, sum=delta*num_rounds;
19 264 ▶ for (i=0; i < num_rounds; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i=0; i < num_rounds; i++) { 256 8 264
20 256 v1 -= (((v0 << 4) ^ (v0 >> 5)) + v0) ^ (sum + key[(sum>>11) & 3]);
21 256 sum -= delta;
22 256 v0 -= (((v1 << 4) ^ (v1 >> 5)) + v1) ^ (sum + key[sum & 3]);
23 }
24 8 v[0]=v0; v[1]=v1;
25 8 }
« XTEA.xs ↑ Summary