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

◆ X500DistinguishedNameDecode()

unsafe string Internal.Cryptography.Pal.X509Pal.X500DistinguishedNameDecode ( byte[] encodedDistinguishedName,
X500DistinguishedNameFlags flag )
inline

Implements Internal.Cryptography.Pal.IX509Pal.

Definition at line 464 of file X509Pal.cs.

465 {
466 int dwStrType = (int)(CertNameStrTypeAndFlags.CERT_X500_NAME_STR | MapNameToStrFlag(flag));
467 fixed (byte* pbData = encodedDistinguishedName)
468 {
469 Unsafe.SkipInit(out CRYPTOAPI_BLOB cRYPTOAPI_BLOB);
470 cRYPTOAPI_BLOB.cbData = encodedDistinguishedName.Length;
471 cRYPTOAPI_BLOB.pbData = pbData;
472 int num = global::Interop.Crypt32.CertNameToStr(65537, &cRYPTOAPI_BLOB, dwStrType, null, 0);
473 if (num == 0)
474 {
475 throw (-2146762476).ToCryptographicException();
476 }
477 Span<char> span = ((num > 256) ? ((Span<char>)new char[num]) : stackalloc char[num]);
478 Span<char> span2 = span;
479 fixed (char* psz = span2)
480 {
481 if (global::Interop.Crypt32.CertNameToStr(65537, &cRYPTOAPI_BLOB, dwStrType, psz, num) == 0)
482 {
483 throw (-2146762476).ToCryptographicException();
484 }
485 }
486 return new string(span2.Slice(0, num - 1));
487 }
488 }
static CertNameStrTypeAndFlags MapNameToStrFlag(X500DistinguishedNameFlags flag)
Definition X509Pal.cs:531
Span< T > Slice(int start)
Definition Span.cs:271

References Internal.Cryptography.Pal.X509Pal.MapNameToStrFlag(), and System.Span< T >.Slice().