summary refs log tree commit diff
path: root/crypto/src/asn1/DerEncoding.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/asn1/DerEncoding.cs')
-rw-r--r--crypto/src/asn1/DerEncoding.cs38
1 files changed, 38 insertions, 0 deletions
diff --git a/crypto/src/asn1/DerEncoding.cs b/crypto/src/asn1/DerEncoding.cs
new file mode 100644

index 000000000..8de808d8c --- /dev/null +++ b/crypto/src/asn1/DerEncoding.cs
@@ -0,0 +1,38 @@ +using System; +using System.Diagnostics; + +namespace Org.BouncyCastle.Asn1 +{ + internal abstract class DerEncoding + : IAsn1Encoding, IComparable<DerEncoding> + { + protected internal readonly int m_tagClass; + protected internal readonly int m_tagNo; + + protected internal DerEncoding(int tagClass, int tagNo) + { + Debug.Assert((tagClass & Asn1Tags.Private) == tagClass); + Debug.Assert(tagNo >= 0); + m_tagClass = tagClass; + m_tagNo = tagNo; + } + + protected internal abstract int CompareLengthAndContents(DerEncoding other); + + public int CompareTo(DerEncoding other) + { + Debug.Assert(other != null); + if (other == null) + return 1; + if (m_tagClass != other.m_tagClass) + return m_tagClass - other.m_tagClass; + if (m_tagNo != other.m_tagNo) + return m_tagNo - other.m_tagNo; + return CompareLengthAndContents(other); + } + + public abstract void Encode(Asn1OutputStream asn1Out); + + public abstract int GetLength(); + } +}