Index: tests/Zend/Crypt/DiffieHellmanTest.php =================================================================== --- tests/Zend/Crypt/DiffieHellmanTest.php (revision 21515) +++ tests/Zend/Crypt/DiffieHellmanTest.php (working copy) @@ -133,4 +133,12 @@ $this->assertEquals($expectedSharedSecret, $aliceSecretKey); $this->assertEquals($expectedSharedSecret, $bobSecretKey); } + + public function testGenerateKeysWithUnsetPrivateKey() + { + $dh = new Zend_Crypt_DiffieHellman(563, 5); + $dh->generateKeys(); + $privateKey = $dh->getPrivateKey(); + $this->assertNotNull($privateKey); + } } Index: library/Zend/Crypt/DiffieHellman.php =================================================================== --- library/Zend/Crypt/DiffieHellman.php (revision 21515) +++ library/Zend/Crypt/DiffieHellman.php (working copy) @@ -324,7 +324,7 @@ public function getPrivateKey($type = self::NUMBER) { if (!$this->hasPrivateKey()) { - $this->setPrivateKey($this->_generatePrivateKey()); + $this->setPrivateKey($this->_generatePrivateKey(), self::BINARY); } if ($type == self::BINARY) { return $this->_math->toBinary($this->_privateKey); @@ -377,4 +377,4 @@ return $rand; } -} \ No newline at end of file +}