summary refs log tree commit diff
diff options
context:
space:
mode:
-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>