Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/mcs/class
diff options
context:
space:
mode:
Diffstat (limited to 'mcs/class')
-rw-r--r--mcs/class/Mono.Security/Mono.Security.Cryptography/RSAManaged.cs5
-rw-r--r--mcs/class/corlib/Makefile2
-rw-r--r--mcs/class/corlib/ReferenceSources/SharedStatics.cs22
-rw-r--r--mcs/class/corlib/System.Security.Cryptography/AsymmetricAlgorithm.cs119
-rw-r--r--mcs/class/corlib/System.Security.Cryptography/CryptoConfig.cs6
-rwxr-xr-xmcs/class/corlib/System.Security.Cryptography/CryptoConfig.fullaot.cs5
-rw-r--r--mcs/class/corlib/System.Security.Cryptography/CspParameters.cs127
-rw-r--r--mcs/class/corlib/System.Security.Cryptography/CspProviderFlags.cs49
-rw-r--r--mcs/class/corlib/System.Security.Cryptography/DES.cs188
-rw-r--r--mcs/class/corlib/System.Security.Cryptography/DESCryptoServiceProvider.cs28
-rw-r--r--mcs/class/corlib/System.Security.Cryptography/DSA.cs182
-rw-r--r--mcs/class/corlib/System.Security.Cryptography/DSASignatureDeformatter.cs85
-rw-r--r--mcs/class/corlib/System.Security.Cryptography/DSASignatureFormatter.cs85
-rw-r--r--mcs/class/corlib/System.Security.Cryptography/RSA.cs176
-rw-r--r--mcs/class/corlib/System.Security.Cryptography/RSACryptoServiceProvider.cs23
-rw-r--r--mcs/class/corlib/System.Security.Cryptography/RSAOAEPKeyExchangeDeformatter.cs75
-rw-r--r--mcs/class/corlib/System.Security.Cryptography/RSAOAEPKeyExchangeFormatter.cs90
-rw-r--r--mcs/class/corlib/System.Security.Cryptography/RSAPKCS1KeyExchangeDeformatter.cs81
-rw-r--r--mcs/class/corlib/System.Security.Cryptography/RSAPKCS1KeyExchangeFormatter.cs94
-rw-r--r--mcs/class/corlib/System.Security.Cryptography/RSAParameters.cs53
-rw-r--r--mcs/class/corlib/System.Security.Cryptography/TripleDES.cs138
-rw-r--r--mcs/class/corlib/System.Security.Cryptography/TripleDESCryptoServiceProvider.cs28
-rw-r--r--mcs/class/corlib/System.Security/SecurityElement.cs67
-rw-r--r--mcs/class/corlib/Test/System.Security.Cryptography/CryptoStreamTest.cs13
-rw-r--r--mcs/class/corlib/Test/System.Security.Cryptography/CspParametersTest.cs (renamed from mcs/class/corlib/System.Security.Cryptography/DSAParameters.cs)57
-rw-r--r--mcs/class/corlib/Test/System.Security.Cryptography/DSACryptoServiceProviderTest.cs5
-rw-r--r--mcs/class/corlib/Test/System.Security.Cryptography/RSACryptoServiceProviderTest.cs14
-rw-r--r--mcs/class/corlib/Test/System.Security.Cryptography/RSAPKCS1KeyExchangeDeformatterTest.cs2
-rw-r--r--mcs/class/corlib/corlib.dll.sources35
-rw-r--r--mcs/class/corlib/corlib_test.dll.sources1
30 files changed, 190 insertions, 1665 deletions
diff --git a/mcs/class/Mono.Security/Mono.Security.Cryptography/RSAManaged.cs b/mcs/class/Mono.Security/Mono.Security.Cryptography/RSAManaged.cs
index 5d798ac5d22..7240fa54809 100644
--- a/mcs/class/Mono.Security/Mono.Security.Cryptography/RSAManaged.cs
+++ b/mcs/class/Mono.Security/Mono.Security.Cryptography/RSAManaged.cs
@@ -145,7 +145,10 @@ namespace Mono.Security.Cryptography {
// overrides from RSA class
public override int KeySize {
- get {
+ get {
+ if (m_disposed)
+ throw new ObjectDisposedException (Locale.GetText ("Keypair was disposed"));
+
// in case keypair hasn't been (yet) generated
if (keypairGenerated) {
int ks = n.BitCount ();
diff --git a/mcs/class/corlib/Makefile b/mcs/class/corlib/Makefile
index ba3274cdc9d..9647ea80508 100644
--- a/mcs/class/corlib/Makefile
+++ b/mcs/class/corlib/Makefile
@@ -36,7 +36,7 @@ RESOURCE_FILES = \
resources/collation.cjkKO.bin \
resources/collation.cjkKOlv2.bin
-REFERENCE_SOURCES_FLAGS = -d:FEATURE_PAL,GENERICS_WORK,FEATURE_LIST_PREDICATES,FEATURE_SERIALIZATION,FEATURE_ASCII,FEATURE_LATIN1,FEATURE_UTF7,FEATURE_UTF32,MONO_HYBRID_ENCODING_SUPPORT,FEATURE_ASYNC_IO,NEW_EXPERIMENTAL_ASYNC_IO,FEATURE_UTF32,FEATURE_EXCEPTIONDISPATCHINFO,FEATURE_CORRUPTING_EXCEPTIONS,FEATURE_EXCEPTION_NOTIFICATIONS,FEATURE_STRONGNAME_MIGRATION,FEATURE_USE_LCID,FEATURE_FUSION,FEATURE_CRYPTO
+REFERENCE_SOURCES_FLAGS = -d:FEATURE_PAL,GENERICS_WORK,FEATURE_LIST_PREDICATES,FEATURE_SERIALIZATION,FEATURE_ASCII,FEATURE_LATIN1,FEATURE_UTF7,FEATURE_UTF32,MONO_HYBRID_ENCODING_SUPPORT,FEATURE_ASYNC_IO,NEW_EXPERIMENTAL_ASYNC_IO,FEATURE_UTF32,FEATURE_EXCEPTIONDISPATCHINFO,FEATURE_CORRUPTING_EXCEPTIONS,FEATURE_EXCEPTION_NOTIFICATIONS,FEATURE_STRONGNAME_MIGRATION,FEATURE_USE_LCID,FEATURE_FUSION,FEATURE_CRYPTO,FEATURE_X509_SECURESTRINGS
MOBILE_STATIC := $(filter mobile_static monotouch monotouch_runtime, $(PROFILE))
diff --git a/mcs/class/corlib/ReferenceSources/SharedStatics.cs b/mcs/class/corlib/ReferenceSources/SharedStatics.cs
new file mode 100644
index 00000000000..01252ccc2f1
--- /dev/null
+++ b/mcs/class/corlib/ReferenceSources/SharedStatics.cs
@@ -0,0 +1,22 @@
+using System.Threading;
+using StringMaker = System.Security.Util.Tokenizer.StringMaker;
+
+namespace System
+{
+ static class SharedStatics
+ {
+ static StringMaker shared;
+ static public StringMaker GetSharedStringMaker ()
+ {
+ if (shared == null)
+ Interlocked.CompareExchange (ref shared, new StringMaker (), null);
+
+ return shared;
+ }
+
+ static public void ReleaseSharedStringMaker (ref StringMaker maker)
+ {
+
+ }
+ }
+} \ No newline at end of file
diff --git a/mcs/class/corlib/System.Security.Cryptography/AsymmetricAlgorithm.cs b/mcs/class/corlib/System.Security.Cryptography/AsymmetricAlgorithm.cs
deleted file mode 100644
index 5f1591d4854..00000000000
--- a/mcs/class/corlib/System.Security.Cryptography/AsymmetricAlgorithm.cs
+++ /dev/null
@@ -1,119 +0,0 @@
-//
-// System.Security.Cryptography.AsymmetricAlgorithm Class implementation
-//
-// Authors:
-// Thomas Neidhart (tome@sbox.tugraz.at)
-// Sebastien Pouliot (sebastien@ximian.com)
-//
-// Portions (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com)
-// Copyright (C) 2004-2005, 2008 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System.Globalization;
-using System.Runtime.InteropServices;
-
-namespace System.Security.Cryptography {
-
- [ComVisible (true)]
- public abstract class AsymmetricAlgorithm : IDisposable {
-
- protected int KeySizeValue;
- protected KeySizes[] LegalKeySizesValue;
-
- protected AsymmetricAlgorithm ()
- {
- }
-
- public abstract string KeyExchangeAlgorithm {
- get;
- }
-
- public virtual int KeySize {
- get { return this.KeySizeValue; }
- set {
- if (!KeySizes.IsLegalKeySize (this.LegalKeySizesValue, value))
- throw new CryptographicException (Locale.GetText ("Key size not supported by algorithm."));
-
- this.KeySizeValue = value;
- }
- }
-
- public virtual KeySizes[] LegalKeySizes {
- get { return this.LegalKeySizesValue; }
- }
-
- public abstract string SignatureAlgorithm {
- get;
- }
-
- public void Dispose ()
- {
- Dispose (true);
- GC.SuppressFinalize (this); // Finalization is now unnecessary
- }
-
- public void Clear ()
- {
- Dispose (false);
- }
-
- protected virtual void Dispose (bool disposing)
- {
- }
- public abstract void FromXmlString (string xmlString);
-
- public abstract string ToXmlString (bool includePrivateParameters);
-
- public static AsymmetricAlgorithm Create ()
- {
-#if FULL_AOT_RUNTIME
- return new RSACryptoServiceProvider ();
-#else
- return Create ("System.Security.Cryptography.AsymmetricAlgorithm");
-#endif
- }
-
- public static AsymmetricAlgorithm Create (string algName)
- {
- return (AsymmetricAlgorithm) CryptoConfig.CreateFromName (algName);
- }
-
- // parsing helper shared between DSA and RSA
- internal static byte [] GetNamedParam (string xml, string param)
- {
- string start_element = "<" + param + ">";
- int start = xml.IndexOf (start_element);
- if (start == -1)
- return null;
-
- string end_element = "</" + param + ">";
- int end = xml.IndexOf (end_element);
- if ((end == -1) || (end <= start))
- return null;
-
- start += start_element.Length;
-
- string base64 = xml.Substring (start, end - start);
- return Convert.FromBase64String (base64);
- }
- }
-}
diff --git a/mcs/class/corlib/System.Security.Cryptography/CryptoConfig.cs b/mcs/class/corlib/System.Security.Cryptography/CryptoConfig.cs
index 74e4d73a1f7..d580e4829a6 100644
--- a/mcs/class/corlib/System.Security.Cryptography/CryptoConfig.cs
+++ b/mcs/class/corlib/System.Security.Cryptography/CryptoConfig.cs
@@ -41,6 +41,7 @@ using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using System.Text;
+using System.Security.Cryptography.X509Certificates;
using Mono.Xml;
@@ -511,6 +512,11 @@ public partial class CryptoConfig {
}
}
+ internal static string MapNameToOID (string name, OidGroup oidGroup)
+ {
+ return MapNameToOID (name);
+ }
+
public static string MapNameToOID (string name)
{
if (name == null)
diff --git a/mcs/class/corlib/System.Security.Cryptography/CryptoConfig.fullaot.cs b/mcs/class/corlib/System.Security.Cryptography/CryptoConfig.fullaot.cs
index 32bf463ec4d..b9cc49f1464 100755
--- a/mcs/class/corlib/System.Security.Cryptography/CryptoConfig.fullaot.cs
+++ b/mcs/class/corlib/System.Security.Cryptography/CryptoConfig.fullaot.cs
@@ -185,6 +185,11 @@ namespace System.Security.Cryptography {
}
}
+ internal static string MapNameToOID (string name, object arg)
+ {
+ return MapNameToOID (name);
+ }
+
public static string MapNameToOID (string name)
{
if (name == null)
diff --git a/mcs/class/corlib/System.Security.Cryptography/CspParameters.cs b/mcs/class/corlib/System.Security.Cryptography/CspParameters.cs
deleted file mode 100644
index 0df95669944..00000000000
--- a/mcs/class/corlib/System.Security.Cryptography/CspParameters.cs
+++ /dev/null
@@ -1,127 +0,0 @@
-//
-// System.Security.Cryptography.CspParameters.cs
-//
-// Authors:
-// Thomas Neidhart (tome@sbox.tugraz.at)
-// Sebastien Pouliot <sebastien@ximian.com>
-//
-// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System.Runtime.InteropServices;
-using System.Security.AccessControl;
-
-namespace System.Security.Cryptography {
-
- [ComVisible (true)]
- public sealed class CspParameters {
-
- private CspProviderFlags _Flags;
-
- public CspParameters ()
- : this (1)
- {
- }
-
- public CspParameters (int dwTypeIn)
- : this (dwTypeIn, null)
- {
- }
-
- public CspParameters (int dwTypeIn, string strProviderNameIn)
- : this (dwTypeIn, null, null)
- {
- }
-
- public CspParameters (int dwTypeIn, string strProviderNameIn, string strContainerNameIn)
- {
- ProviderType = dwTypeIn;
- ProviderName = strProviderNameIn;
- KeyContainerName = strContainerNameIn;
-
- // not defined in specs, only tested from M$ impl
- KeyNumber = -1;
- }
-
- public string KeyContainerName;
-
- public int KeyNumber;
-
- public string ProviderName;
-
- public int ProviderType;
-
- public CspProviderFlags Flags {
- get { return _Flags; }
- set { _Flags = value; }
- }
-
- private SecureString _password;
- private IntPtr _windowHandle;
-
- public CspParameters (int providerType, string providerName, string keyContainerName,
- CryptoKeySecurity cryptoKeySecurity, IntPtr parentWindowHandle)
- : this (providerType, providerName, keyContainerName)
- {
- if (cryptoKeySecurity != null)
- CryptoKeySecurity = cryptoKeySecurity;
- _windowHandle = parentWindowHandle;
- }
-
- public CspParameters (int providerType, string providerName, string keyContainerName,
- CryptoKeySecurity cryptoKeySecurity, SecureString keyPassword)
- : this (providerType, providerName, keyContainerName)
- {
- if (cryptoKeySecurity != null)
- CryptoKeySecurity = cryptoKeySecurity;
- _password = keyPassword;
- }
-
- internal CspParameters(CspParameters parameters)
- : this(parameters.ProviderType, parameters.ProviderName, parameters.KeyContainerName)
- {
- if (parameters.CryptoKeySecurity != null)
- CryptoKeySecurity = parameters.CryptoKeySecurity;
-
- _Flags = parameters.Flags;
- KeyNumber = parameters.KeyNumber;
- _password = parameters.KeyPassword;
- _windowHandle = parameters.ParentWindowHandle;
- }
-
- [MonoTODO ("access control isn't implemented")]
- public CryptoKeySecurity CryptoKeySecurity {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
- }
-
- public SecureString KeyPassword {
- get { return _password; }
- set { _password = value; }
- }
-
- public IntPtr ParentWindowHandle {
- get { return _windowHandle; }
- set { _windowHandle = value; }
- }
- }
-}
diff --git a/mcs/class/corlib/System.Security.Cryptography/CspProviderFlags.cs b/mcs/class/corlib/System.Security.Cryptography/CspProviderFlags.cs
deleted file mode 100644
index bb40c751b45..00000000000
--- a/mcs/class/corlib/System.Security.Cryptography/CspProviderFlags.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-//
-// System.Security.Cryptography CspProviderFlags enumeration
-//
-// Authors:
-// Thomas Neidhart <tome@sbox.tugraz.at>
-// Sebastien Pouliot <sebastien@ximian.com>
-//
-// Copyright (C) 2004-2005, 2011 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System.Runtime.InteropServices;
-
-namespace System.Security.Cryptography {
-
- [Flags]
- [Serializable]
- [ComVisible (true)]
- public enum CspProviderFlags {
- UseMachineKeyStore = 1,
- UseDefaultKeyContainer = 2,
- UseExistingKey = 8,
- NoFlags = 0,
- NoPrompt = 64,
- UseArchivableKey = 16,
- UseNonExportableKey = 4,
- UseUserProtectedKey = 32,
- CreateEphemeralKey = 128
- }
-}
-
diff --git a/mcs/class/corlib/System.Security.Cryptography/DES.cs b/mcs/class/corlib/System.Security.Cryptography/DES.cs
deleted file mode 100644
index 7c042cd9ddd..00000000000
--- a/mcs/class/corlib/System.Security.Cryptography/DES.cs
+++ /dev/null
@@ -1,188 +0,0 @@
-//
-// System.Security.Cryptography.DES.cs
-//
-// Author:
-// Sergey Chaban (serge@wildwestsoftware.com)
-// Sebastien Pouliot <sebastien@ximian.com>
-//
-// Portions (C) 2002 Motus Technologies Inc. (http://www.motus.com)
-// Copyright (C) 2004-2006 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System.Globalization;
-using System.Runtime.InteropServices;
-
-// References:
-// a. FIPS PUB 46-3: Data Encryption Standard
-// http://csrc.nist.gov/publications/fips/fips46-3/fips46-3.pdf
-
-namespace System.Security.Cryptography {
-
-[ComVisible (true)]
-public abstract class DES : SymmetricAlgorithm {
-
- private const int keySizeByte = 8;
-
- protected DES ()
- {
- KeySizeValue = 64;
- BlockSizeValue = 64;
- FeedbackSizeValue = 8;
-
- LegalKeySizesValue = new KeySizes[1];
- LegalKeySizesValue[0] = new KeySizes(64, 64, 0);
-
- LegalBlockSizesValue = new KeySizes[1];
- LegalBlockSizesValue[0] = new KeySizes(64, 64, 0);
- }
-
- public static new DES Create ()
- {
-#if FULL_AOT_RUNTIME
- return new System.Security.Cryptography.DESCryptoServiceProvider ();
-#else
- return Create ("System.Security.Cryptography.DES");
-#endif
- }
-
- public static new DES Create (string algName)
- {
- return (DES) CryptoConfig.CreateFromName (algName);
- }
-
-
- // Ek(Ek(m)) = m
- internal static readonly byte[,] weakKeys = {
- { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 },
- { 0x1F, 0x1F, 0x1F, 0x1F, 0x0F, 0x0F, 0x0F, 0x0F },
- { 0xE1, 0xE1, 0xE1, 0xE1, 0xF1, 0xF1, 0xF1, 0xF1 },
- { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
- };
-
- // Ek1(Ek2(m)) = m
- internal static readonly byte[,] semiWeakKeys = {
- { 0x00, 0x1E, 0x00, 0x1E, 0x00, 0x0E, 0x00, 0x0E }, // map to packed key 011F011F010E010E
- { 0x00, 0xE0, 0x00, 0xE0, 0x00, 0xF0, 0x00, 0xF0 }, // map to packed key 01E001E001F101F1
- { 0x00, 0xFE, 0x00, 0xFE, 0x00, 0xFE, 0x00, 0xFE }, // map to packed key 01FE01FE01FE01FE
- { 0x1E, 0x00, 0x1E, 0x00, 0x0E, 0x00, 0x0E, 0x00 }, // map to packed key 1F011F010E010E01
- { 0x1E, 0xE0, 0x1E, 0xE0, 0x0E, 0xF0, 0x0E, 0xF0 }, // map to packed key 1FE01FE00EF10EF1
- { 0x1E, 0xFE, 0x1E, 0xFE, 0x0E, 0xFE, 0x0E, 0xFE }, // map to packed key 1FFE1FFE0EFE0EFE
- { 0xE0, 0x00, 0xE0, 0x00, 0xF0, 0x00, 0xF0, 0x00 }, // map to packed key E001E001F101F101
- { 0xE0, 0x1E, 0xE0, 0x1E, 0xF0, 0x0E, 0xF0, 0x0E }, // map to packed key E01FE01FF10EF10E
- { 0xE0, 0xFE, 0xE0, 0xFE, 0xF0, 0xFE, 0xF0, 0xFE }, // map to packed key E0FEE0FEF1FEF1FE
- { 0xFE, 0x00, 0xFE, 0x00, 0xFE, 0x00, 0xFE, 0x00 }, // map to packed key FE01FE01FE01FE01
- { 0xFE, 0x1E, 0xFE, 0x1E, 0xFE, 0x0E, 0xFE, 0x0E }, // map to packed key FE1FFE1FFE0EFE0E
- { 0xFE, 0xE0, 0xFE, 0xE0, 0xFE, 0xF0, 0xFE, 0xF0 }, // map to packed key FEE0FEE0FEF1FEF1
- };
-
- public static bool IsWeakKey (byte[] rgbKey)
- {
- if (rgbKey == null)
- throw new CryptographicException (Locale.GetText ("Null Key"));
- if (rgbKey.Length != keySizeByte)
- throw new CryptographicException (Locale.GetText ("Wrong Key Length"));
-
- // (fast) pre-check with "weak bytes"
- for (int i=0; i < rgbKey.Length; i++) {
- switch (rgbKey [i] | 0x11) {
- case 0x11:
- case 0x1F:
- case 0xF1:
- case 0xFF:
- break;
- default:
- return false;
- }
- }
-
- // compare with known weak keys
- for (int i=0; i < (weakKeys.Length >> 3); i++) {
- int j = 0;
- for (; j < rgbKey.Length; j++) {
- if ((rgbKey [j] ^ weakKeys [i,j]) > 1)
- break;
- }
- if (j==8)
- return true;
- }
- return false;
- }
-
- public static bool IsSemiWeakKey (byte[] rgbKey)
- {
- if (rgbKey == null)
- throw new CryptographicException (Locale.GetText ("Null Key"));
- if (rgbKey.Length != keySizeByte)
- throw new CryptographicException (Locale.GetText ("Wrong Key Length"));
-
- // (fast) pre-check with "weak bytes"
- for (int i=0; i < rgbKey.Length; i++) {
- switch (rgbKey [i] | 0x11) {
- case 0x11:
- case 0x1F:
- case 0xF1:
- case 0xFF:
- break;
- default:
- return false;
- }
- }
-
- // compare with known weak keys
- for (int i=0; i < (semiWeakKeys.Length >> 3); i++) {
- int j = 0;
- for (; j < rgbKey.Length; j++) {
- if ((rgbKey [j] ^ semiWeakKeys [i,j]) > 1)
- break;
- }
- if (j==8)
- return true;
- }
- return false;
- }
-
- public override byte[] Key {
- get {
- if (KeyValue == null) {
- // GenerateKey is responsible to return a valid key
- // e.g. no weak or semi-weak keys
- GenerateKey ();
- }
- return (byte[]) KeyValue.Clone ();
- }
- set {
- if (value == null)
- throw new ArgumentNullException ("Key");
- if (value.Length != keySizeByte)
- throw new ArgumentException (Locale.GetText ("Wrong Key Length"));
- if (IsWeakKey (value))
- throw new CryptographicException (Locale.GetText ("Weak Key"));
- if (IsSemiWeakKey (value))
- throw new CryptographicException (Locale.GetText ("Semi Weak Key"));
-
- KeyValue = (byte[]) value.Clone ();
- }
- }
-}
-
-}
-
diff --git a/mcs/class/corlib/System.Security.Cryptography/DESCryptoServiceProvider.cs b/mcs/class/corlib/System.Security.Cryptography/DESCryptoServiceProvider.cs
index 452b278f9c1..00248cd8c3e 100644
--- a/mcs/class/corlib/System.Security.Cryptography/DESCryptoServiceProvider.cs
+++ b/mcs/class/corlib/System.Security.Cryptography/DESCryptoServiceProvider.cs
@@ -655,34 +655,6 @@ namespace System.Security.Cryptography {
key = KeyBuilder.Key (DESTransform.KEY_BYTE_SIZE);
return key;
}
- }
-
- [ComVisible (true)]
- public sealed class DESCryptoServiceProvider : DES {
-
- public DESCryptoServiceProvider ()
- {
- }
-
- public override ICryptoTransform CreateDecryptor (byte[] rgbKey, byte[] rgbIV)
- {
- return new DESTransform (this, false, rgbKey, rgbIV);
- }
-
- public override ICryptoTransform CreateEncryptor (byte[] rgbKey, byte[] rgbIV)
- {
- return new DESTransform (this, true, rgbKey, rgbIV);
- }
-
- public override void GenerateIV ()
- {
- IVValue = KeyBuilder.IV (DESTransform.BLOCK_BYTE_SIZE);
- }
-
- public override void GenerateKey ()
- {
- KeyValue = DESTransform.GetStrongKey ();
- }
}
}
diff --git a/mcs/class/corlib/System.Security.Cryptography/DSA.cs b/mcs/class/corlib/System.Security.Cryptography/DSA.cs
deleted file mode 100644
index 73abc4d4c4f..00000000000
--- a/mcs/class/corlib/System.Security.Cryptography/DSA.cs
+++ /dev/null
@@ -1,182 +0,0 @@
-//
-// System.Security.Cryptography.DSA.cs class implementation
-//
-// Authors:
-// Thomas Neidhart (tome@sbox.tugraz.at)
-// Sebastien Pouliot (sebastien@ximian.com)
-//
-// Portions (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com)
-// Copyright (C) 2004-2005, 2008 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System.Globalization;
-using System.Runtime.InteropServices;
-using System.Text;
-
-using Mono.Xml;
-using Mono.Security;
-
-// References:
-// a. FIPS PUB 186-2: Digital Signature Standard (DSS)
-// http://csrc.nist.gov/publications/fips/fips186-2/fips186-2-change1.pdf
-
-namespace System.Security.Cryptography {
-
- [ComVisible (true)]
- public abstract class DSA : AsymmetricAlgorithm {
-
- // Constructor visibility fixed in Fx 2.0
- protected DSA ()
- {
- }
-
- public static new DSA Create ()
- {
-#if FULL_AOT_RUNTIME
- return new System.Security.Cryptography.DSACryptoServiceProvider ();
-#else
- return Create ("System.Security.Cryptography.DSA");
-#endif
- }
-
- public static new DSA Create (string algName)
- {
- return (DSA) CryptoConfig.CreateFromName (algName);
- }
-
- public abstract byte[] CreateSignature (byte[] rgbHash);
-
- public abstract DSAParameters ExportParameters (bool includePrivateParameters);
-
- internal void ZeroizePrivateKey (DSAParameters parameters)
- {
- if (parameters.X != null)
- Array.Clear (parameters.X, 0, parameters.X.Length);
- }
-
- public override void FromXmlString (string xmlString)
- {
- if (xmlString == null)
- throw new ArgumentNullException ("xmlString");
-
- DSAParameters dsaParams = new DSAParameters ();
- try {
- dsaParams.P = GetNamedParam (xmlString, "P");
- dsaParams.Q = GetNamedParam (xmlString, "Q");
- dsaParams.G = GetNamedParam (xmlString, "G");
- dsaParams.J = GetNamedParam (xmlString, "J");
- dsaParams.Y = GetNamedParam (xmlString, "Y");
- dsaParams.X = GetNamedParam (xmlString, "X");
- dsaParams.Seed = GetNamedParam (xmlString, "Seed");
- byte[] counter = GetNamedParam (xmlString, "PgenCounter");
- if (counter != null) {
- byte[] counter4b = new byte [4]; // always 4 bytes
- Buffer.BlockCopy (counter, 0, counter4b, 0, counter.Length);
- dsaParams.Counter = BitConverterLE.ToInt32 (counter4b, 0);
- }
- ImportParameters (dsaParams);
- }
- catch {
- ZeroizePrivateKey (dsaParams);
- throw;
- }
- finally {
- ZeroizePrivateKey (dsaParams);
- }
- }
-
- public abstract void ImportParameters (DSAParameters parameters);
-
- // note: using SecurityElement.ToXml wouldn't generate the same string as the MS implementation
- public override string ToXmlString (bool includePrivateParameters)
- {
- StringBuilder sb = new StringBuilder ();
- DSAParameters dsaParams = ExportParameters (includePrivateParameters);
- try {
- sb.Append ("<DSAKeyValue>");
-
- sb.Append ("<P>");
- sb.Append (Convert.ToBase64String (dsaParams.P));
- sb.Append ("</P>");
-
- sb.Append ("<Q>");
- sb.Append (Convert.ToBase64String (dsaParams.Q));
- sb.Append ("</Q>");
-
- sb.Append ("<G>");
- sb.Append (Convert.ToBase64String (dsaParams.G));
- sb.Append ("</G>");
-
- sb.Append ("<Y>");
- sb.Append (Convert.ToBase64String (dsaParams.Y));
- sb.Append( "</Y>");
-
- if (dsaParams.J != null) {
- // if J wasn't imported then it's not exported and neither
- // is part of the XML output
- sb.Append ("<J>");
- sb.Append (Convert.ToBase64String (dsaParams.J));
- sb.Append ("</J>");
- }
-
- if (dsaParams.Seed != null) {
- sb.Append ("<Seed>");
- sb.Append (Convert.ToBase64String (dsaParams.Seed));
- sb.Append ("</Seed>");
-
- sb.Append ("<PgenCounter>");
- // the number of bytes is important (no matter == 0x00)
- if (dsaParams.Counter != 0) {
- byte[] inArr = BitConverterLE.GetBytes (dsaParams.Counter);
- int l = inArr.Length;
- while (inArr[l-1] == 0x00)
- l--;
-
- sb.Append (Convert.ToBase64String (inArr, 0, l));
- } else {
- sb.Append ("AA=="); // base64 encoded 0
- }
- sb.Append ("</PgenCounter>");
- }
-
- if (dsaParams.X != null) {
- sb.Append ("<X>");
- sb.Append (Convert.ToBase64String (dsaParams.X));
- sb.Append ("</X>");
- }
- else if (includePrivateParameters) {
- throw new ArgumentNullException ("X");
- }
-
- sb.Append ("</DSAKeyValue>");
- }
- catch {
- ZeroizePrivateKey (dsaParams);
- throw;
- }
-
- return sb.ToString ();
- }
-
- public abstract bool VerifySignature (byte[] rgbHash, byte[] rgbSignature);
- }
-}
diff --git a/mcs/class/corlib/System.Security.Cryptography/DSASignatureDeformatter.cs b/mcs/class/corlib/System.Security.Cryptography/DSASignatureDeformatter.cs
deleted file mode 100644
index 6a7284a036e..00000000000
--- a/mcs/class/corlib/System.Security.Cryptography/DSASignatureDeformatter.cs
+++ /dev/null
@@ -1,85 +0,0 @@
-//
-// System.Security.Cryptography DSASignatureDeformatter.cs
-//
-// Authors:
-// Thomas Neidhart (tome@sbox.tugraz.at)
-// Sebastien Pouliot <sebastien@xamarin.com>
-//
-// Portions (C) 2002 Motus Technologies Inc. (http://www.motus.com)
-// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
-// Copyright 2013 Xamarin Inc. (http://www.xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System.Globalization;
-using System.Runtime.InteropServices;
-
-using Mono.Security.Cryptography;
-
-namespace System.Security.Cryptography {
-
- [ComVisible (true)]
- public class DSASignatureDeformatter : AsymmetricSignatureDeformatter {
-
- private DSA dsa;
-
- public DSASignatureDeformatter () : base ()
- {
- }
-
- public DSASignatureDeformatter (AsymmetricAlgorithm key) : base ()
- {
- SetKey (key);
- }
-
- public override void SetHashAlgorithm (string strName)
- {
- if (strName == null)
- throw new ArgumentNullException ("strName");
-
- var instance = PKCS1.CreateFromName (strName) as SHA1;
- if (instance == null)
- throw new CryptographicUnexpectedOperationException (
- Locale.GetText ("DSA requires SHA1"));
- }
-
- public override void SetKey (AsymmetricAlgorithm key)
- {
- if (key != null) {
- // this will throw a InvalidCastException if this isn't
- // a DSA keypair
- dsa = (DSA) key;
- }
- else
- throw new ArgumentNullException ("key");
- }
-
- public override bool VerifySignature (byte[] rgbHash, byte[] rgbSignature)
- {
- if (dsa == null) {
- throw new CryptographicUnexpectedOperationException (
- Locale.GetText ("missing key"));
- }
-
- return dsa.VerifySignature (rgbHash, rgbSignature);
- }
- }
-}
diff --git a/mcs/class/corlib/System.Security.Cryptography/DSASignatureFormatter.cs b/mcs/class/corlib/System.Security.Cryptography/DSASignatureFormatter.cs
deleted file mode 100644
index d4e775316d9..00000000000
--- a/mcs/class/corlib/System.Security.Cryptography/DSASignatureFormatter.cs
+++ /dev/null
@@ -1,85 +0,0 @@
-//
-// System.Security.Cryptography DSASignatureFormatter.cs
-//
-// Authors:
-// Thomas Neidhart (tome@sbox.tugraz.at)
-// Sebastien Pouliot <sebastien@xamarin.com>
-//
-// Portions (C) 2002 Motus Technologies Inc. (http://www.motus.com)
-// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
-// Copyright 2013 Xamarin Inc. (http://www.xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System.Globalization;
-using System.Runtime.InteropServices;
-
-using Mono.Security.Cryptography;
-
-namespace System.Security.Cryptography {
-
- [ComVisible (true)]
- public class DSASignatureFormatter : AsymmetricSignatureFormatter {
-
- private DSA dsa;
-
- public DSASignatureFormatter () : base ()
- {
- }
-
- public DSASignatureFormatter (AsymmetricAlgorithm key) : base ()
- {
- SetKey (key);
- }
-
- public override byte[] CreateSignature (byte[] rgbHash)
- {
- if (dsa == null) {
- throw new CryptographicUnexpectedOperationException (
- Locale.GetText ("missing key"));
- }
-
- return dsa.CreateSignature (rgbHash);
- }
-
- public override void SetHashAlgorithm (string strName)
- {
- if (strName == null)
- throw new ArgumentNullException ("strName");
-
- var instance = PKCS1.CreateFromName (strName) as SHA1;
- if (instance == null)
- throw new CryptographicUnexpectedOperationException (
- Locale.GetText ("DSA requires SHA1"));
- }
-
- public override void SetKey (AsymmetricAlgorithm key)
- {
- if (key != null) {
- // this will throw a InvalidCastException if this isn't
- // a DSA keypair
- dsa = (DSA) key;
- }
- else
- throw new ArgumentNullException ("key");
- }
- }
-}
diff --git a/mcs/class/corlib/System.Security.Cryptography/RSA.cs b/mcs/class/corlib/System.Security.Cryptography/RSA.cs
deleted file mode 100644
index 1a575931845..00000000000
--- a/mcs/class/corlib/System.Security.Cryptography/RSA.cs
+++ /dev/null
@@ -1,176 +0,0 @@
-//
-// System.Security.Cryptography.RSA.cs
-//
-// Authors:
-// Dan Lewis (dihlewis@yahoo.co.uk)
-// Sebastien Pouliot (sebastien@ximian.com)
-//
-// (C) 2002
-// Portions (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com)
-// Copyright (C) 2004-2006,2008 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System.Globalization;
-using System.Runtime.InteropServices;
-using System.Text;
-
-using Mono.Xml;
-
-namespace System.Security.Cryptography {
-
- [ComVisible (true)]
- public abstract class RSA : AsymmetricAlgorithm {
-
- public static new RSA Create ()
- {
-#if FULL_AOT_RUNTIME
- return new System.Security.Cryptography.RSACryptoServiceProvider ();
-#else
- return Create ("System.Security.Cryptography.RSA");
-#endif
- }
-
- public static new RSA Create (string algName)
- {
- return (RSA) CryptoConfig.CreateFromName (algName);
- }
-
- protected RSA ()
- {
- }
-
- public abstract byte[] EncryptValue (byte[] rgb);
-
- public abstract byte[] DecryptValue (byte[] rgb);
-
- public abstract RSAParameters ExportParameters (bool includePrivateParameters);
-
- public abstract void ImportParameters (RSAParameters parameters);
-
- internal void ZeroizePrivateKey (RSAParameters parameters)
- {
- if (parameters.P != null)
- Array.Clear (parameters.P, 0, parameters.P.Length);
- if (parameters.Q != null)
- Array.Clear (parameters.Q, 0, parameters.Q.Length);
- if (parameters.DP != null)
- Array.Clear (parameters.DP, 0, parameters.DP.Length);
- if (parameters.DQ != null)
- Array.Clear (parameters.DQ, 0, parameters.DQ.Length);
- if (parameters.InverseQ != null)
- Array.Clear (parameters.InverseQ, 0, parameters.InverseQ.Length);
- if (parameters.D != null)
- Array.Clear (parameters.D, 0, parameters.D.Length);
- }
-
- public override void FromXmlString (string xmlString)
- {
- if (xmlString == null)
- throw new ArgumentNullException ("xmlString");
-
- RSAParameters rsaParams = new RSAParameters ();
- try {
- rsaParams.P = GetNamedParam (xmlString, "P");
- rsaParams.Q = GetNamedParam (xmlString, "Q");
- rsaParams.D = GetNamedParam (xmlString, "D");
- rsaParams.DP = GetNamedParam (xmlString, "DP");
- rsaParams.DQ = GetNamedParam (xmlString, "DQ");
- rsaParams.InverseQ = GetNamedParam (xmlString, "InverseQ");
- rsaParams.Exponent = GetNamedParam (xmlString, "Exponent");
- rsaParams.Modulus = GetNamedParam (xmlString, "Modulus");
- ImportParameters (rsaParams);
- }
- catch (Exception e) {
- ZeroizePrivateKey (rsaParams);
- throw new CryptographicException (
- Locale.GetText ("Couldn't decode XML"), e);
- }
- finally {
- ZeroizePrivateKey (rsaParams);
- }
- }
-
- public override string ToXmlString (bool includePrivateParameters)
- {
- StringBuilder sb = new StringBuilder ();
- RSAParameters rsaParams = ExportParameters (includePrivateParameters);
- try {
- sb.Append ("<RSAKeyValue>");
-
- sb.Append ("<Modulus>");
- sb.Append (Convert.ToBase64String (rsaParams.Modulus));
- sb.Append ("</Modulus>");
-
- sb.Append ("<Exponent>");
- sb.Append (Convert.ToBase64String (rsaParams.Exponent));
- sb.Append ("</Exponent>");
-
- if (includePrivateParameters) {
- // we want an ArgumentNullException is only the D is missing, but a
- // CryptographicException if other parameters (CRT) are missings
- if (rsaParams.D == null) {
- string msg = Locale.GetText ("Missing D parameter for the private key.");
- throw new ArgumentNullException (msg);
- } else if ((rsaParams.P == null) || (rsaParams.Q == null) || (rsaParams.DP == null) ||
- (rsaParams.DQ == null) || (rsaParams.InverseQ == null)) {
- // note: we can import a private key, using FromXmlString,
- // without the CRT parameters but we export it using ToXmlString!
- string msg = Locale.GetText ("Missing some CRT parameters for the private key.");
- throw new CryptographicException (msg);
- }
-
- sb.Append ("<P>");
- sb.Append (Convert.ToBase64String (rsaParams.P));
- sb.Append ("</P>");
-
- sb.Append ("<Q>");
- sb.Append (Convert.ToBase64String (rsaParams.Q));
- sb.Append ("</Q>");
-
- sb.Append ("<DP>");
- sb.Append (Convert.ToBase64String (rsaParams.DP));
- sb.Append ("</DP>");
-
- sb.Append ("<DQ>");
- sb.Append (Convert.ToBase64String (rsaParams.DQ));
- sb.Append ("</DQ>");
-
- sb.Append ("<InverseQ>");
- sb.Append (Convert.ToBase64String (rsaParams.InverseQ));
- sb.Append ("</InverseQ>");
-
- sb.Append ("<D>");
- sb.Append (Convert.ToBase64String (rsaParams.D));
- sb.Append ("</D>");
- }
-
- sb.Append ("</RSAKeyValue>");
- }
- catch {
- ZeroizePrivateKey (rsaParams);
- throw;
- }
-
- return sb.ToString ();
- }
- }
-}
diff --git a/mcs/class/corlib/System.Security.Cryptography/RSACryptoServiceProvider.cs b/mcs/class/corlib/System.Security.Cryptography/RSACryptoServiceProvider.cs
index 4cd3779172c..53667fb87df 100644
--- a/mcs/class/corlib/System.Security.Cryptography/RSACryptoServiceProvider.cs
+++ b/mcs/class/corlib/System.Security.Cryptography/RSACryptoServiceProvider.cs
@@ -168,6 +168,13 @@ namespace System.Security.Cryptography {
public byte[] Decrypt (byte[] rgb, bool fOAEP)
{
+ if (rgb == null)
+ throw new ArgumentNullException("rgb");
+
+ // size check -- must be at most the modulus size
+ if (rgb.Length > (KeySize / 8))
+ throw new CryptographicException(Environment.GetResourceString("Cryptography_Padding_DecDataTooBig", KeySize / 8));
+
if (m_disposed)
throw new ObjectDisposedException ("rsa");
// choose between OAEP or PKCS#1 v.1.5 padding
@@ -220,7 +227,21 @@ namespace System.Security.Cryptography {
if ((includePrivateParameters) && (!privateKeyExportable))
throw new CryptographicException ("cannot export private key");
- return rsa.ExportParameters (includePrivateParameters);
+ var rsaParams = rsa.ExportParameters (includePrivateParameters);
+ if (includePrivateParameters) {
+ // we want an ArgumentNullException is only the D is missing, but a
+ // CryptographicException if other parameters (CRT) are missings
+ if (rsaParams.D == null) {
+ throw new ArgumentNullException ("Missing D parameter for the private key.");
+ } else if ((rsaParams.P == null) || (rsaParams.Q == null) || (rsaParams.DP == null) ||
+ (rsaParams.DQ == null) || (rsaParams.InverseQ == null)) {
+ // note: we can import a private key, using FromXmlString,
+ // without the CRT parameters but we export it using ToXmlString!
+ throw new CryptographicException ("Missing some CRT parameters for the private key.");
+ }
+ }
+
+ return rsaParams;
}
public override void ImportParameters (RSAParameters parameters)
diff --git a/mcs/class/corlib/System.Security.Cryptography/RSAOAEPKeyExchangeDeformatter.cs b/mcs/class/corlib/System.Security.Cryptography/RSAOAEPKeyExchangeDeformatter.cs
deleted file mode 100644
index ecb8f2209e0..00000000000
--- a/mcs/class/corlib/System.Security.Cryptography/RSAOAEPKeyExchangeDeformatter.cs
+++ /dev/null
@@ -1,75 +0,0 @@
-//
-// RSAOAEPKeyExchangeDeformatter.cs - Handles OAEP keyex decryption.
-//
-// Author:
-// Sebastien Pouliot <sebastien@ximian.com>
-//
-// (C) 2002 Motus Technologies Inc. (http://www.motus.com)
-// Copyright (C) 2004-2006 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System.Globalization;
-using System.Runtime.InteropServices;
-using Mono.Security.Cryptography;
-
-namespace System.Security.Cryptography {
-
- [ComVisible (true)]
- public class RSAOAEPKeyExchangeDeformatter : AsymmetricKeyExchangeDeformatter {
-
- private RSA rsa;
-// private string param;
-
- public RSAOAEPKeyExchangeDeformatter ()
- {
- }
-
- public RSAOAEPKeyExchangeDeformatter (AsymmetricAlgorithm key)
- {
- SetKey (key);
- }
-
- public override string Parameters {
- get { return null; }
- set { ; }
- }
-
- public override byte[] DecryptKeyExchange (byte[] rgbData)
- {
- if (rsa == null) {
- string msg = Locale.GetText ("No RSA key specified");
- throw new CryptographicUnexpectedOperationException (msg);
- }
- SHA1 sha1 = SHA1.Create ();
- byte[] result = PKCS1.Decrypt_OAEP (rsa, sha1, rgbData);
- if (result != null)
- return result;
-
- throw new CryptographicException (Locale.GetText ("OAEP decoding error."));
- }
-
- public override void SetKey (AsymmetricAlgorithm key)
- {
- rsa = (RSA)key;
- }
- }
-}
diff --git a/mcs/class/corlib/System.Security.Cryptography/RSAOAEPKeyExchangeFormatter.cs b/mcs/class/corlib/System.Security.Cryptography/RSAOAEPKeyExchangeFormatter.cs
deleted file mode 100644
index 5aed06336a3..00000000000
--- a/mcs/class/corlib/System.Security.Cryptography/RSAOAEPKeyExchangeFormatter.cs
+++ /dev/null
@@ -1,90 +0,0 @@
-//
-// RSAOAEPKeyExchangeFormatter.cs - Handles OAEP keyex encryption.
-//
-// Author:
-// Sebastien Pouliot <sebastien@ximian.com>
-//
-// (C) 2002 Motus Technologies Inc. (http://www.motus.com)
-// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System.Globalization;
-using System.Runtime.InteropServices;
-using Mono.Security.Cryptography;
-
-namespace System.Security.Cryptography {
-
- [ComVisible (true)]
- public class RSAOAEPKeyExchangeFormatter : AsymmetricKeyExchangeFormatter {
-
- private RSA rsa;
- private RandomNumberGenerator random;
- private byte[] param;
-
- public RSAOAEPKeyExchangeFormatter ()
- {
- rsa = null;
- }
-
- public RSAOAEPKeyExchangeFormatter (AsymmetricAlgorithm key)
- {
- SetKey (key);
- }
-
- public byte[] Parameter {
- get { return param; }
- set { param = value; }
- }
-
- public override string Parameters {
- get { return null; }
- }
-
- public RandomNumberGenerator Rng {
- get { return random; }
- set { random = value; }
- }
-
- public override byte[] CreateKeyExchange (byte[] rgbData)
- {
- if (random == null)
- random = RandomNumberGenerator.Create (); // create default
- if (rsa == null) {
- string msg = Locale.GetText ("No RSA key specified");
- throw new CryptographicUnexpectedOperationException (msg);
- }
- SHA1 sha1 = SHA1.Create ();
- return PKCS1.Encrypt_OAEP (rsa, sha1, random, rgbData);
- }
-
- public override byte[] CreateKeyExchange (byte[] rgbData, Type symAlgType)
- {
- // documentation says that symAlgType is not used !?!
- return CreateKeyExchange (rgbData);
- }
-
- public override void SetKey (AsymmetricAlgorithm key)
- {
- rsa = (RSA) key;
- }
- }
-}
diff --git a/mcs/class/corlib/System.Security.Cryptography/RSAPKCS1KeyExchangeDeformatter.cs b/mcs/class/corlib/System.Security.Cryptography/RSAPKCS1KeyExchangeDeformatter.cs
deleted file mode 100644
index 163fd303d4b..00000000000
--- a/mcs/class/corlib/System.Security.Cryptography/RSAPKCS1KeyExchangeDeformatter.cs
+++ /dev/null
@@ -1,81 +0,0 @@
-//
-// RSAPKCS1KeyExchangeDeformatter.cs - Handles PKCS#1 v.1.5 keyex decryption.
-//
-// Author:
-// Sebastien Pouliot <sebastien@ximian.com>
-//
-// (C) 2002 Motus Technologies Inc. (http://www.motus.com)
-// Copyright (C) 2004-2006 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System.Globalization;
-using System.Runtime.InteropServices;
-using Mono.Security.Cryptography;
-
-namespace System.Security.Cryptography {
-
- [ComVisible (true)]
- public class RSAPKCS1KeyExchangeDeformatter : AsymmetricKeyExchangeDeformatter {
-
- private RSA rsa;
-// private string param;
- private RandomNumberGenerator random;
-
- public RSAPKCS1KeyExchangeDeformatter ()
- {
- }
-
- public RSAPKCS1KeyExchangeDeformatter (AsymmetricAlgorithm key)
- {
- SetKey (key);
- }
-
- public override string Parameters {
- get { return null; }
- set { ; }
- }
-
- public RandomNumberGenerator RNG {
- get { return random; }
- set { random = value; }
- }
-
- public override byte[] DecryptKeyExchange (byte[] rgbIn)
- {
- if (rsa == null) {
- throw new CryptographicUnexpectedOperationException (
- Locale.GetText ("No key pair available."));
- }
-
- byte[] result = PKCS1.Decrypt_v15 (rsa, rgbIn);
- if (result != null)
- return result;
-
- throw new CryptographicException (Locale.GetText ("PKCS1 decoding error."));
- }
-
- public override void SetKey (AsymmetricAlgorithm key)
- {
- rsa = (RSA)key;
- }
- }
-}
diff --git a/mcs/class/corlib/System.Security.Cryptography/RSAPKCS1KeyExchangeFormatter.cs b/mcs/class/corlib/System.Security.Cryptography/RSAPKCS1KeyExchangeFormatter.cs
deleted file mode 100644
index b3d9e27dd00..00000000000
--- a/mcs/class/corlib/System.Security.Cryptography/RSAPKCS1KeyExchangeFormatter.cs
+++ /dev/null
@@ -1,94 +0,0 @@
-//
-// RSAPKCS1KeyExchangeFormatter.cs: Handles PKCS#1 v.1.5 keyex encryption.
-//
-// Author:
-// Sebastien Pouliot <sebastien@ximian.com>
-//
-// (C) 2002 Motus Technologies Inc. (http://www.motus.com)
-// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System.Globalization;
-using System.Runtime.InteropServices;
-using Mono.Security.Cryptography;
-
-namespace System.Security.Cryptography {
-
- // LAMESPEC: There seems no way to select a hash algorithm. The default
- // algorithm, is SHA1 because the class use the PKCS1MaskGenerationMethod -
- // which default to SHA1.
- [ComVisible (true)]
- public class RSAPKCS1KeyExchangeFormatter: AsymmetricKeyExchangeFormatter
- {
- private RSA rsa;
- private RandomNumberGenerator random;
-
- public RSAPKCS1KeyExchangeFormatter ()
- {
- }
-
- public RSAPKCS1KeyExchangeFormatter (AsymmetricAlgorithm key)
- {
- SetRSAKey (key);
- }
-
- public RandomNumberGenerator Rng {
- get { return random; }
- set { random = value; }
- }
-
- public override string Parameters {
- get { return "<enc:KeyEncryptionMethod enc:Algorithm=\"http://www.microsoft.com/xml/security/algorithm/PKCS1-v1.5-KeyEx\" xmlns:enc=\"http://www.microsoft.com/xml/security/encryption/v1.0\" />"; }
- }
-
- public override byte[] CreateKeyExchange (byte[] rgbData)
- {
- if (rgbData == null)
- throw new ArgumentNullException ("rgbData");
- if (rsa == null) {
- string msg = Locale.GetText ("No RSA key specified");
- throw new CryptographicUnexpectedOperationException (msg);
- }
- if (random == null)
- random = RandomNumberGenerator.Create (); // create default
- return PKCS1.Encrypt_v15 (rsa, random, rgbData);
- }
-
- public override byte[] CreateKeyExchange (byte[] rgbData, Type symAlgType)
- {
- // documentation says that symAlgType is not used !?!
- return CreateKeyExchange (rgbData);
- }
-
- private void SetRSAKey (AsymmetricAlgorithm key)
- {
- if (key == null)
- throw new ArgumentNullException ("key");
- rsa = (RSA) key;
- }
-
- public override void SetKey (AsymmetricAlgorithm key)
- {
- SetRSAKey (key);
- }
- }
-}
diff --git a/mcs/class/corlib/System.Security.Cryptography/RSAParameters.cs b/mcs/class/corlib/System.Security.Cryptography/RSAParameters.cs
deleted file mode 100644
index 00edafc356b..00000000000
--- a/mcs/class/corlib/System.Security.Cryptography/RSAParameters.cs
+++ /dev/null
@@ -1,53 +0,0 @@
-//
-// System.Security.Cryptography.RSAParameters.cs
-//
-// Authors:
-// Dan Lewis (dihlewis@yahoo.co.uk)
-//
-// (C) 2002
-// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System.Runtime.InteropServices;
-
-namespace System.Security.Cryptography {
-
- [Serializable]
- [ComVisible (true)]
- public struct RSAParameters {
- [NonSerialized]
- public byte[] P;
- [NonSerialized]
- public byte[] Q;
- [NonSerialized]
- public byte[] D;
- [NonSerialized]
- public byte[] DP;
- [NonSerialized]
- public byte[] DQ;
- [NonSerialized]
- public byte[] InverseQ;
-
- public byte[] Modulus;
- public byte[] Exponent;
- }
-}
diff --git a/mcs/class/corlib/System.Security.Cryptography/TripleDES.cs b/mcs/class/corlib/System.Security.Cryptography/TripleDES.cs
deleted file mode 100644
index 3fa0800cdff..00000000000
--- a/mcs/class/corlib/System.Security.Cryptography/TripleDES.cs
+++ /dev/null
@@ -1,138 +0,0 @@
-//
-// TripleDES.cs: Handles TripleDES (abstract class)
-//
-// Author:
-// Sebastien Pouliot <sebastien@ximian.com>
-//
-// (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com)
-// Copyright (C) 2004-2006 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System.Globalization;
-using System.Runtime.InteropServices;
-using System.Security.Cryptography;
-
-namespace System.Security.Cryptography {
-
-// References:
-// a. FIPS PUB 46-3: TripleDES
-// http://csrc.nist.gov/publications/fips/fips46-3/fips46-3.pdf
-// b. ANSI X9.52
-// not free :-(
-// http://webstore.ansi.org/ansidocstore/product.asp?sku=ANSI+X9%2E52%2D1998
-
-[ComVisible (true)]
-public abstract class TripleDES : SymmetricAlgorithm {
-
- protected TripleDES ()
- {
- // from SymmetricAlgorithm
- KeySizeValue = 192;
- BlockSizeValue = 64;
- FeedbackSizeValue = 8;
-
- LegalKeySizesValue = new KeySizes [1];
- LegalKeySizesValue [0] = new KeySizes (128, 192, 64);
-
- LegalBlockSizesValue = new KeySizes [1];
- LegalBlockSizesValue [0] = new KeySizes (64, 64, 0);
- }
-
- public override byte[] Key {
- get {
- if (KeyValue == null) {
- // generate keys as long as we get weak keys
- GenerateKey ();
- while (IsWeakKey (KeyValue))
- GenerateKey ();
- }
- return (byte[]) KeyValue.Clone ();
- }
- set {
- if (value == null)
- throw new ArgumentNullException ("Key");
- // this will check for both key size and weak keys
- if (IsWeakKey (value))
- throw new CryptographicException (Locale.GetText ("Weak Key"));
- KeyValue = (byte[]) value.Clone ();
- }
- }
-
- // Triple DES is DES in EDE = Encrypt - Decrypt - Encrypt
- // with 2 keys (a,b)
- // EDE = Encrypt (a) - Decrypt (b) - Encrypt (a)
- // if a == b then TripleDES == DES(a) (hence weak key)
- // with 3 keys (a,b,c)
- // EDE = Encrypt (a) - Decrypt (b) - Encrypt (c)
- // if ( a == b ) then TripleDES == DES(c) (hence weak key)
- // if ( b == c ) then TripleDES == DES(a) (hence weak key)
- public static bool IsWeakKey (byte[] rgbKey)
- {
- if (rgbKey == null)
- throw new CryptographicException (Locale.GetText ("Null Key"));
- // 128 bits (16 bytes) is 3 DES with 2 keys
- if (rgbKey.Length == 16) {
- // weak if first half == second half
- for (int i = 0; i < 8; i++)
- if (rgbKey [i] != rgbKey [i+8])
- return false;
- }
- // 192 bits (24 bytes) is 3 DES with 3 keys
- else if (rgbKey.Length == 24) {
- bool bFirstCase = true;
- // weak if first third == second third
- for (int i = 0; i < 8; i++) {
- if (rgbKey [i] != rgbKey [i+8]) {
- bFirstCase = false;
- break;
- }
- }
- // weak if second third == third third
- if (!bFirstCase) {
- for (int i = 8; i < 16; i++)
- if (rgbKey [i] != rgbKey [i+8])
- return false;
- }
- }
- else
- throw new CryptographicException (Locale.GetText ("Wrong Key Length"));
-
- return true;
- }
-
- public static new TripleDES Create ()
- {
-#if FULL_AOT_RUNTIME
- return new System.Security.Cryptography.TripleDESCryptoServiceProvider ();
-#else
- return Create ("System.Security.Cryptography.TripleDES");
-#endif
- }
-
- public static new TripleDES Create (string str)
- {
- return (TripleDES) CryptoConfig.CreateFromName (str);
- }
-}
-
-}
-
diff --git a/mcs/class/corlib/System.Security.Cryptography/TripleDESCryptoServiceProvider.cs b/mcs/class/corlib/System.Security.Cryptography/TripleDESCryptoServiceProvider.cs
index ed8b1393304..6c66f945e9b 100644
--- a/mcs/class/corlib/System.Security.Cryptography/TripleDESCryptoServiceProvider.cs
+++ b/mcs/class/corlib/System.Security.Cryptography/TripleDESCryptoServiceProvider.cs
@@ -39,34 +39,6 @@ namespace System.Security.Cryptography {
// not free :-(
// http://webstore.ansi.org/ansidocstore/product.asp?sku=ANSI+X9%2E52%2D1998
- [ComVisible (true)]
- public sealed class TripleDESCryptoServiceProvider : TripleDES {
-
- public TripleDESCryptoServiceProvider ()
- {
- }
-
- public override void GenerateIV ()
- {
- IVValue = KeyBuilder.IV (BlockSizeValue >> 3);
- }
-
- public override void GenerateKey ()
- {
- KeyValue = TripleDESTransform.GetStrongKey ();
- }
-
- public override ICryptoTransform CreateDecryptor (byte[] rgbKey, byte[] rgbIV)
- {
- return new TripleDESTransform (this, false, rgbKey, rgbIV);
- }
-
- public override ICryptoTransform CreateEncryptor (byte[] rgbKey, byte[] rgbIV)
- {
- return new TripleDESTransform (this, true, rgbKey, rgbIV);
- }
- }
-
// TripleDES is just DES-EDE
internal class TripleDESTransform : SymmetricTransform {
diff --git a/mcs/class/corlib/System.Security/SecurityElement.cs b/mcs/class/corlib/System.Security/SecurityElement.cs
index ca0513ba86a..0212e8b390a 100644
--- a/mcs/class/corlib/System.Security/SecurityElement.cs
+++ b/mcs/class/corlib/System.Security/SecurityElement.cs
@@ -33,11 +33,19 @@ using System.Globalization;
using System.Collections;
using System.Runtime.InteropServices;
using System.Text;
+using System.Diagnostics.Contracts;
using Mono.Xml;
namespace System.Security {
+ internal enum SecurityElementType
+ {
+ Regular = 0,
+ Format = 1,
+ Comment = 2
+ }
+
[ComVisible (true)]
[Serializable]
public sealed class SecurityElement
@@ -454,5 +462,64 @@ namespace System.Security {
}
return null;
}
+
+ internal string m_strTag {
+ get {
+ return tag;
+ }
+ }
+
+ internal string m_strText {
+ get {
+ return text;
+ }
+ set {
+ text = value;
+ }
+ }
+
+ internal ArrayList m_lAttributes {
+ get {
+ return attributes;
+ }
+ }
+
+ internal ArrayList InternalChildren {
+ get {
+ return children;
+ }
+ }
+
+ internal String SearchForTextOfLocalName(String strLocalName)
+ {
+ // Search on each child in order and each
+ // child's child, depth-first
+
+ if (strLocalName == null)
+ throw new ArgumentNullException( "strLocalName" );
+ Contract.EndContractBlock();
+
+ // Note: we don't check for a valid tag here because
+ // an invalid tag simply won't be found.
+
+ // First we check this.
+
+ if (tag == null) return null;
+ if (tag.Equals( strLocalName ) || tag.EndsWith( ":" + strLocalName, StringComparison.Ordinal ))
+ return Unescape( text );
+ if (children == null)
+ return null;
+
+ IEnumerator enumerator = children.GetEnumerator();
+
+ while (enumerator.MoveNext())
+ {
+ String current = ((SecurityElement)enumerator.Current).SearchForTextOfLocalName( strLocalName );
+
+ if (current != null)
+ return current;
+ }
+ return null;
+ }
}
}
diff --git a/mcs/class/corlib/Test/System.Security.Cryptography/CryptoStreamTest.cs b/mcs/class/corlib/Test/System.Security.Cryptography/CryptoStreamTest.cs
index f6856446bab..7f3320e9c92 100644
--- a/mcs/class/corlib/Test/System.Security.Cryptography/CryptoStreamTest.cs
+++ b/mcs/class/corlib/Test/System.Security.Cryptography/CryptoStreamTest.cs
@@ -326,9 +326,7 @@ namespace MonoTests.System.Security.Cryptography {
#if !NET_2_1
[Test]
- // MS BUG [ExpectedException (typeof (ObjectDisposedException))]
- [Category ("NotWorking")]
- [ExpectedException (typeof (IndexOutOfRangeException))]
+ [ExpectedException (typeof (NotSupportedException))]
public void Read_Disposed_Break ()
{
// do no corrupt readStream in further tests
@@ -423,11 +421,8 @@ namespace MonoTests.System.Security.Cryptography {
cs.Read (buffer, Int32.MaxValue, 4);
}
-#if !NET_2_1
[Test]
- // MS BUG [ExpectedException (typeof (ObjectDisposedException))]
- [Category ("NotWorking")]
- [ExpectedException (typeof (IndexOutOfRangeException))]
+ [ExpectedException (typeof (NotSupportedException))]
public void Write_Disposed ()
{
// do no corrupt writeStream in further tests
@@ -438,7 +433,6 @@ namespace MonoTests.System.Security.Cryptography {
cs.Write (buffer, 0, 8);
}
}
-#endif
[Test]
[ExpectedException (typeof (NotSupportedException))]
@@ -823,7 +817,6 @@ namespace MonoTests.System.Security.Cryptography {
Assert.AreEqual ("ximian", Encoding.Unicode.GetString (data, 0, len), "Unicode DES Roundtrip");
}
- [Category ("NotWorking")]
[Test]
public void DecryptPartial_TransformFinalBlock_2Pass ()
{
@@ -850,7 +843,6 @@ namespace MonoTests.System.Security.Cryptography {
}
// based on http://www.c-sharpcorner.com/Code/2002/May/FileEncryption.asp
- [Category ("NotWorking")]
[Test]
public void WriteByteReadByte ()
{
@@ -1242,7 +1234,6 @@ namespace MonoTests.System.Security.Cryptography {
byte[] digest = hash.Hash;
Assert.AreEqual ("71-04-12-D1-95-01-CF-F9-8D-8F-F8-0D-F9-AA-11-7D", BitConverter.ToString (digest), "Hash");
}
- [Category ("NotWorking")]
[Test]
public void CascadedCryptoStream_Read ()
{
diff --git a/mcs/class/corlib/System.Security.Cryptography/DSAParameters.cs b/mcs/class/corlib/Test/System.Security.Cryptography/CspParametersTest.cs
index c1aef2ef10e..11e81774310 100644
--- a/mcs/class/corlib/System.Security.Cryptography/DSAParameters.cs
+++ b/mcs/class/corlib/Test/System.Security.Cryptography/CspParametersTest.cs
@@ -1,10 +1,10 @@
-//
-// System.Security.Cryptography DSAParameters.cs
-//
-// Author:
-// Thomas Neidhart (tome@sbox.tugraz.at)
//
-// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
+// CspParametersTest.cs - NUnit Test Cases for CspParameters
+//
+// Author:
+// Marek Safar <marek.safar@gmail.com>
+//
+// Copyright (C) 2015 Xamarin Inc (http://www.xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -25,30 +25,21 @@
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-
-using System.Runtime.InteropServices;
-
-namespace System.Security.Cryptography {
-
- [Serializable]
- [ComVisible (true)]
- public struct DSAParameters {
-
- public int Counter;
-
- public byte[] G;
-
- public byte[] J;
-
- public byte[] P;
-
- public byte[] Q;
-
- public byte[] Seed;
-
- [NonSerialized]
- public byte[] X;
-
- public byte[] Y;
- }
-}
+
+using NUnit.Framework;
+using System;
+using System.Security.Cryptography;
+
+namespace MonoTests.System.Security.Cryptography {
+
+ [TestFixture]
+ public class CspParametersTest {
+
+ [Test]
+ public void Ctor ()
+ {
+ var cp = new CspParameters ();
+ Assert.AreEqual (24, cp.ProviderType);
+ }
+ }
+}
diff --git a/mcs/class/corlib/Test/System.Security.Cryptography/DSACryptoServiceProviderTest.cs b/mcs/class/corlib/Test/System.Security.Cryptography/DSACryptoServiceProviderTest.cs
index 18e26afb297..a609ce74e2d 100644
--- a/mcs/class/corlib/Test/System.Security.Cryptography/DSACryptoServiceProviderTest.cs
+++ b/mcs/class/corlib/Test/System.Security.Cryptography/DSACryptoServiceProviderTest.cs
@@ -326,17 +326,14 @@ public class DSACryptoServiceProviderTest {
Assert.IsFalse (emptyDSA.VerifySignature (hash, sign));
}
-#if !NET_2_1
[Test]
- [Category ("NotWorking")]
+ [ExpectedException (typeof (ObjectDisposedException))]
public void ImportDisposed ()
{
DSACryptoServiceProvider import = new DSACryptoServiceProvider (minKeySize);
import.Clear ();
import.ImportParameters (AllTests.GetKey (false));
- // no exception from Fx 2.0 +
}
-#endif
[Test]
[ExpectedException (typeof (ObjectDisposedException))]
diff --git a/mcs/class/corlib/Test/System.Security.Cryptography/RSACryptoServiceProviderTest.cs b/mcs/class/corlib/Test/System.Security.Cryptography/RSACryptoServiceProviderTest.cs
index 56f9a9be336..8a20b9add45 100644
--- a/mcs/class/corlib/Test/System.Security.Cryptography/RSACryptoServiceProviderTest.cs
+++ b/mcs/class/corlib/Test/System.Security.Cryptography/RSACryptoServiceProviderTest.cs
@@ -843,6 +843,20 @@ public class RSACryptoServiceProviderTest {
rsa.ToXmlString (true);
}
+ [Test]
+ [ExpectedException (typeof (CryptographicException))]
+ public void ExportWithoutCRT_2 ()
+ {
+ try {
+ rsa = new RSACryptoServiceProvider ();
+ rsa.FromXmlString (MonoXml384woCRT);
+ }
+ catch {
+ }
+ // exception is HERE!
+ rsa.ExportParameters (true);
+ }
+
// Validate that we can sign with every keypair and verify the signature
// With Windows this means that we can use Mono keypairs to sign and verify.
// For Mono this doesn't mean much.
diff --git a/mcs/class/corlib/Test/System.Security.Cryptography/RSAPKCS1KeyExchangeDeformatterTest.cs b/mcs/class/corlib/Test/System.Security.Cryptography/RSAPKCS1KeyExchangeDeformatterTest.cs
index ab26551a6c0..bee89257a04 100644
--- a/mcs/class/corlib/Test/System.Security.Cryptography/RSAPKCS1KeyExchangeDeformatterTest.cs
+++ b/mcs/class/corlib/Test/System.Security.Cryptography/RSAPKCS1KeyExchangeDeformatterTest.cs
@@ -197,7 +197,7 @@ public class RSAPKCS1KeyExchangeDeformatterTest {
}
[Test]
- [ExpectedException (typeof (CryptographicException))]
+ [ExpectedException (typeof (CryptographicUnexpectedOperationException))]
public void Bug79320 ()
{
string s = "hdphq/mn8goBi43YGPkmOfPj5vXjHrKPJkT4mLT3l+XzLttHMLC4/yBYkuzlXtbrl2jtAJRb6oA8UcQFalUMnCa09LDZrgNU2yySn7YbiG8raSq7u2nfDCbPu+c8T9fyHxrCHrX0zeqqImX33csIn6rIrQZ8HKcMsoQso4qtS2A=";
diff --git a/mcs/class/corlib/corlib.dll.sources b/mcs/class/corlib/corlib.dll.sources
index 93e15044762..19a34311a56 100644
--- a/mcs/class/corlib/corlib.dll.sources
+++ b/mcs/class/corlib/corlib.dll.sources
@@ -721,37 +721,22 @@ System.Security.AccessControl/ResourceType.cs
System.Security.AccessControl/SddlAccessRight.cs
System.Security.AccessControl/SecurityInfos.cs
System.Security.AccessControl/SystemAcl.cs
-System.Security.Cryptography/AsymmetricAlgorithm.cs
System.Security.Cryptography/CryptoAPITransform.cs
System.Security.Cryptography/CryptoConfig.cs
System.Security.Cryptography/CryptoConfig_2_1.cs
System.Security.Cryptography/CryptoConfig.fullaot.cs
System.Security.Cryptography/CspKeyContainerInfo.cs
-System.Security.Cryptography/CspParameters.cs
-System.Security.Cryptography/CspProviderFlags.cs
-System.Security.Cryptography/DES.cs
System.Security.Cryptography/DESCryptoServiceProvider.cs
-System.Security.Cryptography/DSA.cs
System.Security.Cryptography/DSACryptoServiceProvider.cs
-System.Security.Cryptography/DSAParameters.cs
-System.Security.Cryptography/DSASignatureDeformatter.cs
-System.Security.Cryptography/DSASignatureFormatter.cs
System.Security.Cryptography/ICspAsymmetricAlgorithm.cs
System.Security.Cryptography/KeyNumber.cs
System.Security.Cryptography/MD5CryptoServiceProvider.cs
System.Security.Cryptography/RC2CryptoServiceProvider.cs
System.Security.Cryptography/RNGCryptoServiceProvider.cs
-System.Security.Cryptography/RSA.cs
System.Security.Cryptography/RSACryptoServiceProvider.cs
-System.Security.Cryptography/RSAOAEPKeyExchangeDeformatter.cs
-System.Security.Cryptography/RSAOAEPKeyExchangeFormatter.cs
-System.Security.Cryptography/RSAParameters.cs
-System.Security.Cryptography/RSAPKCS1KeyExchangeDeformatter.cs
-System.Security.Cryptography/RSAPKCS1KeyExchangeFormatter.cs
System.Security.Cryptography/RSAPKCS1SignatureDeformatter.cs
System.Security.Cryptography/RSAPKCS1SignatureFormatter.cs
System.Security.Cryptography/SHA1CryptoServiceProvider.cs
-System.Security.Cryptography/TripleDES.cs
System.Security.Cryptography/TripleDESCryptoServiceProvider.cs
System.Security.Cryptography.X509Certificates/X509Certificate.cs
System.Security.Cryptography.X509Certificates/X509Certificate20.cs
@@ -938,6 +923,7 @@ ReferenceSources/TypeBuilderInstantiation.cs
ReferenceSources/Buffer.cs
ReferenceSources/TextInfo.cs
ReferenceSources/win32native.cs
+ReferenceSources/SharedStatics.cs
../../../external/referencesource/mscorlib/system/__filters.cs
../../../external/referencesource/mscorlib/system/__hresults.cs
@@ -1380,6 +1366,7 @@ ReferenceSources/win32native.cs
../../../external/referencesource/mscorlib/system/runtime/compilerservices/YieldAwaitable.cs
../../../external/referencesource/mscorlib/system/security/attributes.cs
+../../../external/referencesource/mscorlib/system/security/securitydocument.cs
../../../external/referencesource/mscorlib/system/security/claims/Claim.cs
../../../external/referencesource/mscorlib/system/security/claims/ClaimsIdentity.cs
@@ -1389,14 +1376,21 @@ ReferenceSources/win32native.cs
../../../external/referencesource/mscorlib/system/security/claims/RoleClaimProvider.cs
../../../external/referencesource/mscorlib/system/security/cryptography/aes.cs
+../../../external/referencesource/mscorlib/system/security/cryptography/asymmetricalgorithm.cs
../../../external/referencesource/mscorlib/system/security/cryptography/asymmetrickeyexchangedeformatter.cs
../../../external/referencesource/mscorlib/system/security/cryptography/asymmetrickeyexchangeformatter.cs
../../../external/referencesource/mscorlib/system/security/cryptography/asymmetricsignaturedeformatter.cs
../../../external/referencesource/mscorlib/system/security/cryptography/asymmetricsignatureformatter.cs
../../../external/referencesource/mscorlib/system/security/cryptography/base64transforms.cs
../../../external/referencesource/mscorlib/system/security/cryptography/crypto.cs
+../../../external/referencesource/mscorlib/system/security/cryptography/cryptoapitransform.cs
../../../external/referencesource/mscorlib/system/security/cryptography/cryptostream.cs
../../../external/referencesource/mscorlib/system/security/cryptography/derivebytes.cs
+../../../external/referencesource/mscorlib/system/security/cryptography/des.cs
+../../../external/referencesource/mscorlib/system/security/cryptography/descryptoserviceprovider.cs
+../../../external/referencesource/mscorlib/system/security/cryptography/dsa.cs
+../../../external/referencesource/mscorlib/system/security/cryptography/dsasignaturedeformatter.cs
+../../../external/referencesource/mscorlib/system/security/cryptography/dsasignatureformatter.cs
../../../external/referencesource/mscorlib/system/security/cryptography/hashalgorithm.cs
../../../external/referencesource/mscorlib/system/security/cryptography/hmac.cs
../../../external/referencesource/mscorlib/system/security/cryptography/hmacmd5.cs
@@ -1421,6 +1415,11 @@ ReferenceSources/win32native.cs
../../../external/referencesource/mscorlib/system/security/cryptography/rijndaelmanagedtransform.cs
../../../external/referencesource/mscorlib/system/security/cryptography/ripemd160.cs
../../../external/referencesource/mscorlib/system/security/cryptography/ripemd160managed.cs
+../../../external/referencesource/mscorlib/system/security/cryptography/rsa.cs
+../../../external/referencesource/mscorlib/system/security/cryptography/rsaoaepkeyexchangedeformatter.cs
+../../../external/referencesource/mscorlib/system/security/cryptography/rsaoaepkeyexchangeformatter.cs
+../../../external/referencesource/mscorlib/system/security/cryptography/rsapkcs1keyexchangedeformatter.cs
+../../../external/referencesource/mscorlib/system/security/cryptography/rsapkcs1keyexchangeformatter.cs
../../../external/referencesource/mscorlib/system/security/cryptography/sha1.cs
../../../external/referencesource/mscorlib/system/security/cryptography/sha1managed.cs
../../../external/referencesource/mscorlib/system/security/cryptography/sha256.cs
@@ -1431,11 +1430,17 @@ ReferenceSources/win32native.cs
../../../external/referencesource/mscorlib/system/security/cryptography/sha512managed.cs
../../../external/referencesource/mscorlib/system/security/cryptography/signaturedescription.cs
../../../external/referencesource/mscorlib/system/security/cryptography/symmetricalgorithm.cs
+../../../external/referencesource/mscorlib/system/security/cryptography/tripledes.cs
+../../../external/referencesource/mscorlib/system/security/cryptography/tripledescryptoserviceprovider.cs
../../../external/referencesource/mscorlib/system/security/cryptography/utils.cs
+../../../external/referencesource/mscorlib/system/security/cryptography/x509certificates/x509utils.cs
+
../../../external/referencesource/mscorlib/system/security/principal/genericidentity.cs
../../../external/referencesource/mscorlib/system/security/util/hex.cs
+../../../external/referencesource/mscorlib/system/security/util/parser.cs
+../../../external/referencesource/mscorlib/system/security/util/tokenizer.cs
../../../external/referencesource/mscorlib/system/text/asciiencoding.cs
../../../external/referencesource/mscorlib/system/text/codepageencoding.cs
diff --git a/mcs/class/corlib/corlib_test.dll.sources b/mcs/class/corlib/corlib_test.dll.sources
index 8d2cafa883a..0efa920e175 100644
--- a/mcs/class/corlib/corlib_test.dll.sources
+++ b/mcs/class/corlib/corlib_test.dll.sources
@@ -245,6 +245,7 @@ System.Security.Cryptography/CipherModeTest.cs
System.Security.Cryptography/CfbTest.cs
System.Security.Cryptography/CryptoConfigTest.cs
System.Security.Cryptography/CryptoStreamTest.cs
+System.Security.Cryptography/CspParametersTest.cs
System.Security.Cryptography/CspProviderFlagsTest.cs
System.Security.Cryptography/DesCfbTest.cs
System.Security.Cryptography/DESCryptoServiceProviderTest.cs