Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/sun/security/pkcs/EncryptedPrivateKeyInfo/EncryptedPKInfoEqualsHashCode.java
38853 views
/*1* Copyright (c) 1999, 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* @author Gary Ellison26* @bug 417063527* @summary Verify equals()/hashCode() contract honored28*/2930import java.io.*;3132import sun.security.x509.*;33import sun.security.pkcs.*;343536public class EncryptedPKInfoEqualsHashCode {3738public static void main(String[] args) throws Exception {3940EncryptedPrivateKeyInfo ev1;41EncryptedPrivateKeyInfo ev2;4243AlgorithmId dh = AlgorithmId.get("DH");4445byte key1[] = {46(byte)0xD4,(byte)0xA0,(byte)0xBA,(byte)0x02,47(byte)0x50,(byte)0xB6,(byte)0xFD,(byte)0x2E,48(byte)0xC6,(byte)0x26,(byte)0xE7,(byte)0xEF,49(byte)0xD6,(byte)0x37,(byte)0xDF,(byte)0x76,50(byte)0xC7,(byte)0x16,(byte)0xE2,(byte)0x2D,51(byte)0x09,(byte)0x44,(byte)0xB8,(byte)0x8B,52};5354ev1 = new EncryptedPrivateKeyInfo(dh, key1);55ev2 = new EncryptedPrivateKeyInfo(dh, key1);5657// the test58if ( (ev1.equals(ev2)) == (ev1.hashCode()==ev2.hashCode()) )59System.out.println("PASSED");60else61throw new Exception("Failed equals()/hashCode() contract");6263}64}656667