summary refs log tree commit diff
path: root/crypto/src/cms/PasswordRecipientInformation.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/cms/PasswordRecipientInformation.cs')
-rw-r--r--crypto/src/cms/PasswordRecipientInformation.cs13
1 files changed, 9 insertions, 4 deletions
diff --git a/crypto/src/cms/PasswordRecipientInformation.cs b/crypto/src/cms/PasswordRecipientInformation.cs
index f629caba6..ff4a20d68 100644
--- a/crypto/src/cms/PasswordRecipientInformation.cs
+++ b/crypto/src/cms/PasswordRecipientInformation.cs
@@ -54,12 +54,17 @@ namespace Org.BouncyCastle.Cms
 				string				cName = CmsEnvelopedHelper.Instance.GetRfc3211WrapperName(kekAlgName);
 				IWrapper			keyWrapper = WrapperUtilities.GetWrapper(cName);
 
-				byte[] iv = Asn1OctetString.GetInstance(kekAlgParams[1]).GetOctets();
+                var iv = Asn1OctetString.GetInstance(kekAlgParams[1]);
 
-				ICipherParameters parameters = ((CmsPbeKey)key).GetEncoded(kekAlgName);
-				parameters = new ParametersWithIV(parameters, iv);
+                ICipherParameters parameters = ((CmsPbeKey)key).GetEncoded(kekAlgName);
 
-				keyWrapper.Init(false, parameters);
+#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
+                parameters = new ParametersWithIV(parameters, iv.GetOctetsSpan());
+#else
+				parameters = new ParametersWithIV(parameters, iv.GetOctets());
+#endif
+
+                keyWrapper.Init(false, parameters);
 
 				KeyParameter sKey = ParameterUtilities.CreateKeyParameter(
 					GetContentAlgorithmName(), keyWrapper.Unwrap(encryptedKey, 0, encryptedKey.Length));