Path: blob/master/test/jdk/sun/security/rsa/pss/DefaultParamSpec.java
41153 views
/*1* Copyright (c) 2020, 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*/2223import sun.security.x509.X500Name;24import sun.security.x509.X509CRLImpl;2526import java.security.KeyFactory;27import java.security.KeyPairGenerator;28import java.security.spec.MGF1ParameterSpec;29import java.security.spec.PSSParameterSpec;30import java.security.spec.RSAKeyGenParameterSpec;31import java.util.Date;3233/**34* @test35* @bug 824281136* @modules java.base/sun.security.x50937* @summary AlgorithmId::getDefaultAlgorithmParameterSpec returns incompatible38* PSSParameterSpec for an RSASSA-PSS key39*/40public class DefaultParamSpec {41public static void main(String[] args) throws Exception {42KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSASSA-PSS");43KeyFactory kf = KeyFactory.getInstance("RSASSA-PSS");44kpg.initialize(new RSAKeyGenParameterSpec(2048,45RSAKeyGenParameterSpec.F4,46new PSSParameterSpec(47"SHA-384", "MGF1",48new MGF1ParameterSpec("SHA-384"),4948, PSSParameterSpec.TRAILER_FIELD_BC)));5051X509CRLImpl crl = new X509CRLImpl(52new X500Name("CN=Issuer"), new Date(), new Date());53crl.sign(kpg.generateKeyPair().getPrivate(), "RSASSA-PSS");54}55}565758