summary refs log tree commit diff
path: root/crypto/src/asn1
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/asn1')
-rw-r--r--crypto/src/asn1/Asn1OctetString.cs6
-rw-r--r--crypto/src/asn1/pkcs/PrivateKeyInfo.cs10
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; }