diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-04-11 18:13:27 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-04-11 18:13:27 +0700 |
commit | 35d6cf0af1e8305c84fb2fccafd97fc91db9f099 (patch) | |
tree | 42fe3cd0651d4fd1b86e0cd26f6546f7feef7806 /crypto/src/security/PublicKeyFactory.cs | |
parent | Add some API TODOs (diff) | |
download | BouncyCastle.NET-ed25519-35d6cf0af1e8305c84fb2fccafd97fc91db9f099.tar.xz |
Add Memory/Span accessors to avoid some copies
Diffstat (limited to 'crypto/src/security/PublicKeyFactory.cs')
-rw-r--r-- | crypto/src/security/PublicKeyFactory.cs | 11 |
1 files changed, 11 insertions, 0 deletions
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) { |