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

◆ ComputeCapiSha1OfPublicKey()

unsafe byte[] Internal.Cryptography.Pal.X509Pal.ComputeCapiSha1OfPublicKey ( PublicKey key)
inline

Implements Internal.Cryptography.Pal.IX509Pal.

Definition at line 115 of file X509Pal.cs.

116 {
117 fixed (byte* value = key.Oid.ValueAsAscii())
118 {
119 byte[] rawData = key.EncodedParameters.RawData;
120 fixed (byte* pbData = rawData)
121 {
122 byte[] rawData2 = key.EncodedKeyValue.RawData;
123 fixed (byte* pbData2 = rawData2)
124 {
125 CERT_PUBLIC_KEY_INFO cERT_PUBLIC_KEY_INFO = default(CERT_PUBLIC_KEY_INFO);
126 cERT_PUBLIC_KEY_INFO.Algorithm = new CRYPT_ALGORITHM_IDENTIFIER
127 {
128 pszObjId = new IntPtr(value),
129 Parameters = new CRYPTOAPI_BLOB(rawData.Length, pbData)
130 };
131 cERT_PUBLIC_KEY_INFO.PublicKey = new CRYPT_BIT_BLOB
132 {
133 cbData = rawData2.Length,
134 pbData = pbData2,
135 cUnusedBits = 0
136 };
137 CERT_PUBLIC_KEY_INFO pInfo = cERT_PUBLIC_KEY_INFO;
138 int pcbComputedHash = 20;
139 byte[] array = new byte[pcbComputedHash];
140 if (!global::Interop.crypt32.CryptHashPublicKeyInfo(IntPtr.Zero, 32772, 0, CertEncodingType.All, ref pInfo, array, ref pcbComputedHash))
141 {
142 throw Marshal.GetHRForLastWin32Error().ToCryptographicException();
143 }
144 if (pcbComputedHash < array.Length)
145 {
146 byte[] array2 = new byte[pcbComputedHash];
147 Buffer.BlockCopy(array, 0, array2, 0, pcbComputedHash);
148 array = array2;
149 }
150 return array;
151 }
152 }
153 }
154 }
static void BlockCopy(Array src, int srcOffset, Array dst, int dstOffset, int count)
Definition Buffer.cs:102
static readonly IntPtr Zero
Definition IntPtr.cs:18

References System.array, System.Buffer.BlockCopy(), System.Runtime.InteropServices.Marshal.GetHRForLastWin32Error(), System.key, System.value, and System.IntPtr.Zero.