| 1 |
/* PR middle-end/55150 */ |
| 2 |
/* { dg-do compile } */ |
| 3 |
/* { dg-require-effective-target fpic } */ |
| 4 |
/* { dg-options "-Os -g -fPIC" } */ |
| 5 |
|
| 6 |
typedef unsigned char DES_cblock[8]; |
| 7 |
typedef struct DES_ks { |
| 8 |
} |
| 9 |
DES_key_schedule; |
| 10 |
void DES_encrypt1 (long *, DES_key_schedule *, int); |
| 11 |
void DES_ede3_cbcm_encrypt (const unsigned char *in, unsigned char *out, long length, DES_key_schedule * ks1, DES_key_schedule * ks2, DES_key_schedule * ks3, DES_cblock * ivec1, DES_cblock * ivec2, int enc) { |
| 12 |
register unsigned long tout0, tout1, xor0, xor1, m0, m1; |
| 13 |
register long l = length; |
| 14 |
unsigned long tin[2]; |
| 15 |
unsigned char *iv1, *iv2; |
| 16 |
iv1 = &(*ivec1)[0]; |
| 17 |
iv2 = &(*ivec2)[0]; |
| 18 |
if (enc) { |
| 19 |
(m0 = ((unsigned long) (*((iv1)++))), m0 |= ((unsigned long) (*((iv1)++))) << 8L, m0 |= ((unsigned long) (*((iv1)++))) << 16L, m0 |= ((unsigned long) (*((iv1)++))) << 24L); |
| 20 |
(m1 = ((unsigned long) (*((iv1)++))), m1 |= ((unsigned long) (*((iv1)++))) << 8L, m1 |= ((unsigned long) (*((iv1)++))) << 16L, m1 |= ((unsigned long) (*((iv1)++))) << 24L); |
| 21 |
(tout0 = ((unsigned long) (*((iv2)++))), tout0 |= ((unsigned long) (*((iv2)++))) << 8L, tout0 |= ((unsigned long) (*((iv2)++))) << 16L, tout0 |= ((unsigned long) (*((iv2)++))) << 24L); |
| 22 |
for (l -= 8; |
| 23 |
l >= -7; |
| 24 |
l -= 8) { |
| 25 |
DES_encrypt1 (tin, ks3, 1); |
| 26 |
DES_encrypt1 (tin, ks1, 1); |
| 27 |
} |
| 28 |
(*((iv1)++) = (unsigned char) (((m0)) & 0xff), *((iv1)++) = (unsigned char) (((m0) >> 8L) & 0xff), *((iv1)++) = (unsigned char) (((m0) >> 16L) & 0xff), *((iv1)++) = (unsigned char) (((m0) >> 24L) & 0xff)); |
| 29 |
(*((iv1)++) = (unsigned char) (((m1)) & 0xff), *((iv1)++) = (unsigned char) (((m1) >> 8L) & 0xff), *((iv1)++) = (unsigned char) (((m1) >> 16L) & 0xff), *((iv1)++) = (unsigned char) (((m1) >> 24L) & 0xff)); |
| 30 |
(*((iv2)++) = (unsigned char) (((tout0)) & 0xff), *((iv2)++) = (unsigned char) (((tout0) >> 8L) & 0xff), *((iv2)++) = (unsigned char) (((tout0) >> 16L) & 0xff), *((iv2)++) = (unsigned char) (((tout0) >> 24L) & 0xff)); |
| 31 |
} |
| 32 |
else { |
| 33 |
(m0 = ((unsigned long) (*((iv1)++))), m0 |= ((unsigned long) (*((iv1)++))) << 8L, m0 |= ((unsigned long) (*((iv1)++))) << 16L, m0 |= ((unsigned long) (*((iv1)++))) << 24L); |
| 34 |
(xor1 = ((unsigned long) (*((iv2)++))), xor1 |= ((unsigned long) (*((iv2)++))) << 8L, xor1 |= ((unsigned long) (*((iv2)++))) << 16L, xor1 |= ((unsigned long) (*((iv2)++))) << 24L); |
| 35 |
for (l -= 8; |
| 36 |
l >= -7; |
| 37 |
l -= 8) { |
| 38 |
DES_encrypt1 (tin, ks3, 1); |
| 39 |
if (l < 0) { |
| 40 |
{ |
| 41 |
switch (l + 8) { |
| 42 |
case 7: *(--(out)) = (unsigned char) (((tout1) >> 16L) & 0xff); |
| 43 |
case 6: *(--(out)) = (unsigned char) (((tout1) >> 8L) & 0xff); |
| 44 |
case 5: *(--(out)) = (unsigned char) (((tout1)) & 0xff); |
| 45 |
case 4: *(--(out)) = (unsigned char) (((tout0) >> 24L) & 0xff); |
| 46 |
case 1: *(--(out)) = (unsigned char) (((tout0)) & 0xff); |
| 47 |
} |
| 48 |
}; |
| 49 |
} |
| 50 |
} |
| 51 |
(*((iv1)++) = (unsigned char) (((m0)) & 0xff), *((iv1)++) = (unsigned char) (((m0) >> 8L) & 0xff), *((iv1)++) = (unsigned char) (((m0) >> 16L) & 0xff), *((iv1)++) = (unsigned char) (((m0) >> 24L) & 0xff)); |
| 52 |
(*((iv2)++) = (unsigned char) (((xor0)) & 0xff), *((iv2)++) = (unsigned char) (((xor0) >> 8L) & 0xff), *((iv2)++) = (unsigned char) (((xor0) >> 16L) & 0xff), *((iv2)++) = (unsigned char) (((xor0) >> 24L) & 0xff)); |
| 53 |
(*((iv2)++) = (unsigned char) (((xor1)) & 0xff), *((iv2)++) = (unsigned char) (((xor1) >> 8L) & 0xff), *((iv2)++) = (unsigned char) (((xor1) >> 16L) & 0xff), *((iv2)++) = (unsigned char) (((xor1) >> 24L) & 0xff)); |
| 54 |
} |
| 55 |
} |