Imported Upstream version 5.18.0.142

Former-commit-id: 7467d4b717762eeaf652d77f1486dd11ffb1ff1f
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2018-10-09 08:20:59 +00:00
parent e52655b4dc
commit 0abdbe5a7d
1547 changed files with 93792 additions and 47893 deletions

View File

@ -741,22 +741,26 @@ namespace Mono.Security.X509 {
private void AddPrivateKey (PKCS8.PrivateKeyInfo pki)
{
byte[] privateKey = pki.PrivateKey;
switch (privateKey [0]) {
case 0x02:
try {
switch (pki.Algorithm) {
case X509Certificate.OID_RSA:
_keyBags.Add (PKCS8.PrivateKeyInfo.DecodeRSA (privateKey));
break;
case X509Certificate.OID_DSA:
bool found;
DSAParameters p = GetExistingParameters (out found);
if (found) {
_keyBags.Add (PKCS8.PrivateKeyInfo.DecodeDSA (privateKey, p));
}
break;
case 0x30:
_keyBags.Add (PKCS8.PrivateKeyInfo.DecodeRSA (privateKey));
break;
case X509Certificate.OID_ECC: // TODO
default:
Array.Clear (privateKey, 0, privateKey.Length);
throw new CryptographicException ("Unknown private key format");
}
}
finally {
Array.Clear (privateKey, 0, privateKey.Length);
}
Array.Clear (privateKey, 0, privateKey.Length);
}
private void ReadSafeBag (ASN1 safeBag)