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

◆ ParsePrimitiveBitStringContents()

static void System.Formats.Asn1.AsnDecoder.ParsePrimitiveBitStringContents ( ReadOnlySpan< byte > source,
AsnEncodingRules ruleSet,
out int unusedBitCount,
out ReadOnlySpan< byte > value,
out byte normalizedLastByte )
inlinestaticprivate

Definition at line 457 of file AsnDecoder.cs.

458 {
459 if (ruleSet == AsnEncodingRules.CER && source.Length > 1000)
460 {
461 throw new AsnContentException(System.SR.ContentException_InvalidUnderCer_TryBerOrDer);
462 }
463 if (source.Length == 0)
464 {
465 throw new AsnContentException();
466 }
468 if (unusedBitCount > 7)
469 {
470 throw new AsnContentException();
471 }
472 if (source.Length == 1)
473 {
474 if (unusedBitCount > 0)
475 {
476 throw new AsnContentException();
477 }
480 return;
481 }
482 int num = -1 << unusedBitCount;
483 byte b = source[source.Length - 1];
484 byte b2 = (byte)(b & num);
485 if (b2 != b && (ruleSet == AsnEncodingRules.DER || ruleSet == AsnEncodingRules.CER))
486 {
487 throw new AsnContentException(System.SR.ContentException_InvalidUnderCerOrDer_TryBer);
488 }
490 value = source.Slice(1);
491 }
static string ContentException_InvalidUnderCerOrDer_TryBer
Definition SR.cs:56
static string ContentException_InvalidUnderCer_TryBerOrDer
Definition SR.cs:54
Definition SR.cs:7

References System.SR.ContentException_InvalidUnderCer_TryBerOrDer, System.SR.ContentException_InvalidUnderCerOrDer_TryBer, System.source, and System.value.

Referenced by System.Formats.Asn1.AsnDecoder.ProcessConstructedBitString(), and System.Formats.Asn1.AsnDecoder.TryReadPrimitiveBitStringCore().