always have a defined return value

This commit is contained in:
Björn Schießle 2013-06-19 16:55:31 +02:00
parent e2e370f199
commit fe61230cc1
1 changed files with 4 additions and 4 deletions

View File

@ -51,18 +51,18 @@ class Crypt {
*/ */
public static function createKeypair() { public static function createKeypair() {
$return = false;
$res = openssl_pkey_new(array('private_key_bits' => 4096)); $res = openssl_pkey_new(array('private_key_bits' => 4096));
if ($res === false) { if ($res === false) {
\OCP\Util::writeLog('Encryption library', 'couldn\'t generate users key-pair for ' . \OCP\User::getUser(), \OCP\Util::ERROR); \OCP\Util::writeLog('Encryption library', 'couldn\'t generate users key-pair for ' . \OCP\User::getUser(), \OCP\Util::ERROR);
$result = false;
} elseif (openssl_pkey_export($res, $privateKey)) { } elseif (openssl_pkey_export($res, $privateKey)) {
// Get public key // Get public key
$publicKey = openssl_pkey_get_details($res); $publicKey = openssl_pkey_get_details($res);
$publicKey = $publicKey['key']; $publicKey = $publicKey['key'];
$result = array( $return = array(
'publicKey' => $publicKey, 'publicKey' => $publicKey,
'privateKey' => $privateKey 'privateKey' => $privateKey
); );
@ -70,7 +70,7 @@ class Crypt {
\OCP\Util::writeLog('Encryption library', 'couldn\'t export users private key, please check your servers openSSL configuration.' . \OCP\User::getUser(), \OCP\Util::ERROR); \OCP\Util::writeLog('Encryption library', 'couldn\'t export users private key, please check your servers openSSL configuration.' . \OCP\User::getUser(), \OCP\Util::ERROR);
} }
return $result; return $return;
} }
/** /**