CngAlgorithm.cs :  » 2.6.4-mono-.net-core » System.Security » System » Security » Cryptography » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » 2.6.4 mono .net core » System.Security 
System.Security » System » Security » Cryptography » CngAlgorithm.cs
//
// System.Security.Cryptography.CngAlgorithm
//
// Authors:
//  Sebastien Pouliot  <sebastien@ximian.com>
//
// Copyright (C) 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;

namespace System.Security.Cryptography{

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

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

    private string algo;

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

      algo = algorithm;
    }

    public string Algorithm {
      get { return algo; }
    }

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

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

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

    public override string ToString ()
    {
      return algo;
    }

    // static

    static CngAlgorithm dh256;
    static CngAlgorithm dh384;
    static CngAlgorithm dh521;
    static CngAlgorithm dsa256;
    static CngAlgorithm dsa384;
    static CngAlgorithm dsa521;
    static CngAlgorithm md5;
    static CngAlgorithm sha1;
    static CngAlgorithm sha256;
    static CngAlgorithm sha384;
    static CngAlgorithm sha512;

    public static CngAlgorithm ECDiffieHellmanP256 {
      get {
        if (dh256 == null)
          dh256 = new CngAlgorithm ("ECDH_P256");
        return dh256;
      }
    }

    public static CngAlgorithm ECDiffieHellmanP384 {
      get {
        if (dh384 == null)
          dh384 = new CngAlgorithm ("ECDH_P384");
        return dh384;
      }
    }

    public static CngAlgorithm ECDiffieHellmanP521 {
      get {
        if (dh521 == null)
          dh521 = new CngAlgorithm ("ECDH_P521");
        return dh521;
      }
    }

    public static CngAlgorithm ECDsaP256 {
      get {
        if (dsa256 == null)
          dsa256 = new CngAlgorithm ("ECDSA_P256");
        return dsa256;
      }
    }

    public static CngAlgorithm ECDsaP384 {
      get {
        if (dsa384 == null)
          dsa384 = new CngAlgorithm ("ECDSA_P384");
        return dsa384;
      }
    }

    public static CngAlgorithm ECDsaP521 {
      get {
        if (dsa521 == null)
          dsa521 = new CngAlgorithm ("ECDSA_P521");
        return dsa521;
      }
    }

    public static CngAlgorithm MD5 {
      get {
        if (md5 == null)
          md5 = new CngAlgorithm ("MD5");
        return md5;
      }
    }

    public static CngAlgorithm Sha1 {
      get {
        if (sha1 == null)
          sha1 = new CngAlgorithm ("SHA1");
        return sha1;
      }
    }

    public static CngAlgorithm Sha256 {
      get {
        if (sha256 == null)
          sha256 = new CngAlgorithm ("SHA256");
        return sha256;
      }
    }

    public static CngAlgorithm Sha384 {
      get {
        if (sha384 == null)
          sha384 = new CngAlgorithm ("SHA384");
        return sha384;
      }
    }

    public static CngAlgorithm Sha512 {
      get {
        if (sha512 == null)
          sha512 = new CngAlgorithm ("SHA512");
        return sha512;
      }
    }

    public static bool operator == (CngAlgorithm left, CngAlgorithm right)
    {
      if ((object)left == null)
        return ((object)right == null);
      if ((object)right == null)
        return false;
      return left.algo == right.algo;
    }

    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;
    }
  }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.