diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-07-18 11:16:50 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-07-18 11:16:50 +0700 |
commit | 24214b3eed3cc1b85ea228e88c42a29f14955f3a (patch) | |
tree | 35827d78fdea04902451715032f33a466c2bf7ec /crypto/src/asn1 | |
parent | Refactoring in Asn1 (diff) | |
download | BouncyCastle.NET-ed25519-24214b3eed3cc1b85ea228e88c42a29f14955f3a.tar.xz |
Refactoring around PrivateKeyInfo
Diffstat (limited to 'crypto/src/asn1')
-rw-r--r-- | crypto/src/asn1/Asn1OctetString.cs | 6 | ||||
-rw-r--r-- | crypto/src/asn1/pkcs/PrivateKeyInfo.cs | 10 |
2 files changed, 13 insertions, 3 deletions
diff --git a/crypto/src/asn1/Asn1OctetString.cs b/crypto/src/asn1/Asn1OctetString.cs index d8a7bf27a..9104c9ad3 100644 --- a/crypto/src/asn1/Asn1OctetString.cs +++ b/crypto/src/asn1/Asn1OctetString.cs @@ -110,15 +110,17 @@ namespace Org.BouncyCastle.Asn1 return contents; } + public virtual int GetOctetsLength() => GetOctets().Length; + #if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER internal ReadOnlyMemory<byte> GetOctetsMemory() { - return contents.AsMemory(); + return GetOctets().AsMemory(); } internal ReadOnlySpan<byte> GetOctetsSpan() { - return contents.AsSpan(); + return GetOctets().AsSpan(); } #endif diff --git a/crypto/src/asn1/pkcs/PrivateKeyInfo.cs b/crypto/src/asn1/pkcs/PrivateKeyInfo.cs index 8d767c477..9535dbcae 100644 --- a/crypto/src/asn1/pkcs/PrivateKeyInfo.cs +++ b/crypto/src/asn1/pkcs/PrivateKeyInfo.cs @@ -170,10 +170,15 @@ namespace Org.BouncyCastle.Asn1.Pkcs get { return privateKeyAlgorithm; } } + public virtual Asn1OctetString PrivateKey => privateKey; + + [Obsolete("Use 'PrivateKey' instead")] public virtual Asn1OctetString PrivateKeyData { get { return privateKey; } - } + } + + public virtual int PrivateKeyLength => privateKey.GetOctetsLength(); public virtual Asn1Object ParsePrivateKey() { @@ -186,7 +191,10 @@ namespace Org.BouncyCastle.Asn1.Pkcs return publicKey == null ? null : Asn1Object.FromByteArray(publicKey.GetOctets()); } + public virtual DerBitString PublicKey => publicKey; + /// <summary>Return the public key as a raw bit string.</summary> + [Obsolete("Use 'PublicKey' instead")] public virtual DerBitString PublicKeyData { get { return publicKey; } |