diff options
Diffstat (limited to 'src/lib/libcrypto/des/qud_cksm.c')
| -rw-r--r-- | src/lib/libcrypto/des/qud_cksm.c | 53 |
1 files changed, 24 insertions, 29 deletions
diff --git a/src/lib/libcrypto/des/qud_cksm.c b/src/lib/libcrypto/des/qud_cksm.c index 8526abf334..dac201227e 100644 --- a/src/lib/libcrypto/des/qud_cksm.c +++ b/src/lib/libcrypto/des/qud_cksm.c | |||
| @@ -73,28 +73,32 @@ | |||
| 73 | /* Got the value MIT uses via brute force :-) 2/10/90 eay */ | 73 | /* Got the value MIT uses via brute force :-) 2/10/90 eay */ |
| 74 | #define NOISE ((DES_LONG)83653421L) | 74 | #define NOISE ((DES_LONG)83653421L) |
| 75 | 75 | ||
| 76 | DES_LONG des_quad_cksum(input, output, length, out_count, seed) | 76 | DES_LONG DES_quad_cksum(const unsigned char *input, DES_cblock output[], |
| 77 | des_cblock (*input); | 77 | long length, int out_count, DES_cblock *seed) |
| 78 | des_cblock (*output); | ||
| 79 | long length; | ||
| 80 | int out_count; | ||
| 81 | des_cblock (*seed); | ||
| 82 | { | 78 | { |
| 83 | DES_LONG z0,z1,t0,t1; | 79 | DES_LONG z0,z1,t0,t1; |
| 84 | int i; | 80 | int i; |
| 85 | long l; | 81 | long l; |
| 86 | unsigned char *cp; | 82 | const unsigned char *cp; |
| 87 | unsigned char *lp; | 83 | #ifdef _CRAY |
| 84 | struct lp_st { int a:32; int b:32; } *lp; | ||
| 85 | #else | ||
| 86 | DES_LONG *lp; | ||
| 87 | #endif | ||
| 88 | 88 | ||
| 89 | if (out_count < 1) out_count=1; | 89 | if (out_count < 1) out_count=1; |
| 90 | lp=(unsigned char *)output; | 90 | #ifdef _CRAY |
| 91 | lp = (struct lp_st *) &(output[0])[0]; | ||
| 92 | #else | ||
| 93 | lp = (DES_LONG *) &(output[0])[0]; | ||
| 94 | #endif | ||
| 91 | 95 | ||
| 92 | z0=Q_B0((*seed)[0])|Q_B1((*seed)[1])|Q_B2((*seed)[2])|Q_B3((*seed)[3]); | 96 | z0=Q_B0((*seed)[0])|Q_B1((*seed)[1])|Q_B2((*seed)[2])|Q_B3((*seed)[3]); |
| 93 | z1=Q_B0((*seed)[4])|Q_B1((*seed)[5])|Q_B2((*seed)[6])|Q_B3((*seed)[7]); | 97 | z1=Q_B0((*seed)[4])|Q_B1((*seed)[5])|Q_B2((*seed)[6])|Q_B3((*seed)[7]); |
| 94 | 98 | ||
| 95 | for (i=0; ((i<4)&&(i<out_count)); i++) | 99 | for (i=0; ((i<4)&&(i<out_count)); i++) |
| 96 | { | 100 | { |
| 97 | cp=(unsigned char *)input; | 101 | cp=input; |
| 98 | l=length; | 102 | l=length; |
| 99 | while (l > 0) | 103 | while (l > 0) |
| 100 | { | 104 | { |
| @@ -118,25 +122,16 @@ des_cblock (*seed); | |||
| 118 | } | 122 | } |
| 119 | if (lp != NULL) | 123 | if (lp != NULL) |
| 120 | { | 124 | { |
| 121 | /* I believe I finally have things worked out. | 125 | /* The MIT library assumes that the checksum is |
| 122 | * The MIT library assumes that the checksum | 126 | * composed of 2*out_count 32 bit ints */ |
| 123 | * is one huge number and it is returned in a | 127 | #ifdef _CRAY |
| 124 | * host dependant byte order. | 128 | (*lp).a = z0; |
| 125 | */ | 129 | (*lp).b = z1; |
| 126 | static DES_LONG ltmp=1; | 130 | lp++; |
| 127 | static unsigned char *c=(unsigned char *)<mp; | 131 | #else |
| 128 | 132 | *lp++ = z0; | |
| 129 | if (c[0]) | 133 | *lp++ = z1; |
| 130 | { | 134 | #endif |
| 131 | l2c(z0,lp); | ||
| 132 | l2c(z1,lp); | ||
| 133 | } | ||
| 134 | else | ||
| 135 | { | ||
| 136 | lp=output[out_count-i-1]; | ||
| 137 | l2n(z1,lp); | ||
| 138 | l2n(z0,lp); | ||
| 139 | } | ||
| 140 | } | 135 | } |
| 141 | } | 136 | } |
| 142 | return(z0); | 137 | return(z0); |
