/** * @param array $input * @param array $errors * @param array $options */ private function process_standard_options(&$input, &$errors, &$options) { if (empty($input[LaunchKey_WP_Options::OPTION_ROCKET_KEY])) { $errors[] = $this->wp_facade->__('Rocket Key is a required field', $this->language_domain); } else { $rocket_key = trim($input[LaunchKey_WP_Options::OPTION_ROCKET_KEY]); if (!is_numeric($rocket_key)) { $errors[] = $this->wp_facade->__('Rocket Key must be numeric', $this->language_domain); } elseif (strlen($rocket_key) !== 10) { $errors[] = $this->wp_facade->__('Rocket Key must be 10 digits', $this->language_domain); } else { $options[LaunchKey_WP_Options::OPTION_ROCKET_KEY] = $rocket_key; } } if (empty($input[LaunchKey_WP_Options::OPTION_SECRET_KEY]) && empty($options[LaunchKey_WP_Options::OPTION_SECRET_KEY])) { $errors[] = $this->wp_facade->__('Secret Key is a required field', $this->language_domain); } else { if (!empty($input[LaunchKey_WP_Options::OPTION_SECRET_KEY])) { $secret_key = trim($input[LaunchKey_WP_Options::OPTION_SECRET_KEY]); if (!ctype_alnum($secret_key)) { $errors[] = $this->wp_facade->__('Secret Key must be alphanumeric', $this->language_domain); } elseif (strlen($secret_key) !== 32) { $errors[] = $this->wp_facade->__('Secret Key must be 32 characters', $this->language_domain); } else { $options[LaunchKey_WP_Options::OPTION_SECRET_KEY] = $secret_key; } } } $app_display_name = isset($input[LaunchKey_WP_Options::OPTION_APP_DISPLAY_NAME]) ? trim($input[LaunchKey_WP_Options::OPTION_APP_DISPLAY_NAME]) : null; if ('LaunchKey' !== $app_display_name && LaunchKey_WP_Implementation_Type::WHITE_LABEL !== $options[LaunchKey_WP_Options::OPTION_IMPLEMENTATION_TYPE]) { $errors[] = $this->wp_facade->__('App Display Name can only be modified for White Label implementations', $this->language_domain); $options[LaunchKey_WP_Options::OPTION_APP_DISPLAY_NAME] = 'LaunchKey'; } else { $options[LaunchKey_WP_Options::OPTION_APP_DISPLAY_NAME] = $app_display_name ?: null; } if (empty($_FILES['private_key']['tmp_name']) && empty($options[LaunchKey_WP_Options::OPTION_PRIVATE_KEY]) && isset($options[LaunchKey_WP_Options::OPTION_IMPLEMENTATION_TYPE]) && LaunchKey_WP_Implementation_Type::requires_private_key($options[LaunchKey_WP_Options::OPTION_IMPLEMENTATION_TYPE])) { $errors[] = $this->wp_facade->__('Private Key is required', $this->language_domain); } else { if (!empty($_FILES['private_key']['tmp_name'])) { $private_key = @file_get_contents($_FILES['private_key']['tmp_name']); $rsa = new \phpseclib\Crypt\RSA(); if (@$rsa->loadKey($private_key)) { if ($rsa->getPrivateKey($rsa->privateKeyFormat)) { $options[LaunchKey_WP_Options::OPTION_PRIVATE_KEY] = $private_key; } else { $errors[] = $this->wp_facade->__('The Key file provided was a valid RSA key file but did not contain a private key. Did you mistakenly supply the public key file?', $this->language_domain); } } else { $errors[] = $this->wp_facade->__('The Private Key provided was invalid', $this->language_domain); } } } }
<?php include '../phpseclib/vendor/autoload.php'; $rsa = new \phpseclib\Crypt\RSA(); $private = file_get_contents('private.pem'); $rsa->setPassword('VdcpDTWTc5Aehxgv2uL9haaFddDBhrc8uCMG3ykg'); phpseclib\Crypt\RSA\PKCS1::setEncryptionAlgorithm('AES-256-CBC'); $rsa->setHash('sha512'); $rsa->setMGFHash('sha512'); $rsa->load($private); foreach ($rsa->primes as $key => $prime) { echo 'p' . $key . '= ' . $prime . '(' . strlen($prime) . ')' . PHP_EOL; } echo 'n= ' . $rsa->modulus . PHP_EOL; echo 'e= ' . $rsa->publicExponent . '(binary: ' . decbin($rsa->publicExponent->value) . ')' . '(hexadecimal: ' . dechex($rsa->publicExponent->value) . ')' . PHP_EOL; if ($rsa->password) { echo 'password= '******'Bits: ' . $rsa->getSize() . ' bits.' . '(' . strlen($rsa->modulus) . ')(2^' . $rsa->getSize() . ')' . PHP_EOL; echo PHP_EOL; echo $rsa->getPrivateKey('PKCS1') . PHP_EOL;