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) {
79 if (!@openssl_private_decrypt(base64_decode($data),
$result, $privateKey)) {
94 if (is_callable(
'openssl_pkey_new')) {
98 $testKey = @openssl_pkey_new();
99 if (is_resource($testKey)) {
100 openssl_free_key($testKey);
114 $index = strpos($data,
'Exponent: ');
117 return (
int)substr($data, $index + 10);
127 $fragment = preg_replace(
'/.*Modulus.*?\\n(.*)Exponent:.*/ms',
'\\1', $data);
128 $fragment = preg_replace(
'/[\\s\\n\\r:]/',
'', $fragment);
129 $result = trim(strtoupper(substr($fragment, 2)));
decrypt($privateKey, $data)
static makeInstance($className)
if($list_of_literals) if(!empty($literals)) if(!empty($literals)) $result
Analyse literals to prepend the N char to them if their contents aren't numeric.
extractPublicKeyModulus($data)