internal X509ExtensionCollection (MX.X509Certificate cert) { _list = new ArrayList (cert.Extensions.Count); if (cert.Extensions.Count == 0) return; object[] parameters = new object [2]; foreach (MX.X509Extension ext in cert.Extensions) { bool critical = ext.Critical; string oid = ext.Oid; byte[] raw_data = null; // extension data is embedded in an octet stream (4) ASN1 value = ext.Value; if ((value.Tag == 0x04) && (value.Count > 0)) raw_data = value [0].GetBytes (); parameters [0] = new AsnEncodedData (oid, raw_data); parameters [1] = critical; X509Extension newt = (X509Extension) CryptoConfig.CreateFromName (oid, parameters); if (newt == null) { // not registred in CryptoConfig, using default newt = new X509Extension (oid, raw_data, critical); } _list.Add (newt); } }
internal PublicKey (MSX.X509Certificate certificate) { // note: _key MUSTonly contains the public part of the key bool export_required = true; if (certificate.KeyAlgorithm == rsaOid) { #if !MOONLIGHT // shortcut export/import in the case the private key isn't available RSACryptoServiceProvider rcsp = (certificate.RSA as RSACryptoServiceProvider); if ((rcsp != null) && rcsp.PublicOnly) { _key = certificate.RSA; export_required = false; } else #endif { RSAManaged rsam = (certificate.RSA as RSAManaged); if ((rsam != null) && rsam.PublicOnly) { _key = certificate.RSA; export_required = false; } } if (export_required) { RSAParameters rsap = certificate.RSA.ExportParameters (false); _key = RSA.Create (); (_key as RSA).ImportParameters (rsap); } } else { #if !MOONLIGHT // shortcut export/import in the case the private key isn't available DSACryptoServiceProvider dcsp = (certificate.DSA as DSACryptoServiceProvider); if ((dcsp != null) && dcsp.PublicOnly) { _key = certificate.DSA; export_required = false; } // note: DSAManaged isn't available in Mono.Security due to a bug in Fx 1.x if (export_required) { DSAParameters rsap = certificate.DSA.ExportParameters (false); _key = DSA.Create (); (_key as DSA).ImportParameters (rsap); } #endif } _oid = new Oid (certificate.KeyAlgorithm); _keyValue = new AsnEncodedData (_oid, certificate.PublicKey); _params = new AsnEncodedData (_oid, certificate.KeyAlgorithmParameters); }
internal X509ExtensionCollection (MX.X509Certificate cert) { _list = new ArrayList (cert.Extensions.Count); if (cert.Extensions.Count == 0) return; #if !MOONLIGHT object[] parameters = new object [2]; #endif foreach (MX.X509Extension ext in cert.Extensions) { bool critical = ext.Critical; string oid = ext.Oid; byte[] raw_data = null; // extension data is embedded in an octet stream (4) ASN1 value = ext.Value; if ((value.Tag == 0x04) && (value.Count > 0)) raw_data = value [0].GetBytes (); X509Extension newt = null; #if MOONLIGHT || FULL_AOT_RUNTIME // non-extensible switch (oid) { case "2.5.29.14": newt = new X509SubjectKeyIdentifierExtension (new AsnEncodedData (oid, raw_data), critical); break; case "2.5.29.15": newt = new X509KeyUsageExtension (new AsnEncodedData (oid, raw_data), critical); break; case "2.5.29.19": newt = new X509BasicConstraintsExtension (new AsnEncodedData (oid, raw_data), critical); break; case "2.5.29.37": newt = new X509EnhancedKeyUsageExtension (new AsnEncodedData (oid, raw_data), critical); break; } #else parameters [0] = new AsnEncodedData (oid, raw_data ?? Empty); parameters [1] = critical; newt = (X509Extension) CryptoConfig.CreateFromName (oid, parameters); #endif if (newt == null) { // not registred in CryptoConfig, using default newt = new X509Extension (oid, raw_data ?? Empty, critical); } _list.Add (newt); } }