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

◆ GetKeyPairHelper()

static SafeKeyHandle Internal.NativeCrypto.CapiHelper.GetKeyPairHelper ( CspAlgorithmType keyType,
CspParameters parameters,
int keySize,
SafeProvHandle safeProvHandle )
inlinestaticpackage

Definition at line 874 of file CapiHelper.cs.

875 {
876 SafeKeyHandle safeKeyHandle;
877 int userKey = GetUserKey(safeProvHandle, parameters.KeyNumber, out safeKeyHandle);
878 if (userKey != 0)
879 {
880 safeKeyHandle.Dispose();
881 if (IsFlagBitSet((uint)parameters.Flags, 8u) || userKey != -2146893811)
882 {
883 throw userKey.ToCryptographicException();
884 }
885 GenerateKey(safeProvHandle, parameters.KeyNumber, (int)parameters.Flags, (uint)keySize, out safeKeyHandle);
886 }
887 byte[] keyParameter = GetKeyParameter(safeKeyHandle, 9);
888 int num = BinaryPrimitives.ReadInt32LittleEndian(keyParameter);
889 if ((keyType == CspAlgorithmType.Rsa && num != 41984 && num != 9216) || (keyType == CspAlgorithmType.Dss && num != 8704))
890 {
891 safeKeyHandle.Dispose();
893 }
894 return safeKeyHandle;
895 }
static bool IsFlagBitSet(uint dwImp, uint flag)
static int GenerateKey(SafeProvHandle safeProvHandle, int algID, int flags, uint keySize, out SafeKeyHandle safeKeyHandle)
static int GetUserKey(SafeProvHandle safeProvHandle, int keySpec, out SafeKeyHandle safeKeyHandle)
static byte[] GetKeyParameter(SafeKeyHandle safeKeyHandle, int keyParam)
static int ReadInt32LittleEndian(ReadOnlySpan< byte > source)
static string Cryptography_CSP_WrongKeySpec
Definition SR.cs:26
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
Definition SR.cs:7
override void Dispose(bool disposing)

References System.SR.Cryptography_CSP_WrongKeySpec, System.Runtime.InteropServices.SafeHandle.Dispose(), System.Security.Cryptography.CspParameters.Flags, System.SR.Format(), Internal.NativeCrypto.CapiHelper.GenerateKey(), Internal.NativeCrypto.CapiHelper.GetKeyParameter(), Internal.NativeCrypto.CapiHelper.GetUserKey(), Internal.NativeCrypto.CapiHelper.IsFlagBitSet(), System.Security.Cryptography.CspParameters.KeyNumber, and System.Buffers.Binary.BinaryPrimitives.ReadInt32LittleEndian().