Path: blob/master/test/jdk/com/sun/crypto/provider/Cipher/PBE/PKCS12Oid.java
41161 views
/*1* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/**24* @test25* @bug 4898810 638320026* @summary ensure PBEWithSHA1AndDESede, PBEWithSHA1AndRC2_40/12827* and PBEWithSHA1AndRC4_40/128 are registered under correct OID.28* @author Valerie Peng29*/3031import java.io.*;32import java.util.*;33import java.security.*;34import javax.crypto.*;35import javax.crypto.spec.*;36import javax.crypto.interfaces.PBEKey;3738public class PKCS12Oid {39private static String OID_PKCS12 = "1.2.840.113549.1.12.1.";40private static String OID_PBEWithSHAAnd128BitRC4 = OID_PKCS12 + "1";41private static String OID_PBEWithSHAAnd40BitRC4 = OID_PKCS12 + "2";42private static String OID_PBEWithSHAAnd3KeyTripleDESCBC = OID_PKCS12 + "3";43private static String OID_PBEWithSHAAnd128BitRC2CBC = OID_PKCS12 + "5";44private static String OID_PBEWithSHAAnd40BitRC2CBC = OID_PKCS12 + "6";4546public static void main(String[] argv) throws Exception {47Cipher c = Cipher.getInstance(OID_PBEWithSHAAnd40BitRC2CBC, "SunJCE");48c = Cipher.getInstance(OID_PBEWithSHAAnd3KeyTripleDESCBC, "SunJCE");4950c = Cipher.getInstance(OID_PBEWithSHAAnd128BitRC4, "SunJCE");51c = Cipher.getInstance(OID_PBEWithSHAAnd40BitRC4, "SunJCE");52c = Cipher.getInstance(OID_PBEWithSHAAnd128BitRC2CBC, "SunJCE");53System.out.println("All tests passed");54}55}565758