++2004-12-23 Sebastien Pouliot <sebastien@ximian.com>
++
++ * System.Security.dll.sources: Added System.Security.Cryptography/
++ ProtectedData.cs, ProtectedMemory.cs, DataProtectionScope.cs and
++ MemoryProtectionScope.cs as they been moved from mscorlib to here.
++ * System.Security_test.dll.sources : Added Test/System.Security.
++ Cryptography/ProtectedDataTest.cs and ProtectedMemoryTest.cs for the
++ same reason.
++
2004-09-04 Tim Coleman <tim@timcoleman.com>
* System.Security.dll.sources:
Add new System.Security.Cryptography.Pkcs classes.
--- /dev/null
--- /dev/null
++//
++// DataProtectionScope.cs: Scope for ProtectData
++//
++// Author:
++// Sebastien Pouliot (spouliot@motus.com)
++//
++// (C) 2003 Motus Technologies Inc. (http://www.motus.com)
++//
++
++//
++// Copyright (C) 2004 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.
++//
++
++#if NET_2_0
++
++using System;
++
++namespace System.Security.Cryptography {
++
++ public enum DataProtectionScope {
++ CurrentUser,
++ LocalMachine
++ }
++}
++
++#endif
--- /dev/null
--- /dev/null
++//
++// MemoryProtectionScope.cs: Scope for ProtectMemory
++//
++// Author:
++// Sebastien Pouliot (spouliot@motus.com)
++//
++// (C) 2003 Motus Technologies Inc. (http://www.motus.com)
++//
++
++//
++// Copyright (C) 2004 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.
++//
++
++#if NET_2_0
++
++using System;
++
++namespace System.Security.Cryptography {
++
++ public enum MemoryProtectionScope {
++ SameProcess,
++ CrossProcess,
++ SameLogon
++ }
++}
++
++#endif
--- /dev/null
--- /dev/null
++//
++// ProtectedData.cs: Protect (encrypt) data without (user involved) key management
++//
++// Author:
++// Sebastien Pouliot (spouliot@motus.com)
++//
++// (C) 2003 Motus Technologies Inc. (http://www.motus.com)
++// Copyright (C) 2004 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.
++//
++
++#if NET_2_0
++
++using System;
++
++namespace System.Security.Cryptography {
++
++ // References:
++ // a. Windows Data Protection
++ // http://msdn.microsoft.com/library/en-us/dnsecure/html/windataprotection-dpapi.asp?frame=true
++
++ public sealed class ProtectedData {
++
++ private ProtectedData ()
++ {
++ }
++
++ // FIXME: interop could be important under windows - if one application protect some data using
++ // mono and another one unprotects it using ms.net
++
++ [MonoTODO ("interop with MS implementation ?")]
++ public static byte[] Protect (byte[] userData, byte[] optionalEntropy, DataProtectionScope scope)
++ {
++ if (userData == null)
++ throw new ArgumentNullException ("userData");
++
++ // on Windows this is supported only under 2000 and later OS
++ throw new PlatformNotSupportedException ();
++ }
++
++ [MonoTODO ("interop with MS implementation ?")]
++ public static byte[] Unprotect (byte[] encryptedData, byte[] optionalEntropy, DataProtectionScope scope)
++ {
++ if (encryptedData == null)
++ throw new ArgumentNullException ("encryptedData");
++
++ // on Windows this is supported only under 2000 and later OS
++ throw new PlatformNotSupportedException ();
++ }
++ }
++}
++
++#endif
--- /dev/null
--- /dev/null
++//
++// ProtectedMemory.cs: Protect (encrypt) memory without (user involved) key management
++//
++// Author:
++// Sebastien Pouliot (spouliot@motus.com)
++//
++// (C) 2003 Motus Technologies Inc. (http://www.motus.com)
++// Copyright (C) 2004 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.
++//
++
++#if NET_2_0
++
++using System;
++
++namespace System.Security.Cryptography {
++
++ // References:
++ // a. Windows Data Protection
++ // http://msdn.microsoft.com/library/en-us/dnsecure/html/windataprotection-dpapi.asp?frame=true
++
++ public sealed class ProtectedMemory {
++
++ private ProtectedMemory ()
++ {
++ }
++
++ [MonoTODO]
++ public static void Protect (byte[] userData, MemoryProtectionScope scope)
++ {
++ if (userData == null)
++ throw new ArgumentNullException ("userData");
++ if (userData.Length % 16 != 0)
++ throw new CryptographicException ("not a multiple of 16 bytes");
++
++ // on Windows this is supported only under XP and later OS
++ throw new PlatformNotSupportedException ();
++ }
++
++ [MonoTODO]
++ public static void Unprotect (byte[] encryptedData, MemoryProtectionScope scope)
++ {
++ if (encryptedData == null)
++ throw new ArgumentNullException ("encryptedData");
++ if (encryptedData.Length % 16 != 0)
++ throw new CryptographicException ("not a multiple of 16 bytes");
++
++ // on Windows this is supported only under XP and later OS
++ throw new PlatformNotSupportedException ();
++ }
++ }
++}
++
++#endif
System.Security.Cryptography/CryptographicAttribute.cs
System.Security.Cryptography/CryptographicAttributeCollection.cs
System.Security.Cryptography/CryptographicAttributeEnumerator.cs
++System.Security.Cryptography/DataProtectionScope.cs
++System.Security.Cryptography/MemoryProtectionScope.cs
System.Security.Cryptography/Oid.cs
System.Security.Cryptography/OidCollection.cs
System.Security.Cryptography/OidEnumerator.cs
++System.Security.Cryptography/ProtectedData.cs
++System.Security.Cryptography/ProtectedMemory.cs
System.Security.Cryptography.Pkcs/AlgorithmIdentifier.cs
System.Security.Cryptography.Pkcs/ContentInfo.cs
System.Security.Cryptography.Pkcs/EnvelopedCms.cs
System.Security.Cryptography/OidCollectionTest.cs
System.Security.Cryptography/OidEnumeratorTest.cs
System.Security.Cryptography/OidTest.cs
++System.Security.Cryptography/ProtectedDataTest.cs
++System.Security.Cryptography/ProtectedMemoryTest.cs
System.Security.Cryptography.Pkcs/AlgorithmIdentifierTest.cs
System.Security.Cryptography.Pkcs/CmsRecipientTest.cs
System.Security.Cryptography.Pkcs/CmsSignerTest.cs
--- /dev/null
--- /dev/null
++//
++// ProtectedDataTest.cs - NUnit Test Cases for ProtectedData
++//
++// Author:
++// Sebastien Pouliot (spouliot@motus.com)
++//
++// (C) 2003 Motus Technologies Inc. (http://www.motus.com)
++//
++
++#if NET_2_0
++
++using NUnit.Framework;
++
++using System;
++using System.Security.Cryptography;
++
++namespace MonoTests.System.Security.Cryptography {
++
++ // References:
++ // a.
++
++ [TestFixture]
++ public class ProtectedDataTest : Assertion {
++
++ private void ProtectUnprotect (byte[] entropy, DataProtectionScope scope)
++ {
++ byte[] data = new byte [16];
++ byte[] encdata = ProtectedData.Protect (data, entropy, scope);
++ int total = 0;
++ for (int i=0; i < 16; i++)
++ total += encdata [i];
++ Assert ("Protect", (total != 0));
++
++ byte[] decdata = ProtectedData.Unprotect (encdata, entropy, scope);
++ total = 0;
++ for (int i=0; i < 16; i++)
++ total += decdata [i];
++ Assert ("Unprotect", (total == 0));
++ }
++
++ [Test]
++ public void ProtectCurrentUser ()
++ {
++ try {
++ byte[] notMuchEntropy = new byte [16];
++ // we're testing the DataProtectionScope definition but
++ // not if it's really limited to the scope specified
++ ProtectUnprotect (notMuchEntropy, DataProtectionScope.CurrentUser);
++ }
++ catch (PlatformNotSupportedException) {
++ Console.WriteLine ("Only supported under Windows 2000 and later");
++ }
++ }
++
++ [Test]
++ public void ProtectLocalMachine ()
++ {
++ try {
++ byte[] notMuchEntropy = new byte [16];
++ // we're testing the DataProtectionScope definition but
++ // not if it's really limited to the scope specified
++ ProtectUnprotect (notMuchEntropy, DataProtectionScope.LocalMachine);
++ }
++ catch (PlatformNotSupportedException) {
++ Console.WriteLine ("Only supported under Windows 2000 and later");
++ }
++ }
++
++ [Test]
++ [ExpectedException (typeof (ArgumentNullException))]
++ public void ProtectNull ()
++ {
++ byte[] notMuchEntropy = new byte [16];
++ ProtectedData.Protect (null, notMuchEntropy, DataProtectionScope.CurrentUser);
++ }
++
++ [Test]
++ public void ProtectNullEntropy ()
++ {
++ try {
++ // we're testing the DataProtectionScope definition but
++ // not if it's really limited to the scope specified
++ ProtectUnprotect (null, DataProtectionScope.LocalMachine);
++ }
++ catch (PlatformNotSupportedException) {
++ Console.WriteLine ("Only supported under Windows 2000 and later");
++ }
++ }
++
++ [Test]
++ [ExpectedException (typeof (CryptographicException))]
++ public void UnprotectNotProtectedData ()
++ {
++ byte[] baddata = new byte [16];
++ byte[] notMuchEntropy = new byte [16];
++ ProtectedData.Unprotect (baddata, notMuchEntropy, DataProtectionScope.CurrentUser);
++ }
++
++ [Test]
++ [ExpectedException (typeof (ArgumentNullException))]
++ public void UnprotectNull ()
++ {
++ byte[] notMuchEntropy = new byte [16];
++ ProtectedData.Unprotect (null, notMuchEntropy, DataProtectionScope.CurrentUser);
++ }
++ }
++}
++
++#endif
--- /dev/null
--- /dev/null
++//
++// ProtectedMemoryTest.cs - NUnit Test Cases for ProtectedMemory
++//
++// Author:
++// Sebastien Pouliot (spouliot@motus.com)
++//
++// (C) 2003 Motus Technologies Inc. (http://www.motus.com)
++//
++
++#if NET_2_0
++
++using NUnit.Framework;
++
++using System;
++using System.Security.Cryptography;
++
++namespace MonoTests.System.Security.Cryptography {
++
++ // References:
++ // a.
++
++ [TestFixture]
++ public class ProtectedMemoryTest : Assertion {
++
++ private void ProtectUnprotect (MemoryProtectionScope scope)
++ {
++ byte[] data = new byte [16];
++ ProtectedMemory.Protect (data, scope);
++ int total = 0;
++ for (int i=0; i < 16; i++)
++ total += data [i];
++ Assert ("Protect", (total != 0));
++
++ ProtectedMemory.Unprotect (data, scope);
++ total = 0;
++ for (int i=0; i < 16; i++)
++ total += data [i];
++ Assert ("Unprotect", (total == 0));
++ }
++
++ [Test]
++ public void ProtectSameProcess ()
++ {
++ try {
++ // we're testing the MemoryProtectionScope definition but
++ // not if it's really limited to the scope specified
++ ProtectUnprotect (MemoryProtectionScope.SameProcess);
++ }
++ catch (PlatformNotSupportedException) {
++ Console.WriteLine ("Only supported under Windows XP and later");
++ }
++ }
++
++ [Test]
++ public void ProtectSameLogon ()
++ {
++ try {
++ // we're testing the MemoryProtectionScope definition but
++ // not if it's really limited to the scope specified
++ ProtectUnprotect (MemoryProtectionScope.SameLogon);
++ }
++ catch (PlatformNotSupportedException) {
++ Console.WriteLine ("Only supported under Windows XP and later");
++ }
++ }
++
++ [Test]
++ public void ProtectCrossProcess ()
++ {
++ try {
++ // we're testing the MemoryProtectionScope definition but
++ // not if it's really limited to the scope specified
++ ProtectUnprotect (MemoryProtectionScope.CrossProcess);
++ }
++ catch (PlatformNotSupportedException) {
++ Console.WriteLine ("Only supported under Windows XP and later");
++ }
++ }
++
++ [Test]
++ [ExpectedException (typeof (CryptographicException))]
++ public void ProtectBadDataLength ()
++ {
++ byte[] data = new byte [15];
++ ProtectedMemory.Protect (data, MemoryProtectionScope.SameProcess);
++ }
++
++ [Test]
++ [ExpectedException (typeof (ArgumentNullException))]
++ public void ProtectNull ()
++ {
++ ProtectedMemory.Protect (null, MemoryProtectionScope.SameProcess);
++ }
++
++ [Test]
++ [ExpectedException (typeof (CryptographicException))]
++ public void UnprotectBadDataLength ()
++ {
++ byte[] data = new byte [15];
++ ProtectedMemory.Unprotect (data, MemoryProtectionScope.SameProcess);
++ }
++
++ [Test]
++ [ExpectedException (typeof (ArgumentNullException))]
++ public void UnprotectNull ()
++ {
++ ProtectedMemory.Unprotect (null, MemoryProtectionScope.SameProcess);
++ }
++ }
++}
++
++#endif