diff options
Diffstat (limited to 'src/lib/libcrypto/des/destest.c')
-rw-r--r-- | src/lib/libcrypto/des/destest.c | 69 |
1 files changed, 37 insertions, 32 deletions
diff --git a/src/lib/libcrypto/des/destest.c b/src/lib/libcrypto/des/destest.c index 9ad4ecb072..df0d615d6b 100644 --- a/src/lib/libcrypto/des/destest.c +++ b/src/lib/libcrypto/des/destest.c | |||
@@ -336,8 +336,15 @@ int main(int argc, char *argv[]) | |||
336 | unsigned char cbc_in[40]; | 336 | unsigned char cbc_in[40]; |
337 | unsigned char cbc_out[40]; | 337 | unsigned char cbc_out[40]; |
338 | DES_LONG cs; | 338 | DES_LONG cs; |
339 | unsigned char qret[4][4],cret[8]; | 339 | unsigned char cret[8]; |
340 | DES_LONG lqret[4]; | 340 | #ifdef _CRAY |
341 | struct { | ||
342 | int a:32; | ||
343 | int b:32; | ||
344 | } lqret[2]; | ||
345 | #else | ||
346 | DES_LONG lqret[4]; | ||
347 | #endif | ||
341 | int num; | 348 | int num; |
342 | char *str; | 349 | char *str; |
343 | 350 | ||
@@ -701,43 +708,40 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]); | |||
701 | } | 708 | } |
702 | 709 | ||
703 | printf("Doing quad_cksum\n"); | 710 | printf("Doing quad_cksum\n"); |
704 | /* This is obviously done this way especially to puzzle me. Although | 711 | cs=quad_cksum(cbc_data,(des_cblock *)lqret, |
705 | quad_cksum returns up to 4 groups of 8 bytes, this test gets it to | 712 | (long)strlen((char *)cbc_data),2,(des_cblock *)cbc_iv); |
706 | produce 2 groups then treats them as 4 groups of 4 bytes. | 713 | if (cs != 0x70d7a63aL) |
707 | Ben 13 Feb 1999 */ | ||
708 | cs=quad_cksum(cbc_data,(des_cblock *)qret,strlen((char *)cbc_data),2, | ||
709 | &cbc_iv); | ||
710 | |||
711 | { /* Big-endian fix */ | ||
712 | static DES_LONG l=1; | ||
713 | static unsigned char *c=(unsigned char *)&l; | ||
714 | DES_LONG ll; | ||
715 | |||
716 | j=sizeof(lqret[0])-4; | ||
717 | for (i=0; i<4; i++) | ||
718 | { | 714 | { |
719 | lqret[i]=0; | 715 | printf("quad_cksum error, ret %08lx should be 70d7a63a\n", |
720 | memcpy(&(lqret[i]),&(qret[i][0]),4); | 716 | (unsigned long)cs); |
721 | if (!c[0] && (j > 0)) | 717 | err=1; |
722 | lqret[i]=lqret[i]>>(j*8); /* For Cray */ | ||
723 | } | 718 | } |
724 | 719 | #ifdef _CRAY | |
725 | if (!c[0]) | 720 | if (lqret[0].a != 0x327eba8dL) |
726 | { | 721 | { |
727 | ll=lqret[0]^lqret[3]; | 722 | printf("quad_cksum error, out[0] %08lx is not %08lx\n", |
728 | lqret[0]^=ll; | 723 | (unsigned long)lqret[0].a,0x327eba8dUL); |
729 | lqret[3]^=ll; | 724 | err=1; |
730 | ll=lqret[1]^lqret[2]; | ||
731 | lqret[1]^=ll; | ||
732 | lqret[2]^=ll; | ||
733 | } | 725 | } |
734 | } | 726 | if (lqret[0].b != 0x201a49ccL) |
735 | if (cs != 0x70d7a63aL) | ||
736 | { | 727 | { |
737 | printf("quad_cksum error, ret %08lx should be 70d7a63a\n", | 728 | printf("quad_cksum error, out[1] %08lx is not %08lx\n", |
738 | (unsigned long)cs); | 729 | (unsigned long)lqret[0].b,0x201a49ccUL); |
730 | err=1; | ||
731 | } | ||
732 | if (lqret[1].a != 0x70d7a63aL) | ||
733 | { | ||
734 | printf("quad_cksum error, out[2] %08lx is not %08lx\n", | ||
735 | (unsigned long)lqret[1].a,0x70d7a63aUL); | ||
739 | err=1; | 736 | err=1; |
740 | } | 737 | } |
738 | if (lqret[1].b != 0x501c2c26L) | ||
739 | { | ||
740 | printf("quad_cksum error, out[3] %08lx is not %08lx\n", | ||
741 | (unsigned long)lqret[1].b,0x501c2c26UL); | ||
742 | err=1; | ||
743 | } | ||
744 | #else | ||
741 | if (lqret[0] != 0x327eba8dL) | 745 | if (lqret[0] != 0x327eba8dL) |
742 | { | 746 | { |
743 | printf("quad_cksum error, out[0] %08lx is not %08lx\n", | 747 | printf("quad_cksum error, out[0] %08lx is not %08lx\n", |
@@ -763,6 +767,7 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]); | |||
763 | err=1; | 767 | err=1; |
764 | } | 768 | } |
765 | #endif | 769 | #endif |
770 | #endif | ||
766 | 771 | ||
767 | printf("input word alignment test"); | 772 | printf("input word alignment test"); |
768 | for (i=0; i<4; i++) | 773 | for (i=0; i<4; i++) |