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

◆ GenerateNewExportableKey() [1/3]

static SafeNCryptKeyHandle System.Security.Cryptography.CngKeyLite.GenerateNewExportableKey ( string algorithm,
int keySize )
inlinestaticpackage

Definition at line 170 of file CngKeyLite.cs.

171 {
172 global::Interop.NCrypt.ErrorCode errorCode = global::Interop.NCrypt.NCryptCreatePersistedKey(s_microsoftSoftwareProviderHandle, out var phKey, algorithm, null, 0, CngKeyCreationOptions.None);
173 if (errorCode != 0)
174 {
175 throw errorCode.ToCryptographicException();
176 }
177 SetExportable(phKey);
178 SetKeyLength(phKey, keySize);
179 errorCode = global::Interop.NCrypt.NCryptFinalizeKey(phKey, 0);
180 if (errorCode != 0)
181 {
182 throw errorCode.ToCryptographicException();
183 }
184 return phKey;
185 }
static readonly SafeNCryptProviderHandle s_microsoftSoftwareProviderHandle
Definition CngKeyLite.cs:10
static unsafe void SetKeyLength(SafeNCryptKeyHandle keyHandle, int keySize)
static unsafe void SetExportable(SafeNCryptKeyHandle keyHandle)

References System.Security.Cryptography.CngKeyLite.s_microsoftSoftwareProviderHandle, System.Security.Cryptography.CngKeyLite.SetExportable(), and System.Security.Cryptography.CngKeyLite.SetKeyLength().

Referenced by System.Security.Cryptography.ECCngKey.GenerateKey(), System.Security.Cryptography.DSAImplementation.DSACng.GetDuplicatedKeyHandle(), System.Security.Cryptography.RSAImplementation.RSACng.GetDuplicatedKeyHandle(), and System.Security.Cryptography.ECCngKey.GetDuplicatedKeyHandle().