diff options
Diffstat (limited to 'crypto/src/asn1/Asn1Sequence.cs')
-rw-r--r-- | crypto/src/asn1/Asn1Sequence.cs | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/crypto/src/asn1/Asn1Sequence.cs b/crypto/src/asn1/Asn1Sequence.cs index 8025492d2..9ab41ffd3 100644 --- a/crypto/src/asn1/Asn1Sequence.cs +++ b/crypto/src/asn1/Asn1Sequence.cs @@ -62,16 +62,16 @@ namespace Org.BouncyCastle.Asn1 */ public static Asn1Sequence GetInstance(Asn1TaggedObject taggedObject, bool declaredExplicit) { - Asn1Object baseObject = taggedObject.GetObject(); - if (declaredExplicit) { if (!taggedObject.IsExplicit()) throw new ArgumentException("object implicit - explicit expected."); - return (Asn1Sequence)baseObject; + return GetInstance(taggedObject.GetObject()); } + Asn1Object baseObject = taggedObject.GetObject(); + // If parsed as explicit though declared implicit, it should have been a sequence of one if (taggedObject.IsExplicit()) { @@ -235,7 +235,7 @@ namespace Org.BouncyCastle.Asn1 return true; } - internal override bool EncodeConstructed() + internal override bool EncodeConstructed(int encoding) { return true; } @@ -245,6 +245,17 @@ namespace Org.BouncyCastle.Asn1 return CollectionUtilities.ToString(elements); } + internal int CalculateContentsLength(int encoding) + { + int contentsLength = 0; + for (int i = 0, count = elements.Length; i < count; ++i) + { + Asn1Object asn1Object = elements[i].ToAsn1Object(); + contentsLength += asn1Object.EncodedLength(encoding, true); + } + return contentsLength; + } + // TODO[asn1] Preferably return an Asn1BitString[] (doesn't exist yet) internal DerBitString[] GetConstructedBitStrings() { |