mirror of
https://github.com/phpseclib/phpseclib.git
synced 2025-01-28 01:28:27 +00:00
RSA: rename PUBLIC_FORMAT_PKCS1_RAW -> PUBLIC_FORMAT_PKCS8
also make CRYPT_RSA_PUBLIC_FORMAT_PKCS8 the default format
This commit is contained in:
parent
4878f2a99b
commit
83301097ea
@ -235,6 +235,7 @@ define('CRYPT_RSA_PUBLIC_FORMAT_RAW', 3);
|
|||||||
*
|
*
|
||||||
* Analogous to ssh-keygen's pem format (as specified by -m)
|
* Analogous to ssh-keygen's pem format (as specified by -m)
|
||||||
*/
|
*/
|
||||||
|
define('CRYPT_RSA_PUBLIC_FORMAT_PKCS1', 4);
|
||||||
define('CRYPT_RSA_PUBLIC_FORMAT_PKCS1_RAW', 4);
|
define('CRYPT_RSA_PUBLIC_FORMAT_PKCS1_RAW', 4);
|
||||||
/**
|
/**
|
||||||
* XML formatted public key
|
* XML formatted public key
|
||||||
@ -255,11 +256,11 @@ define('CRYPT_RSA_PUBLIC_FORMAT_OPENSSH', 6);
|
|||||||
*
|
*
|
||||||
* -----BEGIN PUBLIC KEY-----
|
* -----BEGIN PUBLIC KEY-----
|
||||||
*
|
*
|
||||||
* Analogous to ssh-keygen's pkcs8 format (as specified by -m)
|
* Analogous to ssh-keygen's pkcs8 format (as specified by -m). Although PKCS8
|
||||||
* (the applicability of PKCS8 is dubious since PKCS8 is talking about
|
* is specific to private keys it's basically creating a DER-encoded wrapper
|
||||||
* private keys but whatever)
|
* for keys. This just extends that same concept to public keys (much like ssh-keygen)
|
||||||
*/
|
*/
|
||||||
define('CRYPT_RSA_PUBLIC_FORMAT_PKCS1', 7);
|
define('CRYPT_RSA_PUBLIC_FORMAT_PKCS8', 7);
|
||||||
/**#@-*/
|
/**#@-*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -301,7 +302,7 @@ class Crypt_RSA
|
|||||||
* @var Integer
|
* @var Integer
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $publicKeyFormat = CRYPT_RSA_PUBLIC_FORMAT_PKCS1;
|
var $publicKeyFormat = CRYPT_RSA_PUBLIC_FORMAT_PKCS8;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Modulus (ie. n)
|
* Modulus (ie. n)
|
||||||
@ -1748,7 +1749,7 @@ class Crypt_RSA
|
|||||||
* @param String $key
|
* @param String $key
|
||||||
* @param Integer $type optional
|
* @param Integer $type optional
|
||||||
*/
|
*/
|
||||||
function getPublicKey($type = CRYPT_RSA_PUBLIC_FORMAT_PKCS1)
|
function getPublicKey($type = CRYPT_RSA_PUBLIC_FORMAT_PKCS8)
|
||||||
{
|
{
|
||||||
if (empty($this->modulus) || empty($this->publicExponent)) {
|
if (empty($this->modulus) || empty($this->publicExponent)) {
|
||||||
return false;
|
return false;
|
||||||
@ -1795,7 +1796,7 @@ class Crypt_RSA
|
|||||||
* @param String $key
|
* @param String $key
|
||||||
* @param Integer $type optional
|
* @param Integer $type optional
|
||||||
*/
|
*/
|
||||||
function _getPrivatePublicKey($mode = CRYPT_RSA_PUBLIC_FORMAT_PKCS1)
|
function _getPrivatePublicKey($mode = CRYPT_RSA_PUBLIC_FORMAT_PKCS8)
|
||||||
{
|
{
|
||||||
if (empty($this->modulus) || empty($this->exponent)) {
|
if (empty($this->modulus) || empty($this->exponent)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -4235,7 +4235,7 @@ class File_X509
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
default: // Should be a key object (i.e.: Crypt_RSA).
|
default: // Should be a key object (i.e.: Crypt_RSA).
|
||||||
$key = $key->getPublicKey(CRYPT_RSA_PUBLIC_FORMAT_PKCS1_RAW);
|
$key = $key->getPublicKey(CRYPT_RSA_PUBLIC_FORMAT_PKCS1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4276,7 +4276,7 @@ class File_X509
|
|||||||
//return new File_ASN1_Element(base64_decode(preg_replace('#-.+-|[\r\n]#', '', $this->publicKey->getPublicKey())));
|
//return new File_ASN1_Element(base64_decode(preg_replace('#-.+-|[\r\n]#', '', $this->publicKey->getPublicKey())));
|
||||||
return array(
|
return array(
|
||||||
'algorithm' => array('algorithm' => 'rsaEncryption'),
|
'algorithm' => array('algorithm' => 'rsaEncryption'),
|
||||||
'subjectPublicKey' => $this->publicKey->getPublicKey(CRYPT_RSA_PUBLIC_FORMAT_PKCS1_RAW)
|
'subjectPublicKey' => $this->publicKey->getPublicKey(CRYPT_RSA_PUBLIC_FORMAT_PKCS1)
|
||||||
);
|
);
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user