Skip to content

Commit adb70b0

Browse files
committed
Revert "apply 0001-Refactor-SHA-functions-and-move-them-to-src-common.patch"
This reverts commit f1b8189.
1 parent 436c9ea commit adb70b0

File tree

13 files changed

+976
-1118
lines changed

13 files changed

+976
-1118
lines changed

contrib/pgcrypto/.gitignore

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
# Source file copied from src/common
2-
/sha.c
3-
/sha_openssl.c
4-
51
# Generated subdirectories
62
/log/
73
/results/

contrib/pgcrypto/Makefile

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
# contrib/pgcrypto/Makefile
22

3-
INT_SRCS = md5.c internal.c internal-sha2.c blf.c rijndael.c \
4-
fortuna.c random.c pgp-mpi-internal.c imath.c \
5-
sha.c
3+
INT_SRCS = md5.c sha1.c sha2.c internal.c internal-sha2.c blf.c rijndael.c \
4+
fortuna.c random.c pgp-mpi-internal.c imath.c
65
INT_TESTS = sha2
76

8-
OSSL_SRCS = openssl.c pgp-mpi-openssl.c sha_openssl.c
7+
OSSL_SRCS = openssl.c pgp-mpi-openssl.c
98
OSSL_TESTS = sha2 des 3des cast5
109

1110
ZLIB_TST = pgp-compression
@@ -60,9 +59,6 @@ SHLIB_LINK += $(filter -leay32, $(LIBS))
6059
SHLIB_LINK += -lws2_32
6160
endif
6261

63-
sha.c sha_openssl.c: % : $(top_srcdir)/src/common/%
64-
rm -f $@ && $(LN_S) $< .
65-
6662
rijndael.o: rijndael.tbl
6763

6864
rijndael.tbl:

contrib/pgcrypto/fortuna.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434
#include <sys/time.h>
3535
#include <time.h>
3636

37-
#include "common/sha.h"
3837
#include "px.h"
3938
#include "rijndael.h"
39+
#include "sha2.h"
4040
#include "fortuna.h"
4141

4242

@@ -112,7 +112,7 @@
112112
#define CIPH_BLOCK 16
113113

114114
/* for internal wrappers */
115-
#define MD_CTX pg_sha256_ctx
115+
#define MD_CTX SHA256_CTX
116116
#define CIPH_CTX rijndael_ctx
117117

118118
struct fortuna_state
@@ -154,22 +154,22 @@ ciph_encrypt(CIPH_CTX * ctx, const uint8 *in, uint8 *out)
154154
static void
155155
md_init(MD_CTX * ctx)
156156
{
157-
pg_sha256_init(ctx);
157+
SHA256_Init(ctx);
158158
}
159159

160160
static void
161161
md_update(MD_CTX * ctx, const uint8 *data, int len)
162162
{
163-
pg_sha256_update(ctx, data, len);
163+
SHA256_Update(ctx, data, len);
164164
}
165165

166166
static void
167167
md_result(MD_CTX * ctx, uint8 *dst)
168168
{
169-
pg_sha256_ctx tmp;
169+
SHA256_CTX tmp;
170170

171171
memcpy(&tmp, ctx, sizeof(*ctx));
172-
pg_sha256_final(&tmp, dst);
172+
SHA256_Final(dst, &tmp);
173173
px_memset(&tmp, 0, sizeof(tmp));
174174
}
175175

contrib/pgcrypto/internal-sha2.c

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333

3434
#include <time.h>
3535

36-
#include "common/sha.h"
3736
#include "px.h"
37+
#include "sha2.h"
3838

3939
void init_sha224(PX_MD *h);
4040
void init_sha256(PX_MD *h);
@@ -46,43 +46,43 @@ void init_sha512(PX_MD *h);
4646
static unsigned
4747
int_sha224_len(PX_MD *h)
4848
{
49-
return PG_SHA224_DIGEST_LENGTH;
49+
return SHA224_DIGEST_LENGTH;
5050
}
5151

5252
static unsigned
5353
int_sha224_block_len(PX_MD *h)
5454
{
55-
return PG_SHA224_BLOCK_LENGTH;
55+
return SHA224_BLOCK_LENGTH;
5656
}
5757

5858
static void
5959
int_sha224_update(PX_MD *h, const uint8 *data, unsigned dlen)
6060
{
61-
pg_sha224_ctx *ctx = (pg_sha224_ctx *) h->p.ptr;
61+
SHA224_CTX *ctx = (SHA224_CTX *) h->p.ptr;
6262

63-
pg_sha224_update(ctx, data, dlen);
63+
SHA224_Update(ctx, data, dlen);
6464
}
6565

