diff --git a/src/share/classes/sun/security/pkcs11/SunPKCS11.java b/src/share/classes/sun/security/pkcs11/SunPKCS11.java index b94ca875e6c36bb3bac2d036ff04a1a674b8e61b..8c432571e3a99a65d1a53ecaaee3bfbc5407e2cf 100644 --- a/src/share/classes/sun/security/pkcs11/SunPKCS11.java +++ b/src/share/classes/sun/security/pkcs11/SunPKCS11.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -606,24 +606,32 @@ public final class SunPKCS11 extends AuthProvider { m(CKM_DES_CBC)); d(CIP, "DES/CBC/PKCS5Padding", P11Cipher, m(CKM_DES_CBC_PAD, CKM_DES_CBC)); - d(CIP, "DES/ECB", P11Cipher, s("DES"), + d(CIP, "DES/ECB/NoPadding", P11Cipher, + m(CKM_DES_ECB)); + d(CIP, "DES/ECB/PKCS5Padding", P11Cipher, s("DES"), m(CKM_DES_ECB)); d(CIP, "DESede/CBC/NoPadding", P11Cipher, m(CKM_DES3_CBC)); d(CIP, "DESede/CBC/PKCS5Padding", P11Cipher, m(CKM_DES3_CBC_PAD, CKM_DES3_CBC)); - d(CIP, "DESede/ECB", P11Cipher, s("DESede"), + d(CIP, "DESede/ECB/NoPadding", P11Cipher, + m(CKM_DES3_ECB)); + d(CIP, "DESede/ECB/PKCS5Padding", P11Cipher, s("DESede"), m(CKM_DES3_ECB)); d(CIP, "AES/CBC/NoPadding", P11Cipher, m(CKM_AES_CBC)); d(CIP, "AES/CBC/PKCS5Padding", P11Cipher, m(CKM_AES_CBC_PAD, CKM_AES_CBC)); - d(CIP, "AES/ECB", P11Cipher, s("AES"), + d(CIP, "AES/ECB/NoPadding", P11Cipher, + m(CKM_AES_ECB)); + d(CIP, "AES/ECB/PKCS5Padding", P11Cipher, s("AES"), m(CKM_AES_ECB)); d(CIP, "AES/CTR/NoPadding", P11Cipher, m(CKM_AES_CTR)); - d(CIP, "Blowfish/CBC", P11Cipher, + d(CIP, "Blowfish/CBC/NoPadding", P11Cipher, + m(CKM_BLOWFISH_CBC)); + d(CIP, "Blowfish/CBC/PKCS5Padding", P11Cipher, m(CKM_BLOWFISH_CBC)); // XXX RSA_X_509, RSA_OAEP not yet supported diff --git a/test/javax/crypto/Cipher/GetMaxAllowed.java b/test/javax/crypto/Cipher/GetMaxAllowed.java index 3c14f8663eb882c24a5d12e4d186415266a0fc0c..7ef6f439aacde761778a88228053592a619fcc7f 100644 --- a/test/javax/crypto/Cipher/GetMaxAllowed.java +++ b/test/javax/crypto/Cipher/GetMaxAllowed.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /** * @test - * @bug 4807942 + * @bug 4807942 7033170 * @summary Test the Cipher.getMaxAllowedKeyLength(String) and * getMaxAllowedParameterSpec(String) methods * @author Valerie Peng @@ -40,7 +40,7 @@ import javax.crypto.spec.*; public class GetMaxAllowed { - private static void runTest(boolean isUnlimited) throws Exception { + private static void runTest1(boolean isUnlimited) throws Exception { System.out.println("Testing " + (isUnlimited? "un":"") + "limited policy..."); @@ -78,6 +78,20 @@ public class GetMaxAllowed { System.out.println("All tests passed"); } + private static void runTest2() throws Exception { + System.out.println("Testing against Security.getAlgorithms()"); + + Set algorithms = Security.getAlgorithms("Cipher"); + + for (String algorithm: algorithms) { + int keylength = -1; + + // if 7033170 is not fixed, NoSuchAlgorithmException is thrown + keylength = Cipher.getMaxAllowedKeyLength(algorithm); + + } + } + public static void main(String[] args) throws Exception { // decide if the installed jurisdiction policy file is the // unlimited version @@ -88,6 +102,9 @@ public class GetMaxAllowed { } catch (InvalidKeyException ike) { isUnlimited = false; } - runTest(isUnlimited); + runTest1(isUnlimited); + + // test using the set of algorithms returned by Security.getAlgorithms() + runTest2(); } }