summary refs log tree commit diff
path: root/crypto/src/security
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/security')
-rw-r--r--crypto/src/security/PrivateKeyFactory.cs7
-rw-r--r--crypto/src/security/PublicKeyFactory.cs11
2 files changed, 18 insertions, 0 deletions
diff --git a/crypto/src/security/PrivateKeyFactory.cs b/crypto/src/security/PrivateKeyFactory.cs

index 5d70423f4..38e571cd6 100644 --- a/crypto/src/security/PrivateKeyFactory.cs +++ b/crypto/src/security/PrivateKeyFactory.cs
@@ -350,10 +350,17 @@ namespace Org.BouncyCastle.Security } } +#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER + private static ReadOnlySpan<byte> GetRawKey(PrivateKeyInfo keyInfo) + { + return Asn1OctetString.GetInstance(keyInfo.ParsePrivateKey()).GetOctetsSpan(); + } +#else private static byte[] GetRawKey(PrivateKeyInfo keyInfo) { return Asn1OctetString.GetInstance(keyInfo.ParsePrivateKey()).GetOctets(); } +#endif public static AsymmetricKeyParameter DecryptKey( char[] passPhrase, diff --git a/crypto/src/security/PublicKeyFactory.cs b/crypto/src/security/PublicKeyFactory.cs
index 775884e94..03cabbb13 100644 --- a/crypto/src/security/PublicKeyFactory.cs +++ b/crypto/src/security/PublicKeyFactory.cs
@@ -280,6 +280,16 @@ namespace Org.BouncyCastle.Security } } +#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER + private static ReadOnlySpan<byte> GetRawKey(SubjectPublicKeyInfo keyInfo) + { + /* + * TODO[RFC 8422] + * - Require keyInfo.Algorithm.Parameters == null? + */ + return keyInfo.PublicKeyData.GetOctetsSpan(); + } +#else private static byte[] GetRawKey(SubjectPublicKeyInfo keyInfo) { /* @@ -288,6 +298,7 @@ namespace Org.BouncyCastle.Security */ return keyInfo.PublicKeyData.GetOctets(); } +#endif private static bool IsPkcsDHParam(Asn1Sequence seq) {