summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2023-02-02 11:05:18 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2023-02-02 11:05:18 +0700
commita61642e7462cdc6ef66374297020421437fa5abb (patch)
tree39f4460c289c3fb4d7d684215a1448dde75b242d
parentCleanup warnings (diff)
downloadBouncyCastle.NET-ed25519-a61642e7462cdc6ef66374297020421437fa5abb.tar.xz
Support null 'otherInfo'
-rw-r--r--crypto/src/crypto/agreement/kdf/ConcatenationKdfGenerator.cs7
1 files changed, 5 insertions, 2 deletions
diff --git a/crypto/src/crypto/agreement/kdf/ConcatenationKdfGenerator.cs b/crypto/src/crypto/agreement/kdf/ConcatenationKdfGenerator.cs
index 207c795da..8467460b4 100644
--- a/crypto/src/crypto/agreement/kdf/ConcatenationKdfGenerator.cs
+++ b/crypto/src/crypto/agreement/kdf/ConcatenationKdfGenerator.cs
@@ -29,9 +29,12 @@ namespace Org.BouncyCastle.Crypto.Agreement.Kdf
             byte[] sharedSecret = kdfParameters.GetSharedSecret();
             byte[] otherInfo = kdfParameters.GetIV();
 
-            m_buffer = new byte[4 + sharedSecret.Length + otherInfo.Length + m_hLen];
+            m_buffer = new byte[4 + sharedSecret.Length + (otherInfo == null ? 0 : otherInfo.Length) + m_hLen];
             sharedSecret.CopyTo(m_buffer, 4);
-            otherInfo.CopyTo(m_buffer, 4 + sharedSecret.Length);
+            if (otherInfo != null)
+            {
+                otherInfo.CopyTo(m_buffer, 4 + sharedSecret.Length);
+            }
         }
 
         /// <summary>the underlying digest.</summary>