summary refs log tree commit diff
path: root/crypto/src/bcpg/EdSecretBcpgKey.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/bcpg/EdSecretBcpgKey.cs')
-rw-r--r--crypto/src/bcpg/EdSecretBcpgKey.cs43
1 files changed, 43 insertions, 0 deletions
diff --git a/crypto/src/bcpg/EdSecretBcpgKey.cs b/crypto/src/bcpg/EdSecretBcpgKey.cs
new file mode 100644
index 000000000..5b53f558d
--- /dev/null
+++ b/crypto/src/bcpg/EdSecretBcpgKey.cs
@@ -0,0 +1,43 @@
+using System;
+
+using Org.BouncyCastle.Math;
+
+namespace Org.BouncyCastle.Bcpg
+{
+    public sealed class EdSecretBcpgKey
+        : BcpgObject, IBcpgKey
+    {
+        internal readonly MPInteger m_x;
+
+        public EdSecretBcpgKey(BcpgInputStream bcpgIn)
+        {
+            m_x = new MPInteger(bcpgIn);
+        }
+
+        public EdSecretBcpgKey(BigInteger x)
+        {
+            m_x = new MPInteger(x);
+        }
+
+        public string Format => "PGP";
+
+        public override byte[] GetEncoded()
+        {
+            try
+            {
+                return base.GetEncoded();
+            }
+            catch (Exception)
+            {
+                return null;
+            }
+        }
+
+        public override void Encode(BcpgOutputStream bcpgOut)
+        {
+            bcpgOut.WriteObject(m_x);
+        }
+
+        public BigInteger X => m_x.Value;
+    }
+}