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

◆ InitializeKeyProperties()

static unsafe void System.Security.Cryptography.CngKey.InitializeKeyProperties ( SafeNCryptKeyHandle keyHandle,
CngKeyCreationParameters creationParameters )
inlinestaticprivate

Definition at line 318 of file CngKey.cs.

319 {
320 if (creationParameters.ExportPolicy.HasValue)
321 {
322 CngExportPolicies value = creationParameters.ExportPolicy.Value;
323 keyHandle.SetExportPolicy(value);
324 }
325 if (creationParameters.KeyUsage.HasValue)
326 {
327 CngKeyUsages value2 = creationParameters.KeyUsage.Value;
328 global::Interop.NCrypt.ErrorCode errorCode = global::Interop.NCrypt.NCryptSetProperty(keyHandle, "Key Usage", &value2, 4, CngPropertyOptions.Persist);
329 if (errorCode != 0)
330 {
331 throw errorCode.ToCryptographicException();
332 }
333 }
334 if (creationParameters.ParentWindowHandle != IntPtr.Zero)
335 {
336 IntPtr parentWindowHandle = creationParameters.ParentWindowHandle;
337 global::Interop.NCrypt.ErrorCode errorCode2 = global::Interop.NCrypt.NCryptSetProperty(keyHandle, "HWND Handle", &parentWindowHandle, sizeof(IntPtr), CngPropertyOptions.None);
338 if (errorCode2 != 0)
339 {
340 throw errorCode2.ToCryptographicException();
341 }
342 }
343 CngUIPolicy uIPolicy = creationParameters.UIPolicy;
344 if (uIPolicy != null)
345 {
346 InitializeKeyUiPolicyProperties(keyHandle, uIPolicy);
347 }
348 foreach (CngProperty parameter in creationParameters.Parameters)
349 {
350 byte[] valueWithoutCopying = parameter.GetValueWithoutCopying();
351 int cbInput = ((valueWithoutCopying != null) ? valueWithoutCopying.Length : 0);
352 fixed (byte* pbInput = valueWithoutCopying.MapZeroLengthArrayToNonNullPointer())
353 {
354 global::Interop.NCrypt.ErrorCode errorCode3 = global::Interop.NCrypt.NCryptSetProperty(keyHandle, parameter.Name, pbInput, cbInput, parameter.Options);
355 if (errorCode3 != 0)
356 {
357 throw errorCode3.ToCryptographicException();
358 }
359 }
360 }
361 }
static unsafe void InitializeKeyUiPolicyProperties(SafeNCryptKeyHandle keyHandle, CngUIPolicy uiPolicy)
Definition CngKey.cs:363

References System.Security.Cryptography.CngKeyCreationParameters.ExportPolicy, System.Security.Cryptography.CngProperty.GetValueWithoutCopying(), System.Security.Cryptography.CngKey.InitializeKeyUiPolicyProperties(), System.Security.Cryptography.CngKeyCreationParameters.KeyUsage, System.Security.Cryptography.CngProperty.Name, System.Security.Cryptography.CngProperty.Options, System.Security.Cryptography.CngKeyCreationParameters.ParentWindowHandle, System.Security.Cryptography.CngKeyCreationParameters.UIPolicy, System.value, and System.IntPtr.Zero.

Referenced by System.Security.Cryptography.CngKey.Create().