| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/libressl/src/crypto/des/ede_cbcm_enc.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||
|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||
| 2 | - | |||||||
| 3 | - | |||||||
| 4 | void DES_ede3_cbcm_encrypt(const unsigned char *in, unsigned char *out, | - | ||||||
| 5 | long length, DES_key_schedule *ks1, DES_key_schedule *ks2, | - | ||||||
| 6 | DES_key_schedule *ks3, DES_cblock *ivec1, DES_cblock *ivec2, | - | ||||||
| 7 | int enc) | - | ||||||
| 8 | { | - | ||||||
| 9 | unsigned int tin0,tin1; | - | ||||||
| 10 | unsigned int tout0,tout1,xor0,xor1,m0,m1; | - | ||||||
| 11 | long l=length; | - | ||||||
| 12 | unsigned int tin[2]; | - | ||||||
| 13 | unsigned char *iv1,*iv2; | - | ||||||
| 14 | - | |||||||
| 15 | iv1 = &(*ivec1)[0]; | - | ||||||
| 16 | iv2 = &(*ivec2)[0]; | - | ||||||
| 17 | - | |||||||
| 18 | if (enc
| 1-2 | ||||||
| 19 | { | - | ||||||
| 20 | (m0 =((unsigned int)(*((iv1)++))) , m0|=((unsigned int)(*((iv1)++)))<< 8L, m0|=((unsigned int)(*((iv1)++)))<<16L, m0|=((unsigned int)(*((iv1)++)))<<24L); | - | ||||||
| 21 | (m1 =((unsigned int)(*((iv1)++))) , m1|=((unsigned int)(*((iv1)++)))<< 8L, m1|=((unsigned int)(*((iv1)++)))<<16L, m1|=((unsigned int)(*((iv1)++)))<<24L); | - | ||||||
| 22 | (tout0 =((unsigned int)(*((iv2)++))) , tout0|=((unsigned int)(*((iv2)++)))<< 8L, tout0|=((unsigned int)(*((iv2)++)))<<16L, tout0|=((unsigned int)(*((iv2)++)))<<24L); | - | ||||||
| 23 | (tout1 =((unsigned int)(*((iv2)++))) , tout1|=((unsigned int)(*((iv2)++)))<< 8L, tout1|=((unsigned int)(*((iv2)++)))<<16L, tout1|=((unsigned int)(*((iv2)++)))<<24L); | - | ||||||
| 24 | for (l-=8; l>=-7
| 2-4 | ||||||
| 25 | { | - | ||||||
| 26 | tin[0]=m0; | - | ||||||
| 27 | tin[1]=m1; | - | ||||||
| 28 | DES_encrypt1(tin,ks3,1); | - | ||||||
| 29 | m0=tin[0]; | - | ||||||
| 30 | m1=tin[1]; | - | ||||||
| 31 | - | |||||||
| 32 | if(l < 0
| 1-3 | ||||||
| 33 | { | - | ||||||
| 34 | { in+=l+8; tin0=tin1=0; switch (l+8) { case never executed: 8:case 8:never executed: tin1 =((unsigned int)(*(--(in))))<<24L; casecase 8:never executed: 7:case 7:never executed: case 7:code before this statement never executed: tin1|=((unsigned int)(*(--(in))))<<16L; casecase 7:never executed: 6:case 6:never executed: case 6:code before this statement never executed: tin1|=((unsigned int)(*(--(in))))<< 8L; casecase 6:executed 1 time by 1 test: case 5:Executed by:
code before this statement never executed: case 5:executed 1 time by 1 test: 5:case 5:Executed by:
code before this statement never executed: case 5:executed 1 time by 1 test: tin1|=((unsigned int)(*(--(in)))); casecase 5:Executed by:
never executed: case 4:code before this statement executed 1 time by 1 test: case 4:Executed by:
never executed: 4:case 4:code before this statement executed 1 time by 1 test: case 4:Executed by:
never executed: tin0 =((unsigned int)(*(--(in))))<<24L; casecase 4:never executed: case 3:code before this statement executed 1 time by 1 test: case 3:Executed by:
never executed: 3:case 3:code before this statement executed 1 time by 1 test: case 3:Executed by:
never executed: tin0|=((unsigned int)(*(--(in))))<<16L; casecase 3:never executed: case 2:code before this statement executed 1 time by 1 test: case 2:Executed by:
never executed: 2:case 2:code before this statement executed 1 time by 1 test: case 2:Executed by:
never executed: tin0|=((unsigned int)(*(--(in))))<< 8L; casecase 2:executed 1 time by 1 test: 1:case 1:Executed by:
executed 1 time by 1 test: case 1:Executed by:
code before this statement executed 1 time by 1 test: tin0|=((unsigned int)(*(--(in)))); }case 1:Executed by:
executed 1 time by 1 test: };end of blockExecuted by:
| 0-1 | ||||||
| 35 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||
| 36 | else | - | ||||||
| 37 | { | - | ||||||
| 38 | (tin0 =((unsigned int)(*((in)++))) , tin0|=((unsigned int)(*((in)++)))<< 8L, tin0|=((unsigned int)(*((in)++)))<<16L, tin0|=((unsigned int)(*((in)++)))<<24L); | - | ||||||
| 39 | (tin1 =((unsigned int)(*((in)++))) , tin1|=((unsigned int)(*((in)++)))<< 8L, tin1|=((unsigned int)(*((in)++)))<<16L, tin1|=((unsigned int)(*((in)++)))<<24L); | - | ||||||
| 40 | } executed 3 times by 1 test: end of blockExecuted by:
| 3 | ||||||
| 41 | tin0^=tout0; | - | ||||||
| 42 | tin1^=tout1; | - | ||||||
| 43 | - | |||||||
| 44 | tin[0]=tin0; | - | ||||||
| 45 | tin[1]=tin1; | - | ||||||
| 46 | DES_encrypt1(tin,ks1,1); | - | ||||||
| 47 | tin[0]^=m0; | - | ||||||
| 48 | tin[1]^=m1; | - | ||||||
| 49 | DES_encrypt1(tin,ks2,0); | - | ||||||
| 50 | tin[0]^=m0; | - | ||||||
| 51 | tin[1]^=m1; | - | ||||||
| 52 | DES_encrypt1(tin,ks1,1); | - | ||||||
| 53 | tout0=tin[0]; | - | ||||||
| 54 | tout1=tin[1]; | - | ||||||
| 55 | - | |||||||
| 56 | (*((out)++)=(unsigned char)(((tout0) )&0xff), *((out)++)=(unsigned char)(((tout0)>> 8L)&0xff), *((out)++)=(unsigned char)(((tout0)>>16L)&0xff), *((out)++)=(unsigned char)(((tout0)>>24L)&0xff)); | - | ||||||
| 57 | (*((out)++)=(unsigned char)(((tout1) )&0xff), *((out)++)=(unsigned char)(((tout1)>> 8L)&0xff), *((out)++)=(unsigned char)(((tout1)>>16L)&0xff), *((out)++)=(unsigned char)(((tout1)>>24L)&0xff)); | - | ||||||
| 58 | } executed 4 times by 1 test: end of blockExecuted by:
| 4 | ||||||
| 59 | iv1=&(*ivec1)[0]; | - | ||||||
| 60 | (*((iv1)++)=(unsigned char)(((m0) )&0xff), *((iv1)++)=(unsigned char)(((m0)>> 8L)&0xff), *((iv1)++)=(unsigned char)(((m0)>>16L)&0xff), *((iv1)++)=(unsigned char)(((m0)>>24L)&0xff)); | - | ||||||
| 61 | (*((iv1)++)=(unsigned char)(((m1) )&0xff), *((iv1)++)=(unsigned char)(((m1)>> 8L)&0xff), *((iv1)++)=(unsigned char)(((m1)>>16L)&0xff), *((iv1)++)=(unsigned char)(((m1)>>24L)&0xff)); | - | ||||||
| 62 | - | |||||||
| 63 | iv2=&(*ivec2)[0]; | - | ||||||
| 64 | (*((iv2)++)=(unsigned char)(((tout0) )&0xff), *((iv2)++)=(unsigned char)(((tout0)>> 8L)&0xff), *((iv2)++)=(unsigned char)(((tout0)>>16L)&0xff), *((iv2)++)=(unsigned char)(((tout0)>>24L)&0xff)); | - | ||||||
| 65 | (*((iv2)++)=(unsigned char)(((tout1) )&0xff), *((iv2)++)=(unsigned char)(((tout1)>> 8L)&0xff), *((iv2)++)=(unsigned char)(((tout1)>>16L)&0xff), *((iv2)++)=(unsigned char)(((tout1)>>24L)&0xff)); | - | ||||||
| 66 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||
| 67 | else | - | ||||||
| 68 | { | - | ||||||
| 69 | unsigned int t0,t1; | - | ||||||
| 70 | - | |||||||
| 71 | (m0 =((unsigned int)(*((iv1)++))) , m0|=((unsigned int)(*((iv1)++)))<< 8L, m0|=((unsigned int)(*((iv1)++)))<<16L, m0|=((unsigned int)(*((iv1)++)))<<24L); | - | ||||||
| 72 | (m1 =((unsigned int)(*((iv1)++))) , m1|=((unsigned int)(*((iv1)++)))<< 8L, m1|=((unsigned int)(*((iv1)++)))<<16L, m1|=((unsigned int)(*((iv1)++)))<<24L); | - | ||||||
| 73 | (xor0 =((unsigned int)(*((iv2)++))) , xor0|=((unsigned int)(*((iv2)++)))<< 8L, xor0|=((unsigned int)(*((iv2)++)))<<16L, xor0|=((unsigned int)(*((iv2)++)))<<24L); | - | ||||||
| 74 | (xor1 =((unsigned int)(*((iv2)++))) , xor1|=((unsigned int)(*((iv2)++)))<< 8L, xor1|=((unsigned int)(*((iv2)++)))<<16L, xor1|=((unsigned int)(*((iv2)++)))<<24L); | - | ||||||
| 75 | for (l-=8; l>=-7
| 1-4 | ||||||
| 76 | { | - | ||||||
| 77 | tin[0]=m0; | - | ||||||
| 78 | tin[1]=m1; | - | ||||||
| 79 | DES_encrypt1(tin,ks3,1); | - | ||||||
| 80 | m0=tin[0]; | - | ||||||
| 81 | m1=tin[1]; | - | ||||||
| 82 | - | |||||||
| 83 | (tin0 =((unsigned int)(*((in)++))) , tin0|=((unsigned int)(*((in)++)))<< 8L, tin0|=((unsigned int)(*((in)++)))<<16L, tin0|=((unsigned int)(*((in)++)))<<24L); | - | ||||||
| 84 | (tin1 =((unsigned int)(*((in)++))) , tin1|=((unsigned int)(*((in)++)))<< 8L, tin1|=((unsigned int)(*((in)++)))<<16L, tin1|=((unsigned int)(*((in)++)))<<24L); | - | ||||||
| 85 | - | |||||||
| 86 | t0=tin0; | - | ||||||
| 87 | t1=tin1; | - | ||||||
| 88 | - | |||||||
| 89 | tin[0]=tin0; | - | ||||||
| 90 | tin[1]=tin1; | - | ||||||
| 91 | DES_encrypt1(tin,ks1,0); | - | ||||||
| 92 | tin[0]^=m0; | - | ||||||
| 93 | tin[1]^=m1; | - | ||||||
| 94 | DES_encrypt1(tin,ks2,1); | - | ||||||
| 95 | tin[0]^=m0; | - | ||||||
| 96 | tin[1]^=m1; | - | ||||||
| 97 | DES_encrypt1(tin,ks1,0); | - | ||||||
| 98 | tout0=tin[0]; | - | ||||||
| 99 | tout1=tin[1]; | - | ||||||
| 100 | - | |||||||
| 101 | tout0^=xor0; | - | ||||||
| 102 | tout1^=xor1; | - | ||||||
| 103 | if(l < 0
| 1-3 | ||||||
| 104 | { | - | ||||||
| 105 | { out+=l+8; switch (l+8) { case never executed: 8:case 8:never executed: *(--(out))=(unsigned char)(((tout1)>>24L)&0xff); casecase 8:never executed: 7:case 7:never executed: case 7:code before this statement never executed: *(--(out))=(unsigned char)(((tout1)>>16L)&0xff); casecase 7:never executed: 6:case 6:never executed: case 6:code before this statement never executed: *(--(out))=(unsigned char)(((tout1)>> 8L)&0xff); casecase 6:executed 1 time by 1 test: case 5:Executed by:
code before this statement never executed: case 5:executed 1 time by 1 test: 5:case 5:Executed by:
code before this statement never executed: case 5:executed 1 time by 1 test: *(--(out))=(unsigned char)(((tout1) )&0xff); casecase 5:Executed by:
never executed: case 4:code before this statement executed 1 time by 1 test: case 4:Executed by:
never executed: 4:case 4:code before this statement executed 1 time by 1 test: case 4:Executed by:
never executed: *(--(out))=(unsigned char)(((tout0)>>24L)&0xff); casecase 4:never executed: case 3:code before this statement executed 1 time by 1 test: case 3:Executed by:
never executed: 3:case 3:code before this statement executed 1 time by 1 test: case 3:Executed by:
never executed: *(--(out))=(unsigned char)(((tout0)>>16L)&0xff); casecase 3:never executed: case 2:code before this statement executed 1 time by 1 test: case 2:Executed by:
never executed: 2:case 2:code before this statement executed 1 time by 1 test: case 2:Executed by:
never executed: *(--(out))=(unsigned char)(((tout0)>> 8L)&0xff); casecase 2:executed 1 time by 1 test: 1:case 1:Executed by:
executed 1 time by 1 test: case 1:Executed by:
code before this statement executed 1 time by 1 test: *(--(out))=(unsigned char)(((tout0) )&0xff); }case 1:Executed by:
executed 1 time by 1 test: };end of blockExecuted by:
| 0-1 | ||||||
| 106 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||
| 107 | else | - | ||||||
| 108 | { | - | ||||||
| 109 | (*((out)++)=(unsigned char)(((tout0) )&0xff), *((out)++)=(unsigned char)(((tout0)>> 8L)&0xff), *((out)++)=(unsigned char)(((tout0)>>16L)&0xff), *((out)++)=(unsigned char)(((tout0)>>24L)&0xff)); | - | ||||||
| 110 | (*((out)++)=(unsigned char)(((tout1) )&0xff), *((out)++)=(unsigned char)(((tout1)>> 8L)&0xff), *((out)++)=(unsigned char)(((tout1)>>16L)&0xff), *((out)++)=(unsigned char)(((tout1)>>24L)&0xff)); | - | ||||||
| 111 | } executed 3 times by 1 test: end of blockExecuted by:
| 3 | ||||||
| 112 | xor0=t0; | - | ||||||
| 113 | xor1=t1; | - | ||||||
| 114 | } executed 4 times by 1 test: end of blockExecuted by:
| 4 | ||||||
| 115 | - | |||||||
| 116 | iv1=&(*ivec1)[0]; | - | ||||||
| 117 | (*((iv1)++)=(unsigned char)(((m0) )&0xff), *((iv1)++)=(unsigned char)(((m0)>> 8L)&0xff), *((iv1)++)=(unsigned char)(((m0)>>16L)&0xff), *((iv1)++)=(unsigned char)(((m0)>>24L)&0xff)); | - | ||||||
| 118 | (*((iv1)++)=(unsigned char)(((m1) )&0xff), *((iv1)++)=(unsigned char)(((m1)>> 8L)&0xff), *((iv1)++)=(unsigned char)(((m1)>>16L)&0xff), *((iv1)++)=(unsigned char)(((m1)>>24L)&0xff)); | - | ||||||
| 119 | - | |||||||
| 120 | iv2=&(*ivec2)[0]; | - | ||||||
| 121 | (*((iv2)++)=(unsigned char)(((xor0) )&0xff), *((iv2)++)=(unsigned char)(((xor0)>> 8L)&0xff), *((iv2)++)=(unsigned char)(((xor0)>>16L)&0xff), *((iv2)++)=(unsigned char)(((xor0)>>24L)&0xff)); | - | ||||||
| 122 | (*((iv2)++)=(unsigned char)(((xor1) )&0xff), *((iv2)++)=(unsigned char)(((xor1)>> 8L)&0xff), *((iv2)++)=(unsigned char)(((xor1)>>16L)&0xff), *((iv2)++)=(unsigned char)(((xor1)>>24L)&0xff)); | - | ||||||
| 123 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||
| 124 | tin0=tin1=tout0=tout1=xor0=xor1=0; | - | ||||||
| 125 | tin[0]=tin[1]=0; | - | ||||||
| 126 | } executed 3 times by 1 test: end of blockExecuted by:
| 3 | ||||||
| Switch to Source code | Preprocessed file |