Skip to content

Commit e4833c9

Browse files
committed
Add a new constructor which accepts RsaPrivateKeyStructure
This commit adds a new constructor which allows to create an instance of RsaPrivateCrtKeyParameters directly from a RsaPrivateKeyStructure, rather then building it manually.
1 parent 04e57f9 commit e4833c9

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

crypto/src/crypto/parameters/RsaPrivateCrtKeyParameters.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
using Org.BouncyCastle.Crypto;
44
using Org.BouncyCastle.Math;
5+
using Org.BouncyCastle.Asn1.Pkcs;
56

67
namespace Org.BouncyCastle.Crypto.Parameters
78
{
@@ -36,7 +37,20 @@ public RsaPrivateCrtKeyParameters(
3637
this.qInv = qInv;
3738
}
3839

39-
public BigInteger PublicExponent
40+
public RsaPrivateCrtKeyParameters(RsaPrivateKeyStructure rsaPrivateKey)
41+
: this(
42+
rsaPrivateKey.Modulus,
43+
rsaPrivateKey.PublicExponent,
44+
rsaPrivateKey.PrivateExponent,
45+
rsaPrivateKey.Prime1,
46+
rsaPrivateKey.Prime2,
47+
rsaPrivateKey.Exponent1,
48+
rsaPrivateKey.Exponent2,
49+
rsaPrivateKey.Coefficient
50+
)
51+
{ }
52+
53+
public BigInteger PublicExponent
4054
{
4155
get { return e; }
4256
}

0 commit comments

Comments
 (0)