mirror of
https://github.com/postgres/postgres.git
synced 2025-07-20 05:03:10 +03:00
Fix initialization bug in pgcrypto openssl code. Marko Kreen
This commit is contained in:
@ -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');
|
|||||||
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 @@
|
|||||||
* 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)
|
|||||||
|
|
||||||
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');
|
|||||||
|
|
||||||
-- 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');
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user