6666
static void
6767
int_sha224_reset(PX_MD *h)
6868
{
69-
pg_sha224_ctx *ctx = (pg_sha224_ctx *) h->p.ptr;
69+
SHA224_CTX *ctx = (SHA224_CTX *) h->p.ptr;
7070

71-
pg_sha224_init(ctx);
71+
SHA224_Init(ctx);
7272
}
7373

7474
static void
7575
int_sha224_finish(PX_MD *h, uint8 *dst)
7676
{
77-
pg_sha224_ctx *ctx = (pg_sha224_ctx *) h->p.ptr;
77+
SHA224_CTX *ctx = (SHA224_CTX *) h->p.ptr;
7878

79-
pg_sha224_final(ctx, dst);
79+
SHA224_Final(dst, ctx);
8080
}
8181

8282
static void
8383
int_sha224_free(PX_MD *h)
8484
{
85-
pg_sha224_ctx *ctx = (pg_sha224_ctx *) h->p.ptr;
85+
SHA224_CTX *ctx = (SHA224_CTX *) h->p.ptr;
8686

8787
px_memset(ctx, 0, sizeof(*ctx));
8888
px_free(ctx);
@@ -94,43 +94,43 @@ int_sha224_free(PX_MD *h)
9494
static unsigned
9595
int_sha256_len(PX_MD *h)
9696
{
97-
return PG_SHA256_DIGEST_LENGTH;
97+
return SHA256_DIGEST_LENGTH;
9898
}
9999

100100
static unsigned
101101
int_sha256_block_len(PX_MD *h)
102102
{
103-
return PG_SHA256_BLOCK_LENGTH;
103+
return SHA256_BLOCK_LENGTH;
104104
}
105105

106106
static void
107107
int_sha256_update(PX_MD *h, const uint8 *data, unsigned dlen)
108108
{
109-
pg_sha256_ctx *ctx = (pg_sha256_ctx *) h->p.ptr;
109+
SHA256_CTX *ctx = (SHA256_CTX *) h->p.ptr;
110110

111-
pg_sha256_update(ctx, data, dlen);
111+
SHA256_Update(ctx, data, dlen);
112112
}
113113

114114
static void
115115
int_sha256_reset(PX_MD *h)
116116
{
117-
pg_sha256_ctx *ctx = (pg_sha256_ctx *) h->p.ptr;
117+
SHA256_CTX *ctx = (SHA256_CTX *) h->p.ptr;
118118

119-
pg_sha256_init(ctx);
119+
SHA256_Init(ctx);
120120
}
121121

122122
static void
123123
int_sha256_finish(PX_MD *h, uint8 *dst)
124124
{
125-
pg_sha256_ctx *ctx = (pg_sha256_ctx *) h->p.ptr;
125+
SHA256_CTX *ctx = (SHA256_CTX *) h->p.ptr;
126126

127-
pg_sha256_final(ctx, dst);
127+
SHA256_Final(dst, ctx);
128128
}
129129

130130
static void
131131
int_sha256_free(PX_MD *h)
132132
{
133-
pg_sha256_ctx *ctx = (pg_sha256_ctx *) h->p.ptr;
133+
SHA256_CTX *ctx = (SHA256_CTX *) h->p.ptr;
134134

135135
px_memset(ctx, 0, sizeof(*ctx));
136136
px_free(ctx);
@@ -142,43 +142,43 @@ int_sha256_free(PX_MD *h)
142142
static unsigned
143143
int_sha384_len(PX_MD *h)
144144
{
145-
return PG_SHA384_DIGEST_LENGTH;
145+
return SHA384_DIGEST_LENGTH;
146146
}
147147

148148
static unsigned
149149
int_sha384_block_len(PX_MD *h)
150150
{
151-
return PG_SHA384_BLOCK_LENGTH;
151+
return SHA384_BLOCK_LENGTH;
152152
}
153153

154154
static void
155155
int_sha384_update(PX_MD *h, const uint8 *data, unsigned dlen)
156156
{
157-
pg_sha384_ctx *ctx = (pg_sha384_ctx *) h->p.ptr;
157+
SHA384_CTX *ctx = (SHA384_CTX *) h->p.ptr;
158158

159-
pg_sha384_update(ctx, data, dlen);
159+
SHA384_Update(ctx, data, dlen);
160160
}
161161

162162
static void
163163
int_sha384_reset(PX_MD *h)
164164
{
165-
pg_sha384_ctx *ctx = (pg_sha384_ctx *) h->p.ptr;
165+
SHA384_CTX *ctx = (SHA384_CTX *) h->p.ptr;
166166

167-
pg_sha384_init(ctx);
167+
SHA384_Init(ctx);
168168
}
169169

170170
static void
171171
int_sha384_finish(PX_MD *h, uint8 *dst)
172172
{
173-
pg_sha384_ctx *ctx = (pg_sha384_ctx *) h->p.ptr;
173+
SHA384_CTX *ctx = (SHA384_CTX *) h->p.ptr;
174174

175-
pg_sha384_final(ctx, dst);
175+
SHA384_Final(dst, ctx);
176176
}
177177

178178
static void
179179
int_sha384_free(PX_MD *h)
180180
{
181-
pg_sha384_ctx *ctx = (pg_sha384_ctx *) h->p.ptr;
181+
SHA384_CTX *ctx = (SHA384_CTX *) h->p.ptr;
182182

183183
px_memset(ctx, 0, sizeof(*ctx));
184184
px_free(ctx);
@@ -190,43 +190,43 @@ int_sha384_free(PX_MD *h)
190190
static unsigned
191191
int_sha512_len(PX_MD *h)
192192
{
193-
return PG_SHA512_DIGEST_LENGTH;
193+
return SHA512_DIGEST_LENGTH;
194194
}
195195

196196
static unsigned
197197
int_sha512_block_len(PX_MD *h)
198198
{
199-
return PG_SHA512_BLOCK_LENGTH;
199+
return SHA512_BLOCK_LENGTH;
200200
}
201201

202202
static void
203203
int_sha512_update(PX_MD *h, const uint8 *data, unsigned dlen)
204204
{
205-
pg_sha512_ctx *ctx = (pg_sha512_ctx *) h->p.ptr;
205+
SHA512_CTX *ctx = (SHA512_CTX *) h->p.ptr;
206206

207-
pg_sha512_update(ctx, data, dlen);
207+
SHA512_Update(ctx, data, dlen);
208208
}
209209

210210
static void
211211
int_sha512_reset(PX_MD *h)
212212
{
213-
pg_sha512_ctx *ctx = (pg_sha512_ctx *) h->p.ptr;
213+
SHA512_CTX *ctx = (SHA512_CTX *) h->p.ptr;
214214

215-
pg_sha512_init(ctx);
215+
SHA512_Init(ctx);
216216
}
217217

218218
static void
219219
int_sha512_finish(PX_MD *h, uint8 *dst)
220220
{
221-
pg_sha512_ctx *ctx = (pg_sha512_ctx *) h->p.ptr;
221+
SHA512_CTX *ctx = (SHA512_CTX *) h->p.ptr;
222222

223-
pg_sha512_final(ctx, dst);
223+
SHA512_Final(dst, ctx);
224224
}
225225

226226
static void
227227
int_sha512_free(PX_MD *h)
228228
{
229-
pg_sha512_ctx *ctx = (pg_sha512_ctx *) h->p.ptr;
229+
SHA512_CTX *ctx = (SHA512_CTX *) h->p.ptr;
230230

231231
px_memset(ctx, 0, sizeof(*ctx));
232232
px_free(ctx);
@@ -238,7 +238,7 @@ int_sha512_free(PX_MD *h)
238238
void
239239
init_sha224(PX_MD *md)
240240
{
241-
pg_sha224_ctx *ctx;
241+
SHA224_CTX *ctx;
242242

243243
ctx = px_alloc(sizeof(*ctx));
244244
memset(ctx, 0, sizeof(*ctx));
@@ -258,7 +258,7 @@ init_sha224(PX_MD *md)
258258
void
259259
init_sha256(PX_MD *md)
260260
{
261-
pg_sha256_ctx *ctx;
261+
SHA256_CTX *ctx;
262262

263263
ctx = px_alloc(sizeof(*ctx));
264264
memset(ctx, 0, sizeof(*ctx));
@@ -278,7 +278,7 @@ init_sha256(PX_MD *md)
278278
void
279279
init_sha384(PX_MD *md)
280280
{
281-
pg_sha384_ctx *ctx;
281+
SHA384_CTX *ctx;
282282

283283
ctx = px_alloc(sizeof(*ctx));
284284
memset(ctx, 0, sizeof(*ctx));
@@ -298,7 +298,7 @@ init_sha384(PX_MD *md)
298298
void
299299
init_sha512(PX_MD *md)
300300
{
301-
pg_sha512_ctx *ctx;
301+
SHA512_CTX *ctx;
302302

303303
ctx = px_alloc(sizeof(*ctx));
304304
memset(ctx, 0, sizeof(*ctx));

0 commit comments

Comments
 (0)