mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-11-18 19:25:13 +00:00
RSA: update comments for _extractBER
This commit is contained in:
parent
3a0193875a
commit
b23a693ae5
@ -2791,14 +2791,14 @@ class Crypt_RSA
|
||||
*/
|
||||
function _extractBER($str)
|
||||
{
|
||||
/*
|
||||
X.509 certs are assumed to be base64 encoded but sometimes they'll have additional things in them above and beyond the ceritificate. ie.
|
||||
some may have the following preceding the -----BEGIN CERTIFICATE----- line:
|
||||
|
||||
Bag Attributes
|
||||
localKeyID: 01 00 00 00
|
||||
subject=/O=organization/OU=org unit/CN=common name
|
||||
issuer=/O=organization/CN=common name
|
||||
/* X.509 certs are assumed to be base64 encoded but sometimes they'll have additional things in them
|
||||
* above and beyond the ceritificate.
|
||||
* ie. some may have the following preceding the -----BEGIN CERTIFICATE----- line:
|
||||
*
|
||||
* Bag Attributes
|
||||
* localKeyID: 01 00 00 00
|
||||
* subject=/O=organization/OU=org unit/CN=common name
|
||||
* issuer=/O=organization/CN=common name
|
||||
*/
|
||||
$temp = preg_replace('#.*?^-+[^-]+-+#ms', '', $str, 1);
|
||||
// remove the -----BEGIN CERTIFICATE----- and -----END CERTIFICATE----- stuff
|
||||
|
@ -4413,14 +4413,14 @@ class File_X509
|
||||
*/
|
||||
function _extractBER($str)
|
||||
{
|
||||
/*
|
||||
X.509 certs are assumed to be base64 encoded but sometimes they'll have additional things in them above and beyond the ceritificate. ie.
|
||||
some may have the following preceding the -----BEGIN CERTIFICATE----- line:
|
||||
|
||||
Bag Attributes
|
||||
localKeyID: 01 00 00 00
|
||||
subject=/O=organization/OU=org unit/CN=common name
|
||||
issuer=/O=organization/CN=common name
|
||||
/* X.509 certs are assumed to be base64 encoded but sometimes they'll have additional things in them
|
||||
* above and beyond the ceritificate.
|
||||
* ie. some may have the following preceding the -----BEGIN CERTIFICATE----- line:
|
||||
*
|
||||
* Bag Attributes
|
||||
* localKeyID: 01 00 00 00
|
||||
* subject=/O=organization/OU=org unit/CN=common name
|
||||
* issuer=/O=organization/CN=common name
|
||||
*/
|
||||
$temp = preg_replace('#.*?^-+[^-]+-+#ms', '', $str, 1);
|
||||
// remove the -----BEGIN CERTIFICATE----- and -----END CERTIFICATE----- stuff
|
||||
|
37
tests/Crypt/RSA/Test.php
Normal file
37
tests/Crypt/RSA/Test.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright MMXIII Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
*/
|
||||
|
||||
class Crypt_RSA_Test extends PhpseclibTestCase
|
||||
{
|
||||
static public function setUpBeforeClass()
|
||||
{
|
||||
require_once('Crypt/RSA.php');
|
||||
}
|
||||
|
||||
public function testLoadKey()
|
||||
{
|
||||
$rsa = new Crypt_RSA();
|
||||
|
||||
$key1 = '-----BEGIN RSA PRIVATE KEY-----
|
||||
MIICXAIBAAKBgQCqGKukO1De7zhZj6+H0qtjTkVxwTCpvKe4eCZ0FPqri0cb2JZfXJ/DgYSF6vUp
|
||||
wmJG8wVQZKjeGcjDOL5UlsuusFncCzWBQ7RKNUSesmQRMSGkVb1/3j+skZ6UtW+5u09lHNsj6tQ5
|
||||
1s1SPrCBkedbNf0Tp0GbMJDyR4e9T04ZZwIDAQABAoGAFijko56+qGyN8M0RVyaRAXz++xTqHBLh
|
||||
3tx4VgMtrQ+WEgCjhoTwo23KMBAuJGSYnRmoBZM3lMfTKevIkAidPExvYCdm5dYq3XToLkkLv5L2
|
||||
pIIVOFMDG+KESnAFV7l2c+cnzRMW0+b6f8mR1CJzZuxVLL6Q02fvLi55/mbSYxECQQDeAw6fiIQX
|
||||
GukBI4eMZZt4nscy2o12KyYner3VpoeE+Np2q+Z3pvAMd/aNzQ/W9WaI+NRfcxUJrmfPwIGm63il
|
||||
AkEAxCL5HQb2bQr4ByorcMWm/hEP2MZzROV73yF41hPsRC9m66KrheO9HPTJuo3/9s5p+sqGxOlF
|
||||
L0NDt4SkosjgGwJAFklyR1uZ/wPJjj611cdBcztlPdqoxssQGnh85BzCj/u3WqBpE2vjvyyvyI5k
|
||||
X6zk7S0ljKtt2jny2+00VsBerQJBAJGC1Mg5Oydo5NwD6BiROrPxGo2bpTbu/fhrT8ebHkTz2epl
|
||||
U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ
|
||||
37sJ5QsW+sJyoNde3xH8vdXhzU7eT82D6X/scw9RZz+/6rCJ4p0=
|
||||
-----END RSA PRIVATE KEY-----';
|
||||
$key2 = str_replace(array("\r", "\n", "\r\n"), ' ', $key1);
|
||||
|
||||
$this->assertTrue($rsa->loadKey($key1));
|
||||
$this->assertTrue($rsa->loadKey($key2));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user