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

◆ GenerateNewExportableKey() [2/3]

static SafeNCryptKeyHandle System.Security.Cryptography.CngKeyLite.GenerateNewExportableKey ( string algorithm,
ref ECCurve explicitCurve )
inlinestaticpackage

Definition at line 204 of file CngKeyLite.cs.

205 {
206 global::Interop.NCrypt.ErrorCode errorCode = global::Interop.NCrypt.NCryptCreatePersistedKey(s_microsoftSoftwareProviderHandle, out var phKey, algorithm, null, 0, CngKeyCreationOptions.None);
207 if (errorCode != 0)
208 {
209 throw errorCode.ToCryptographicException();
210 }
211 SetExportable(phKey);
212 byte[] primeCurveParameterBlob = ECCng.GetPrimeCurveParameterBlob(ref explicitCurve);
213 SetProperty(phKey, "ECCParameters", primeCurveParameterBlob);
214 errorCode = global::Interop.NCrypt.NCryptFinalizeKey(phKey, 0);
215 if (errorCode != 0)
216 {
217 throw errorCode.ToCryptographicException();
218 }
219 return phKey;
220 }
static readonly SafeNCryptProviderHandle s_microsoftSoftwareProviderHandle
Definition CngKeyLite.cs:10
static unsafe void SetExportable(SafeNCryptKeyHandle keyHandle)
static unsafe void SetProperty(SafeNCryptHandle ncryptHandle, string propertyName, byte[] value)

References System.Security.Cryptography.ECCng.GetPrimeCurveParameterBlob(), System.Security.Cryptography.CngKeyLite.s_microsoftSoftwareProviderHandle, System.Security.Cryptography.CngKeyLite.SetExportable(), and System.Security.Cryptography.CngKeyLite.SetProperty().