| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/mdc2/mdc2dgst.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | static void mdc2_body(MDC2_CTX *c, const unsigned char *in, size_t len); | - | ||||||||||||||||||||||||
| 2 | int MDC2_Init(MDC2_CTX *c) | - | ||||||||||||||||||||||||
| 3 | { | - | ||||||||||||||||||||||||
| 4 | c->num = 0; | - | ||||||||||||||||||||||||
| 5 | c->pad_type = 1; | - | ||||||||||||||||||||||||
| 6 | memset(&(c->h[0]), 0x52, 8); | - | ||||||||||||||||||||||||
| 7 | memset(&(c->hh[0]), 0x25, 8); | - | ||||||||||||||||||||||||
| 8 | return executed 3 times by 1 test: 1;return 1;Executed by:
executed 3 times by 1 test: return 1;Executed by:
| 3 | ||||||||||||||||||||||||
| 9 | } | - | ||||||||||||||||||||||||
| 10 | - | |||||||||||||||||||||||||
| 11 | int MDC2_Update(MDC2_CTX *c, const unsigned char *in, size_t len) | - | ||||||||||||||||||||||||
| 12 | { | - | ||||||||||||||||||||||||
| 13 | size_t i, j; | - | ||||||||||||||||||||||||
| 14 | - | |||||||||||||||||||||||||
| 15 | i = c->num; | - | ||||||||||||||||||||||||
| 16 | if (i != 0
| 0-3 | ||||||||||||||||||||||||
| 17 | if (len < 8 - i
| 0 | ||||||||||||||||||||||||
| 18 | - | |||||||||||||||||||||||||
| 19 | memcpy(&(c->data[i]), in, len); | - | ||||||||||||||||||||||||
| 20 | c->num += (int)len; | - | ||||||||||||||||||||||||
| 21 | return never executed: 1;return 1;never executed: return 1; | 0 | ||||||||||||||||||||||||
| 22 | } else { | - | ||||||||||||||||||||||||
| 23 | - | |||||||||||||||||||||||||
| 24 | j = 8 - i; | - | ||||||||||||||||||||||||
| 25 | memcpy(&(c->data[i]), in, j); | - | ||||||||||||||||||||||||
| 26 | len -= j; | - | ||||||||||||||||||||||||
| 27 | in += j; | - | ||||||||||||||||||||||||
| 28 | c->num = 0; | - | ||||||||||||||||||||||||
| 29 | mdc2_body(c, &(c->data[0]), 8); | - | ||||||||||||||||||||||||
| 30 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 31 | } | - | ||||||||||||||||||||||||
| 32 | i = len & ~((size_t)8 - 1); | - | ||||||||||||||||||||||||
| 33 | if (i > 0
| 0-3 | ||||||||||||||||||||||||
| 34 | mdc2_body(c, in, i); executed 3 times by 1 test: mdc2_body(c, in, i);Executed by:
| 3 | ||||||||||||||||||||||||
| 35 | j = len - i; | - | ||||||||||||||||||||||||
| 36 | if (j > 0
| 0-3 | ||||||||||||||||||||||||
| 37 | memcpy(&(c->data[0]), &(in[i]), j); | - | ||||||||||||||||||||||||
| 38 | c->num = (int)j; | - | ||||||||||||||||||||||||
| 39 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 40 | return executed 3 times by 1 test: 1;return 1;Executed by:
executed 3 times by 1 test: return 1;Executed by:
| 3 | ||||||||||||||||||||||||
| 41 | } | - | ||||||||||||||||||||||||
| 42 | - | |||||||||||||||||||||||||
| 43 | static void mdc2_body(MDC2_CTX *c, const unsigned char *in, size_t len) | - | ||||||||||||||||||||||||
| 44 | { | - | ||||||||||||||||||||||||
| 45 | register DES_LONG tin0, tin1; | - | ||||||||||||||||||||||||
| 46 | register DES_LONG ttin0, ttin1; | - | ||||||||||||||||||||||||
| 47 | DES_LONG d[2], dd[2]; | - | ||||||||||||||||||||||||
| 48 | DES_key_schedule k; | - | ||||||||||||||||||||||||
| 49 | unsigned char *p; | - | ||||||||||||||||||||||||
| 50 | size_t i; | - | ||||||||||||||||||||||||
| 51 | - | |||||||||||||||||||||||||
| 52 | for (i = 0; i < len
| 4-10 | ||||||||||||||||||||||||
| 53 | (tin0 =((DES_LONG)(*((in)++))) , tin0|=((DES_LONG)(*((in)++)))<< 8L, tin0|=((DES_LONG)(*((in)++)))<<16L, tin0|=((DES_LONG)(*((in)++)))<<24L); | - | ||||||||||||||||||||||||
| 54 | d[0] = dd[0] = tin0; | - | ||||||||||||||||||||||||
| 55 | (tin1 =((DES_LONG)(*((in)++))) , tin1|=((DES_LONG)(*((in)++)))<< 8L, tin1|=((DES_LONG)(*((in)++)))<<16L, tin1|=((DES_LONG)(*((in)++)))<<24L); | - | ||||||||||||||||||||||||
| 56 | d[1] = dd[1] = tin1; | - | ||||||||||||||||||||||||
| 57 | c->h[0] = (c->h[0] & 0x9f) | 0x40; | - | ||||||||||||||||||||||||
| 58 | c->hh[0] = (c->hh[0] & 0x9f) | 0x20; | - | ||||||||||||||||||||||||
| 59 | - | |||||||||||||||||||||||||
| 60 | DES_set_odd_parity(&c->h); | - | ||||||||||||||||||||||||
| 61 | DES_set_key_unchecked(&c->h, &k); | - | ||||||||||||||||||||||||
| 62 | DES_encrypt1(d, &k, 1); | - | ||||||||||||||||||||||||
| 63 | - | |||||||||||||||||||||||||
| 64 | DES_set_odd_parity(&c->hh); | - | ||||||||||||||||||||||||
| 65 | DES_set_key_unchecked(&c->hh, &k); | - | ||||||||||||||||||||||||
| 66 | DES_encrypt1(dd, &k, 1); | - | ||||||||||||||||||||||||
| 67 | - | |||||||||||||||||||||||||
| 68 | ttin0 = tin0 ^ dd[0]; | - | ||||||||||||||||||||||||
| 69 | ttin1 = tin1 ^ dd[1]; | - | ||||||||||||||||||||||||
| 70 | tin0 ^= d[0]; | - | ||||||||||||||||||||||||
| 71 | tin1 ^= d[1]; | - | ||||||||||||||||||||||||
| 72 | - | |||||||||||||||||||||||||
| 73 | p = c->h; | - | ||||||||||||||||||||||||
| 74 | (*((p)++)=(unsigned char)(((tin0) )&0xff), *((p)++)=(unsigned char)(((tin0)>> 8L)&0xff), *((p)++)=(unsigned char)(((tin0)>>16L)&0xff), *((p)++)=(unsigned char)(((tin0)>>24L)&0xff)); | - | ||||||||||||||||||||||||
| 75 | (*((p)++)=(unsigned char)(((ttin1) )&0xff), *((p)++)=(unsigned char)(((ttin1)>> 8L)&0xff), *((p)++)=(unsigned char)(((ttin1)>>16L)&0xff), *((p)++)=(unsigned char)(((ttin1)>>24L)&0xff)); | - | ||||||||||||||||||||||||
| 76 | p = c->hh; | - | ||||||||||||||||||||||||
| 77 | (*((p)++)=(unsigned char)(((ttin0) )&0xff), *((p)++)=(unsigned char)(((ttin0)>> 8L)&0xff), *((p)++)=(unsigned char)(((ttin0)>>16L)&0xff), *((p)++)=(unsigned char)(((ttin0)>>24L)&0xff)); | - | ||||||||||||||||||||||||
| 78 | (*((p)++)=(unsigned char)(((tin1) )&0xff), *((p)++)=(unsigned char)(((tin1)>> 8L)&0xff), *((p)++)=(unsigned char)(((tin1)>>16L)&0xff), *((p)++)=(unsigned char)(((tin1)>>24L)&0xff)); | - | ||||||||||||||||||||||||
| 79 | } executed 10 times by 1 test: end of blockExecuted by:
| 10 | ||||||||||||||||||||||||
| 80 | } executed 4 times by 1 test: end of blockExecuted by:
| 4 | ||||||||||||||||||||||||
| 81 | - | |||||||||||||||||||||||||
| 82 | int MDC2_Final(unsigned char *md, MDC2_CTX *c) | - | ||||||||||||||||||||||||
| 83 | { | - | ||||||||||||||||||||||||
| 84 | unsigned int i; | - | ||||||||||||||||||||||||
| 85 | int j; | - | ||||||||||||||||||||||||
| 86 | - | |||||||||||||||||||||||||
| 87 | i = c->num; | - | ||||||||||||||||||||||||
| 88 | j = c->pad_type; | - | ||||||||||||||||||||||||
| 89 | if ((
| 0-3 | ||||||||||||||||||||||||
| 90 | if (j == 2
| 0-1 | ||||||||||||||||||||||||
| 91 | c->data[i++] = 0x80; executed 1 time by 1 test: c->data[i++] = 0x80;Executed by:
| 1 | ||||||||||||||||||||||||
| 92 | memset(&(c->data[i]), 0, 8 - i); | - | ||||||||||||||||||||||||
| 93 | mdc2_body(c, c->data, 8); | - | ||||||||||||||||||||||||
| 94 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||||||||||||||
| 95 | memcpy(md, (char *)c->h, 8); | - | ||||||||||||||||||||||||
| 96 | memcpy(&(md[8]), (char *)c->hh, 8); | - | ||||||||||||||||||||||||
| 97 | return executed 3 times by 1 test: 1;return 1;Executed by:
executed 3 times by 1 test: return 1;Executed by:
| 3 | ||||||||||||||||||||||||
| 98 | } | - | ||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |