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

◆ InitializeKeyUiPolicyProperties()

static unsafe void System.Security.Cryptography.CngKey.InitializeKeyUiPolicyProperties ( SafeNCryptKeyHandle keyHandle,
CngUIPolicy uiPolicy )
inlinestaticprivate

Definition at line 363 of file CngKey.cs.

364 {
365 //The blocks IL_0031, IL_0039, IL_004a, IL_00b2 are reachable both inside and outside the pinned region starting at IL_002c. ILSpy has duplicated these blocks in order to place them both within and outside the `fixed` statement.
366 fixed (char* value3 = uiPolicy.CreationTitle)
367 {
368 string? friendlyName = uiPolicy.FriendlyName;
369 char* intPtr;
370 string? description;
371 global::Interop.NCrypt.NCRYPT_UI_POLICY nCRYPT_UI_POLICY2;
372 if (friendlyName == null)
373 {
374 char* value;
375 intPtr = (value = null);
376 description = uiPolicy.Description;
377 fixed (char* ptr = description)
378 {
379 char* value2 = ptr;
380 global::Interop.NCrypt.NCRYPT_UI_POLICY nCRYPT_UI_POLICY = default(global::Interop.NCrypt.NCRYPT_UI_POLICY);
381 nCRYPT_UI_POLICY.dwVersion = 1;
382 nCRYPT_UI_POLICY.dwFlags = uiPolicy.ProtectionLevel;
383 nCRYPT_UI_POLICY.pszCreationTitle = new IntPtr(value3);
384 nCRYPT_UI_POLICY.pszFriendlyName = new IntPtr(value);
385 nCRYPT_UI_POLICY.pszDescription = new IntPtr(value2);
386 nCRYPT_UI_POLICY2 = nCRYPT_UI_POLICY;
387 global::Interop.NCrypt.ErrorCode errorCode = global::Interop.NCrypt.NCryptSetProperty(keyHandle, "UI Policy", &nCRYPT_UI_POLICY2, sizeof(global::Interop.NCrypt.NCRYPT_UI_POLICY), CngPropertyOptions.Persist);
388 if (errorCode != 0)
389 {
390 throw errorCode.ToCryptographicException();
391 }
392 }
393 }
394 else
395 {
396 fixed (char* ptr2 = &friendlyName.GetPinnableReference())
397 {
398 char* value;
399 intPtr = (value = ptr2);
400 description = uiPolicy.Description;
401 fixed (char* ptr = description)
402 {
403 char* value2 = ptr;
404 global::Interop.NCrypt.NCRYPT_UI_POLICY nCRYPT_UI_POLICY = default(global::Interop.NCrypt.NCRYPT_UI_POLICY);
405 nCRYPT_UI_POLICY.dwVersion = 1;
406 nCRYPT_UI_POLICY.dwFlags = uiPolicy.ProtectionLevel;
407 nCRYPT_UI_POLICY.pszCreationTitle = new IntPtr(value3);
408 nCRYPT_UI_POLICY.pszFriendlyName = new IntPtr(value);
409 nCRYPT_UI_POLICY.pszDescription = new IntPtr(value2);
410 nCRYPT_UI_POLICY2 = nCRYPT_UI_POLICY;
411 global::Interop.NCrypt.ErrorCode errorCode = global::Interop.NCrypt.NCryptSetProperty(keyHandle, "UI Policy", &nCRYPT_UI_POLICY2, sizeof(global::Interop.NCrypt.NCRYPT_UI_POLICY), CngPropertyOptions.Persist);
412 if (errorCode != 0)
413 {
414 throw errorCode.ToCryptographicException();
415 }
416 }
417 }
418 }
419 }
420 string useContext = uiPolicy.UseContext;
421 if (useContext == null)
422 {
423 return;
424 }
425 int cbInput = checked((useContext.Length + 1) * 2);
426 fixed (char* pbInput = useContext)
427 {
428 global::Interop.NCrypt.ErrorCode errorCode2 = global::Interop.NCrypt.NCryptSetProperty(keyHandle, "Use Context", pbInput, cbInput, CngPropertyOptions.Persist);
429 if (errorCode2 != 0)
430 {
431 throw errorCode2.ToCryptographicException();
432 }
433 }
434 }

References System.Security.Cryptography.CngUIPolicy.CreationTitle, System.Security.Cryptography.CngUIPolicy.Description, System.Security.Cryptography.CngUIPolicy.FriendlyName, System.Security.Cryptography.CngUIPolicy.ProtectionLevel, System.Security.Cryptography.CngUIPolicy.UseContext, and System.value.

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