From ad0b6c99d34da50d5473a9c14837a9ce199d0200 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Wed, 19 Feb 2020 21:03:22 +0700 Subject: ASN.1 updates from bc-java --- crypto/src/asn1/ASN1StreamParser.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'crypto/src/asn1/ASN1StreamParser.cs') diff --git a/crypto/src/asn1/ASN1StreamParser.cs b/crypto/src/asn1/ASN1StreamParser.cs index 3eaaadaee..860dc99b1 100644 --- a/crypto/src/asn1/ASN1StreamParser.cs +++ b/crypto/src/asn1/ASN1StreamParser.cs @@ -59,7 +59,7 @@ namespace Org.BouncyCastle.Asn1 if (_in is IndefiniteLengthInputStream) { if (!constructed) - throw new IOException("indefinite length primitive encoding encountered"); + throw new IOException("indefinite-length primitive encoding encountered"); return ReadIndef(tag); } @@ -134,12 +134,13 @@ namespace Org.BouncyCastle.Asn1 // // calculate length // - int length = Asn1InputStream.ReadLength(_in, _limit); + int length = Asn1InputStream.ReadLength(_in, _limit, + tagNo == Asn1Tags.OctetString || tagNo == Asn1Tags.Sequence || tagNo == Asn1Tags.Set || tagNo == Asn1Tags.External); - if (length < 0) // indefinite length method + if (length < 0) // indefinite-length method { if (!isConstructed) - throw new IOException("indefinite length primitive encoding encountered"); + throw new IOException("indefinite-length primitive encoding encountered"); IndefiniteLengthInputStream indIn = new IndefiniteLengthInputStream(_in, _limit); Asn1StreamParser sp = new Asn1StreamParser(indIn, _limit); @@ -158,7 +159,7 @@ namespace Org.BouncyCastle.Asn1 } else { - DefiniteLengthInputStream defIn = new DefiniteLengthInputStream(_in, length); + DefiniteLengthInputStream defIn = new DefiniteLengthInputStream(_in, length, _limit); if ((tag & Asn1Tags.Application) != 0) { -- cgit 1.4.1