Java8 でSunJCE プロバイダーPBEWITHHMACSHA256ANDAES_256
のアルゴリズムを使用したいと考えています。
jar のように見え、すべての構成は Java8 ですぐに使用できますが、PBEWITHHMACSHA256ANDAES_256
アルゴリズムを使用できません。
私はこれらの2つの瓶を持っています:
jdk1.8.0_40\jre\lib\jce.jar
jdk1.8.0_40\jre\lib\ext\sunjce_provider.jar
このエントリがありますjdk1.8.0_40\jre\lib\security\java.security
security.provider.5=com.sun.crypto.provider.SunJCE
このエントリがありますjdk1.8.0_40\jre\lib\security\java.policy
grant codeBase "file:${{java.ext.dirs}}/*" {
permission java.security.AllPermission;
};
com.sun.crypto.provider.SunJCE
呼び出すと配列で見ることができますSecurity.getProviders()
しかし、次のコードはスローしますEncryptionOperationNotPossibleException
import org.jasypt.encryption.pbe.StandardPBEStringEncryptor;
import org.jasypt.encryption.pbe.config.SimpleStringPBEConfig;
import org.jasypt.exceptions.EncryptionOperationNotPossibleException;
import org.junit.Assert;
import org.junit.Test;
public class EncryptionTest {
@Test
public void test() {
SimpleStringPBEConfig pbeConfig = new SimpleStringPBEConfig();
pbeConfig.setAlgorithm("PBEWITHHMACSHA256ANDAES_256");
pbeConfig.setPassword("changeme");
StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();
encryptor.setConfig(pbeConfig);
String encrypted = encryptor.encrypt("foo");
String decrypted = encryptor.decrypt(encrypted);
Assert.assertEquals("foo", decrypted);
}
}
例外
org.jasypt.exceptions.EncryptionOperationNotPossibleException: Encryption raised an exception. A possible cause is you are using strong encryption algorithms and you have not installed the Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files in this Java Virtual Machine
at org.jasypt.encryption.pbe.StandardPBEByteEncryptor.handleInvalidKeyException(StandardPBEByteEncryptor.java:999)
at org.jasypt.encryption.pbe.StandardPBEByteEncryptor.encrypt(StandardPBEByteEncryptor.java:868)
at org.jasypt.encryption.pbe.StandardPBEStringEncryptor.encrypt(StandardPBEStringEncryptor.java:642)
at foo.bar.EncryptionTest.test(EncryptionTest.java:40)
PBEWITHHMACSHA256ANDAES_256 が EncryptionOperationNotPossibleException をスローしている理由はありますか?