summary refs log tree commit diff
path: root/crypto/src/cmp/ProtectedPkiMessage.cs
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2023-07-28 20:13:02 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2023-07-28 20:13:02 +0700
commita375c08770711d4265a1606baae162c185ef916f (patch)
tree4ddb6a00add42ab5249d6a37caacd2db29dcb7cd /crypto/src/cmp/ProtectedPkiMessage.cs
parentRefactoring around digest calculation (diff)
downloadBouncyCastle.NET-ed25519-a375c08770711d4265a1606baae162c185ef916f.tar.xz
Refactoring around digest calculation
Diffstat (limited to 'crypto/src/cmp/ProtectedPkiMessage.cs')
-rw-r--r--crypto/src/cmp/ProtectedPkiMessage.cs14
1 files changed, 6 insertions, 8 deletions
diff --git a/crypto/src/cmp/ProtectedPkiMessage.cs b/crypto/src/cmp/ProtectedPkiMessage.cs
index 9e442c426..dbce3c453 100644
--- a/crypto/src/cmp/ProtectedPkiMessage.cs
+++ b/crypto/src/cmp/ProtectedPkiMessage.cs
@@ -24,7 +24,7 @@ namespace Org.BouncyCastle.Cmp
         public ProtectedPkiMessage(GeneralPkiMessage pkiMessage)
         {
             if (!pkiMessage.HasProtection)
-                throw new ArgumentException("GeneralPkiMessage not protected");
+                throw new ArgumentException("GeneralPkiMessage not protected", nameof(pkiMessage));
 
             m_pkiMessage = pkiMessage.ToAsn1Structure();
         }
@@ -38,7 +38,7 @@ namespace Org.BouncyCastle.Cmp
         public ProtectedPkiMessage(PkiMessage pkiMessage)
         {
             if (null == pkiMessage.Header.ProtectionAlg)
-                throw new ArgumentException("PkiMessage not protected");
+                throw new ArgumentException("PkiMessage not protected", nameof(pkiMessage));
 
             m_pkiMessage = pkiMessage;
         }
@@ -60,10 +60,8 @@ namespace Org.BouncyCastle.Cmp
         /// to verify the message if this method returns true.
         /// </summary>
         /// <returns>true if protection MAC PBE based, false otherwise.</returns>
-        public virtual bool HasPasswordBasedMacProtected
-        {
-            get { return CmpObjectIdentifiers.passwordBasedMac.Equals(Header.ProtectionAlg.Algorithm); }
-        }
+        public virtual bool HasPasswordBasedMacProtected =>
+            CmpObjectIdentifiers.passwordBasedMac.Equals(ProtectionAlgorithm.Algorithm);
 
         /**
          * Return the message's protection algorithm.
@@ -105,7 +103,7 @@ namespace Org.BouncyCastle.Cmp
 #if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
             return Verify(pkMacBuilder, password.AsSpan());
 #else
-            var protectionAlgorithm = m_pkiMessage.Header.ProtectionAlg;
+            var protectionAlgorithm = ProtectionAlgorithm;
 
             if (!CmpObjectIdentifiers.passwordBasedMac.Equals(protectionAlgorithm.Algorithm))
                 throw new InvalidOperationException("protection algorithm is not mac based");
@@ -122,7 +120,7 @@ namespace Org.BouncyCastle.Cmp
 #if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
         public virtual bool Verify(PKMacBuilder pkMacBuilder, ReadOnlySpan<char> password)
         {
-            var protectionAlgorithm = m_pkiMessage.Header.ProtectionAlg;
+            var protectionAlgorithm = ProtectionAlgorithm;
 
             if (!CmpObjectIdentifiers.passwordBasedMac.Equals(protectionAlgorithm.Algorithm))
                 throw new InvalidOperationException("protection algorithm is not mac based");