2 namespace TYPO3\CMS\Rsaauth\Backend;
56 $this->temporaryDirectory = PATH_site .
'typo3temp';
58 $extconf = unserialize(
$GLOBALS[
'TYPO3_CONF_VARS'][
'EXT'][
'extConf'][
'rsaauth']);
60 $extconf[
'temporaryDirectory'] !==
''
61 && $extconf[
'temporaryDirectory'][0] ===
'/'
62 && @is_dir($extconf[
'temporaryDirectory'])
63 && is_writable($extconf[
'temporaryDirectory'])
65 $this->temporaryDirectory = $extconf[
'temporaryDirectory'];
81 if ($keyPair->isReady()) {
85 if ($this->opensslPath ===
false) {
97 $command = $this->opensslPath .
' genrsa -out ' . escapeshellarg($privateKeyFile) .
' 1024';
98 if (TYPO3_OS ===
'WIN') {
101 $command .=
' 2>/dev/null';
105 $privateKey = file_get_contents($privateKeyFile);
106 if (
false !== strpos($privateKey,
'BEGIN RSA PRIVATE KEY')) {
108 $command = $this->opensslPath .
' rsa -noout -modulus -in ' . escapeshellarg($privateKeyFile);
110 if (substr($value, 0, 8) ===
'Modulus=') {
111 $publicKey = substr($value, 8);
113 $keyPair->setExponent(self::DEFAULT_EXPONENT);
114 $keyPair->setPrivateKey($privateKey);
115 $keyPair->setPublicKey($publicKey);
121 @unlink($privateKeyFile);
135 file_put_contents($privateKeyFile, $privateKey);
137 file_put_contents($dataFile, base64_decode($data));
139 $command = $this->opensslPath .
' rsautl -inkey ' . escapeshellarg($privateKeyFile) .
' -in ' . escapeshellarg($dataFile) .
' -decrypt';
144 @unlink($privateKeyFile);
146 return implode(LF, $output);
159 if ($this->opensslPath) {
162 $result = substr($test, 0, 8) ===
'OpenSSL ';