blob: fd2313c89cd1edbeb99f2a2b967b2e9f356b9b24 (
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
using System;
using Org.BouncyCastle.Math;
namespace Org.BouncyCastle.Bcpg
{
/// <remarks>Base class for an RSA public key.</remarks>
public class RsaPublicBcpgKey
: BcpgObject, IBcpgKey
{
private readonly MPInteger n, e;
/// <summary>Construct an RSA public key from the passed in stream.</summary>
public RsaPublicBcpgKey(
BcpgInputStream bcpgIn)
{
this.n = new MPInteger(bcpgIn);
this.e = new MPInteger(bcpgIn);
}
/// <param name="n">The modulus.</param>
/// <param name="e">The public exponent.</param>
public RsaPublicBcpgKey(
BigInteger n,
BigInteger e)
{
this.n = new MPInteger(n);
this.e = new MPInteger(e);
}
public BigInteger PublicExponent
{
get { return e.Value; }
}
public BigInteger Modulus
{
get { return n.Value; }
}
/// <summary>The format, as a string, always "PGP".</summary>
public string Format
{
get { return "PGP"; }
}
/// <summary>Return the standard PGP encoding of the key.</summary>
public override byte[] GetEncoded()
{
try
{
return base.GetEncoded();
}
catch (Exception)
{
return null;
}
}
public override void Encode(
BcpgOutputStream bcpgOut)
{
bcpgOut.WriteObjects(n, e);
}
}
}
|