diff options
Diffstat (limited to 'crypto/src/asn1/Asn1Utilities.cs')
-rw-r--r-- | crypto/src/asn1/Asn1Utilities.cs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/crypto/src/asn1/Asn1Utilities.cs b/crypto/src/asn1/Asn1Utilities.cs index cdef45646..169f1fb37 100644 --- a/crypto/src/asn1/Asn1Utilities.cs +++ b/crypto/src/asn1/Asn1Utilities.cs @@ -652,6 +652,20 @@ namespace Org.BouncyCastle.Asn1 #region Sequence cursor + public static TResult ReadContextTagged<TState, TResult>(Asn1Sequence sequence, ref int sequencePosition, + int tagNo, TState state, Func<Asn1TaggedObject, TState, TResult> constructor) + { + return ReadTagged(sequence, ref sequencePosition, Asn1Tags.ContextSpecific, tagNo, state, constructor); + } + + public static TResult ReadTagged<TState, TResult>(Asn1Sequence sequence, ref int sequencePosition, int tagClass, + int tagNo, TState state, Func<Asn1TaggedObject, TState, TResult> constructor) + { + var tagged = Asn1TaggedObject.GetInstance(sequence[sequencePosition++], tagClass, tagNo); + + return constructor(tagged, state); + } + public static TResult ReadOptional<TResult>(Asn1Sequence sequence, ref int sequencePosition, Func<Asn1Encodable, TResult> constructor) where TResult : class |