Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/sun/security/tools/jarsigner/ec.sh
38854 views
#1# Copyright (c) 2009, 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#2223# @test24# @bug 687081225# @summary enhance security tools to use ECC algorithm26#2728if [ "${TESTJAVA}" = "" ] ; then29JAVAC_CMD=`which javac`30TESTJAVA=`dirname $JAVAC_CMD`/..31fi3233# set platform-dependent variables34OS=`uname -s`35case "$OS" in36Windows_* )37FS="\\"38;;39* )40FS="/"41;;42esac4344KS=ec.jks45JFILE=ec.jar4647KT="$TESTJAVA${FS}bin${FS}keytool -storepass changeit -keypass changeit -keystore $KS"48JAR=$TESTJAVA${FS}bin${FS}jar49JARSIGNER=$TESTJAVA${FS}bin${FS}jarsigner5051rm $KS $JFILE52echo A > A53$JAR cvf $JFILE A5455$KT -alias ca -dname CN=ca -keyalg ec -genkey -validity 300 -ext bc:c || exit 115657$KT -alias a -dname CN=a -keyalg ec -genkey || exit 1158$KT -alias a -certreq | $KT -gencert -alias ca -validity 300 | $KT -import -alias a || exit 1115960$KT -alias b -dname CN=b -keyalg ec -genkey || exit 1261$KT -alias b -certreq | $KT -gencert -alias ca -validity 300 | $KT -import -alias b || exit 1216263# Ensure that key length is sufficient for the intended hash (SHA512withECDSA)64$KT -alias c -dname CN=c -keyalg ec -genkey -keysize 521 || exit 1365$KT -alias c -certreq | $KT -gencert -alias ca -validity 300 | $KT -import -alias c || exit 1316667$KT -alias x -dname CN=x -keyalg ec -genkey -validity 300 || exit 1468$KT -alias x -certreq | $KT -gencert -alias ca -validity 300 | $KT -import -alias x || exit 1416970$JARSIGNER -keystore $KS -storepass changeit $JFILE a -debug -strict || exit 2171$JARSIGNER -keystore $KS -storepass changeit $JFILE b -debug -strict -sigalg SHA256withECDSA || exit 2272$JARSIGNER -keystore $KS -storepass changeit $JFILE c -debug -strict -sigalg SHA512withECDSA || exit 237374$JARSIGNER -keystore $KS -storepass changeit -verify $JFILE a -debug -strict || exit 3175$JARSIGNER -keystore $KS -storepass changeit -verify $JFILE b -debug -strict || exit 3276$JARSIGNER -keystore $KS -storepass changeit -verify $JFILE c -debug -strict || exit 337778# Not signed by x, should exit with non-zero79$JARSIGNER -keystore $KS -storepass changeit -verify $JFILE x -debug -strict && exit 348081exit 082838485