update namespaces

This commit is contained in:
Luke Pulverenti 2016-06-30 17:56:14 -04:00
parent 68df03b872
commit edfd04129e
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,31 +161,30 @@ namespace Mono.Security.Cryptography {
throw new CryptographicException ("Invalid blob.", e); throw new CryptographicException ("Invalid blob.", e);
} }
#if INSIDE_CORLIB && MOBILE
RSA rsa = RSA.Create ();
rsa.ImportParameters (rsap);
#else
RSA rsa = null; RSA rsa = null;
try { try
{
rsa = RSA.Create(); rsa = RSA.Create();
rsa.ImportParameters(rsap); rsa.ImportParameters(rsap);
} }
catch (CryptographicException ce) { catch (CryptographicException ce)
{
// this may cause problem when this code is run under // this may cause problem when this code is run under
// the SYSTEM identity on Windows (e.g. ASP.NET). See // the SYSTEM identity on Windows (e.g. ASP.NET). See
// http://bugzilla.ximian.com/show_bug.cgi?id=77559 // http://bugzilla.ximian.com/show_bug.cgi?id=77559
try { 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;
} }
@ -251,31 +245,30 @@ namespace Mono.Security.Cryptography {
throw new CryptographicException ("Invalid blob.", e); throw new CryptographicException ("Invalid blob.", e);
} }
#if INSIDE_CORLIB && MOBILE
DSA dsa = (DSA)DSA.Create ();
dsa.ImportParameters (dsap);
#else
DSA dsa = null; DSA dsa = null;
try { try
{
dsa = (DSA)DSA.Create(); dsa = (DSA)DSA.Create();
dsa.ImportParameters(dsap); dsa.ImportParameters(dsap);
} }
catch (CryptographicException ce) { catch (CryptographicException ce)
{
// this may cause problem when this code is run under // this may cause problem when this code is run under
// the SYSTEM identity on Windows (e.g. ASP.NET). See // the SYSTEM identity on Windows (e.g. ASP.NET). See
// http://bugzilla.ximian.com/show_bug.cgi?id=77559 // http://bugzilla.ximian.com/show_bug.cgi?id=77559
try { 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;
} }
@ -444,16 +437,14 @@ 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 = RSA.Create ();
rsa.ImportParameters (rsap);
#else
RSA rsa = null; RSA rsa = null;
try { try
{
rsa = RSA.Create(); rsa = RSA.Create();
rsa.ImportParameters(rsap); rsa.ImportParameters(rsap);
} }
catch (CryptographicException) { catch (CryptographicException)
{
// this may cause problem when this code is run under // this may cause problem when this code is run under
// the SYSTEM identity on Windows (e.g. ASP.NET). See // the SYSTEM identity on Windows (e.g. ASP.NET). See
// http://bugzilla.ximian.com/show_bug.cgi?id=77559 // http://bugzilla.ximian.com/show_bug.cgi?id=77559
@ -462,7 +453,6 @@ namespace Mono.Security.Cryptography {
rsa = new RSACryptoServiceProvider(csp); rsa = new RSACryptoServiceProvider(csp);
rsa.ImportParameters(rsap); rsa.ImportParameters(rsap);
} }
#endif
return rsa; return rsa;
} }
catch (Exception e) { catch (Exception 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,28 +639,7 @@ namespace Mono.Security.X509 {
} }
SymmetricAlgorithm sa = null; SymmetricAlgorithm sa = null;
#if INSIDE_CORLIB && FULL_AOT_RUNTIME
// we do not want CryptoConfig to bring the whole crypto stack
// 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); sa = SymmetricAlgorithm.Create(algorithm);
#endif
sa.Key = pd.DeriveKey (keyLength); 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) {

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,11 +272,6 @@ namespace Mono.Security.Cryptography {
rsa.ImportParameters (param); rsa.ImportParameters (param);
} }
catch (CryptographicException) { catch (CryptographicException) {
#if MONOTOUCH
// there's no machine-wide store available for iOS so we can drop the dependency on
// CspParameters (which drops other things, like XML key persistance, unless used elsewhere)
throw;
#else
// this may cause problem when this code is run under // this may cause problem when this code is run under
// the SYSTEM identity on Windows (e.g. ASP.NET). See // the SYSTEM identity on Windows (e.g. ASP.NET). See
// http://bugzilla.ximian.com/show_bug.cgi?id=77559 // http://bugzilla.ximian.com/show_bug.cgi?id=77559
@ -289,7 +279,6 @@ namespace Mono.Security.Cryptography {
csp.Flags = CspProviderFlags.UseMachineKeyStore; csp.Flags = CspProviderFlags.UseMachineKeyStore;
rsa = new RSACryptoServiceProvider(csp); rsa = new RSACryptoServiceProvider(csp);
rsa.ImportParameters(param); rsa.ImportParameters(param);
#endif
} }
return rsa; 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,12 +31,10 @@
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
@ -44,11 +42,8 @@ namespace Mono.Security.X509 {
// 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;

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;