2 namespace TYPO3\CMS\Rsaauth\Backend;
35 $keyPair = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Rsaauth\Keypair::class);
36 if ($keyPair->isReady()) {
40 $privateKey = @openssl_pkey_new();
41 if ($privateKey !==
false) {
44 openssl_pkey_export($privateKey, $privateKeyStr);
47 $csr = openssl_csr_new(array(
48 'localityName' =>
'foo',
49 'organizationName' =>
'bar',
51 openssl_csr_export($csr, $exportedData,
false);
56 $keyPair->setExponent($exponent);
57 $keyPair->setPrivateKey($privateKeyStr);
58 $keyPair->setPublicKey($publicKey);
60 openssl_free_key($privateKey);
77 public function decrypt($privateKey, $data)
80 if (!@openssl_private_decrypt(base64_decode($data), $result, $privateKey)) {
96 if (is_callable(
'openssl_pkey_new')) {
100 $testKey = @openssl_pkey_new();
101 if (is_resource($testKey)) {
102 openssl_free_key($testKey);
117 $index = strpos($data,
'Exponent: ');
120 return (
int)substr($data, $index + 10);
131 $fragment = preg_replace(
'/.*Modulus.*?\\n(.*)Exponent:.*/ms',
'\\1', $data);
132 $fragment = preg_replace(
'/[\\s\\n\\r:]/',
'', $fragment);
133 return trim(strtoupper(substr($fragment, 2)));