From 3d97978cee8a12cbe513f5e72f7f986690af33fe Mon Sep 17 00:00:00 2001 From: Andreas Beeker Date: Mon, 26 Jan 2015 00:02:20 +0000 Subject: [PATCH] The default for standard encryption cipher algorithm was wrongly set to rc4 git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1654716 13f79535-47bb-0310-9956-ffa450edef68 --- .../crypt/standard/StandardEncryptionInfoBuilder.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/java/org/apache/poi/poifs/crypt/standard/StandardEncryptionInfoBuilder.java b/src/java/org/apache/poi/poifs/crypt/standard/StandardEncryptionInfoBuilder.java index 0a9b569cd4..43dc569511 100644 --- a/src/java/org/apache/poi/poifs/crypt/standard/StandardEncryptionInfoBuilder.java +++ b/src/java/org/apache/poi/poifs/crypt/standard/StandardEncryptionInfoBuilder.java @@ -57,8 +57,14 @@ public class StandardEncryptionInfoBuilder implements EncryptionInfoBuilder { this.info = info; if (cipherAlgorithm == null) { - cipherAlgorithm = CipherAlgorithm.rc4; + cipherAlgorithm = CipherAlgorithm.aes128; } + if (cipherAlgorithm != CipherAlgorithm.aes128 && + cipherAlgorithm != CipherAlgorithm.aes192 && + cipherAlgorithm != CipherAlgorithm.aes256) { + throw new EncryptedDocumentException("Standard encryption only supports AES128/192/256."); + } + if (hashAlgorithm == null) { hashAlgorithm = HashAlgorithm.sha1; } -- 2.39.5