aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorNeil Conway <neilc@samurai.com>2005-03-12 06:55:14 +0000
committerNeil Conway <neilc@samurai.com>2005-03-12 06:55:14 +0000
commit2450224e6bd10563188985a26d54c2c3d091a223 (patch)
tree971fb7fe17a7aad692f169432e2f8aca1f24861a /contrib
parent989a17a68c5dc1784f1be3876feba8cf81c4fed4 (diff)
downloadpostgresql-2450224e6bd10563188985a26d54c2c3d091a223.tar.gz
postgresql-2450224e6bd10563188985a26d54c2c3d091a223.zip
Some builds (depends on crypto engine support?) of OpenSSL
0.9.7x have EVP_DigestFinal function which which clears all of EVP_MD_CTX. This makes pgcrypto crash in functions which re-use one digest context several times: hmac() and crypt() with md5 algorithm. Following patch fixes it by carring the digest info around EVP_DigestFinal and re-initializing cipher. Marko Kreen.
Diffstat (limited to 'contrib')
-rw-r--r--contrib/pgcrypto/openssl.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/contrib/pgcrypto/openssl.c b/contrib/pgcrypto/openssl.c
index 4b3dc593cef..0095454ccab 100644
--- a/contrib/pgcrypto/openssl.c
+++ b/contrib/pgcrypto/openssl.c
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: openssl.c,v 1.12 2003/08/04 00:43:11 momjian Exp $
+ * $Id: openssl.c,v 1.12.4.1 2005/03/12 06:55:14 neilc Exp $
*/
#include <postgres.h>
@@ -73,8 +73,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