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>$(DefineConstants);PORTABLE;NO_THREADS</DefineConstants>
</PropertyGroup>
<ItemGroup>
- <Compile Include="..\bzip2\src\**\*.cs" />
+ <Compile Include="..\bzip2\src\**\*.cs" LinkBase="bzip2" />
<None Include="..\..\BouncyCastle.snk" />
<PackageReference Include="GitVersionTask" Version="4.0.0-beta0011" PrivateAssets="All" />
<PackageReference Include="MSBuild.Sdk.Extras" Version="1.0.5" PrivateAssets="All" />
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();
|