Merge pull request #1902 from MediaBrowser/dev

update namespaces
This commit is contained in:
Luke 2016-06-30 18:08:14 -04:00 committed by GitHub
commit 55de77ca28
17 changed files with 117 additions and 242 deletions

View File

@ -1,8 +1,8 @@
using MediaBrowser.Model.Logging; using MediaBrowser.Model.Logging;
using Mono.Security.X509;
using System; using System;
using System.Collections; using System.Collections;
using System.Security.Cryptography; using System.Security.Cryptography;
using MediaBrowser.Server.Mono.Security;
namespace MediaBrowser.Server.Mono.Networking namespace MediaBrowser.Server.Mono.Networking
{ {

View File

@ -34,18 +34,13 @@ using System.Collections;
using System.IO; using System.IO;
using System.Text; using System.Text;
namespace Mono.Security { namespace MediaBrowser.Server.Mono.Security {
// References: // References:
// a. ITU ASN.1 standards (free download) // a. ITU ASN.1 standards (free download)
// http://www.itu.int/ITU-T/studygroups/com17/languages/ // http://www.itu.int/ITU-T/studygroups/com17/languages/
#if INSIDE_CORLIB public class ASN1 {
internal
#else
public
#endif
class ASN1 {
private byte m_nTag; private byte m_nTag;
private byte[] m_aValue; private byte[] m_aValue;

View File

@ -30,23 +30,17 @@
// //
using System; using System;
using System.Collections;
using System.Globalization; using System.Globalization;
using System.Security.Cryptography; using System.Security.Cryptography;
using System.Text; using System.Text;
namespace Mono.Security { namespace MediaBrowser.Server.Mono.Security {
// References: // References:
// a. ITU ASN.1 standards (free download) // a. ITU ASN.1 standards (free download)
// http://www.itu.int/ITU-T/studygroups/com17/languages/ // http://www.itu.int/ITU-T/studygroups/com17/languages/
#if INSIDE_CORLIB public static class ASN1Convert {
internal
#else
public
#endif
static class ASN1Convert {
// RFC3280, section 4.2.1.5 // RFC3280, section 4.2.1.5
// CAs conforming to this profile MUST always encode certificate // CAs conforming to this profile MUST always encode certificate
// validity dates through the year 2049 as UTCTime; certificate validity // validity dates through the year 2049 as UTCTime; certificate validity

View File

@ -29,7 +29,7 @@
using System; using System;
namespace Mono.Security namespace MediaBrowser.Server.Mono.Security
{ {
internal sealed class BitConverterLE internal sealed class BitConverterLE
{ {

View File

@ -32,14 +32,9 @@ using System.Globalization;
using System.Security.Cryptography; using System.Security.Cryptography;
using System.Text; using System.Text;
namespace Mono.Security.Cryptography { namespace MediaBrowser.Server.Mono.Security {
#if INSIDE_CORLIB public sealed class CryptoConvert {
internal
#else
public
#endif
sealed class CryptoConvert {
private CryptoConvert () private CryptoConvert ()
{ {
@ -166,32 +161,31 @@ namespace Mono.Security.Cryptography {
throw new CryptographicException ("Invalid blob.", e); throw new CryptographicException ("Invalid blob.", e);
} }
#if INSIDE_CORLIB && MOBILE RSA rsa = null;
RSA rsa = RSA.Create (); try
rsa.ImportParameters (rsap); {
#else rsa = RSA.Create();
RSA rsa = null; rsa.ImportParameters(rsap);
try { }
rsa = RSA.Create (); catch (CryptographicException ce)
rsa.ImportParameters (rsap); {
} // this may cause problem when this code is run under
catch (CryptographicException ce) { // the SYSTEM identity on Windows (e.g. ASP.NET). See
// this may cause problem when this code is run under // http://bugzilla.ximian.com/show_bug.cgi?id=77559
// the SYSTEM identity on Windows (e.g. ASP.NET). See try
// http://bugzilla.ximian.com/show_bug.cgi?id=77559 {
try { CspParameters csp = new CspParameters();
CspParameters csp = new CspParameters (); csp.Flags = CspProviderFlags.UseMachineKeyStore;
csp.Flags = CspProviderFlags.UseMachineKeyStore; rsa = new RSACryptoServiceProvider(csp);
rsa = new RSACryptoServiceProvider (csp); rsa.ImportParameters(rsap);
rsa.ImportParameters (rsap); }
} catch
catch { {
// rethrow original, not the later, exception if this fails // rethrow original, not the later, exception if this fails
throw ce; throw ce;
} }
} }
#endif return rsa;
return rsa;
} }
static public DSA FromCapiPrivateKeyBlobDSA (byte[] blob) static public DSA FromCapiPrivateKeyBlobDSA (byte[] blob)
@ -251,32 +245,31 @@ namespace Mono.Security.Cryptography {
throw new CryptographicException ("Invalid blob.", e); throw new CryptographicException ("Invalid blob.", e);
} }
#if INSIDE_CORLIB && MOBILE DSA dsa = null;
DSA dsa = (DSA)DSA.Create (); try
dsa.ImportParameters (dsap); {
#else dsa = (DSA)DSA.Create();
DSA dsa = null; dsa.ImportParameters(dsap);
try { }
dsa = (DSA)DSA.Create (); catch (CryptographicException ce)
dsa.ImportParameters (dsap); {
} // this may cause problem when this code is run under
catch (CryptographicException ce) { // the SYSTEM identity on Windows (e.g. ASP.NET). See
// this may cause problem when this code is run under // http://bugzilla.ximian.com/show_bug.cgi?id=77559
// the SYSTEM identity on Windows (e.g. ASP.NET). See try
// http://bugzilla.ximian.com/show_bug.cgi?id=77559 {
try { CspParameters csp = new CspParameters();
CspParameters csp = new CspParameters (); csp.Flags = CspProviderFlags.UseMachineKeyStore;
csp.Flags = CspProviderFlags.UseMachineKeyStore; dsa = new DSACryptoServiceProvider(csp);
dsa = new DSACryptoServiceProvider (csp); dsa.ImportParameters(dsap);
dsa.ImportParameters (dsap); }
} catch
catch { {
// rethrow original, not the later, exception if this fails // rethrow original, not the later, exception if this fails
throw ce; throw ce;
} }
} }
#endif return dsa;
return dsa;
} }
static public byte[] ToCapiPrivateKeyBlob (RSA rsa) static public byte[] ToCapiPrivateKeyBlob (RSA rsa)
@ -444,26 +437,23 @@ namespace Mono.Security.Cryptography {
rsap.Modulus = new byte [byteLen]; rsap.Modulus = new byte [byteLen];
Buffer.BlockCopy (blob, pos, rsap.Modulus, 0, byteLen); Buffer.BlockCopy (blob, pos, rsap.Modulus, 0, byteLen);
Array.Reverse (rsap.Modulus); Array.Reverse (rsap.Modulus);
#if INSIDE_CORLIB && MOBILE RSA rsa = null;
RSA rsa = RSA.Create (); try
rsa.ImportParameters (rsap); {
#else rsa = RSA.Create();
RSA rsa = null; rsa.ImportParameters(rsap);
try { }
rsa = RSA.Create (); catch (CryptographicException)
rsa.ImportParameters (rsap); {
} // this may cause problem when this code is run under
catch (CryptographicException) { // the SYSTEM identity on Windows (e.g. ASP.NET). See
// this may cause problem when this code is run under // http://bugzilla.ximian.com/show_bug.cgi?id=77559
// the SYSTEM identity on Windows (e.g. ASP.NET). See CspParameters csp = new CspParameters();
// http://bugzilla.ximian.com/show_bug.cgi?id=77559 csp.Flags = CspProviderFlags.UseMachineKeyStore;
CspParameters csp = new CspParameters (); rsa = new RSACryptoServiceProvider(csp);
csp.Flags = CspProviderFlags.UseMachineKeyStore; rsa.ImportParameters(rsap);
rsa = new RSACryptoServiceProvider (csp); }
rsa.ImportParameters (rsap); return rsa;
}
#endif
return rsa;
} }
catch (Exception e) { catch (Exception e) {
throw new CryptographicException ("Invalid blob.", e); throw new CryptographicException ("Invalid blob.", e);

View File

@ -31,18 +31,13 @@
using System; using System;
using System.Security.Cryptography; using System.Security.Cryptography;
namespace Mono.Security.Cryptography { namespace MediaBrowser.Server.Mono.Security {
// References: // References:
// a. PKCS#1: RSA Cryptography Standard // a. PKCS#1: RSA Cryptography Standard
// http://www.rsasecurity.com/rsalabs/pkcs/pkcs-1/index.html // http://www.rsasecurity.com/rsalabs/pkcs/pkcs-1/index.html
#if INSIDE_CORLIB public sealed class PKCS1 {
internal
#else
public
#endif
sealed class PKCS1 {
private PKCS1 () private PKCS1 ()
{ {

View File

@ -37,17 +37,9 @@ using System.IO;
using System.Security.Cryptography; using System.Security.Cryptography;
using System.Text; using System.Text;
using Mono.Security; namespace MediaBrowser.Server.Mono.Security {
using Mono.Security.Cryptography;
namespace Mono.Security.X509 { public class PKCS5 {
#if INSIDE_CORLIB
internal
#else
public
#endif
class PKCS5 {
public const string pbeWithMD2AndDESCBC = "1.2.840.113549.1.5.1"; public const string pbeWithMD2AndDESCBC = "1.2.840.113549.1.5.1";
public const string pbeWithMD5AndDESCBC = "1.2.840.113549.1.5.3"; public const string pbeWithMD5AndDESCBC = "1.2.840.113549.1.5.3";
@ -59,12 +51,7 @@ namespace Mono.Security.X509 {
public PKCS5 () {} public PKCS5 () {}
} }
#if INSIDE_CORLIB public class PKCS9 {
internal
#else
public
#endif
class PKCS9 {
public const string friendlyName = "1.2.840.113549.1.9.20"; public const string friendlyName = "1.2.840.113549.1.9.20";
public const string localKeyId = "1.2.840.113549.1.9.21"; public const string localKeyId = "1.2.840.113549.1.9.21";
@ -92,12 +79,7 @@ namespace Mono.Security.X509 {
} }
#if INSIDE_CORLIB public class PKCS12 : ICloneable {
internal
#else
public
#endif
class PKCS12 : ICloneable {
public const string pbeWithSHAAnd128BitRC4 = "1.2.840.113549.1.12.1.1"; public const string pbeWithSHAAnd128BitRC4 = "1.2.840.113549.1.12.1.1";
public const string pbeWithSHAAnd40BitRC4 = "1.2.840.113549.1.12.1.2"; public const string pbeWithSHAAnd40BitRC4 = "1.2.840.113549.1.12.1.2";
@ -657,29 +639,8 @@ namespace Mono.Security.X509 {
} }
SymmetricAlgorithm sa = null; SymmetricAlgorithm sa = null;
#if INSIDE_CORLIB && FULL_AOT_RUNTIME sa = SymmetricAlgorithm.Create(algorithm);
// we do not want CryptoConfig to bring the whole crypto stack sa.Key = pd.DeriveKey (keyLength);
// in particular Rijndael which is not supported by CommonCrypto
switch (algorithm) {
case "DES":
sa = DES.Create ();
break;
case "RC2":
sa = RC2.Create ();
break;
case "TripleDES":
sa = TripleDES.Create ();
break;
case "RC4":
sa = RC4.Create ();
break;
default:
throw new NotSupportedException (algorithm);
}
#else
sa = SymmetricAlgorithm.Create (algorithm);
#endif
sa.Key = pd.DeriveKey (keyLength);
// IV required only for block ciphers (not stream ciphers) // IV required only for block ciphers (not stream ciphers)
if (ivLength > 0) { if (ivLength > 0) {
sa.IV = pd.DeriveIV (ivLength); sa.IV = pd.DeriveIV (ivLength);

View File

@ -33,16 +33,9 @@ using System;
using System.Collections; using System.Collections;
using System.Security.Cryptography; using System.Security.Cryptography;
using Mono.Security.X509; namespace MediaBrowser.Server.Mono.Security {
namespace Mono.Security { public sealed class PKCS7 {
#if INSIDE_CORLIB
internal
#else
public
#endif
sealed class PKCS7 {
public class Oid { public class Oid {
// pkcs 1 // pkcs 1

View File

@ -33,14 +33,9 @@ using System;
using System.Collections; using System.Collections;
using System.Security.Cryptography; using System.Security.Cryptography;
using Mono.Security.X509; namespace MediaBrowser.Server.Mono.Security {
namespace Mono.Security.Cryptography { public sealed class PKCS8 {
#if !INSIDE_CORLIB
public
#endif
sealed class PKCS8 {
public enum KeyInfo { public enum KeyInfo {
PrivateKey, PrivateKey,
@ -277,21 +272,15 @@ namespace Mono.Security.Cryptography {
rsa.ImportParameters (param); rsa.ImportParameters (param);
} }
catch (CryptographicException) { catch (CryptographicException) {
#if MONOTOUCH // this may cause problem when this code is run under
// there's no machine-wide store available for iOS so we can drop the dependency on // the SYSTEM identity on Windows (e.g. ASP.NET). See
// CspParameters (which drops other things, like XML key persistance, unless used elsewhere) // http://bugzilla.ximian.com/show_bug.cgi?id=77559
throw; CspParameters csp = new CspParameters();
#else csp.Flags = CspProviderFlags.UseMachineKeyStore;
// this may cause problem when this code is run under rsa = new RSACryptoServiceProvider(csp);
// the SYSTEM identity on Windows (e.g. ASP.NET). See rsa.ImportParameters(param);
// http://bugzilla.ximian.com/show_bug.cgi?id=77559 }
CspParameters csp = new CspParameters (); return rsa;
csp.Flags = CspProviderFlags.UseMachineKeyStore;
rsa = new RSACryptoServiceProvider (csp);
rsa.ImportParameters (param);
#endif
}
return rsa;
} }
/* /*

View File

@ -31,10 +31,7 @@ using System;
using System.Globalization; using System.Globalization;
using System.Text; using System.Text;
using Mono.Security; namespace MediaBrowser.Server.Mono.Security {
using Mono.Security.Cryptography;
namespace Mono.Security.X509 {
// References: // References:
// 1. Information technology - Open Systems Interconnection - The Directory: Models // 1. Information technology - Open Systems Interconnection - The Directory: Models
@ -49,12 +46,7 @@ namespace Mono.Security.X509 {
* *
* RelativeDistinguishedName ::= SET OF AttributeTypeAndValue * RelativeDistinguishedName ::= SET OF AttributeTypeAndValue
*/ */
#if INSIDE_CORLIB public sealed class X501 {
internal
#else
public
#endif
sealed class X501 {
static byte[] countryName = { 0x55, 0x04, 0x06 }; static byte[] countryName = { 0x55, 0x04, 0x06 };
static byte[] organizationName = { 0x55, 0x04, 0x0A }; static byte[] organizationName = { 0x55, 0x04, 0x0A };

View File

@ -33,9 +33,7 @@ using System;
using System.Globalization; using System.Globalization;
using System.Security.Cryptography; using System.Security.Cryptography;
using Mono.Security; namespace MediaBrowser.Server.Mono.Security {
namespace Mono.Security.X509 {
public abstract class X509Builder { public abstract class X509Builder {

View File

@ -31,26 +31,21 @@
using System; using System;
using System.Runtime.Serialization; using System.Runtime.Serialization;
using System.Security.Cryptography; using System.Security.Cryptography;
using SSCX = System.Security.Cryptography.X509Certificates;
using System.Security.Permissions; using System.Security.Permissions;
using System.Text; using System.Text;
using Mono.Security.Cryptography;
namespace Mono.Security.X509 { namespace MediaBrowser.Server.Mono.Security {
// References: // References:
// a. Internet X.509 Public Key Infrastructure Certificate and CRL Profile // a. Internet X.509 Public Key Infrastructure Certificate and CRL Profile
// http://www.ietf.org/rfc/rfc3280.txt // http://www.ietf.org/rfc/rfc3280.txt
// b. ITU ASN.1 standards (free download) // b. ITU ASN.1 standards (free download)
// http://www.itu.int/ITU-T/studygroups/com17/languages/ // http://www.itu.int/ITU-T/studygroups/com17/languages/
#if INSIDE_CORLIB public class X509Certificate : ISerializable
internal class X509Certificate : ISerializable { {
#else
public class X509Certificate : ISerializable {
#endif
private ASN1 decoder; private ASN1 decoder;
private byte[] m_encodedcert; private byte[] m_encodedcert;
private DateTime m_from; private DateTime m_from;

View File

@ -32,7 +32,7 @@
using System; using System;
using System.Security.Cryptography; using System.Security.Cryptography;
namespace Mono.Security.X509 { namespace MediaBrowser.Server.Mono.Security {
// From RFC3280 // From RFC3280
/* /*
* Certificate ::= SEQUENCE { * Certificate ::= SEQUENCE {

View File

@ -31,15 +31,10 @@
using System; using System;
using System.Collections; using System.Collections;
namespace Mono.Security.X509 { namespace MediaBrowser.Server.Mono.Security {
[Serializable] [Serializable]
#if INSIDE_CORLIB public class X509CertificateCollection : CollectionBase, IEnumerable {
internal
#else
public
#endif
class X509CertificateCollection : CollectionBase, IEnumerable {
public X509CertificateCollection () public X509CertificateCollection ()
{ {

View File

@ -31,9 +31,7 @@ using System;
using System.Globalization; using System.Globalization;
using System.Text; using System.Text;
using Mono.Security; namespace MediaBrowser.Server.Mono.Security {
namespace Mono.Security.X509 {
/* /*
* Extension ::= SEQUENCE { * Extension ::= SEQUENCE {
* extnID OBJECT IDENTIFIER, * extnID OBJECT IDENTIFIER,
@ -41,12 +39,7 @@ namespace Mono.Security.X509 {
* extnValue OCTET STRING * extnValue OCTET STRING
* } * }
*/ */
#if INSIDE_CORLIB public class X509Extension {
internal
#else
public
#endif
class X509Extension {
protected string extnOid; protected string extnOid;
protected bool extnCritical; protected bool extnCritical;

View File

@ -32,20 +32,13 @@
using System; using System;
using System.Collections; using System.Collections;
using Mono.Security; namespace MediaBrowser.Server.Mono.Security {
namespace Mono.Security.X509 {
/* /*
* Extensions ::= SEQUENCE SIZE (1..MAX) OF Extension * Extensions ::= SEQUENCE SIZE (1..MAX) OF Extension
* *
* Note: 1..MAX -> There shouldn't be 0 Extensions in the ASN1 structure * Note: 1..MAX -> There shouldn't be 0 Extensions in the ASN1 structure
*/ */
#if INSIDE_CORLIB public sealed class X509ExtensionCollection : CollectionBase, IEnumerable {
internal
#else
public
#endif
sealed class X509ExtensionCollection : CollectionBase, IEnumerable {
private bool readOnly; private bool readOnly;

View File

@ -28,12 +28,9 @@
// //
using System; using System;
using System.Globalization;
using System.Text; using System.Text;
using Mono.Security; namespace MediaBrowser.Server.Mono.Security {
namespace Mono.Security.X509 {
// References: // References:
// 1. Information technology - Open Systems Interconnection - The Directory: Selected attribute types // 1. Information technology - Open Systems Interconnection - The Directory: Selected attribute types
@ -55,12 +52,7 @@ namespace Mono.Security.X509 {
* *
* AttributeValue ::= ANY DEFINED BY AttributeType * AttributeValue ::= ANY DEFINED BY AttributeType
*/ */
#if INSIDE_CORLIB public class X520 {
internal
#else
public
#endif
class X520 {
public abstract class AttributeTypeAndValue { public abstract class AttributeTypeAndValue {
private string oid; private string oid;