| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/libressl/src/crypto/idea/i_skey.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||
|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||
| 2 | static unsigned int inverse(unsigned int xin); | - | ||||||
| 3 | void idea_set_encrypt_key(const unsigned char *key, IDEA_KEY_SCHEDULE *ks) | - | ||||||
| 4 | { | - | ||||||
| 5 | int i; | - | ||||||
| 6 | unsigned int *kt,*kf,r0,r1,r2; | - | ||||||
| 7 | - | |||||||
| 8 | kt= &(ks->data[0][0]); | - | ||||||
| 9 | (kt[0] =((unsigned int)(*((key)++)))<< 8L, kt[0]|=((unsigned int)(*((key)++))) ); (kt[1] =((unsigned int)(*((key)++)))<< 8L, kt[1]|=((unsigned int)(*((key)++))) ); (kt[2] =((unsigned int)(*((key)++)))<< 8L, kt[2]|=((unsigned int)(*((key)++))) ); (kt[3] =((unsigned int)(*((key)++)))<< 8L, kt[3]|=((unsigned int)(*((key)++))) ); | - | ||||||
| 10 | (kt[4] =((unsigned int)(*((key)++)))<< 8L, kt[4]|=((unsigned int)(*((key)++))) ); (kt[5] =((unsigned int)(*((key)++)))<< 8L, kt[5]|=((unsigned int)(*((key)++))) ); (kt[6] =((unsigned int)(*((key)++)))<< 8L, kt[6]|=((unsigned int)(*((key)++))) ); (kt[7] =((unsigned int)(*((key)++)))<< 8L, kt[7]|=((unsigned int)(*((key)++))) ); | - | ||||||
| 11 | - | |||||||
| 12 | kf=kt; | - | ||||||
| 13 | kt+=8; | - | ||||||
| 14 | for (i=0; i<6
| 0-12 | ||||||
| 15 | { | - | ||||||
| 16 | r2= kf[1]; | - | ||||||
| 17 | r1= kf[2]; | - | ||||||
| 18 | *(kt++)= ((r2<<9) | (r1>>7))&0xffff; | - | ||||||
| 19 | r0= kf[3]; | - | ||||||
| 20 | *(kt++)= ((r1<<9) | (r0>>7))&0xffff; | - | ||||||
| 21 | r1= kf[4]; | - | ||||||
| 22 | *(kt++)= ((r0<<9) | (r1>>7))&0xffff; | - | ||||||
| 23 | r0= kf[5]; | - | ||||||
| 24 | *(kt++)= ((r1<<9) | (r0>>7))&0xffff; | - | ||||||
| 25 | r1= kf[6]; | - | ||||||
| 26 | *(kt++)= ((r0<<9) | (r1>>7))&0xffff; | - | ||||||
| 27 | r0= kf[7]; | - | ||||||
| 28 | *(kt++)= ((r1<<9) | (r0>>7))&0xffff; | - | ||||||
| 29 | r1= kf[0]; | - | ||||||
| 30 | if (i >= 5
executed 2 times by 1 test: break;Executed by:
| 2-10 | ||||||
| 31 | *(kt++)= ((r0<<9) | (r1>>7))&0xffff; | - | ||||||
| 32 | *(kt++)= ((r1<<9) | (r2>>7))&0xffff; | - | ||||||
| 33 | kf+=8; | - | ||||||
| 34 | } executed 10 times by 1 test: end of blockExecuted by:
| 10 | ||||||
| 35 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||
| 36 | - | |||||||
| 37 | void idea_set_decrypt_key(IDEA_KEY_SCHEDULE *ek, IDEA_KEY_SCHEDULE *dk) | - | ||||||
| 38 | { | - | ||||||
| 39 | int r; | - | ||||||
| 40 | unsigned int *fp,*tp,t; | - | ||||||
| 41 | - | |||||||
| 42 | tp= &(dk->data[0][0]); | - | ||||||
| 43 | fp= &(ek->data[8][0]); | - | ||||||
| 44 | for (r=0; r<9
| 0-18 | ||||||
| 45 | { | - | ||||||
| 46 | *(tp++)=inverse(fp[0]); | - | ||||||
| 47 | *(tp++)=((int)(0x10000L-fp[2])&0xffff); | - | ||||||
| 48 | *(tp++)=((int)(0x10000L-fp[1])&0xffff); | - | ||||||
| 49 | *(tp++)=inverse(fp[3]); | - | ||||||
| 50 | if (r == 8
executed 2 times by 1 test: break;Executed by:
| 2-16 | ||||||
| 51 | fp-=6; | - | ||||||
| 52 | *(tp++)=fp[4]; | - | ||||||
| 53 | *(tp++)=fp[5]; | - | ||||||
| 54 | } executed 16 times by 1 test: end of blockExecuted by:
| 16 | ||||||
| 55 | - | |||||||
| 56 | tp= &(dk->data[0][0]); | - | ||||||
| 57 | t=tp[1]; | - | ||||||
| 58 | tp[1]=tp[2]; | - | ||||||
| 59 | tp[2]=t; | - | ||||||
| 60 | - | |||||||
| 61 | t=tp[49]; | - | ||||||
| 62 | tp[49]=tp[50]; | - | ||||||
| 63 | tp[50]=t; | - | ||||||
| 64 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||
| 65 | - | |||||||
| 66 | - | |||||||
| 67 | static unsigned int inverse(unsigned int xin) | - | ||||||
| 68 | { | - | ||||||
| 69 | long n1,n2,q,r,b1,b2,t; | - | ||||||
| 70 | - | |||||||
| 71 | if (xin == 0
| 0-36 | ||||||
| 72 | b2=0; never executed: b2=0; | 0 | ||||||
| 73 | else | - | ||||||
| 74 | { | - | ||||||
| 75 | n1=0x10001; | - | ||||||
| 76 | n2=xin; | - | ||||||
| 77 | b2=1; | - | ||||||
| 78 | b1=0; | - | ||||||
| 79 | - | |||||||
| 80 | do { | - | ||||||
| 81 | r=(n1%n2); | - | ||||||
| 82 | q=(n1-r)/n2; | - | ||||||
| 83 | if (r == 0
| 36-230 | ||||||
| 84 | { if (b2 < 0
executed 24 times by 1 test: }b2=0x10001+b2;Executed by:
executed 36 times by 1 test: end of blockExecuted by:
| 12-36 | ||||||
| 85 | else | - | ||||||
| 86 | { | - | ||||||
| 87 | n1=n2; | - | ||||||
| 88 | n2=r; | - | ||||||
| 89 | t=b2; | - | ||||||
| 90 | b2=b1-q*b2; | - | ||||||
| 91 | b1=t; | - | ||||||
| 92 | } executed 230 times by 1 test: end of blockExecuted by:
| 230 | ||||||
| 93 | } while (r != 0
| 36-230 | ||||||
| 94 | } executed 36 times by 1 test: end of blockExecuted by:
| 36 | ||||||
| 95 | return executed 36 times by 1 test: ((unsigned int)b2);return((unsigned int)b2);Executed by:
executed 36 times by 1 test: return((unsigned int)b2);Executed by:
| 36 | ||||||
| 96 | } | - | ||||||
| Switch to Source code | Preprocessed file |