summary refs log tree commit diff
path: root/crypto/src/asn1/Asn1OutputStream.cs
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2023-02-28 20:45:20 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2023-02-28 20:45:20 +0700
commit3a208d8c441470d6dfb580d7594dfcc63e477d6f (patch)
tree71f261fd68ed5837d02ff2cd1435c1695dd58083 /crypto/src/asn1/Asn1OutputStream.cs
parentAsn1InputStream refactoring (diff)
downloadBouncyCastle.NET-ed25519-3a208d8c441470d6dfb580d7594dfcc63e477d6f.tar.xz
Refactoring around ASN.1 DL encodings
Diffstat (limited to 'crypto/src/asn1/Asn1OutputStream.cs')
-rw-r--r--crypto/src/asn1/Asn1OutputStream.cs11
1 files changed, 8 insertions, 3 deletions
diff --git a/crypto/src/asn1/Asn1OutputStream.cs b/crypto/src/asn1/Asn1OutputStream.cs
index 1363aa676..78cb8e0a8 100644
--- a/crypto/src/asn1/Asn1OutputStream.cs
+++ b/crypto/src/asn1/Asn1OutputStream.cs
@@ -103,11 +103,11 @@ namespace Org.BouncyCastle.Asn1
 #endif
         }
 
-        internal void WriteIdentifier(int tagClass, int tagNo)
+        internal void WriteIdentifier(int flags, int tagNo)
         {
             if (tagNo < 31)
             {
-                WriteByte((byte)(tagClass | tagNo));
+                WriteByte((byte)(flags | tagNo));
                 return;
             }
 
@@ -125,7 +125,7 @@ namespace Org.BouncyCastle.Asn1
                 stack[--pos] = (byte)(tagNo & 0x7F | 0x80);
             }
 
-            stack[--pos] = (byte)(tagClass | 0x1F);
+            stack[--pos] = (byte)(flags | 0x1F);
 
 #if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
             Write(stack[pos..]);
@@ -168,6 +168,11 @@ namespace Org.BouncyCastle.Asn1
             return length;
         }
 
+        internal static int GetLengthOfEncodingDL(int tagNo, int contentsLength)
+        {
+            return GetLengthOfIdentifier(tagNo) + GetLengthOfDL(contentsLength) + contentsLength;
+        }
+
         internal static int GetLengthOfIdentifier(int tagNo)
         {
             if (tagNo < 31)