Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/worker/src/PHPSecLi.../Crypt
File: RSA.php
<?php
[0] Fix | Delete
[1] Fix | Delete
/**
[2] Fix | Delete
* Pure-PHP PKCS#1 (v2.1) compliant implementation of RSA.
[3] Fix | Delete
*
[4] Fix | Delete
* PHP versions 4 and 5
[5] Fix | Delete
*
[6] Fix | Delete
* Here's an example of how to encrypt and decrypt text with this library:
[7] Fix | Delete
* <code>
[8] Fix | Delete
* <?php
[9] Fix | Delete
* include 'Crypt/RSA.php';
[10] Fix | Delete
*
[11] Fix | Delete
* $rsa = new Crypt_RSA();
[12] Fix | Delete
* extract($rsa->createKey());
[13] Fix | Delete
*
[14] Fix | Delete
* $plaintext = 'terrafrost';
[15] Fix | Delete
*
[16] Fix | Delete
* $rsa->loadKey($privatekey);
[17] Fix | Delete
* $ciphertext = $rsa->encrypt($plaintext);
[18] Fix | Delete
*
[19] Fix | Delete
* $rsa->loadKey($publickey);
[20] Fix | Delete
* echo $rsa->decrypt($ciphertext);
[21] Fix | Delete
* ?>
[22] Fix | Delete
* </code>
[23] Fix | Delete
*
[24] Fix | Delete
* Here's an example of how to create signatures and verify signatures with this library:
[25] Fix | Delete
* <code>
[26] Fix | Delete
* <?php
[27] Fix | Delete
* include 'Crypt/RSA.php';
[28] Fix | Delete
*
[29] Fix | Delete
* $rsa = new Crypt_RSA();
[30] Fix | Delete
* extract($rsa->createKey());
[31] Fix | Delete
*
[32] Fix | Delete
* $plaintext = 'terrafrost';
[33] Fix | Delete
*
[34] Fix | Delete
* $rsa->loadKey($privatekey);
[35] Fix | Delete
* $signature = $rsa->sign($plaintext);
[36] Fix | Delete
*
[37] Fix | Delete
* $rsa->loadKey($publickey);
[38] Fix | Delete
* echo $rsa->verify($plaintext, $signature) ? 'verified' : 'unverified';
[39] Fix | Delete
* ?>
[40] Fix | Delete
* </code>
[41] Fix | Delete
*
[42] Fix | Delete
* LICENSE: Permission is hereby granted, free of charge, to any person obtaining a copy
[43] Fix | Delete
* of this software and associated documentation files (the "Software"), to deal
[44] Fix | Delete
* in the Software without restriction, including without limitation the rights
[45] Fix | Delete
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
[46] Fix | Delete
* copies of the Software, and to permit persons to whom the Software is
[47] Fix | Delete
* furnished to do so, subject to the following conditions:
[48] Fix | Delete
*
[49] Fix | Delete
* The above copyright notice and this permission notice shall be included in
[50] Fix | Delete
* all copies or substantial portions of the Software.
[51] Fix | Delete
*
[52] Fix | Delete
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
[53] Fix | Delete
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
[54] Fix | Delete
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
[55] Fix | Delete
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
[56] Fix | Delete
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
[57] Fix | Delete
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
[58] Fix | Delete
* THE SOFTWARE.
[59] Fix | Delete
*
[60] Fix | Delete
* @category Crypt
[61] Fix | Delete
* @package Crypt_RSA
[62] Fix | Delete
* @author Jim Wigginton <terrafrost@php.net>
[63] Fix | Delete
* @copyright MMIX Jim Wigginton
[64] Fix | Delete
* @license http://www.opensource.org/licenses/mit-license.html MIT License
[65] Fix | Delete
* @link http://phpseclib.sourceforge.net
[66] Fix | Delete
*/
[67] Fix | Delete
[68] Fix | Delete
/**
[69] Fix | Delete
* Include Crypt_Random
[70] Fix | Delete
*/
[71] Fix | Delete
// the class_exists() will only be called if the crypt_random_string function hasn't been defined and
[72] Fix | Delete
// will trigger a call to __autoload() if you're wanting to auto-load classes
[73] Fix | Delete
// call function_exists() a second time to stop the require_once from being called outside
[74] Fix | Delete
// of the auto loader
[75] Fix | Delete
if (!function_exists('crypt_random_string')) {
[76] Fix | Delete
require_once dirname(__FILE__).'/Random.php';
[77] Fix | Delete
}
[78] Fix | Delete
[79] Fix | Delete
/**
[80] Fix | Delete
* Include Crypt_Hash
[81] Fix | Delete
*/
[82] Fix | Delete
if (!class_exists('Crypt_Hash')) {
[83] Fix | Delete
require_once dirname(__FILE__).'/Hash.php';
[84] Fix | Delete
}
[85] Fix | Delete
[86] Fix | Delete
/**#@+
[87] Fix | Delete
* @access public
[88] Fix | Delete
* @see Crypt_RSA::encrypt()
[89] Fix | Delete
* @see Crypt_RSA::decrypt()
[90] Fix | Delete
*/
[91] Fix | Delete
/**
[92] Fix | Delete
* Use {@link http://en.wikipedia.org/wiki/Optimal_Asymmetric_Encryption_Padding Optimal Asymmetric Encryption Padding}
[93] Fix | Delete
* (OAEP) for encryption / decryption.
[94] Fix | Delete
*
[95] Fix | Delete
* Uses sha1 by default.
[96] Fix | Delete
*
[97] Fix | Delete
* @see Crypt_RSA::setHash()
[98] Fix | Delete
* @see Crypt_RSA::setMGFHash()
[99] Fix | Delete
*/
[100] Fix | Delete
define('CRYPT_RSA_ENCRYPTION_OAEP', 1);
[101] Fix | Delete
/**
[102] Fix | Delete
* Use PKCS#1 padding.
[103] Fix | Delete
*
[104] Fix | Delete
* Although CRYPT_RSA_ENCRYPTION_OAEP offers more security, including PKCS#1 padding is necessary for purposes of backwards
[105] Fix | Delete
* compatibility with protocols (like SSH-1) written before OAEP's introduction.
[106] Fix | Delete
*/
[107] Fix | Delete
define('CRYPT_RSA_ENCRYPTION_PKCS1', 2);
[108] Fix | Delete
/**#@-*/
[109] Fix | Delete
[110] Fix | Delete
/**#@+
[111] Fix | Delete
* @access public
[112] Fix | Delete
* @see Crypt_RSA::sign()
[113] Fix | Delete
* @see Crypt_RSA::verify()
[114] Fix | Delete
* @see Crypt_RSA::setHash()
[115] Fix | Delete
*/
[116] Fix | Delete
/**
[117] Fix | Delete
* Use the Probabilistic Signature Scheme for signing
[118] Fix | Delete
*
[119] Fix | Delete
* Uses sha1 by default.
[120] Fix | Delete
*
[121] Fix | Delete
* @see Crypt_RSA::setSaltLength()
[122] Fix | Delete
* @see Crypt_RSA::setMGFHash()
[123] Fix | Delete
*/
[124] Fix | Delete
define('CRYPT_RSA_SIGNATURE_PSS', 1);
[125] Fix | Delete
/**
[126] Fix | Delete
* Use the PKCS#1 scheme by default.
[127] Fix | Delete
*
[128] Fix | Delete
* Although CRYPT_RSA_SIGNATURE_PSS offers more security, including PKCS#1 signing is necessary for purposes of backwards
[129] Fix | Delete
* compatibility with protocols (like SSH-2) written before PSS's introduction.
[130] Fix | Delete
*/
[131] Fix | Delete
define('CRYPT_RSA_SIGNATURE_PKCS1', 2);
[132] Fix | Delete
/**#@-*/
[133] Fix | Delete
[134] Fix | Delete
/**#@+
[135] Fix | Delete
* @access private
[136] Fix | Delete
* @see Crypt_RSA::createKey()
[137] Fix | Delete
*/
[138] Fix | Delete
/**
[139] Fix | Delete
* ASN1 Integer
[140] Fix | Delete
*/
[141] Fix | Delete
define('CRYPT_RSA_ASN1_INTEGER', 2);
[142] Fix | Delete
/**
[143] Fix | Delete
* ASN1 Bit String
[144] Fix | Delete
*/
[145] Fix | Delete
define('CRYPT_RSA_ASN1_BITSTRING', 3);
[146] Fix | Delete
/**
[147] Fix | Delete
* ASN1 Octet String
[148] Fix | Delete
*/
[149] Fix | Delete
define('CRYPT_RSA_ASN1_OCTETSTRING', 4);
[150] Fix | Delete
/**
[151] Fix | Delete
* ASN1 Object Identifier
[152] Fix | Delete
*/
[153] Fix | Delete
define('CRYPT_RSA_ASN1_OBJECT', 6);
[154] Fix | Delete
/**
[155] Fix | Delete
* ASN1 Sequence (with the constucted bit set)
[156] Fix | Delete
*/
[157] Fix | Delete
define('CRYPT_RSA_ASN1_SEQUENCE', 48);
[158] Fix | Delete
/**#@-*/
[159] Fix | Delete
[160] Fix | Delete
/**#@+
[161] Fix | Delete
* @access private
[162] Fix | Delete
* @see Crypt_RSA::Crypt_RSA()
[163] Fix | Delete
*/
[164] Fix | Delete
/**
[165] Fix | Delete
* To use the pure-PHP implementation
[166] Fix | Delete
*/
[167] Fix | Delete
define('CRYPT_RSA_MODE_INTERNAL', 1);
[168] Fix | Delete
/**
[169] Fix | Delete
* To use the OpenSSL library
[170] Fix | Delete
*
[171] Fix | Delete
* (if enabled; otherwise, the internal implementation will be used)
[172] Fix | Delete
*/
[173] Fix | Delete
define('CRYPT_RSA_MODE_OPENSSL', 2);
[174] Fix | Delete
/**#@-*/
[175] Fix | Delete
[176] Fix | Delete
/**
[177] Fix | Delete
* Default openSSL configuration file.
[178] Fix | Delete
*/
[179] Fix | Delete
define('CRYPT_RSA_OPENSSL_CONFIG', dirname(__FILE__).'/../openssl.cnf');
[180] Fix | Delete
[181] Fix | Delete
/**#@+
[182] Fix | Delete
* @access public
[183] Fix | Delete
* @see Crypt_RSA::createKey()
[184] Fix | Delete
* @see Crypt_RSA::setPrivateKeyFormat()
[185] Fix | Delete
*/
[186] Fix | Delete
/**
[187] Fix | Delete
* PKCS#1 formatted private key
[188] Fix | Delete
*
[189] Fix | Delete
* Used by OpenSSH
[190] Fix | Delete
*/
[191] Fix | Delete
define('CRYPT_RSA_PRIVATE_FORMAT_PKCS1', 0);
[192] Fix | Delete
/**
[193] Fix | Delete
* PuTTY formatted private key
[194] Fix | Delete
*/
[195] Fix | Delete
define('CRYPT_RSA_PRIVATE_FORMAT_PUTTY', 1);
[196] Fix | Delete
/**
[197] Fix | Delete
* XML formatted private key
[198] Fix | Delete
*/
[199] Fix | Delete
define('CRYPT_RSA_PRIVATE_FORMAT_XML', 2);
[200] Fix | Delete
/**
[201] Fix | Delete
* PKCS#8 formatted private key
[202] Fix | Delete
*/
[203] Fix | Delete
define('CRYPT_RSA_PRIVATE_FORMAT_PKCS8', 3);
[204] Fix | Delete
/**#@-*/
[205] Fix | Delete
[206] Fix | Delete
/**#@+
[207] Fix | Delete
* @access public
[208] Fix | Delete
* @see Crypt_RSA::createKey()
[209] Fix | Delete
* @see Crypt_RSA::setPublicKeyFormat()
[210] Fix | Delete
*/
[211] Fix | Delete
/**
[212] Fix | Delete
* Raw public key
[213] Fix | Delete
*
[214] Fix | Delete
* An array containing two Math_BigInteger objects.
[215] Fix | Delete
*
[216] Fix | Delete
* The exponent can be indexed with any of the following:
[217] Fix | Delete
*
[218] Fix | Delete
* 0, e, exponent, publicExponent
[219] Fix | Delete
*
[220] Fix | Delete
* The modulus can be indexed with any of the following:
[221] Fix | Delete
*
[222] Fix | Delete
* 1, n, modulo, modulus
[223] Fix | Delete
*/
[224] Fix | Delete
define('CRYPT_RSA_PUBLIC_FORMAT_RAW', 3);
[225] Fix | Delete
/**
[226] Fix | Delete
* PKCS#1 formatted public key (raw)
[227] Fix | Delete
*
[228] Fix | Delete
* Used by File/X509.php
[229] Fix | Delete
*
[230] Fix | Delete
* Has the following header:
[231] Fix | Delete
*
[232] Fix | Delete
* -----BEGIN RSA PUBLIC KEY-----
[233] Fix | Delete
*
[234] Fix | Delete
* Analogous to ssh-keygen's pem format (as specified by -m)
[235] Fix | Delete
*/
[236] Fix | Delete
define('CRYPT_RSA_PUBLIC_FORMAT_PKCS1', 4);
[237] Fix | Delete
define('CRYPT_RSA_PUBLIC_FORMAT_PKCS1_RAW', 4);
[238] Fix | Delete
/**
[239] Fix | Delete
* XML formatted public key
[240] Fix | Delete
*/
[241] Fix | Delete
define('CRYPT_RSA_PUBLIC_FORMAT_XML', 5);
[242] Fix | Delete
/**
[243] Fix | Delete
* OpenSSH formatted public key
[244] Fix | Delete
*
[245] Fix | Delete
* Place in $HOME/.ssh/authorized_keys
[246] Fix | Delete
*/
[247] Fix | Delete
define('CRYPT_RSA_PUBLIC_FORMAT_OPENSSH', 6);
[248] Fix | Delete
/**
[249] Fix | Delete
* PKCS#1 formatted public key (encapsulated)
[250] Fix | Delete
*
[251] Fix | Delete
* Used by PHP's openssl_public_encrypt() and openssl's rsautl (when -pubin is set)
[252] Fix | Delete
*
[253] Fix | Delete
* Has the following header:
[254] Fix | Delete
*
[255] Fix | Delete
* -----BEGIN PUBLIC KEY-----
[256] Fix | Delete
*
[257] Fix | Delete
* Analogous to ssh-keygen's pkcs8 format (as specified by -m). Although PKCS8
[258] Fix | Delete
* is specific to private keys it's basically creating a DER-encoded wrapper
[259] Fix | Delete
* for keys. This just extends that same concept to public keys (much like ssh-keygen)
[260] Fix | Delete
*/
[261] Fix | Delete
define('CRYPT_RSA_PUBLIC_FORMAT_PKCS8', 7);
[262] Fix | Delete
/**#@-*/
[263] Fix | Delete
[264] Fix | Delete
/**
[265] Fix | Delete
* Pure-PHP PKCS#1 compliant implementation of RSA.
[266] Fix | Delete
*
[267] Fix | Delete
* @package Crypt_RSA
[268] Fix | Delete
* @author Jim Wigginton <terrafrost@php.net>
[269] Fix | Delete
* @access public
[270] Fix | Delete
*/
[271] Fix | Delete
class Crypt_RSA
[272] Fix | Delete
{
[273] Fix | Delete
/**
[274] Fix | Delete
* Precomputed Zero
[275] Fix | Delete
*
[276] Fix | Delete
* @var Array
[277] Fix | Delete
* @access private
[278] Fix | Delete
*/
[279] Fix | Delete
public $zero;
[280] Fix | Delete
[281] Fix | Delete
/**
[282] Fix | Delete
* Precomputed One
[283] Fix | Delete
*
[284] Fix | Delete
* @var Array
[285] Fix | Delete
* @access private
[286] Fix | Delete
*/
[287] Fix | Delete
public $one;
[288] Fix | Delete
[289] Fix | Delete
/**
[290] Fix | Delete
* Private Key Format
[291] Fix | Delete
*
[292] Fix | Delete
* @var Integer
[293] Fix | Delete
* @access private
[294] Fix | Delete
*/
[295] Fix | Delete
public $privateKeyFormat = CRYPT_RSA_PRIVATE_FORMAT_PKCS1;
[296] Fix | Delete
[297] Fix | Delete
/**
[298] Fix | Delete
* Public Key Format
[299] Fix | Delete
*
[300] Fix | Delete
* @var Integer
[301] Fix | Delete
* @access public
[302] Fix | Delete
*/
[303] Fix | Delete
public $publicKeyFormat = CRYPT_RSA_PUBLIC_FORMAT_PKCS8;
[304] Fix | Delete
[305] Fix | Delete
/**
[306] Fix | Delete
* Modulus (ie. n)
[307] Fix | Delete
*
[308] Fix | Delete
* @var Math_BigInteger
[309] Fix | Delete
* @access private
[310] Fix | Delete
*/
[311] Fix | Delete
public $modulus;
[312] Fix | Delete
[313] Fix | Delete
/**
[314] Fix | Delete
* Modulus length
[315] Fix | Delete
*
[316] Fix | Delete
* @var Math_BigInteger
[317] Fix | Delete
* @access private
[318] Fix | Delete
*/
[319] Fix | Delete
public $k;
[320] Fix | Delete
[321] Fix | Delete
/**
[322] Fix | Delete
* Exponent (ie. e or d)
[323] Fix | Delete
*
[324] Fix | Delete
* @var Math_BigInteger
[325] Fix | Delete
* @access private
[326] Fix | Delete
*/
[327] Fix | Delete
public $exponent;
[328] Fix | Delete
[329] Fix | Delete
/**
[330] Fix | Delete
* Primes for Chinese Remainder Theorem (ie. p and q)
[331] Fix | Delete
*
[332] Fix | Delete
* @var Array
[333] Fix | Delete
* @access private
[334] Fix | Delete
*/
[335] Fix | Delete
public $primes;
[336] Fix | Delete
[337] Fix | Delete
/**
[338] Fix | Delete
* Exponents for Chinese Remainder Theorem (ie. dP and dQ)
[339] Fix | Delete
*
[340] Fix | Delete
* @var Array
[341] Fix | Delete
* @access private
[342] Fix | Delete
*/
[343] Fix | Delete
public $exponents;
[344] Fix | Delete
[345] Fix | Delete
/**
[346] Fix | Delete
* Coefficients for Chinese Remainder Theorem (ie. qInv)
[347] Fix | Delete
*
[348] Fix | Delete
* @var Array
[349] Fix | Delete
* @access private
[350] Fix | Delete
*/
[351] Fix | Delete
public $coefficients;
[352] Fix | Delete
[353] Fix | Delete
/**
[354] Fix | Delete
* Hash name
[355] Fix | Delete
*
[356] Fix | Delete
* @var String
[357] Fix | Delete
* @access private
[358] Fix | Delete
*/
[359] Fix | Delete
public $hashName;
[360] Fix | Delete
[361] Fix | Delete
/**
[362] Fix | Delete
* Hash function
[363] Fix | Delete
*
[364] Fix | Delete
* @var Crypt_Hash
[365] Fix | Delete
* @access private
[366] Fix | Delete
*/
[367] Fix | Delete
public $hash;
[368] Fix | Delete
[369] Fix | Delete
/**
[370] Fix | Delete
* Length of hash function output
[371] Fix | Delete
*
[372] Fix | Delete
* @var Integer
[373] Fix | Delete
* @access private
[374] Fix | Delete
*/
[375] Fix | Delete
public $hLen;
[376] Fix | Delete
[377] Fix | Delete
/**
[378] Fix | Delete
* Length of salt
[379] Fix | Delete
*
[380] Fix | Delete
* @var Integer
[381] Fix | Delete
* @access private
[382] Fix | Delete
*/
[383] Fix | Delete
public $sLen;
[384] Fix | Delete
[385] Fix | Delete
/**
[386] Fix | Delete
* Hash function for the Mask Generation Function
[387] Fix | Delete
*
[388] Fix | Delete
* @var Crypt_Hash
[389] Fix | Delete
* @access private
[390] Fix | Delete
*/
[391] Fix | Delete
public $mgfHash;
[392] Fix | Delete
[393] Fix | Delete
/**
[394] Fix | Delete
* Length of MGF hash function output
[395] Fix | Delete
*
[396] Fix | Delete
* @var Integer
[397] Fix | Delete
* @access private
[398] Fix | Delete
*/
[399] Fix | Delete
public $mgfHLen;
[400] Fix | Delete
[401] Fix | Delete
/**
[402] Fix | Delete
* Encryption mode
[403] Fix | Delete
*
[404] Fix | Delete
* @var Integer
[405] Fix | Delete
* @access private
[406] Fix | Delete
*/
[407] Fix | Delete
public $encryptionMode = CRYPT_RSA_ENCRYPTION_OAEP;
[408] Fix | Delete
[409] Fix | Delete
/**
[410] Fix | Delete
* Signature mode
[411] Fix | Delete
*
[412] Fix | Delete
* @var Integer
[413] Fix | Delete
* @access private
[414] Fix | Delete
*/
[415] Fix | Delete
public $signatureMode = CRYPT_RSA_SIGNATURE_PSS;
[416] Fix | Delete
[417] Fix | Delete
/**
[418] Fix | Delete
* Public Exponent
[419] Fix | Delete
*
[420] Fix | Delete
* @var Mixed
[421] Fix | Delete
* @access private
[422] Fix | Delete
*/
[423] Fix | Delete
public $publicExponent = false;
[424] Fix | Delete
[425] Fix | Delete
/**
[426] Fix | Delete
* Password
[427] Fix | Delete
*
[428] Fix | Delete
* @var String
[429] Fix | Delete
* @access private
[430] Fix | Delete
*/
[431] Fix | Delete
public $password = false;
[432] Fix | Delete
[433] Fix | Delete
/**
[434] Fix | Delete
* Components
[435] Fix | Delete
*
[436] Fix | Delete
* For use with parsing XML formatted keys. PHP's XML Parser functions use utilized - instead of PHP's DOM functions -
[437] Fix | Delete
* because PHP's XML Parser functions work on PHP4 whereas PHP's DOM functions - although surperior - don't.
[438] Fix | Delete
*
[439] Fix | Delete
* @see Crypt_RSA::_start_element_handler()
[440] Fix | Delete
* @var Array
[441] Fix | Delete
* @access private
[442] Fix | Delete
*/
[443] Fix | Delete
public $components = array();
[444] Fix | Delete
[445] Fix | Delete
/**
[446] Fix | Delete
* Current String
[447] Fix | Delete
*
[448] Fix | Delete
* For use with parsing XML formatted keys.
[449] Fix | Delete
*
[450] Fix | Delete
* @see Crypt_RSA::_character_handler()
[451] Fix | Delete
* @see Crypt_RSA::_stop_element_handler()
[452] Fix | Delete
* @var Mixed
[453] Fix | Delete
* @access private
[454] Fix | Delete
*/
[455] Fix | Delete
public $current;
[456] Fix | Delete
[457] Fix | Delete
/**
[458] Fix | Delete
* OpenSSL configuration file name.
[459] Fix | Delete
*
[460] Fix | Delete
* Set to null to use system configuration file.
[461] Fix | Delete
* @see Crypt_RSA::createKey()
[462] Fix | Delete
* @var Mixed
[463] Fix | Delete
* @Access public
[464] Fix | Delete
*/
[465] Fix | Delete
public $configFile;
[466] Fix | Delete
[467] Fix | Delete
/**
[468] Fix | Delete
* Public key comment field.
[469] Fix | Delete
*
[470] Fix | Delete
* @var String
[471] Fix | Delete
* @access private
[472] Fix | Delete
*/
[473] Fix | Delete
public $comment = 'phpseclib-generated-key';
[474] Fix | Delete
[475] Fix | Delete
/**
[476] Fix | Delete
* The constructor
[477] Fix | Delete
*
[478] Fix | Delete
* If you want to make use of the openssl extension, you'll need to set the mode manually, yourself. The reason
[479] Fix | Delete
* Crypt_RSA doesn't do it is because OpenSSL doesn't fail gracefully. openssl_pkey_new(), in particular, requires
[480] Fix | Delete
* openssl.cnf be present somewhere and, unfortunately, the only real way to find out is too late.
[481] Fix | Delete
*
[482] Fix | Delete
* @return Crypt_RSA
[483] Fix | Delete
* @access public
[484] Fix | Delete
*/
[485] Fix | Delete
public function __construct()
[486] Fix | Delete
{
[487] Fix | Delete
if (!class_exists('Math_BigInteger')) {
[488] Fix | Delete
require_once dirname(__FILE__).'/../Math/BigInteger.php';
[489] Fix | Delete
}
[490] Fix | Delete
[491] Fix | Delete
$this->configFile = CRYPT_RSA_OPENSSL_CONFIG;
[492] Fix | Delete
[493] Fix | Delete
if (!defined('CRYPT_RSA_MODE')) {
[494] Fix | Delete
// Math/BigInteger's openssl requirements are a little less stringent than Crypt/RSA's. in particular,
[495] Fix | Delete
// Math/BigInteger doesn't require an openssl.cfg file whereas Crypt/RSA does. so if Math/BigInteger
[496] Fix | Delete
// can't use OpenSSL it can be pretty trivially assumed, then, that Crypt/RSA can't either.
[497] Fix | Delete
if (defined('MATH_BIGINTEGER_OPENSSL_DISABLE')) {
[498] Fix | Delete
define('CRYPT_RSA_MODE', CRYPT_RSA_MODE_INTERNAL);
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function