Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
CngAlgorithm.cs
Go to the documentation of this file.
2
4
5public sealed class CngAlgorithm : IEquatable<CngAlgorithm>
6{
7 private static CngAlgorithm s_ecdh;
8
9 private static CngAlgorithm s_ecdhp256;
10
11 private static CngAlgorithm s_ecdhp384;
12
13 private static CngAlgorithm s_ecdhp521;
14
15 private static CngAlgorithm s_ecdsa;
16
17 private static CngAlgorithm s_ecdsap256;
18
19 private static CngAlgorithm s_ecdsap384;
20
21 private static CngAlgorithm s_ecdsap521;
22
23 private static CngAlgorithm s_md5;
24
25 private static CngAlgorithm s_sha1;
26
27 private static CngAlgorithm s_sha256;
28
29 private static CngAlgorithm s_sha384;
30
31 private static CngAlgorithm s_sha512;
32
33 private static CngAlgorithm s_rsa;
34
35 private readonly string _algorithm;
36
37 public string Algorithm => _algorithm;
38
39 public static CngAlgorithm Rsa => s_rsa ?? (s_rsa = new CngAlgorithm("RSA"));
40
41 public static CngAlgorithm ECDiffieHellman => s_ecdh ?? (s_ecdh = new CngAlgorithm("ECDH"));
42
43 public static CngAlgorithm ECDiffieHellmanP256 => s_ecdhp256 ?? (s_ecdhp256 = new CngAlgorithm("ECDH_P256"));
44
45 public static CngAlgorithm ECDiffieHellmanP384 => s_ecdhp384 ?? (s_ecdhp384 = new CngAlgorithm("ECDH_P384"));
46
47 public static CngAlgorithm ECDiffieHellmanP521 => s_ecdhp521 ?? (s_ecdhp521 = new CngAlgorithm("ECDH_P521"));
48
49 public static CngAlgorithm ECDsa => s_ecdsa ?? (s_ecdsa = new CngAlgorithm("ECDSA"));
50
51 public static CngAlgorithm ECDsaP256 => s_ecdsap256 ?? (s_ecdsap256 = new CngAlgorithm("ECDSA_P256"));
52
53 public static CngAlgorithm ECDsaP384 => s_ecdsap384 ?? (s_ecdsap384 = new CngAlgorithm("ECDSA_P384"));
54
55 public static CngAlgorithm ECDsaP521 => s_ecdsap521 ?? (s_ecdsap521 = new CngAlgorithm("ECDSA_P521"));
56
57 public static CngAlgorithm MD5 => s_md5 ?? (s_md5 = new CngAlgorithm("MD5"));
58
59 public static CngAlgorithm Sha1 => s_sha1 ?? (s_sha1 = new CngAlgorithm("SHA1"));
60
61 public static CngAlgorithm Sha256 => s_sha256 ?? (s_sha256 = new CngAlgorithm("SHA256"));
62
63 public static CngAlgorithm Sha384 => s_sha384 ?? (s_sha384 = new CngAlgorithm("SHA384"));
64
65 public static CngAlgorithm Sha512 => s_sha512 ?? (s_sha512 = new CngAlgorithm("SHA512"));
66
67 public CngAlgorithm(string algorithm)
68 {
69 if (algorithm == null)
70 {
71 throw new ArgumentNullException("algorithm");
72 }
73 if (algorithm.Length == 0)
74 {
76 }
77 _algorithm = algorithm;
78 }
79
80 public static bool operator ==(CngAlgorithm? left, CngAlgorithm? right)
81 {
82 return left?.Equals(right) ?? ((object)right == null);
83 }
84
85 public static bool operator !=(CngAlgorithm? left, CngAlgorithm? right)
86 {
87 if ((object)left == null)
88 {
89 return (object)right != null;
90 }
91 return !left.Equals(right);
92 }
93
94 public override bool Equals([NotNullWhen(true)] object? obj)
95 {
96 return Equals(obj as CngAlgorithm);
97 }
98
99 public bool Equals([NotNullWhen(true)] CngAlgorithm? other)
100 {
101 if ((object)other == null)
102 {
103 return false;
104 }
105 return _algorithm.Equals(other.Algorithm);
106 }
107
108 public override int GetHashCode()
109 {
110 return _algorithm.GetHashCode();
111 }
112
113 public override string ToString()
114 {
115 return _algorithm;
116 }
117}
static string Cryptography_InvalidAlgorithmName
Definition SR.cs:52
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
Definition SR.cs:7
static bool operator==(CngAlgorithm? left, CngAlgorithm? right)
override bool Equals([NotNullWhen(true)] object? obj)
bool Equals([NotNullWhen(true)] CngAlgorithm? other)
static bool operator!=(CngAlgorithm? left, CngAlgorithm? right)