summary refs log tree commit diff
path: root/crypto/src/bcpg/EdSecretBcpgKey.cs
blob: 5b53f558d0fcb23bd91d39e53a11a7b4410b2859 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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;
    }
}