From 4d4cc0e0f5e67278bd2dba3451d31a8ed9a9099c Mon Sep 17 00:00:00 2001 From: Jim Wigginton Date: Wed, 1 Dec 2010 05:09:01 +0000 Subject: [PATCH] - keys should now be null padded if they're too short git-svn-id: http://phpseclib.svn.sourceforge.net/svnroot/phpseclib/trunk@136 21d32557-59b3-4da0-833f-c5933fad653e --- phpseclib/Crypt/DES.php | 2 +- phpseclib/Crypt/Rijndael.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/phpseclib/Crypt/DES.php b/phpseclib/Crypt/DES.php index e0b333f2..903fdc5c 100644 --- a/phpseclib/Crypt/DES.php +++ b/phpseclib/Crypt/DES.php @@ -362,7 +362,7 @@ class Crypt_DES { */ function setKey($key) { - $this->keys = ( CRYPT_DES_MODE == CRYPT_DES_MODE_MCRYPT ) ? substr($key, 0, 8) : $this->_prepareKey($key); + $this->keys = ( CRYPT_DES_MODE == CRYPT_DES_MODE_MCRYPT ) ? str_pad(substr($key, 0, 8), 8, chr(0)) : $this->_prepareKey($key); $this->changed = true; } diff --git a/phpseclib/Crypt/Rijndael.php b/phpseclib/Crypt/Rijndael.php index f2212c69..f6f281f8 100644 --- a/phpseclib/Crypt/Rijndael.php +++ b/phpseclib/Crypt/Rijndael.php @@ -532,7 +532,7 @@ class Crypt_Rijndael { */ function setKey($key) { - $this->key = $key; + $this->key = str_pad(substr($key, 0, $this->key_size), $this->key_size, chr(0)); $this->changed = true; }