Skip to content
Snippets Groups Projects
Commit 576ac4b8 authored by Tom Lane's avatar Tom Lane
Browse files

Fix initialization bug in pgcrypto openssl code. Marko Kreen

parent 7e33fae3
No related branches found
No related tags found
No related merge requests found
...@@ -17,14 +17,14 @@ decode('01 01 01 01 01 01 01 01 ...@@ -17,14 +17,14 @@ decode('01 01 01 01 01 01 01 01
select encode( encrypt('', 'foo', '3des'), 'hex'); select encode( encrypt('', 'foo', '3des'), 'hex');
encode encode
------------------ ------------------
9b641a6936249eb4 752111e37a2d7ac3
(1 row) (1 row)
-- 10 bytes key -- 10 bytes key
select encode( encrypt('foo', '0123456789', '3des'), 'hex'); select encode( encrypt('foo', '0123456789', '3des'), 'hex');
encode encode
------------------ ------------------
6f02b7076a366504 d2fb8baa1717cb02
(1 row) (1 row)
-- 22 bytes key -- 22 bytes key
...@@ -45,10 +45,10 @@ select decrypt(encrypt('foo', '0123456', '3des'), '0123456', '3des'); ...@@ -45,10 +45,10 @@ select decrypt(encrypt('foo', '0123456', '3des'), '0123456', '3des');
select encode(encrypt_iv('foo', '0123456', 'abcd', '3des'), 'hex'); select encode(encrypt_iv('foo', '0123456', 'abcd', '3des'), 'hex');
encode encode
------------------ ------------------
df27c264fb24ed7a 50735067b073bb93
(1 row) (1 row)
select decrypt_iv(decode('df27c264fb24ed7a', 'hex'), '0123456', 'abcd', '3des'); select decrypt_iv(decode('50735067b073bb93', 'hex'), '0123456', 'abcd', '3des');
decrypt_iv decrypt_iv
------------ ------------
foo foo
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * 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 <postgres.h> #include <postgres.h>
...@@ -393,7 +393,7 @@ ossl_des3_init(PX_Cipher * c, const uint8 *key, unsigned klen, const uint8 *iv) ...@@ -393,7 +393,7 @@ ossl_des3_init(PX_Cipher * c, const uint8 *key, unsigned klen, const uint8 *iv)
memset(&xkey1, 0, sizeof(xkey1)); memset(&xkey1, 0, sizeof(xkey1));
memset(&xkey2, 0, sizeof(xkey2)); memset(&xkey2, 0, sizeof(xkey2));
memset(&xkey2, 0, sizeof(xkey2)); memset(&xkey3, 0, sizeof(xkey3));
memcpy(&xkey1, key, klen > 8 ? 8 : klen); memcpy(&xkey1, key, klen > 8 ? 8 : klen);
if (klen > 8) if (klen > 8)
memcpy(&xkey2, key + 8, (klen - 8) > 8 ? 8 : (klen - 8)); memcpy(&xkey2, key + 8, (klen - 8) > 8 ? 8 : (klen - 8));
......
...@@ -22,5 +22,5 @@ select decrypt(encrypt('foo', '0123456', '3des'), '0123456', '3des'); ...@@ -22,5 +22,5 @@ select decrypt(encrypt('foo', '0123456', '3des'), '0123456', '3des');
-- iv -- iv
select encode(encrypt_iv('foo', '0123456', 'abcd', '3des'), 'hex'); 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');
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment