internal static void Decode(AsnReader reader, Asn1Tag expectedTag, out CurveAsn decoded) { if (reader == null) { throw new ArgumentNullException(nameof(reader)); } decoded = default; AsnReader sequenceReader = reader.ReadSequence(expectedTag); if (sequenceReader.TryReadPrimitiveOctetStringBytes(out ReadOnlyMemory <byte> tmpA)) { decoded.A = tmpA; } else { decoded.A = sequenceReader.ReadOctetString(); } if (sequenceReader.TryReadPrimitiveOctetStringBytes(out ReadOnlyMemory <byte> tmpB)) { decoded.B = tmpB; } else { decoded.B = sequenceReader.ReadOctetString(); } if (sequenceReader.HasData && sequenceReader.PeekTag().HasSameClassAndValue(Asn1Tag.PrimitiveBitString)) { if (sequenceReader.TryReadPrimitiveBitStringValue(out _, out ReadOnlyMemory <byte> tmpSeed)) { decoded.Seed = tmpSeed; } else { decoded.Seed = sequenceReader.ReadBitString(out _); } } sequenceReader.ThrowIfNotEmpty(); }
internal static void Decode(AsnReader reader, Asn1Tag expectedTag, out SubjectPublicKeyInfoAsn decoded) { if (reader == null) { throw new ArgumentNullException(nameof(reader)); } decoded = default; AsnReader sequenceReader = reader.ReadSequence(expectedTag); System.Security.Cryptography.Asn1.AlgorithmIdentifierAsn.Decode(sequenceReader, out decoded.Algorithm); if (sequenceReader.TryReadPrimitiveBitStringValue(out _, out ReadOnlyMemory <byte> tmpSubjectPublicKey)) { decoded.SubjectPublicKey = tmpSubjectPublicKey; } else { decoded.SubjectPublicKey = sequenceReader.ReadBitString(out _); } sequenceReader.ThrowIfNotEmpty(); }