简体   繁体   English

找不到任何支持AES / GCM / NoPadding的提供商

[英]Cannot find any provider supporting AES/GCM/NoPadding

We are trying to do encryption supporting AES/GCM/NoPadding in java 7 getting below exception. 我们正在尝试进行加密,支持java 7中的 AES / GCM / NoPadding获得以下异常。

Cannot find any provider supporting AES/GCM/NoPadding 找不到任何支持AES / GCM / NoPadding的提供商

Code sample for generating cipher instance is below. 用于生成密码实例的代码示例如下。

SecretKeySpec eks = new SecretKeySpec(k, "AES");
Cipher c = Cipher.getInstance("AES/GCM/NoPadding");
c.init(Cipher.ENCRYPT_MODE, eks, new GCMParameterSpec(128, iv));

This cipher is not supported by Java 7 SE ( exception for Solaris ). Java 7 SE不支持此密码( Solaris的例外 )。

public static void main(String[] args) throws Exception {
    for (Provider provider : Security.getProviders()) {
        for (Map.Entry<Object, Object> entry : provider.entrySet()) {
            if (((String) entry.getValue()).contains("GCM")) {
                System.out.printf("key: [%s]  value: [%s]%n",
                    entry.getKey(),
                    entry.getValue());
            }
        }
    }
}

You might have a look at Bouncy Castle as service provider in that case. 在这种情况下,您可以将Bouncy Castle视为服务提供商。

Small snippet for using Bouncycastle. 使用Bouncycastle的小片段。

  1. download bcprov-jdk15on-154.jar from http://www.bouncycastle.org/latest_releases.html http://www.bouncycastle.org/latest_releases.html下载bcprov-jdk15on-154.jar
  2. register the service provider in your code 在您的代码中注册服务提供商

     Security.addProvider(new BouncyCastleProvider()); 
  3. then you are able to use the cipher as (the paramter "BC" specifies to use Bounce Castle as service provider, can be omitted if there is no other provider for the same cipher) 然后你就可以使用密码了(参数"BC"指定使用Bounce Castle作为服务提供者,如果同一个密码没有其他提供者,则可以省略)

     Cipher c = Cipher.getInstance("AES/GCM/NOPADDING", "BC"); 

Java 8 support the cipher out of the box with Java 8支持开箱即用的密码

Cipher c = Cipher.getInstance("AES/GCM/NOPADDING");

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 java.security.NoSuchAlgorithmException:找不到任何支持AES的提供程序 - java.security.NoSuchAlgorithmException:cannot find any provider supporting AES 没有这样的算法:AES/GCM/NoPadding - No Such Algorithm : AES/GCM/NoPadding AES / GCM / NoPadding AEADBadTagException - AES/GCM/NoPadding AEADBadTagException 在单元测试中找不到任何支持AES / CBC / ISO7816-4Padding的提供程序 - Cannot find any provider supporting AES/CBC/ISO7816-4Padding in unit tests java.security.NoSuchAlgorithmException:找不到任何支持 AES/ECB/PKCS7PADDING 的提供商 - java.security.NoSuchAlgorithmException:Cannot find any provider supporting AES/ECB/PKCS7PADDING 没有安装的提供程序支持这个密钥:sun.security.rsa.RSAPublicKeyImpl 并且没有这样的算法:AES/GCM/NoPadding - No installed provider supports this key: sun.security.rsa.RSAPublicKeyImpl and No such algorithm: AES/GCM/NoPadding 使用AES / GCM / NoPadding的IvParameterSpec和GCMParameterSpec之间的差异 - Difference between IvParameterSpec and GCMParameterSpec with AES/GCM/NoPadding 运行程序提示 找不到任何支持 RSA 的提供程序 - Tips for running the program Cannot find any provider supporting RSA junit java.security.NoSuchAlgorithmException:找不到任何支持的提供程序 - junit java.security.NoSuchAlgorithmException: Cannot find any provider supporting AES/GCM/NoPadding加密JAVA&解密JavaScript - AES/GCM/NoPadding encryption in JAVA & decryption in JavaScript
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM