diff options
Diffstat (limited to 'contrib')
| -rw-r--r-- | contrib/uuid-ossp/Makefile | 4 | ||||
| -rw-r--r-- | contrib/uuid-ossp/uuid-ossp.c | 16 |
2 files changed, 12 insertions, 8 deletions
diff --git a/contrib/uuid-ossp/Makefile b/contrib/uuid-ossp/Makefile index e4bbffc30d9..0859a5397c9 100644 --- a/contrib/uuid-ossp/Makefile +++ b/contrib/uuid-ossp/Makefile @@ -19,7 +19,7 @@ pgcrypto_src = $(top_srcdir)/contrib/pgcrypto PG_CPPFLAGS = -I$(pgcrypto_src) -EXTRA_CLEAN = md5.c sha1.c +EXTRA_CLEAN = sha1.c ifdef USE_PGXS PG_CONFIG = pg_config @@ -32,5 +32,5 @@ include $(top_builddir)/src/Makefile.global include $(top_srcdir)/contrib/contrib-global.mk endif -md5.c sha1.c: % : $(pgcrypto_src)/% +sha1.c: % : $(pgcrypto_src)/% rm -f $@ && $(LN_S) $< . diff --git a/contrib/uuid-ossp/uuid-ossp.c b/contrib/uuid-ossp/uuid-ossp.c index 2a471e599b1..8f81c94e725 100644 --- a/contrib/uuid-ossp/uuid-ossp.c +++ b/contrib/uuid-ossp/uuid-ossp.c @@ -14,6 +14,7 @@ #include "postgres.h" #include "fmgr.h" +#include "common/cryptohash.h" #include "port/pg_bswap.h" #include "utils/builtins.h" #include "utils/uuid.h" @@ -44,7 +45,6 @@ * so we use a copy of the ones from pgcrypto. Not needed with OSSP, though. */ #ifndef HAVE_UUID_OSSP -#include "md5.h" #include "sha1.h" #endif @@ -324,13 +324,17 @@ uuid_generate_internal(int v, unsigned char *ns, const char *ptr, int len) if (v == 3) { - MD5_CTX ctx; + pg_cryptohash_ctx *ctx = pg_cryptohash_create(PG_MD5); - MD5Init(&ctx); - MD5Update(&ctx, ns, sizeof(uu)); - MD5Update(&ctx, (unsigned char *) ptr, len); + if (pg_cryptohash_init(ctx) < 0) + elog(ERROR, "could not initialize %s context", "MD5"); + if (pg_cryptohash_update(ctx, ns, sizeof(uu)) < 0 || + pg_cryptohash_update(ctx, (unsigned char *) ptr, len) < 0) + elog(ERROR, "could not update %s context", "MD5"); /* we assume sizeof MD5 result is 16, same as UUID size */ - MD5Final((unsigned char *) &uu, &ctx); + if (pg_cryptohash_final(ctx, (unsigned char *) &uu) < 0) + elog(ERROR, "could not finalize %s context", "MD5"); + pg_cryptohash_free(ctx); } else { |
