mirror of
https://github.com/phpseclib/phpseclib.git
synced 2025-02-05 05:18:28 +00:00
Merge branch '3.0'
This commit is contained in:
commit
e2f9d10660
@ -523,11 +523,13 @@ abstract class PKCS8 extends PKCS
|
||||
$key = [
|
||||
'version' => 'v1',
|
||||
'privateKeyAlgorithm' => [
|
||||
'algorithm' => is_string(static::OID_NAME) ? static::OID_NAME : $oid,
|
||||
'parameters' => $params
|
||||
'algorithm' => is_string(static::OID_NAME) ? static::OID_NAME : $oid
|
||||
],
|
||||
'privateKey' => $key
|
||||
];
|
||||
if ($oid != 'id-Ed25519' && $oid != 'id-Ed448') {
|
||||
$key['privateKeyAlgorithm']['parameters'] = $params;
|
||||
}
|
||||
if (!empty($attr)) {
|
||||
$key['attributes'] = $attr;
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ abstract class PKCS8 extends Progenitor
|
||||
$params = ASN1::encodeDER($params, Maps\DHParameter::MAP);
|
||||
$params = new ASN1\Element($params);
|
||||
$key = ASN1::encodeDER($privateKey, ['type' => ASN1::TYPE_INTEGER]);
|
||||
return self::wrapPrivateKey($key, [], $params, $password, $options);
|
||||
return self::wrapPrivateKey($key, [], $params, $password, null, '', $options);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -226,8 +226,7 @@ abstract class PKCS8 extends Progenitor
|
||||
[],
|
||||
null,
|
||||
$password,
|
||||
$curve instanceof Ed25519 ? 'id-Ed25519' : 'id-Ed448',
|
||||
"\0" . $curve->encodePoint($publicKey)
|
||||
$curve instanceof Ed25519 ? 'id-Ed25519' : 'id-Ed448'
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -271,9 +271,11 @@ MCwwBwYDK2VwBQADIQAZv0QJaYTN/oVBusFn3DuWyFCGqjC2tssMXDitcDFm4Q==
|
||||
public function testEd25519PrivateKey()
|
||||
{
|
||||
// without public key (public key should be derived)
|
||||
$key = PublicKeyLoader::load('-----BEGIN PRIVATE KEY-----
|
||||
$expected = '-----BEGIN PRIVATE KEY-----
|
||||
MC4CAQAwBQYDK2VwBCIEINTuctv5E1hK1bbY8fdp+K06/nwoy/HU++CXqI9EdVhC
|
||||
-----END PRIVATE KEY-----');
|
||||
-----END PRIVATE KEY-----';
|
||||
$key = PublicKeyLoader::load($expected);
|
||||
$this->assertSameNL($expected, $key->toString('PKCS8'));
|
||||
$this->assertSameNL('Ed25519', $key->getCurve());
|
||||
$this->assertSameNL('Ed25519', $key->getPublicKey()->getCurve());
|
||||
|
||||
@ -289,14 +291,10 @@ Z9w7lshQhqowtrbLDFw4rXAxZuE=
|
||||
// the above key not only omits NULL - it also includes a
|
||||
// unstructuredName attribute with a value of "Curdle Chairs"
|
||||
// that the following key does not have
|
||||
$expected = '-----BEGIN PRIVATE KEY-----
|
||||
$key = PublicKeyLoader::load('-----BEGIN PRIVATE KEY-----
|
||||
MFMCAQEwBwYDK2VwBQAEIgQg1O5y2/kTWErVttjx92n4rTr+fCjL8dT74Jeoj0R1
|
||||
WEKBIQAZv0QJaYTN/oVBusFn3DuWyFCGqjC2tssMXDitcDFm4Q==
|
||||
-----END PRIVATE KEY-----';
|
||||
$this->assertSameNL($expected, $key->toString('PKCS8'));
|
||||
|
||||
$expected = EC::createKey('Ed25519')->toString('PKCS8');
|
||||
$key = PublicKeyLoader::load($expected);
|
||||
-----END PRIVATE KEY-----');
|
||||
$this->assertSameNL('Ed25519', $key->getCurve());
|
||||
$this->assertSameNL('Ed25519', $key->getPublicKey()->getCurve());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user