Backpatch to 8.0.X openssl portability fixes to pgcrypto.
authorBruce Momjian <[email protected]>
Mon, 4 Jul 2005 14:42:39 +0000 (14:42 +0000)
committerBruce Momjian <[email protected]>
Mon, 4 Jul 2005 14:42:39 +0000 (14:42 +0000)
contrib/pgcrypto/openssl.c

index 7836c9cd1a8e3e0160f26ccad8e9efff560c3135..7ea98e4347d28779e70a451913bef3132e37ef0c 100644 (file)
 #include "px.h"
 
 #include <openssl/evp.h>
+#include <openssl/blowfish.h>
+#include <openssl/cast.h>
+#include <openssl/des.h>
 
+/*
+ * Does OpenSSL support AES? 
+ */
+#undef GOT_AES
+#if OPENSSL_VERSION_NUMBER >= 0x00907000L
+#define GOT_AES
+#include <openssl/aes.h>
+#endif
+  
 /*
  * Hashes
  */
@@ -73,8 +85,15 @@ static void
 digest_finish(PX_MD * h, uint8 *dst)
 {
        EVP_MD_CTX *ctx = (EVP_MD_CTX *) h->p.ptr;
+       const EVP_MD *md = EVP_MD_CTX_md(ctx);
 
        EVP_DigestFinal(ctx, dst, NULL);
+
+       /*
+        * Some builds of 0.9.7x clear all of ctx in EVP_DigestFinal.
+        * Fix it by reinitializing ctx.
+        */
+       EVP_DigestInit(ctx, md);
 }
 
 static void