4589N/A#!/bin/sh
4589N/A
4589N/A#
4589N/A# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
4589N/A# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4589N/A#
4589N/A# This code is free software; you can redistribute it and/or modify it
4589N/A# under the terms of the GNU General Public License version 2 only, as
4589N/A# published by the Free Software Foundation.
4589N/A#
4589N/A# This code is distributed in the hope that it will be useful, but WITHOUT
4589N/A# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4589N/A# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
4589N/A# version 2 for more details (a copy is included in the LICENSE file that
4589N/A# accompanied this code).
4589N/A#
4589N/A# You should have received a copy of the GNU General Public License version
4589N/A# 2 along with this work; if not, write to the Free Software Foundation,
4589N/A# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4589N/A#
4589N/A# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4589N/A# or visit www.oracle.com if you need additional information or have any
4589N/A# questions.
4589N/A#
4589N/A
4589N/A
4589N/A# @test
4589N/A# @bug 7106773
4589N/A# @summary 512 bits RSA key cannot work with SHA384 and SHA512
5640N/A# @run shell ShortRSAKey1024.sh 1024
5640N/A# @run shell ShortRSAKey1024.sh 768
5640N/A# @run shell ShortRSAKey1024.sh 512
4589N/A
4589N/A# set a few environment variables so that the shell-script can run stand-alone
4589N/A# in the source directory
4589N/Aif [ "${TESTSRC}" = "" ] ; then
4589N/A TESTSRC="."
4589N/Afi
4589N/A
4589N/Aif [ "${TESTCLASSES}" = "" ] ; then
4589N/A TESTCLASSES="."
4589N/Afi
4589N/A
4589N/Aif [ "${TESTJAVA}" = "" ] ; then
4589N/A echo "TESTJAVA not set. Test cannot execute."
4589N/A echo "FAILED!!!"
4589N/A exit 1
4589N/Afi
4589N/A
5640N/ABITS=$1
5640N/A
4589N/AOS=`uname -s`
4589N/Acase "$OS" in
4589N/A Windows* | CYGWIN* )
4589N/A
5640N/A echo "Removing the keypair if it already exists (for unknown reason)..."
5640N/A ${TESTJAVA}/bin/keytool \
5640N/A -delete \
5640N/A -storetype Windows-My \
5640N/A -debug \
5640N/A -alias 7106773.$BITS
5640N/A
4589N/A echo "Creating a temporary RSA keypair in the Windows-My store..."
4589N/A ${TESTJAVA}/bin/keytool \
4589N/A -genkeypair \
4589N/A -storetype Windows-My \
4589N/A -keyalg RSA \
5640N/A -alias 7106773.$BITS \
5640N/A -keysize $BITS \
4589N/A -dname "cn=localhost,c=US" \
5640N/A -debug \
4589N/A -noprompt
4589N/A
5640N/A if [ "$?" -ne "0" ]; then
5640N/A echo "Unable to generate key pair in Windows-My keystore"
5640N/A exit 1
5640N/A fi
5640N/A
4589N/A echo
4589N/A echo "Running the test..."
4589N/A ${TESTJAVA}/bin/javac -d . ${TESTSRC}\\ShortRSAKeyWithinTLS.java
5640N/A ${TESTJAVA}/bin/java ShortRSAKeyWithinTLS 7106773.$BITS $BITS \
4589N/A TLSv1.2 TLS_DHE_RSA_WITH_AES_128_CBC_SHA
4589N/A
4589N/A rc=$?
4589N/A
4589N/A echo
4589N/A echo "Removing the temporary RSA keypair from the Windows-My store..."
4589N/A ${TESTJAVA}/bin/keytool \
4589N/A -delete \
4589N/A -storetype Windows-My \
5640N/A -debug \
5640N/A -alias 7106773.$BITS
4589N/A
4589N/A echo done.
4589N/A exit $rc
4589N/A ;;
4589N/A
4589N/A * )
4589N/A echo "This test is not intended for '$OS' - passing test"
4589N/A exit 0
4589N/A ;;
4589N/Aesac