Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ OpenProcessor() [1/2]

static RsaPaddingProcessor System.Security.Cryptography.RsaPaddingProcessor.OpenProcessor ( HashAlgorithmName hashAlgorithmName)
inlinestaticpackage

Definition at line 58 of file RsaPaddingProcessor.cs.

59 {
60 return s_lookup.GetOrAdd(hashAlgorithmName, delegate(HashAlgorithmName hashAlgorithmName)
61 {
62 using IncrementalHash incrementalHash = IncrementalHash.CreateHash(hashAlgorithmName);
63 Span<byte> destination = stackalloc byte[64];
64 ReadOnlyMemory<byte> digestInfoPrefix;
65 if (hashAlgorithmName == HashAlgorithmName.MD5)
66 {
67 digestInfoPrefix = s_digestInfoMD5;
68 }
69 else if (hashAlgorithmName == HashAlgorithmName.SHA1)
70 {
71 digestInfoPrefix = s_digestInfoSha1;
72 }
73 else if (hashAlgorithmName == HashAlgorithmName.SHA256)
74 {
75 digestInfoPrefix = s_digestInfoSha256;
76 }
77 else if (hashAlgorithmName == HashAlgorithmName.SHA384)
78 {
79 digestInfoPrefix = s_digestInfoSha384;
80 }
81 else
82 {
83 if (!(hashAlgorithmName == HashAlgorithmName.SHA512))
84 {
85 throw new CryptographicException();
86 }
87 digestInfoPrefix = s_digestInfoSha512;
88 }
89 if (incrementalHash.TryGetHashAndReset(destination, out var bytesWritten))
90 {
91 return new RsaPaddingProcessor(hashAlgorithmName, bytesWritten, digestInfoPrefix);
92 }
93 byte[] hashAndReset = incrementalHash.GetHashAndReset();
94 return new RsaPaddingProcessor(hashAlgorithmName, hashAndReset.Length, digestInfoPrefix);
95 });
96 }
RsaPaddingProcessor(HashAlgorithmName hashAlgorithmName, int hLen, ReadOnlyMemory< byte > digestInfoPrefix)
static readonly ConcurrentDictionary< HashAlgorithmName, RsaPaddingProcessor > s_lookup

References System.Security.Cryptography.RsaPaddingProcessor.RsaPaddingProcessor(), System.Security.Cryptography.IncrementalHash.CreateHash(), System.destination, System.Security.Cryptography.HashAlgorithmName.MD5, System.Security.Cryptography.RsaPaddingProcessor.s_digestInfoSha512, System.Security.Cryptography.RsaPaddingProcessor.s_lookup, System.Security.Cryptography.HashAlgorithmName.SHA1, System.Security.Cryptography.HashAlgorithmName.SHA256, and System.Security.Cryptography.HashAlgorithmName.SHA384.

Referenced by System.Security.Cryptography.RSAImplementation.RSACng.EncryptOrDecrypt(), System.Security.Cryptography.RSACng.EncryptOrDecrypt(), System.Security.Cryptography.RSAImplementation.RSACng.TryEncryptOrDecrypt(), and System.Security.Cryptography.RSACng.TryEncryptOrDecrypt().