diff options
Diffstat (limited to 'src/lib/libcrypto/des/qud_cksm.c')
-rw-r--r-- | src/lib/libcrypto/des/qud_cksm.c | 81 |
1 files changed, 41 insertions, 40 deletions
diff --git a/src/lib/libcrypto/des/qud_cksm.c b/src/lib/libcrypto/des/qud_cksm.c index 7ff43620a3..c9d2c01fa1 100644 --- a/src/lib/libcrypto/des/qud_cksm.c +++ b/src/lib/libcrypto/des/qud_cksm.c | |||
@@ -1,25 +1,25 @@ | |||
1 | /* $OpenBSD: qud_cksm.c,v 1.8 2022/11/26 16:08:51 tb Exp $ */ | 1 | /* $OpenBSD: qud_cksm.c,v 1.9 2023/07/08 07:11:07 beck Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
5 | * This package is an SSL implementation written | 5 | * This package is an SSL implementation written |
6 | * by Eric Young (eay@cryptsoft.com). | 6 | * by Eric Young (eay@cryptsoft.com). |
7 | * The implementation was written so as to conform with Netscapes SSL. | 7 | * The implementation was written so as to conform with Netscapes SSL. |
8 | * | 8 | * |
9 | * This library is free for commercial and non-commercial use as long as | 9 | * This library is free for commercial and non-commercial use as long as |
10 | * the following conditions are aheared to. The following conditions | 10 | * the following conditions are aheared to. The following conditions |
11 | * apply to all code found in this distribution, be it the RC4, RSA, | 11 | * apply to all code found in this distribution, be it the RC4, RSA, |
12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation |
13 | * included with this distribution is covered by the same copyright terms | 13 | * included with this distribution is covered by the same copyright terms |
14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). |
15 | * | 15 | * |
16 | * Copyright remains Eric Young's, and as such any Copyright notices in | 16 | * Copyright remains Eric Young's, and as such any Copyright notices in |
17 | * the code are not to be removed. | 17 | * the code are not to be removed. |
18 | * If this package is used in a product, Eric Young should be given attribution | 18 | * If this package is used in a product, Eric Young should be given attribution |
19 | * as the author of the parts of the library used. | 19 | * as the author of the parts of the library used. |
20 | * This can be in the form of a textual message at program startup or | 20 | * This can be in the form of a textual message at program startup or |
21 | * in documentation (online or textual) provided with the package. | 21 | * in documentation (online or textual) provided with the package. |
22 | * | 22 | * |
23 | * Redistribution and use in source and binary forms, with or without | 23 | * Redistribution and use in source and binary forms, with or without |
24 | * modification, are permitted provided that the following conditions | 24 | * modification, are permitted provided that the following conditions |
25 | * are met: | 25 | * are met: |
@@ -34,10 +34,10 @@ | |||
34 | * Eric Young (eay@cryptsoft.com)" | 34 | * Eric Young (eay@cryptsoft.com)" |
35 | * The word 'cryptographic' can be left out if the rouines from the library | 35 | * The word 'cryptographic' can be left out if the rouines from the library |
36 | * being used are not cryptographic related :-). | 36 | * being used are not cryptographic related :-). |
37 | * 4. If you include any Windows specific code (or a derivative thereof) from | 37 | * 4. If you include any Windows specific code (or a derivative thereof) from |
38 | * the apps directory (application code) you must include an acknowledgement: | 38 | * the apps directory (application code) you must include an acknowledgement: |
39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" |
40 | * | 40 | * |
41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND |
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
@@ -49,7 +49,7 @@ | |||
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
51 | * SUCH DAMAGE. | 51 | * SUCH DAMAGE. |
52 | * | 52 | * |
53 | * The licence and distribution terms for any publically available version or | 53 | * The licence and distribution terms for any publically available version or |
54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be |
55 | * copied and put under another distribution licence | 55 | * copied and put under another distribution licence |
@@ -73,53 +73,54 @@ | |||
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(const unsigned char *input, DES_cblock output[], | 76 | DES_LONG |
77 | long length, int out_count, DES_cblock *seed) | 77 | DES_quad_cksum(const unsigned char *input, DES_cblock output[], |
78 | { | 78 | long length, int out_count, DES_cblock *seed) |
79 | DES_LONG z0,z1,t0,t1; | 79 | { |
80 | DES_LONG z0, z1, t0, t1; | ||
80 | int i; | 81 | int i; |
81 | long l; | 82 | long l; |
82 | const unsigned char *cp; | 83 | const unsigned char *cp; |
83 | DES_LONG *lp; | 84 | DES_LONG *lp; |
84 | 85 | ||
85 | if (out_count < 1) out_count=1; | 86 | if (out_count < 1) |
86 | lp = (DES_LONG *) &(output[0])[0]; | 87 | out_count = 1; |
88 | lp = (DES_LONG *)&(output[0])[0]; | ||
87 | 89 | ||
88 | z0=Q_B0((*seed)[0])|Q_B1((*seed)[1])|Q_B2((*seed)[2])|Q_B3((*seed)[3]); | 90 | z0 = Q_B0((*seed)[0])|Q_B1((*seed)[1])|Q_B2((*seed)[2])|Q_B3( |
89 | z1=Q_B0((*seed)[4])|Q_B1((*seed)[5])|Q_B2((*seed)[6])|Q_B3((*seed)[7]); | 91 | (*seed)[3]); |
92 | z1 = Q_B0((*seed)[4])|Q_B1((*seed)[5])|Q_B2((*seed)[6])|Q_B3( | ||
93 | (*seed)[7]); | ||
90 | 94 | ||
91 | for (i=0; ((i<4)&&(i<out_count)); i++) | 95 | for (i = 0; ((i < 4) && (i < out_count)); i++) |
92 | { | 96 | { |
93 | cp=input; | 97 | cp = input; |
94 | l=length; | 98 | l = length; |
95 | while (l > 0) | 99 | while (l > 0) { |
96 | { | 100 | if (l > 1) { |
97 | if (l > 1) | 101 | t0 = (DES_LONG)(*(cp++)); |
98 | { | 102 | t0 |= (DES_LONG)Q_B1(*(cp++)); |
99 | t0= (DES_LONG)(*(cp++)); | ||
100 | t0|=(DES_LONG)Q_B1(*(cp++)); | ||
101 | l--; | 103 | l--; |
102 | } | 104 | } else |
103 | else | 105 | t0 = (DES_LONG)(*(cp++)); |
104 | t0= (DES_LONG)(*(cp++)); | ||
105 | l--; | 106 | l--; |
106 | /* add */ | 107 | /* add */ |
107 | t0+=z0; | 108 | t0 += z0; |
108 | t0&=0xffffffffL; | 109 | t0 &= 0xffffffffL; |
109 | t1=z1; | 110 | t1 = z1; |
110 | /* square, well sort of square */ | 111 | /* square, well sort of square */ |
111 | z0=((((t0*t0)&0xffffffffL)+((t1*t1)&0xffffffffL)) | 112 | z0 = ((((t0*t0) & 0xffffffffL) + |
112 | &0xffffffffL)%0x7fffffffL; | 113 | ((t1*t1) & 0xffffffffL)) & 0xffffffffL) % |
113 | z1=((t0*((t1+NOISE)&0xffffffffL))&0xffffffffL)%0x7fffffffL; | 114 | 0x7fffffffL; |
114 | } | 115 | z1 = ((t0*((t1 + NOISE) & 0xffffffffL)) & 0xffffffffL) % |
115 | if (lp != NULL) | 116 | 0x7fffffffL; |
116 | { | 117 | } |
118 | if (lp != NULL) { | ||
117 | /* The MIT library assumes that the checksum is | 119 | /* The MIT library assumes that the checksum is |
118 | * composed of 2*out_count 32 bit ints */ | 120 | * composed of 2*out_count 32 bit ints */ |
119 | *lp++ = z0; | 121 | *lp++ = z0; |
120 | *lp++ = z1; | 122 | *lp++ = z1; |
121 | } | ||
122 | } | 123 | } |
123 | return(z0); | ||
124 | } | 124 | } |
125 | 125 | return (z0); | |
126 | } | ||