aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/poi/poifs
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/org/apache/poi/poifs')
-rw-r--r--src/java/org/apache/poi/poifs/crypt/CryptoFunctions.java11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/java/org/apache/poi/poifs/crypt/CryptoFunctions.java b/src/java/org/apache/poi/poifs/crypt/CryptoFunctions.java
index 33876fc975..42ca434198 100644
--- a/src/java/org/apache/poi/poifs/crypt/CryptoFunctions.java
+++ b/src/java/org/apache/poi/poifs/crypt/CryptoFunctions.java
@@ -22,12 +22,14 @@ import java.security.GeneralSecurityException;
import java.security.MessageDigest;
import java.security.Provider;
import java.security.Security;
+import java.security.spec.AlgorithmParameterSpec;
import java.util.Arrays;
import javax.crypto.Cipher;
import javax.crypto.Mac;
import javax.crypto.SecretKey;
import javax.crypto.spec.IvParameterSpec;
+import javax.crypto.spec.RC2ParameterSpec;
import org.apache.poi.EncryptedDocumentException;
import org.apache.poi.util.LittleEndian;
@@ -188,8 +190,13 @@ public class CryptoFunctions {
if (vec == null) {
cipher.init(cipherMode, key);
} else {
- IvParameterSpec iv = new IvParameterSpec(vec);
- cipher.init(cipherMode, key, iv);
+ AlgorithmParameterSpec aps;
+ if (cipherAlgorithm == CipherAlgorithm.rc2) {
+ aps = new RC2ParameterSpec(key.getEncoded().length*8, vec);
+ } else {
+ aps = new IvParameterSpec(vec);
+ }
+ cipher.init(cipherMode, key, aps);
}
return cipher;
} catch (GeneralSecurityException e) {