Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit e586026

Browse files
committed
The KAME files md5.* and sha1.* have the following changelog
entry: ---------------------------- revision 1.2 date: 2000/12/04 01:20:38; author: tgl; state: Exp; lines: +18 -18 Eliminate some of the more blatant platform-dependencies ... it builds here now, anyway ... ---------------------------- Which basically changes u_int*_t -> uint*_t, so now it does not compile neither under Debian 2.2 nor under NetBSD 1.5 which is platform independent<B8> all right. Also it replaces $KAME$ with $Id$ which is Bad Thing. PostgreSQL Id should be added as a separate line so the file history could be seen. So here is patch: * changes uint*_t -> uint*. I guess that was the original intention * adds uint64 type to include/c.h because its needed [somebody should check if I did it right] * adds back KAME Id, because KAME is the master repository * removes stupid c++ comments in pgcrypto.c * removes <sys/types.h> from the code, its not needed -- marko Marko Kreen
1 parent f906597 commit e586026

File tree

7 files changed

+51
-48
lines changed

7 files changed

+51
-48
lines changed

contrib/pgcrypto/md5.c

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
/* $Id: md5.c,v 1.2 2000/12/04 01:20:38 tgl Exp $ */
1+
/* $Id: md5.c,v 1.3 2001/01/09 16:07:13 momjian Exp $ */
2+
/* $KAME: md5.c,v 1.3 2000/02/22 14:01:17 itojun Exp $ */
23

34
/*
45
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -30,7 +31,6 @@
3031
*/
3132

3233
#include <postgres.h>
33-
#include "pgcrypto.h"
3434

3535
#include "md5.h"
3636

@@ -91,7 +91,7 @@
9191
#define MD5_D0 0x10325476
9292

