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 0a9b569cd..43dc56951 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; }