Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions mcs/class/System.Core/System.Security.Cryptography/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
2011-02-17 Juho Vähä-Herttua <[email protected]>

* CngAlgorithm.cs, CngAlgorithmGroup.cs: Change the private
variable name to match .NET when the class is serialized
* CngKeyBlobFormat.cs: New.
* CngKeyCreationParameters.cs: New.
* CngProperty.cs: New.
* CngPropertyCollection.cs: New.
* CngProvider.cs: New.
* CngUIPolicy.cs: New.

2011-02-16 Juho Vähä-Herttua <[email protected]>

* CngExportPolicies.cs: New.
* CngKeyCreationOptions.cs: New.
* CngKeyOpenOptions.cs: New.
* CngKeyUsages.cs: New.
* CngPropertyOptions.cs: New.
* CngUIProtectionLevels.cs: New.
* ECDiffieHellmanKeyDerivationFunction.cs: New.
* ECKeyXmlFormat.cs: New.

2010-03-18 Sebastien Pouliot <[email protected]>

* Aes.cs: Build here before NET_4_0 (or MOONLIGHT) otherwise
Expand Down
20 changes: 8 additions & 12 deletions mcs/class/System.Core/System.Security.Cryptography/CngAlgorithm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace System.Security.Cryptography {
[Serializable]
public sealed class CngAlgorithm : IEquatable<CngAlgorithm> {

private string algo;
private string m_algorithm;

public CngAlgorithm (string algorithm)
{
Expand All @@ -44,18 +44,18 @@ public CngAlgorithm (string algorithm)
if (algorithm.Length == 0)
throw new ArgumentException ("algorithm");

algo = algorithm;
m_algorithm = algorithm;
}

public string Algorithm {
get { return algo; }
get { return m_algorithm; }
}

public bool Equals (CngAlgorithm other)
{
if (other == null)
return false;
return algo == other.algo;
return m_algorithm == other.m_algorithm;
}

public override bool Equals (object obj)
Expand All @@ -65,12 +65,12 @@ public override bool Equals (object obj)

public override int GetHashCode ()
{
return algo.GetHashCode ();
return m_algorithm.GetHashCode ();
}

public override string ToString ()
{
return algo;
return m_algorithm;
}

// static
Expand Down Expand Up @@ -179,18 +179,14 @@ public static CngAlgorithm Sha512 {
{
if ((object)left == null)
return ((object)right == null);
if ((object)right == null)
return false;
return left.algo == right.algo;
return left.Equals (right);
}

public static bool operator != (CngAlgorithm left, CngAlgorithm right)
{
if ((object)left == null)
return ((object)right != null);
if ((object)right == null)
return true;
return left.algo != right.algo;
return !left.Equals (right);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace System.Security.Cryptography {
[Serializable]
public sealed class CngAlgorithmGroup : IEquatable<CngAlgorithmGroup> {

private string group;
private string m_algorithmGroup;

public CngAlgorithmGroup (string algorithmGroup)
{
Expand All @@ -44,16 +44,18 @@ public CngAlgorithmGroup (string algorithmGroup)
if (algorithmGroup.Length == 0)
throw new ArgumentException ("algorithmGroup");

group = algorithmGroup;
m_algorithmGroup = algorithmGroup;
}

public string AlgorithmGroup {
get { return group; }
get { return m_algorithmGroup; }
}

public bool Equals (CngAlgorithmGroup other)
{
return this == other;
if (other == null)
return false;
return m_algorithmGroup == other.m_algorithmGroup;
}

public override bool Equals (object obj)
Expand All @@ -63,12 +65,12 @@ public override bool Equals (object obj)

public override int GetHashCode ()
{
return group.GetHashCode ();
return m_algorithmGroup.GetHashCode ();
}

public override string ToString ()
{
return group;
return m_algorithmGroup;
}

// static
Expand Down Expand Up @@ -123,18 +125,14 @@ public static CngAlgorithmGroup Rsa {
{
if ((object)left == null)
return ((object)right == null);
if ((object)right == null)
return false;
return left.group == right.group;
return left.Equals (right);
}

public static bool operator != (CngAlgorithmGroup left, CngAlgorithmGroup right)
{
if ((object)left == null)
return ((object)right != null);
if ((object)right == null)
return true;
return left.group != right.group;
return !left.Equals (right);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//
// System.Security.Cryptography.CngExportPolicies
//
// Copyright (C) 2011 Juho Vähä-Herttua
//
// 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;

namespace System.Security.Cryptography {

// note: CNG stands for "Cryptography API: Next Generation"

[Flags]
public enum CngExportPolicies {
None,
AllowExport,
AllowPlaintextExport,
AllowArchiving,
AllowPlaintextArchiving
}
}
148 changes: 148 additions & 0 deletions mcs/class/System.Core/System.Security.Cryptography/CngKeyBlobFormat.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
//
// System.Security.Cryptography.CngKeyBlobFormat
//
// Authors:
// Sebastien Pouliot <[email protected]>
//
// Copyright (C) 2008 Novell, Inc (http://www.novell.com)
// Copyright (C) 2011 Juho Vähä-Herttua
//
// 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;

namespace System.Security.Cryptography {

// note: CNG stands for "Cryptography API: Next Generation"

[Serializable]
public sealed class CngKeyBlobFormat : IEquatable<CngKeyBlobFormat> {

private string m_format;

public CngKeyBlobFormat (string format)
{
if (format == null)
throw new ArgumentNullException ("format");
if (format.Length == 0)
throw new ArgumentException ("format");

m_format = format;
}

public string Format {
get { return m_format; }
}

public bool Equals (CngKeyBlobFormat other)
{
if (other == null)
return false;
return m_format == other.m_format;
}

public override bool Equals (object obj)
{
return Equals (obj as CngKeyBlobFormat);
}

public override int GetHashCode ()
{
return m_format.GetHashCode ();
}

public override string ToString ()
{
return m_format;
}

// static

private static CngKeyBlobFormat opaqueTransportBlob;
private static CngKeyBlobFormat genericPrivateBlob;
private static CngKeyBlobFormat genericPublicBlob;
private static CngKeyBlobFormat eccPrivateBlob;
private static CngKeyBlobFormat eccPublicBlob;
private static CngKeyBlobFormat pkcs8PrivateBlob;

public static CngKeyBlobFormat OpaqueTransportBlob {
get {
if (opaqueTransportBlob == null)
opaqueTransportBlob = new CngKeyBlobFormat ("OpaqueTransport");
return opaqueTransportBlob;
}
}

public static CngKeyBlobFormat GenericPrivateBlob {
get {
if (genericPrivateBlob == null)
genericPrivateBlob = new CngKeyBlobFormat ("PRIVATEBLOB");
return genericPrivateBlob;
}
}

public static CngKeyBlobFormat GenericPublicBlob {
get {
if (genericPublicBlob == null)
genericPublicBlob = new CngKeyBlobFormat ("PUBLICBLOB");
return genericPublicBlob;
}
}

public static CngKeyBlobFormat EccPrivateBlob {
get {
if (eccPrivateBlob == null)
eccPrivateBlob = new CngKeyBlobFormat ("ECCPRIVATEBLOB");
return eccPrivateBlob;
}
}

public static CngKeyBlobFormat EccPublicBlob {
get {
if (eccPublicBlob == null)
eccPublicBlob = new CngKeyBlobFormat ("ECCPUBLICBLOB");
return eccPublicBlob;
}
}

public static CngKeyBlobFormat Pkcs8PrivateBlob {
get {
if (pkcs8PrivateBlob == null)
pkcs8PrivateBlob = new CngKeyBlobFormat ("PKCS8_PRIVATEKEY");
return pkcs8PrivateBlob;
}
}

public static bool operator == (CngKeyBlobFormat left, CngKeyBlobFormat right)
{
if ((object)left == null)
return ((object)right == null);
return left.Equals (right);
}

public static bool operator != (CngKeyBlobFormat left, CngKeyBlobFormat right)
{
if ((object)left == null)
return ((object)right != null);
return !left.Equals (right);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// System.Security.Cryptography.CngKeyCreationOptions
//
// Copyright (C) 2011 Juho Vähä-Herttua
//
// 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;

namespace System.Security.Cryptography {

// note: CNG stands for "Cryptography API: Next Generation"

[Flags]
public enum CngKeyCreationOptions {
None = 0x00,
MachineKey = 0x20,
OverwriteExistingKey = 0x80
}
}
Loading