From 576ac4b8c9337cd5b0e12c2f827dd99c5ee6f25b Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 5 Jul 2005 18:15:36 +0000 Subject: [PATCH] Fix initialization bug in pgcrypto openssl code. Marko Kreen --- contrib/pgcrypto/expected/3des.out | 8 ++++---- contrib/pgcrypto/openssl.c | 4 ++-- contrib/pgcrypto/sql/3des.sql | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/contrib/pgcrypto/expected/3des.out b/contrib/pgcrypto/expected/3des.out index 51de60b2bc..7b6e3dcfdf 100644 --- a/contrib/pgcrypto/expected/3des.out +++ b/contrib/pgcrypto/expected/3des.out @@ -17,14 +17,14 @@ decode('01 01 01 01 01 01 01 01 select encode( encrypt('', 'foo', '3des'), 'hex'); encode ------------------ - 9b641a6936249eb4 + 752111e37a2d7ac3 (1 row) -- 10 bytes key select encode( encrypt('foo', '0123456789', '3des'), 'hex'); encode ------------------ - 6f02b7076a366504 + d2fb8baa1717cb02 (1 row) -- 22 bytes key @@ -45,10 +45,10 @@ select decrypt(encrypt('foo', '0123456', '3des'), '0123456', '3des'); select encode(encrypt_iv('foo', '0123456', 'abcd', '3des'), 'hex'); encode ------------------ - df27c264fb24ed7a + 50735067b073bb93 (1 row) -select decrypt_iv(decode('df27c264fb24ed7a', 'hex'), '0123456', 'abcd', '3des'); +select decrypt_iv(decode('50735067b073bb93', 'hex'), '0123456', 'abcd', '3des'); decrypt_iv ------------ foo diff --git a/contrib/pgcrypto/openssl.c b/contrib/pgcrypto/openssl.c index 8a21194f8c..790f247988 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. * - * $PostgreSQL: pgsql/contrib/pgcrypto/openssl.c,v 1.19 2005/07/04 02:02:01 momjian Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/openssl.c,v 1.20 2005/07/05 18:15:36 tgl Exp $ */ #include @@ -393,7 +393,7 @@ ossl_des3_init(PX_Cipher * c, const uint8 *key, unsigned klen, const uint8 *iv) memset(&xkey1, 0, sizeof(xkey1)); memset(&xkey2, 0, sizeof(xkey2)); - memset(&xkey2, 0, sizeof(xkey2)); + memset(&xkey3, 0, sizeof(xkey3)); memcpy(&xkey1, key, klen > 8 ? 8 : klen); if (klen > 8) memcpy(&xkey2, key + 8, (klen - 8) > 8 ? 8 : (klen - 8)); diff --git a/contrib/pgcrypto/sql/3des.sql b/contrib/pgcrypto/sql/3des.sql index f3c01e2908..7e20aff5c0 100644 --- a/contrib/pgcrypto/sql/3des.sql +++ b/contrib/pgcrypto/sql/3des.sql @@ -22,5 +22,5 @@ select decrypt(encrypt('foo', '0123456', '3des'), '0123456', '3des'); -- iv select encode(encrypt_iv('foo', '0123456', 'abcd', '3des'), 'hex'); -select decrypt_iv(decode('df27c264fb24ed7a', 'hex'), '0123456', 'abcd', '3des'); +select decrypt_iv(decode('50735067b073bb93', 'hex'), '0123456', 'abcd', '3des'); -- 2.11.0