From 03209e362f96ac100991923b99109173eda96fb1 Mon Sep 17 00:00:00 2001 From: Oren Novotny Date: Fri, 14 Jul 2017 10:30:28 -0400 Subject: Fix ups after merge from master --- crypto/src/crypto.csproj | 2 +- crypto/src/crypto/modes/KCcmBlockCipher.cs | 21 ++++++++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) (limited to 'crypto/src') diff --git a/crypto/src/crypto.csproj b/crypto/src/crypto.csproj index 05d2802d2..4d0b9e774 100644 --- a/crypto/src/crypto.csproj +++ b/crypto/src/crypto.csproj @@ -28,7 +28,7 @@ $(DefineConstants);PORTABLE;NO_THREADS - + diff --git a/crypto/src/crypto/modes/KCcmBlockCipher.cs b/crypto/src/crypto/modes/KCcmBlockCipher.cs index 1911ba53b..4cb11a784 100644 --- a/crypto/src/crypto/modes/KCcmBlockCipher.cs +++ b/crypto/src/crypto/modes/KCcmBlockCipher.cs @@ -252,13 +252,21 @@ namespace Org.BouncyCastle.Crypto.Modes if (associatedText.Length > 0) { + +#if PORTABLE + byte[] buf = associatedText.ToArray(); + int bufLen = buf.Length; +#else + byte[] buf = associatedText.GetBuffer(); + int bufLen = (int)buf.Length; +#endif if (forEncryption) { - ProcessAAD(associatedText.GetBuffer(), 0, (int)associatedText.Length, (int)data.Length); + ProcessAAD(buf, 0, bufLen, (int)data.Length); } else { - ProcessAAD(associatedText.GetBuffer(), 0, (int)associatedText.Length, (int)data.Length - macSize); + ProcessAAD(buf, 0, bufLen, (int)data.Length - macSize); } } @@ -397,7 +405,14 @@ namespace Org.BouncyCastle.Crypto.Modes public virtual int DoFinal(byte[] output, int outOff) { - int len = ProcessPacket(data.GetBuffer(), 0, (int)data.Length, output, outOff); +#if PORTABLE + byte[] buf = data.ToArray(); + int bufLen = buf.Length; +#else + byte[] buf = data.GetBuffer(); + int bufLen = (int)buf.Length; +#endif + int len = ProcessPacket(buf, 0, bufLen, output, outOff); Reset(); -- cgit 1.5.1