|
34 | 34 | #include <time.h>
|
35 | 35 |
|
36 | 36 | #include "blf.h"
|
37 |
| -#include "md5.h" |
38 | 37 | #include "px.h"
|
39 | 38 | #include "rijndael.h"
|
40 | 39 | #include "sha1.h"
|
41 | 40 |
|
| 41 | +#include "common/cryptohash.h" |
| 42 | +#include "common/md5.h" |
| 43 | + |
42 | 44 | #ifndef MD5_DIGEST_LENGTH
|
43 | 45 | #define MD5_DIGEST_LENGTH 16
|
44 | 46 | #endif
|
@@ -96,34 +98,33 @@ int_md5_block_len(PX_MD *h)
|
96 | 98 | static void
|
97 | 99 | int_md5_update(PX_MD *h, const uint8 *data, unsigned dlen)
|
98 | 100 | {
|
99 |
| - MD5_CTX *ctx = (MD5_CTX *) h->p.ptr; |
| 101 | + pg_cryptohash_ctx *ctx = (pg_cryptohash_ctx *) h->p.ptr; |
100 | 102 |
|
101 |
| - MD5Update(ctx, data, dlen); |
| 103 | + pg_cryptohash_update(ctx, data, dlen); |
102 | 104 | }
|
103 | 105 |
|
104 | 106 | static void
|
105 | 107 | int_md5_reset(PX_MD *h)
|
106 | 108 | {
|
107 |
| - MD5_CTX *ctx = (MD5_CTX *) h->p.ptr; |
| 109 | + pg_cryptohash_ctx *ctx = (pg_cryptohash_ctx *) h->p.ptr; |
108 | 110 |
|
109 |
| - MD5Init(ctx); |
| 111 | + pg_cryptohash_init(ctx); |
110 | 112 | }
|
111 | 113 |
|
112 | 114 | static void
|
113 | 115 | int_md5_finish(PX_MD *h, uint8 *dst)
|
114 | 116 | {
|
115 |
| - MD5_CTX *ctx = (MD5_CTX *) h->p.ptr; |
| 117 | + pg_cryptohash_ctx *ctx = (pg_cryptohash_ctx *) h->p.ptr; |
116 | 118 |
|
117 |
| - MD5Final(dst, ctx); |
| 119 | + pg_cryptohash_final(ctx, dst); |
118 | 120 | }
|
119 | 121 |
|
120 | 122 | static void
|
121 | 123 | int_md5_free(PX_MD *h)
|
122 | 124 | {
|
123 |
| - MD5_CTX *ctx = (MD5_CTX *) h->p.ptr; |
| 125 | + pg_cryptohash_ctx *ctx = (pg_cryptohash_ctx *) h->p.ptr; |
124 | 126 |
|
125 |
| - px_memset(ctx, 0, sizeof(*ctx)); |
126 |
| - pfree(ctx); |
| 127 | + pg_cryptohash_free(ctx); |
127 | 128 | pfree(h);
|
128 | 129 | }
|
129 | 130 |
|
@@ -180,9 +181,9 @@ int_sha1_free(PX_MD *h)
|
180 | 181 | static void
|
181 | 182 | init_md5(PX_MD *md)
|
182 | 183 | {
|
183 |
| - MD5_CTX *ctx; |
| 184 | + pg_cryptohash_ctx *ctx; |
184 | 185 |
|
185 |
| - ctx = palloc0(sizeof(*ctx)); |
| 186 | + ctx = pg_cryptohash_create(PG_MD5); |
186 | 187 |
|
187 | 188 | md->p.ptr = ctx;
|
188 | 189 |
|
|
0 commit comments