Path: blob/master/test/jdk/java/security/KeyRep/SerialOld.java
41152 views
/*1* Copyright (c) 2003, 2005, 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* @test 1.1, 03/08/1325* @bug 453250626* @summary Serializing KeyPair on one VM (Sun),27* and Deserializing on another (IBM) fails28* @run main/othervm/java.security.policy=SerialOld.policy SerialOld29*/3031import java.io.*;32import java.security.*;3334public class SerialOld {35public static void main(String[] args) throws Exception {3637// verify tiger DSA and RSA public keys still deserialize in our VM3839deserializeTigerKey("DSA");40deserializeTigerKey("RSA");4142// verify pre-tiger keys still deserialize in our VM4344deserializeKey("DSA");45deserializeKey("RSA");46deserializeKey("DH");47deserializeKey("AES");48deserializeKey("Blowfish");49deserializeKey("DES");50deserializeKey("DESede");51deserializeKey("RC5");52deserializeKey("HmacSHA1");53deserializeKey("HmacMD5");54deserializeKey("PBE");55}5657private static void deserializeTigerKey(String algorithm) throws Exception {58ObjectInputStream ois = new ObjectInputStream(new FileInputStream59(System.getProperty("test.src", ".") +60File.separator +61algorithm + ".1.5.key"));62ois.readObject();63ois.close();64}65private static void deserializeKey(String algorithm) throws Exception {66ObjectInputStream ois = new ObjectInputStream(new FileInputStream67(System.getProperty("test.src", ".") +68File.separator +69algorithm + ".pre.1.5.key"));70ois.readObject();71ois.close();72}73}747576