diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-04-13 15:31:14 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-04-13 15:31:14 +0700 |
commit | 8f5512b04798e1a527bdb479dc2b0885f9a6ca7c (patch) | |
tree | 445cb195b93afd9f6c9766c8e17308c139931f6a | |
parent | Fix ParallelHash copy constructor (diff) | |
download | BouncyCastle.NET-ed25519-8f5512b04798e1a527bdb479dc2b0885f9a6ca7c.tar.xz |
Asn1OctetString constructor from Span<byte> (copying)
-rw-r--r-- | crypto/src/asn1/Asn1OctetString.cs | 7 | ||||
-rw-r--r-- | crypto/src/asn1/BerOctetString.cs | 8 | ||||
-rw-r--r-- | crypto/src/asn1/DerOctetString.cs | 7 |
3 files changed, 22 insertions, 0 deletions
diff --git a/crypto/src/asn1/Asn1OctetString.cs b/crypto/src/asn1/Asn1OctetString.cs index e52e50759..d8a7bf27a 100644 --- a/crypto/src/asn1/Asn1OctetString.cs +++ b/crypto/src/asn1/Asn1OctetString.cs @@ -88,6 +88,13 @@ namespace Org.BouncyCastle.Asn1 this.contents = contents; } +#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER + internal Asn1OctetString(ReadOnlySpan<byte> contents) + { + this.contents = contents.ToArray(); + } +#endif + public Stream GetOctetStream() { return new MemoryStream(contents, false); diff --git a/crypto/src/asn1/BerOctetString.cs b/crypto/src/asn1/BerOctetString.cs index 10d8d6db6..fd6b85be2 100644 --- a/crypto/src/asn1/BerOctetString.cs +++ b/crypto/src/asn1/BerOctetString.cs @@ -67,6 +67,14 @@ namespace Org.BouncyCastle.Asn1 { } +#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER + internal BerOctetString(ReadOnlySpan<byte> contents) + : base(contents) + { + this.elements = null; + } +#endif + private BerOctetString(byte[] contents, Asn1OctetString[] elements) : base(contents) { diff --git a/crypto/src/asn1/DerOctetString.cs b/crypto/src/asn1/DerOctetString.cs index 3680a6fd4..7ea9940b3 100644 --- a/crypto/src/asn1/DerOctetString.cs +++ b/crypto/src/asn1/DerOctetString.cs @@ -21,6 +21,13 @@ namespace Org.BouncyCastle.Asn1 { } +#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER + internal DerOctetString(ReadOnlySpan<byte> contents) + : base(contents) + { + } +#endif + internal override IAsn1Encoding GetEncoding(int encoding) { return new PrimitiveEncoding(Asn1Tags.Universal, Asn1Tags.OctetString, contents); |