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

◆ SignValue()

static byte[] Internal.NativeCrypto.CapiHelper.SignValue ( SafeProvHandle hProv,
SafeKeyHandle hKey,
int keyNumber,
int calgKey,
int calgHash,
byte[] hash )
inlinestatic

Definition at line 1142 of file CapiHelper.cs.

1143 {
1144 using SafeHashHandle hHash = hProv.CreateHashHandle(hash, calgHash);
1145 int pdwSigLen = 0;
1146 if (!global::Interop.Advapi32.CryptSignHash(hHash, (global::Interop.Advapi32.KeySpec)keyNumber, null, global::Interop.Advapi32.CryptSignAndVerifyHashFlags.None, null, ref pdwSigLen))
1147 {
1148 int hRForLastWin32Error = Marshal.GetHRForLastWin32Error();
1149 throw hRForLastWin32Error.ToCryptographicException();
1150 }
1151 byte[] array = new byte[pdwSigLen];
1152 if (!global::Interop.Advapi32.CryptSignHash(hHash, (global::Interop.Advapi32.KeySpec)keyNumber, null, global::Interop.Advapi32.CryptSignAndVerifyHashFlags.None, array, ref pdwSigLen))
1153 {
1154 int hRForLastWin32Error2 = Marshal.GetHRForLastWin32Error();
1155 throw hRForLastWin32Error2.ToCryptographicException();
1156 }
1157 switch (calgKey)
1158 {
1159 case 9216:
1161 break;
1162 case 8704:
1163 ReverseDsaSignature(array, pdwSigLen);
1164 break;
1165 default:
1166 throw new InvalidOperationException();
1167 }
1168 return array;
1169 }
static void ReverseDsaSignature(byte[] signature, int cbSignature)
static void Reverse(Array array)
Definition Array.cs:2207

References System.array, System.Runtime.InteropServices.Marshal.GetHRForLastWin32Error(), System.Array.Reverse(), and Internal.NativeCrypto.CapiHelper.ReverseDsaSignature().

Referenced by System.Security.Cryptography.RSACryptoServiceProvider.SignHash(), and System.Security.Cryptography.DSACryptoServiceProvider.SignHash().