|
@@ -24,7 +24,8 @@ namespace Masuit.Tools.Security
|
|
|
public enum RsaKeyType
|
|
public enum RsaKeyType
|
|
|
{
|
|
{
|
|
|
XML,
|
|
XML,
|
|
|
- PEM
|
|
|
|
|
|
|
+ PKCS1,
|
|
|
|
|
+ PKCS8
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -48,11 +49,16 @@ namespace Masuit.Tools.Security
|
|
|
var rsa = new RSA(length);
|
|
var rsa = new RSA(length);
|
|
|
return type switch
|
|
return type switch
|
|
|
{
|
|
{
|
|
|
- RsaKeyType.PEM => RsaKey ??= new RsaKey
|
|
|
|
|
|
|
+ RsaKeyType.PKCS1 => RsaKey ??= new RsaKey
|
|
|
{
|
|
{
|
|
|
PrivateKey = rsa.ToPEM_PKCS1(),
|
|
PrivateKey = rsa.ToPEM_PKCS1(),
|
|
|
PublicKey = rsa.ToPEM_PKCS1(true)
|
|
PublicKey = rsa.ToPEM_PKCS1(true)
|
|
|
},
|
|
},
|
|
|
|
|
+ RsaKeyType.PKCS8 => RsaKey ??= new RsaKey
|
|
|
|
|
+ {
|
|
|
|
|
+ PrivateKey = rsa.ToPEM_PKCS8(),
|
|
|
|
|
+ PublicKey = rsa.ToPEM_PKCS8(true)
|
|
|
|
|
+ },
|
|
|
RsaKeyType.XML => RsaKey ??= new RsaKey
|
|
RsaKeyType.XML => RsaKey ??= new RsaKey
|
|
|
{
|
|
{
|
|
|
PrivateKey = rsa.ToXML(),
|
|
PrivateKey = rsa.ToXML(),
|