| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/libressl/src/crypto/des/cfb64ede.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||
|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||
| 2 | - | |||||||
| 3 | - | |||||||
| 4 | - | |||||||
| 5 | - | |||||||
| 6 | - | |||||||
| 7 | void DES_ede3_cfb64_encrypt(const unsigned char *in, unsigned char *out, | - | ||||||
| 8 | long length, DES_key_schedule *ks1, | - | ||||||
| 9 | DES_key_schedule *ks2, DES_key_schedule *ks3, | - | ||||||
| 10 | DES_cblock *ivec, int *num, int enc) | - | ||||||
| 11 | { | - | ||||||
| 12 | unsigned int v0,v1; | - | ||||||
| 13 | long l=length; | - | ||||||
| 14 | int n= *num; | - | ||||||
| 15 | unsigned int ti[2]; | - | ||||||
| 16 | unsigned char *iv,c,cc; | - | ||||||
| 17 | - | |||||||
| 18 | iv=&(*ivec)[0]; | - | ||||||
| 19 | if (enc
| 6 | ||||||
| 20 | { | - | ||||||
| 21 | while (l--
| 6-3576 | ||||||
| 22 | { | - | ||||||
| 23 | if (n == 0
| 447-3129 | ||||||
| 24 | { | - | ||||||
| 25 | (v0 =((unsigned int)(*((iv)++))) , v0|=((unsigned int)(*((iv)++)))<< 8L, v0|=((unsigned int)(*((iv)++)))<<16L, v0|=((unsigned int)(*((iv)++)))<<24L); | - | ||||||
| 26 | (v1 =((unsigned int)(*((iv)++))) , v1|=((unsigned int)(*((iv)++)))<< 8L, v1|=((unsigned int)(*((iv)++)))<<16L, v1|=((unsigned int)(*((iv)++)))<<24L); | - | ||||||
| 27 | - | |||||||
| 28 | ti[0]=v0; | - | ||||||
| 29 | ti[1]=v1; | - | ||||||
| 30 | DES_encrypt3(ti,ks1,ks2,ks3); | - | ||||||
| 31 | v0=ti[0]; | - | ||||||
| 32 | v1=ti[1]; | - | ||||||
| 33 | - | |||||||
| 34 | iv = &(*ivec)[0]; | - | ||||||
| 35 | (*((iv)++)=(unsigned char)(((v0) )&0xff), *((iv)++)=(unsigned char)(((v0)>> 8L)&0xff), *((iv)++)=(unsigned char)(((v0)>>16L)&0xff), *((iv)++)=(unsigned char)(((v0)>>24L)&0xff)); | - | ||||||
| 36 | (*((iv)++)=(unsigned char)(((v1) )&0xff), *((iv)++)=(unsigned char)(((v1)>> 8L)&0xff), *((iv)++)=(unsigned char)(((v1)>>16L)&0xff), *((iv)++)=(unsigned char)(((v1)>>24L)&0xff)); | - | ||||||
| 37 | iv = &(*ivec)[0]; | - | ||||||
| 38 | } executed 447 times by 2 tests: end of blockExecuted by:
| 447 | ||||||
| 39 | c= *(in++)^iv[n]; | - | ||||||
| 40 | *(out++)=c; | - | ||||||
| 41 | iv[n]=c; | - | ||||||
| 42 | n=(n+1)&0x07; | - | ||||||
| 43 | } executed 3576 times by 2 tests: end of blockExecuted by:
| 3576 | ||||||
| 44 | } executed 6 times by 2 tests: end of blockExecuted by:
| 6 | ||||||
| 45 | else | - | ||||||
| 46 | { | - | ||||||
| 47 | while (l--
| 6-3576 | ||||||
| 48 | { | - | ||||||
| 49 | if (n == 0
| 447-3129 | ||||||
| 50 | { | - | ||||||
| 51 | (v0 =((unsigned int)(*((iv)++))) , v0|=((unsigned int)(*((iv)++)))<< 8L, v0|=((unsigned int)(*((iv)++)))<<16L, v0|=((unsigned int)(*((iv)++)))<<24L); | - | ||||||
| 52 | (v1 =((unsigned int)(*((iv)++))) , v1|=((unsigned int)(*((iv)++)))<< 8L, v1|=((unsigned int)(*((iv)++)))<<16L, v1|=((unsigned int)(*((iv)++)))<<24L); | - | ||||||
| 53 | - | |||||||
| 54 | ti[0]=v0; | - | ||||||
| 55 | ti[1]=v1; | - | ||||||
| 56 | DES_encrypt3(ti,ks1,ks2,ks3); | - | ||||||
| 57 | v0=ti[0]; | - | ||||||
| 58 | v1=ti[1]; | - | ||||||
| 59 | - | |||||||
| 60 | iv = &(*ivec)[0]; | - | ||||||
| 61 | (*((iv)++)=(unsigned char)(((v0) )&0xff), *((iv)++)=(unsigned char)(((v0)>> 8L)&0xff), *((iv)++)=(unsigned char)(((v0)>>16L)&0xff), *((iv)++)=(unsigned char)(((v0)>>24L)&0xff)); | - | ||||||
| 62 | (*((iv)++)=(unsigned char)(((v1) )&0xff), *((iv)++)=(unsigned char)(((v1)>> 8L)&0xff), *((iv)++)=(unsigned char)(((v1)>>16L)&0xff), *((iv)++)=(unsigned char)(((v1)>>24L)&0xff)); | - | ||||||
| 63 | iv = &(*ivec)[0]; | - | ||||||
| 64 | } executed 447 times by 2 tests: end of blockExecuted by:
| 447 | ||||||
| 65 | cc= *(in++); | - | ||||||
| 66 | c=iv[n]; | - | ||||||
| 67 | iv[n]=cc; | - | ||||||
| 68 | *(out++)=c^cc; | - | ||||||
| 69 | n=(n+1)&0x07; | - | ||||||
| 70 | } executed 3576 times by 2 tests: end of blockExecuted by:
| 3576 | ||||||
| 71 | } executed 6 times by 2 tests: end of blockExecuted by:
| 6 | ||||||
| 72 | v0=v1=ti[0]=ti[1]=c=cc=0; | - | ||||||
| 73 | *num=n; | - | ||||||
| 74 | } executed 12 times by 2 tests: end of blockExecuted by:
| 12 | ||||||
| 75 | - | |||||||
| 76 | - | |||||||
| 77 | - | |||||||
| 78 | - | |||||||
| 79 | - | |||||||
| 80 | void DES_ede3_cfb_encrypt(const unsigned char *in,unsigned char *out, | - | ||||||
| 81 | int numbits,long length,DES_key_schedule *ks1, | - | ||||||
| 82 | DES_key_schedule *ks2,DES_key_schedule *ks3, | - | ||||||
| 83 | DES_cblock *ivec,int enc) | - | ||||||
| 84 | { | - | ||||||
| 85 | unsigned int d0,d1,v0,v1; | - | ||||||
| 86 | unsigned long l=length,n=((unsigned int)numbits+7)/8; | - | ||||||
| 87 | int num=numbits,i; | - | ||||||
| 88 | unsigned int ti[2]; | - | ||||||
| 89 | unsigned char *iv; | - | ||||||
| 90 | unsigned char ovec[16]; | - | ||||||
| 91 | - | |||||||
| 92 | if (num > 64
never executed: return; | 0 | ||||||
| 93 | iv = &(*ivec)[0]; | - | ||||||
| 94 | (v0 =((unsigned int)(*((iv)++))) , v0|=((unsigned int)(*((iv)++)))<< 8L, v0|=((unsigned int)(*((iv)++)))<<16L, v0|=((unsigned int)(*((iv)++)))<<24L); | - | ||||||
| 95 | (v1 =((unsigned int)(*((iv)++))) , v1|=((unsigned int)(*((iv)++)))<< 8L, v1|=((unsigned int)(*((iv)++)))<<16L, v1|=((unsigned int)(*((iv)++)))<<24L); | - | ||||||
| 96 | if (enc
| 0 | ||||||
| 97 | { | - | ||||||
| 98 | while (l >= n
| 0 | ||||||
| 99 | { | - | ||||||
| 100 | l-=n; | - | ||||||
| 101 | ti[0]=v0; | - | ||||||
| 102 | ti[1]=v1; | - | ||||||
| 103 | DES_encrypt3(ti,ks1,ks2,ks3); | - | ||||||
| 104 | { in+=n; d0=d1=0; switch (n) { case never executed: 8:case 8:never executed: d1 =((unsigned int)(*(--(in))))<<24L; casecase 8:never executed: 7:case 7:never executed: case 7:code before this statement never executed: d1|=((unsigned int)(*(--(in))))<<16L; casecase 7:never executed: 6:case 6:never executed: case 6:code before this statement never executed: d1|=((unsigned int)(*(--(in))))<< 8L; casecase 6:never executed: 5:case 5:never executed: case 5:code before this statement never executed: d1|=((unsigned int)(*(--(in)))); casecase 5:never executed: 4:case 4:never executed: case 4:code before this statement never executed: d0 =((unsigned int)(*(--(in))))<<24L; casecase 4:never executed: 3:case 3:never executed: case 3:code before this statement never executed: d0|=((unsigned int)(*(--(in))))<<16L; casecase 3:never executed: 2:case 2:never executed: case 2:code before this statement never executed: d0|=((unsigned int)(*(--(in))))<< 8L; casecase 2:never executed: 1:case 1:never executed: case 1:code before this statement never executed: d0|=((unsigned int)(*(--(in)))); }case 1:never executed: };end of block | 0 | ||||||
| 105 | in+=n; | - | ||||||
| 106 | d0^=ti[0]; | - | ||||||
| 107 | d1^=ti[1]; | - | ||||||
| 108 | { out+=n; switch (n) { case never executed: 8:case 8:never executed: *(--(out))=(unsigned char)(((d1)>>24L)&0xff); casecase 8:never executed: 7:case 7:never executed: case 7:code before this statement never executed: *(--(out))=(unsigned char)(((d1)>>16L)&0xff); casecase 7:never executed: 6:case 6:never executed: case 6:code before this statement never executed: *(--(out))=(unsigned char)(((d1)>> 8L)&0xff); casecase 6:never executed: 5:case 5:never executed: case 5:code before this statement never executed: *(--(out))=(unsigned char)(((d1) )&0xff); casecase 5:never executed: 4:case 4:never executed: case 4:code before this statement never executed: *(--(out))=(unsigned char)(((d0)>>24L)&0xff); casecase 4:never executed: 3:case 3:never executed: case 3:code before this statement never executed: *(--(out))=(unsigned char)(((d0)>>16L)&0xff); casecase 3:never executed: 2:case 2:never executed: case 2:code before this statement never executed: *(--(out))=(unsigned char)(((d0)>> 8L)&0xff); casecase 2:never executed: 1:case 1:never executed: case 1:code before this statement never executed: *(--(out))=(unsigned char)(((d0) )&0xff); }case 1:never executed: };end of block | 0 | ||||||
| 109 | out+=n; | - | ||||||
| 110 | - | |||||||
| 111 | - | |||||||
| 112 | if (num == 32
| 0 | ||||||
| 113 | { v0=v1; v1=d0; } never executed: end of block | 0 | ||||||
| 114 | else if (num == 64
| 0 | ||||||
| 115 | { v0=d0; v1=d1; } never executed: end of block | 0 | ||||||
| 116 | else | - | ||||||
| 117 | { | - | ||||||
| 118 | iv=&ovec[0]; | - | ||||||
| 119 | (*((iv)++)=(unsigned char)(((v0) )&0xff), *((iv)++)=(unsigned char)(((v0)>> 8L)&0xff), *((iv)++)=(unsigned char)(((v0)>>16L)&0xff), *((iv)++)=(unsigned char)(((v0)>>24L)&0xff)); | - | ||||||
| 120 | (*((iv)++)=(unsigned char)(((v1) )&0xff), *((iv)++)=(unsigned char)(((v1)>> 8L)&0xff), *((iv)++)=(unsigned char)(((v1)>>16L)&0xff), *((iv)++)=(unsigned char)(((v1)>>24L)&0xff)); | - | ||||||
| 121 | (*((iv)++)=(unsigned char)(((d0) )&0xff), *((iv)++)=(unsigned char)(((d0)>> 8L)&0xff), *((iv)++)=(unsigned char)(((d0)>>16L)&0xff), *((iv)++)=(unsigned char)(((d0)>>24L)&0xff)); | - | ||||||
| 122 | (*((iv)++)=(unsigned char)(((d1) )&0xff), *((iv)++)=(unsigned char)(((d1)>> 8L)&0xff), *((iv)++)=(unsigned char)(((d1)>>16L)&0xff), *((iv)++)=(unsigned char)(((d1)>>24L)&0xff)); | - | ||||||
| 123 | - | |||||||
| 124 | memmove(ovec,ovec+num/8,8+(num%8 ? 1 : 0)); | - | ||||||
| 125 | - | |||||||
| 126 | if(num%8 != 0
| 0 | ||||||
| 127 | for(i=0 ; i < 8
| 0 | ||||||
| 128 | { | - | ||||||
| 129 | ovec[i]<<=num%8; | - | ||||||
| 130 | ovec[i]|=ovec[i+1]>>(8-num%8); | - | ||||||
| 131 | } never executed: end of block | 0 | ||||||
| 132 | iv=&ovec[0]; | - | ||||||
| 133 | (v0 =((unsigned int)(*((iv)++))) , v0|=((unsigned int)(*((iv)++)))<< 8L, v0|=((unsigned int)(*((iv)++)))<<16L, v0|=((unsigned int)(*((iv)++)))<<24L); | - | ||||||
| 134 | (v1 =((unsigned int)(*((iv)++))) , v1|=((unsigned int)(*((iv)++)))<< 8L, v1|=((unsigned int)(*((iv)++)))<<16L, v1|=((unsigned int)(*((iv)++)))<<24L); | - | ||||||
| 135 | } never executed: end of block | 0 | ||||||
| 136 | } | - | ||||||
| 137 | } never executed: end of block | 0 | ||||||
| 138 | else | - | ||||||
| 139 | { | - | ||||||
| 140 | while (l >= n
| 0 | ||||||
| 141 | { | - | ||||||
| 142 | l-=n; | - | ||||||
| 143 | ti[0]=v0; | - | ||||||
| 144 | ti[1]=v1; | - | ||||||
| 145 | DES_encrypt3(ti,ks1,ks2,ks3); | - | ||||||
| 146 | { in+=n; d0=d1=0; switch (n) { case never executed: 8:case 8:never executed: d1 =((unsigned int)(*(--(in))))<<24L; casecase 8:never executed: 7:case 7:never executed: case 7:code before this statement never executed: d1|=((unsigned int)(*(--(in))))<<16L; casecase 7:never executed: 6:case 6:never executed: case 6:code before this statement never executed: d1|=((unsigned int)(*(--(in))))<< 8L; casecase 6:never executed: 5:case 5:never executed: case 5:code before this statement never executed: d1|=((unsigned int)(*(--(in)))); casecase 5:never executed: 4:case 4:never executed: case 4:code before this statement never executed: d0 =((unsigned int)(*(--(in))))<<24L; casecase 4:never executed: 3:case 3:never executed: case 3:code before this statement never executed: d0|=((unsigned int)(*(--(in))))<<16L; casecase 3:never executed: 2:case 2:never executed: case 2:code before this statement never executed: d0|=((unsigned int)(*(--(in))))<< 8L; casecase 2:never executed: 1:case 1:never executed: case 1:code before this statement never executed: d0|=((unsigned int)(*(--(in)))); }case 1:never executed: };end of block | 0 | ||||||
| 147 | in+=n; | - | ||||||
| 148 | - | |||||||
| 149 | - | |||||||
| 150 | if (num == 32
| 0 | ||||||
| 151 | { v0=v1; v1=d0; } never executed: end of block | 0 | ||||||
| 152 | else if (num == 64
| 0 | ||||||
| 153 | { v0=d0; v1=d1; } never executed: end of block | 0 | ||||||
| 154 | else | - | ||||||
| 155 | { | - | ||||||
| 156 | iv=&ovec[0]; | - | ||||||
| 157 | (*((iv)++)=(unsigned char)(((v0) )&0xff), *((iv)++)=(unsigned char)(((v0)>> 8L)&0xff), *((iv)++)=(unsigned char)(((v0)>>16L)&0xff), *((iv)++)=(unsigned char)(((v0)>>24L)&0xff)); | - | ||||||
| 158 | (*((iv)++)=(unsigned char)(((v1) )&0xff), *((iv)++)=(unsigned char)(((v1)>> 8L)&0xff), *((iv)++)=(unsigned char)(((v1)>>16L)&0xff), *((iv)++)=(unsigned char)(((v1)>>24L)&0xff)); | - | ||||||
| 159 | (*((iv)++)=(unsigned char)(((d0) )&0xff), *((iv)++)=(unsigned char)(((d0)>> 8L)&0xff), *((iv)++)=(unsigned char)(((d0)>>16L)&0xff), *((iv)++)=(unsigned char)(((d0)>>24L)&0xff)); | - | ||||||
| 160 | (*((iv)++)=(unsigned char)(((d1) )&0xff), *((iv)++)=(unsigned char)(((d1)>> 8L)&0xff), *((iv)++)=(unsigned char)(((d1)>>16L)&0xff), *((iv)++)=(unsigned char)(((d1)>>24L)&0xff)); | - | ||||||
| 161 | - | |||||||
| 162 | memmove(ovec,ovec+num/8,8+(num%8 ? 1 : 0)); | - | ||||||
| 163 | - | |||||||
| 164 | if(num%8 != 0
| 0 | ||||||
| 165 | for(i=0 ; i < 8
| 0 | ||||||
| 166 | { | - | ||||||
| 167 | ovec[i]<<=num%8; | - | ||||||
| 168 | ovec[i]|=ovec[i+1]>>(8-num%8); | - | ||||||
| 169 | } never executed: end of block | 0 | ||||||
| 170 | iv=&ovec[0]; | - | ||||||
| 171 | (v0 =((unsigned int)(*((iv)++))) , v0|=((unsigned int)(*((iv)++)))<< 8L, v0|=((unsigned int)(*((iv)++)))<<16L, v0|=((unsigned int)(*((iv)++)))<<24L); | - | ||||||
| 172 | (v1 =((unsigned int)(*((iv)++))) , v1|=((unsigned int)(*((iv)++)))<< 8L, v1|=((unsigned int)(*((iv)++)))<<16L, v1|=((unsigned int)(*((iv)++)))<<24L); | - | ||||||
| 173 | } never executed: end of block | 0 | ||||||
| 174 | d0^=ti[0]; | - | ||||||
| 175 | d1^=ti[1]; | - | ||||||
| 176 | { out+=n; switch (n) { case never executed: 8:case 8:never executed: *(--(out))=(unsigned char)(((d1)>>24L)&0xff); casecase 8:never executed: 7:case 7:never executed: case 7:code before this statement never executed: *(--(out))=(unsigned char)(((d1)>>16L)&0xff); casecase 7:never executed: 6:case 6:never executed: case 6:code before this statement never executed: *(--(out))=(unsigned char)(((d1)>> 8L)&0xff); casecase 6:never executed: 5:case 5:never executed: case 5:code before this statement never executed: *(--(out))=(unsigned char)(((d1) )&0xff); casecase 5:never executed: 4:case 4:never executed: case 4:code before this statement never executed: *(--(out))=(unsigned char)(((d0)>>24L)&0xff); casecase 4:never executed: 3:case 3:never executed: case 3:code before this statement never executed: *(--(out))=(unsigned char)(((d0)>>16L)&0xff); casecase 3:never executed: 2:case 2:never executed: case 2:code before this statement never executed: *(--(out))=(unsigned char)(((d0)>> 8L)&0xff); casecase 2:never executed: 1:case 1:never executed: case 1:code before this statement never executed: *(--(out))=(unsigned char)(((d0) )&0xff); }case 1:never executed: };end of block | 0 | ||||||
| 177 | out+=n; | - | ||||||
| 178 | } never executed: end of block | 0 | ||||||
| 179 | } never executed: end of block | 0 | ||||||
| 180 | iv = &(*ivec)[0]; | - | ||||||
| 181 | (*((iv)++)=(unsigned char)(((v0) )&0xff), *((iv)++)=(unsigned char)(((v0)>> 8L)&0xff), *((iv)++)=(unsigned char)(((v0)>>16L)&0xff), *((iv)++)=(unsigned char)(((v0)>>24L)&0xff)); | - | ||||||
| 182 | (*((iv)++)=(unsigned char)(((v1) )&0xff), *((iv)++)=(unsigned char)(((v1)>> 8L)&0xff), *((iv)++)=(unsigned char)(((v1)>>16L)&0xff), *((iv)++)=(unsigned char)(((v1)>>24L)&0xff)); | - | ||||||
| 183 | v0=v1=d0=d1=ti[0]=ti[1]=0; | - | ||||||
| 184 | } never executed: end of block | 0 | ||||||
| Switch to Source code | Preprocessed file |