9393
/* Integer part of 4294967296 times abs(sin(i)), where i is in radians. */
94-
static const uint32_t T[65] = {
94+
static const uint32 T[65] = {
9595
0,
9696
0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee,
9797
0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501,
@@ -114,7 +114,7 @@ static const uint32_t T[65] = {
114114
0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391,
115115
};
116116

117-
static const uint8_t md5_paddat[MD5_BUFLEN] = {
117+
static const uint8 md5_paddat[MD5_BUFLEN] = {
118118
0x80, 0, 0, 0, 0, 0, 0, 0,
119119
0, 0, 0, 0, 0, 0, 0, 0,
120120
0, 0, 0, 0, 0, 0, 0, 0,
@@ -125,7 +125,7 @@ static const uint8_t md5_paddat[MD5_BUFLEN] = {
125125
0, 0, 0, 0, 0, 0, 0, 0,
126126
};
127127

128-
static void md5_calc (uint8_t *, md5_ctxt *);
128+
static void md5_calc (uint8 *, md5_ctxt *);
129129

130130
void md5_init(ctxt)
131131
md5_ctxt *ctxt;
@@ -141,7 +141,7 @@ void md5_init(ctxt)
141141

142142
void md5_loop(ctxt, input, len)
143143
md5_ctxt *ctxt;
144-
uint8_t *input;
144+
uint8 *input;
145145
unsigned int len; /* number of bytes */
146146
{
147147
unsigned int gap, i;
@@ -155,7 +155,7 @@ void md5_loop(ctxt, input, len)
155155
md5_calc(ctxt->md5_buf, ctxt);
156156

157157
for (i = gap; i + MD5_BUFLEN <= len; i += MD5_BUFLEN) {
158-
md5_calc((uint8_t *)(input + i), ctxt);
158+
md5_calc((uint8 *)(input + i), ctxt);
159159
}
160160

161161
ctxt->md5_i = len - i;
@@ -207,7 +207,7 @@ void md5_pad(ctxt)
207207
}
208208

209209
void md5_result(digest, ctxt)
210-
uint8_t *digest;
210+
uint8 *digest;
211211
md5_ctxt *ctxt;
212212
{
213213
/* 4 byte words */
@@ -227,24 +227,24 @@ void md5_result(digest, ctxt)
227227
}
228228

229229
#if BYTE_ORDER == BIG_ENDIAN
230-
uint32_t X[16];
230+
uint32 X[16];
231231
#endif
232232

233233
static void md5_calc(b64, ctxt)
234-
uint8_t *b64;
234+
uint8 *b64;
235235
md5_ctxt *ctxt;
236236
{
237-
uint32_t A = ctxt->md5_sta;
238-
uint32_t B = ctxt->md5_stb;
239-
uint32_t C = ctxt->md5_stc;
240-
uint32_t D = ctxt->md5_std;
237+
uint32 A = ctxt->md5_sta;
238+
uint32 B = ctxt->md5_stb;
239+
uint32 C = ctxt->md5_stc;
240+
uint32 D = ctxt->md5_std;
241241
#if BYTE_ORDER == LITTLE_ENDIAN
242-
uint32_t *X = (uint32_t *)b64;
242+
uint32 *X = (uint32 *)b64;
243243
#endif
244244
#if BYTE_ORDER == BIG_ENDIAN
245245
/* 4 byte words */
246246
/* what a brute force but fast! */
247-
uint8_t *y = (uint8_t *)X;
247+
uint8 *y = (uint8 *)X;
248248
y[ 0] = b64[ 3]; y[ 1] = b64[ 2]; y[ 2] = b64[ 1]; y[ 3] = b64[ 0];
249249
y[ 4] = b64[ 7]; y[ 5] = b64[ 6]; y[ 6] = b64[ 5]; y[ 7] = b64[ 4];
250250
y[ 8] = b64[11]; y[ 9] = b64[10]; y[10] = b64[ 9]; y[11] = b64[ 8];

contrib/pgcrypto/md5.h

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
/* $Id: md5.h,v 1.2 2000/12/04 01:20:38 tgl Exp $ */
1+
/* $Id: md5.h,v 1.3 2001/01/09 16:07:13 momjian Exp $ */
2+
/* $KAME: md5.h,v 1.3 2000/02/22 14:01:18 itojun Exp $ */
23

34
/*
45
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -36,8 +37,8 @@
3637

3738
typedef struct {
3839
union {
39-
uint32_t md5_state32[4];
40-
uint8_t md5_state8[16];
40+
uint32 md5_state32[4];
41+
uint8 md5_state8[16];
4142
} md5_st;
4243

4344
#define md5_sta md5_st.md5_state32[0]
@@ -47,20 +48,20 @@ typedef struct {
4748
#define md5_st8 md5_st.md5_state8
4849

4950
union {
50-
uint64_t md5_count64;
51-
uint8_t md5_count8[8];
51+
uint64 md5_count64;
52+
uint8 md5_count8[8];
5253
} md5_count;
5354
#define md5_n md5_count.md5_count64
5455
#define md5_n8 md5_count.md5_count8
5556

5657
unsigned int md5_i;
57-
uint8_t md5_buf[MD5_BUFLEN];
58+
uint8 md5_buf[MD5_BUFLEN];
5859
} md5_ctxt;
5960

6061
extern void md5_init (md5_ctxt *);
61-
extern void md5_loop (md5_ctxt *, uint8_t *, unsigned int);
62+
extern void md5_loop (md5_ctxt *, uint8 *, unsigned int);
6263
extern void md5_pad (md5_ctxt *);
63-
extern void md5_result (uint8_t *, md5_ctxt *);
64+
extern void md5_result (uint8 *, md5_ctxt *);
6465

6566
/* compatibility */
6667
#define MD5_CTX md5_ctxt

contrib/pgcrypto/pgcrypto.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2727
* SUCH DAMAGE.
2828
*
29-
* $Id: pgcrypto.c,v 1.2 2000/11/20 20:36:56 tgl Exp $
29+
* $Id: pgcrypto.c,v 1.3 2001/01/09 16:07:13 momjian Exp $
3030
*/
3131

3232
#include <postgres.h>
@@ -91,7 +91,7 @@ digest(PG_FUNCTION_ARGS)
9191
to_hex(p, hlen, VARDATA(res));
9292

9393
PG_FREE_IF_COPY(arg, 0);
94-
PG_FREE_IF_COPY(name, 0); // unnecessary i guess
94+
PG_FREE_IF_COPY(name, 0);
9595

9696
PG_RETURN_TEXT_P(res);
9797
}
@@ -112,7 +112,7 @@ digest_exists(PG_FUNCTION_ARGS)
112112

113113
res = find_digest(&_hbuf, name, 1);
114114

115-
PG_FREE_IF_COPY(name, 0); // unnecessary i guess
115+
PG_FREE_IF_COPY(name, 0);
116116

117117
if (res != NULL)
118118
PG_RETURN_BOOL(true);

contrib/pgcrypto/pgcrypto.h

+1-3
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,12 @@
2626
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2727
* SUCH DAMAGE.
2828
*
29-
* $Id: pgcrypto.h,v 1.1 2000/10/31 13:11:28 petere Exp $
29+
* $Id: pgcrypto.h,v 1.2 2001/01/09 16:07:13 momjian Exp $
3030
*/
3131

3232
#ifndef _PG_CRYPTO_H
3333
#define _PG_CRYPTO_H
3434

35-
#include <sys/types.h>
36-
3735
typedef struct _pg_digest pg_digest;
3836
struct _pg_digest {
3937
char *name;

contrib/pgcrypto/sha1.c

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
/* $Id: sha1.c,v 1.2 2000/12/04 01:20:38 tgl Exp $ */
1+
/* $Id: sha1.c,v 1.3 2001/01/09 16:07:13 momjian Exp $ */
2+
/* $KAME: sha1.c,v 1.3 2000/02/22 14:01:18 itojun Exp $ */
23

34
/*
45
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -35,7 +36,6 @@
3536
*/
3637

3738
#include <postgres.h>
38-
#include "pgcrypto.h"
3939

4040
#include "sha1.h"
4141

@@ -49,7 +49,7 @@
4949
#ifndef unsupported
5050

5151
/* constant table */
52-
static uint32_t _K[] = { 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6 };
52+
static uint32 _K[] = { 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6 };
5353
#define K(t) _K[(t) / 20]
5454

5555
#define F0(b, c, d) (((b) & (c)) | ((~(b)) & (d)))
@@ -87,9 +87,9 @@ static void
8787
sha1_step(ctxt)
8888
struct sha1_ctxt *ctxt;
8989
{
90-
uint32_t a, b, c, d, e;
90+
uint32 a, b, c, d, e;
9191
size_t t, s;
92-
uint32_t tmp;
92+
uint32 tmp;
9393

9494
#if BYTE_ORDER == LITTLE_ENDIAN
9595
struct sha1_ctxt tctxt;
@@ -221,13 +221,13 @@ sha1_loop(ctxt, input0, len)
221221
const caddr_t input0;
222222
size_t len;
223223
{
224-
const uint8_t *input;
224+
const uint8 *input;
225225
size_t gaplen;
226226
size_t gapstart;
227227
size_t off;
228228
size_t copysiz;
229229

230-
input = (const uint8_t *)input0;
230+
input = (const uint8 *)input0;
231231
off = 0;
232232

233233
while (off < len) {
@@ -250,9 +250,9 @@ sha1_result(ctxt, digest0)
250250
struct sha1_ctxt *ctxt;
251251
caddr_t digest0;
252252
{
253-
uint8_t *digest;
253+
uint8 *digest;
254254

255-
digest = (uint8_t *)digest0;
255+
digest = (uint8 *)digest0;
256256
sha1_pad(ctxt);
257257
#if BYTE_ORDER == BIG_ENDIAN
258258
bcopy(&ctxt->h.b8[0], digest, 20);

contrib/pgcrypto/sha1.h

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
/* $Id: sha1.h,v 1.2 2000/12/04 01:20:38 tgl Exp $ */
1+
/* $Id: sha1.h,v 1.3 2001/01/09 16:07:13 momjian Exp $ */
2+
/* $KAME: sha1.h,v 1.4 2000/02/22 14:01:18 itojun Exp $ */
23

34
/*
45
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -39,18 +40,18 @@
3940

4041
struct sha1_ctxt {
4142
union {
42-
uint8_t b8[20];
43-
uint32_t b32[5];
43+
uint8 b8[20];
44+
uint32 b32[5];
4445
} h;
4546
union {
46-
uint8_t b8[8];
47-
uint64_t b64[1];
47+
uint8 b8[8];
48+
uint64 b64[1];
4849
} c;
4950
union {
50-
uint8_t b8[64];
51-
uint32_t b32[16];
51+
uint8 b8[64];
52+
uint32 b32[16];
5253
} m;
53-
uint8_t count;
54+
uint8 count;
5455
};
5556

5657
extern void sha1_init (struct sha1_ctxt *);

src/include/c.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
99
* Portions Copyright (c) 1994, Regents of the University of California
1010
*
11-
* $Id: c.h,v 1.85 2000/11/03 18:43:52 petere Exp $
11+
* $Id: c.h,v 1.86 2001/01/09 16:07:14 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -277,13 +277,16 @@ typedef double float8;
277277
#ifdef HAVE_LONG_INT_64
278278
/* Plain "long int" fits, use it */
279279
typedef long int int64;
280+
typedef unsigned long int uint64;
280281
#else
281282
#ifdef HAVE_LONG_LONG_INT_64
282283
/* We have working support for "long long int", use that */
283284
typedef long long int int64;
285+
typedef unsigned long long int uint64;
284286
#else
285287
/* Won't actually work, but fall back to long int so that code compiles */
286288
typedef long int int64;
289+
typedef unsigned long int uint64;
287290
#define INT64_IS_BUSTED
288291
#endif
289292
#endif

0 commit comments

Comments
 (0)