From a61642e7462cdc6ef66374297020421437fa5abb Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Thu, 2 Feb 2023 11:05:18 +0700 Subject: Support null 'otherInfo' --- crypto/src/crypto/agreement/kdf/ConcatenationKdfGenerator.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'crypto') 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); + } } /// the underlying digest. -- cgit 1.4.1