Add Asn1Utilities class
5 files changed, 36 insertions, 0 deletions
diff --git a/crypto/BouncyCastle.Android.csproj b/crypto/BouncyCastle.Android.csproj
index b327e9414..165e97219 100644
--- a/crypto/BouncyCastle.Android.csproj
+++ b/crypto/BouncyCastle.Android.csproj
@@ -77,6 +77,7 @@
<Compile Include="src\asn1\Asn1Set.cs" />
<Compile Include="src\asn1\Asn1TaggedObject.cs" />
<Compile Include="src\asn1\Asn1Tags.cs" />
+ <Compile Include="src\asn1\Asn1Utilities.cs" />
<Compile Include="src\asn1\BERBitString.cs" />
<Compile Include="src\asn1\BERGenerator.cs" />
<Compile Include="src\asn1\BEROctetStringGenerator.cs" />
diff --git a/crypto/BouncyCastle.csproj b/crypto/BouncyCastle.csproj
index 1db300922..ff0490af8 100644
--- a/crypto/BouncyCastle.csproj
+++ b/crypto/BouncyCastle.csproj
@@ -71,6 +71,7 @@
<Compile Include="src\asn1\Asn1Set.cs" />
<Compile Include="src\asn1\Asn1TaggedObject.cs" />
<Compile Include="src\asn1\Asn1Tags.cs" />
+ <Compile Include="src\asn1\Asn1Utilities.cs" />
<Compile Include="src\asn1\BERBitString.cs" />
<Compile Include="src\asn1\BERGenerator.cs" />
<Compile Include="src\asn1\BEROctetStringGenerator.cs" />
diff --git a/crypto/BouncyCastle.iOS.csproj b/crypto/BouncyCastle.iOS.csproj
index 33bbdcf57..5b7adbb36 100644
--- a/crypto/BouncyCastle.iOS.csproj
+++ b/crypto/BouncyCastle.iOS.csproj
@@ -72,6 +72,7 @@
<Compile Include="src\asn1\Asn1Set.cs" />
<Compile Include="src\asn1\Asn1TaggedObject.cs" />
<Compile Include="src\asn1\Asn1Tags.cs" />
+ <Compile Include="src\asn1\Asn1Utilities.cs" />
<Compile Include="src\asn1\BERBitString.cs" />
<Compile Include="src\asn1\BERGenerator.cs" />
<Compile Include="src\asn1\BEROctetStringGenerator.cs" />
diff --git a/crypto/crypto.csproj b/crypto/crypto.csproj
index 5e9459310..2030c97a4 100644
--- a/crypto/crypto.csproj
+++ b/crypto/crypto.csproj
@@ -244,6 +244,11 @@
BuildAction = "Compile"
/>
<File
+ RelPath = "src\asn1\Asn1Utilities.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
RelPath = "src\asn1\BERApplicationSpecific.cs"
SubType = "Code"
BuildAction = "Compile"
diff --git a/crypto/src/asn1/Asn1Utilities.cs b/crypto/src/asn1/Asn1Utilities.cs
new file mode 100644
index 000000000..bdeb46483
--- /dev/null
+++ b/crypto/src/asn1/Asn1Utilities.cs
@@ -0,0 +1,28 @@
+using System;
+
+namespace Org.BouncyCastle.Asn1
+{
+ public abstract class Asn1Utilities
+ {
+ public static string GetTagText(Asn1TaggedObject taggedObject)
+ {
+ // TODO[asn1] Implement and use taggedObject.TagClass
+ return GetTagText(Asn1Tags.ContextSpecific, taggedObject.TagNo);
+ }
+
+ public static string GetTagText(int tagClass, int tagNo)
+ {
+ switch (tagClass)
+ {
+ case Asn1Tags.Application:
+ return "[APPLICATION " + tagNo + "]";
+ case Asn1Tags.ContextSpecific:
+ return "[CONTEXT " + tagNo + "]";
+ case Asn1Tags.Private:
+ return "[PRIVATE " + tagNo + "]";
+ default:
+ return "[UNIVERSAL " + tagNo + "]";
+ }
+ }
+ }
+}
|