jdk/test/sun/security/mscapi/SignUsingNONEwithRSA.java
author rhalade
Fri, 08 Jul 2016 10:15:38 -0700
changeset 39508 b0c063e32440
parent 33868 9c1bde39fe18
permissions -rw-r--r--
8144559: sun/security/mscapi/SignUsingNONEwithRSA.sh failed intermittently Reviewed-by: vinnie
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9533
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
     1
/*
39508
b0c063e32440 8144559: sun/security/mscapi/SignUsingNONEwithRSA.sh failed intermittently
rhalade
parents: 33868
diff changeset
     2
 * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
9533
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
     4
 *
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
     7
 * published by the Free Software Foundation.
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
     8
 *
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    13
 * accompanied this code).
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    14
 *
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    18
 *
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    21
 * questions.
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    22
 */
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    23
39508
b0c063e32440 8144559: sun/security/mscapi/SignUsingNONEwithRSA.sh failed intermittently
rhalade
parents: 33868
diff changeset
    24
 /*
b0c063e32440 8144559: sun/security/mscapi/SignUsingNONEwithRSA.sh failed intermittently
rhalade
parents: 33868
diff changeset
    25
 * @test
b0c063e32440 8144559: sun/security/mscapi/SignUsingNONEwithRSA.sh failed intermittently
rhalade
parents: 33868
diff changeset
    26
 * @bug 6578658
b0c063e32440 8144559: sun/security/mscapi/SignUsingNONEwithRSA.sh failed intermittently
rhalade
parents: 33868
diff changeset
    27
 * @modules java.base/sun.security.x509
b0c063e32440 8144559: sun/security/mscapi/SignUsingNONEwithRSA.sh failed intermittently
rhalade
parents: 33868
diff changeset
    28
 *          java.base/sun.security.tools.keytool
b0c063e32440 8144559: sun/security/mscapi/SignUsingNONEwithRSA.sh failed intermittently
rhalade
parents: 33868
diff changeset
    29
 * @requires os.family == "windows"
b0c063e32440 8144559: sun/security/mscapi/SignUsingNONEwithRSA.sh failed intermittently
rhalade
parents: 33868
diff changeset
    30
 * @summary Sign using the NONEwithRSA signature algorithm from SunMSCAPI
9533
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    31
 */
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    32
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    33
import java.security.*;
39508
b0c063e32440 8144559: sun/security/mscapi/SignUsingNONEwithRSA.sh failed intermittently
rhalade
parents: 33868
diff changeset
    34
import java.security.cert.X509Certificate;
b0c063e32440 8144559: sun/security/mscapi/SignUsingNONEwithRSA.sh failed intermittently
rhalade
parents: 33868
diff changeset
    35
import java.security.interfaces.RSAPrivateCrtKey;
9533
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    36
import java.util.*;
39508
b0c063e32440 8144559: sun/security/mscapi/SignUsingNONEwithRSA.sh failed intermittently
rhalade
parents: 33868
diff changeset
    37
import sun.security.tools.keytool.CertAndKeyGen;
b0c063e32440 8144559: sun/security/mscapi/SignUsingNONEwithRSA.sh failed intermittently
rhalade
parents: 33868
diff changeset
    38
import sun.security.x509.X500Name;
9533
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    39
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    40
public class SignUsingNONEwithRSA {
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    41
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    42
    private static final List<byte[]> precomputedHashes = Arrays.asList(
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    43
        // A MD5 hash
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    44
        new byte[] {
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    45
            0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10,
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    46
            0x11, 0x12, 0x13, 0x14, 0x15, 0x16
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    47
        },
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    48
        // A SHA-1 hash
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    49
        new byte[] {
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    50
            0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10,
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    51
            0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x20
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    52
        },
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    53
        // A concatenation of SHA-1 and MD5 hashes (used during SSL handshake)
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    54
        new byte[] {
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    55
            0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10,
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    56
            0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x20,
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    57
            0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x30,
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    58
            0x31, 0x32, 0x33, 0x34, 0x35, 0x36
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    59
        },
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    60
        // A SHA-256 hash
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    61
        new byte[] {
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    62
            0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10,
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    63
            0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x20,
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    64
            0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x30,
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    65
            0x31, 0x32
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    66
        },
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    67
        // A SHA-384 hash
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    68
        new byte[] {
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    69
            0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10,
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    70
            0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x20,
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    71
            0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x30,
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    72
            0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x40,
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    73
            0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    74
        },
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    75
        // A SHA-512 hash
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    76
        new byte[] {
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    77
            0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10,
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    78
            0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x20,
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    79
            0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x30,
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    80
            0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x40,
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    81
            0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x50,
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    82
            0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x60,
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    83
            0x61, 0x62, 0x63, 0x64
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    84
        });
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    85
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    86
    private static List<byte[]> generatedSignatures = new ArrayList<>();
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    87
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    88
    public static void main(String[] args) throws Exception {
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    89
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    90
        Provider[] providers = Security.getProviders("Signature.NONEwithRSA");
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    91
        if (providers == null) {
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    92
            System.out.println("No JCE providers support the " +
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    93
                "'Signature.NONEwithRSA' algorithm");
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    94
            System.out.println("Skipping this test...");
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    95
            return;
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    96
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    97
        } else {
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    98
            System.out.println("The following JCE providers support the " +
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
    99
                "'Signature.NONEwithRSA' algorithm: ");
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   100
            for (Provider provider : providers) {
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   101
                System.out.println("    " + provider.getName());
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   102
            }
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   103
        }
39508
b0c063e32440 8144559: sun/security/mscapi/SignUsingNONEwithRSA.sh failed intermittently
rhalade
parents: 33868
diff changeset
   104
        System.out.println(
b0c063e32440 8144559: sun/security/mscapi/SignUsingNONEwithRSA.sh failed intermittently
rhalade
parents: 33868
diff changeset
   105
                "Creating a temporary RSA keypair in the Windows-My store");
b0c063e32440 8144559: sun/security/mscapi/SignUsingNONEwithRSA.sh failed intermittently
rhalade
parents: 33868
diff changeset
   106
        KeyStore ks = KeyStore.getInstance("Windows-MY");
b0c063e32440 8144559: sun/security/mscapi/SignUsingNONEwithRSA.sh failed intermittently
rhalade
parents: 33868
diff changeset
   107
        ks.load(null, null);
b0c063e32440 8144559: sun/security/mscapi/SignUsingNONEwithRSA.sh failed intermittently
rhalade
parents: 33868
diff changeset
   108
        CertAndKeyGen ckg = new CertAndKeyGen("RSA", "SHA1withRSA");
b0c063e32440 8144559: sun/security/mscapi/SignUsingNONEwithRSA.sh failed intermittently
rhalade
parents: 33868
diff changeset
   109
        ckg.generate(1024);
b0c063e32440 8144559: sun/security/mscapi/SignUsingNONEwithRSA.sh failed intermittently
rhalade
parents: 33868
diff changeset
   110
        RSAPrivateCrtKey k = (RSAPrivateCrtKey) ckg.getPrivateKey();
b0c063e32440 8144559: sun/security/mscapi/SignUsingNONEwithRSA.sh failed intermittently
rhalade
parents: 33868
diff changeset
   111
        ks.setKeyEntry("6578658", k, null, new X509Certificate[]{
b0c063e32440 8144559: sun/security/mscapi/SignUsingNONEwithRSA.sh failed intermittently
rhalade
parents: 33868
diff changeset
   112
                    ckg.getSelfCertificate(new X500Name("cn=6578658,c=US"), 1000)
b0c063e32440 8144559: sun/security/mscapi/SignUsingNONEwithRSA.sh failed intermittently
rhalade
parents: 33868
diff changeset
   113
                });
b0c063e32440 8144559: sun/security/mscapi/SignUsingNONEwithRSA.sh failed intermittently
rhalade
parents: 33868
diff changeset
   114
        ks.store(null, null);
9533
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   115
39508
b0c063e32440 8144559: sun/security/mscapi/SignUsingNONEwithRSA.sh failed intermittently
rhalade
parents: 33868
diff changeset
   116
        System.out.println("---------------------------------------------");
9533
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   117
39508
b0c063e32440 8144559: sun/security/mscapi/SignUsingNONEwithRSA.sh failed intermittently
rhalade
parents: 33868
diff changeset
   118
        try {
b0c063e32440 8144559: sun/security/mscapi/SignUsingNONEwithRSA.sh failed intermittently
rhalade
parents: 33868
diff changeset
   119
            KeyPair keys = getKeysFromKeyStore();
b0c063e32440 8144559: sun/security/mscapi/SignUsingNONEwithRSA.sh failed intermittently
rhalade
parents: 33868
diff changeset
   120
            signAllUsing("SunMSCAPI", keys.getPrivate());
b0c063e32440 8144559: sun/security/mscapi/SignUsingNONEwithRSA.sh failed intermittently
rhalade
parents: 33868
diff changeset
   121
            System.out.println("---------------------------------------------");
b0c063e32440 8144559: sun/security/mscapi/SignUsingNONEwithRSA.sh failed intermittently
rhalade
parents: 33868
diff changeset
   122
b0c063e32440 8144559: sun/security/mscapi/SignUsingNONEwithRSA.sh failed intermittently
rhalade
parents: 33868
diff changeset
   123
            verifyAllUsing("SunMSCAPI", keys.getPublic());
b0c063e32440 8144559: sun/security/mscapi/SignUsingNONEwithRSA.sh failed intermittently
rhalade
parents: 33868
diff changeset
   124
            System.out.println("---------------------------------------------");
b0c063e32440 8144559: sun/security/mscapi/SignUsingNONEwithRSA.sh failed intermittently
rhalade
parents: 33868
diff changeset
   125
b0c063e32440 8144559: sun/security/mscapi/SignUsingNONEwithRSA.sh failed intermittently
rhalade
parents: 33868
diff changeset
   126
            verifyAllUsing("SunJCE", keys.getPublic());
b0c063e32440 8144559: sun/security/mscapi/SignUsingNONEwithRSA.sh failed intermittently
rhalade
parents: 33868
diff changeset
   127
            System.out.println("---------------------------------------------");
9533
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   128
39508
b0c063e32440 8144559: sun/security/mscapi/SignUsingNONEwithRSA.sh failed intermittently
rhalade
parents: 33868
diff changeset
   129
            keys = generateKeys();
b0c063e32440 8144559: sun/security/mscapi/SignUsingNONEwithRSA.sh failed intermittently
rhalade
parents: 33868
diff changeset
   130
            signAllUsing("SunJCE", keys.getPrivate());
b0c063e32440 8144559: sun/security/mscapi/SignUsingNONEwithRSA.sh failed intermittently
rhalade
parents: 33868
diff changeset
   131
            System.out.println("---------------------------------------------");
9533
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   132
39508
b0c063e32440 8144559: sun/security/mscapi/SignUsingNONEwithRSA.sh failed intermittently
rhalade
parents: 33868
diff changeset
   133
            verifyAllUsing("SunMSCAPI", keys.getPublic());
b0c063e32440 8144559: sun/security/mscapi/SignUsingNONEwithRSA.sh failed intermittently
rhalade
parents: 33868
diff changeset
   134
            System.out.println("---------------------------------------------");
b0c063e32440 8144559: sun/security/mscapi/SignUsingNONEwithRSA.sh failed intermittently
rhalade
parents: 33868
diff changeset
   135
        } finally {
b0c063e32440 8144559: sun/security/mscapi/SignUsingNONEwithRSA.sh failed intermittently
rhalade
parents: 33868
diff changeset
   136
            System.out.println(
b0c063e32440 8144559: sun/security/mscapi/SignUsingNONEwithRSA.sh failed intermittently
rhalade
parents: 33868
diff changeset
   137
                    "Deleting temporary RSA keypair from Windows-My store");
b0c063e32440 8144559: sun/security/mscapi/SignUsingNONEwithRSA.sh failed intermittently
rhalade
parents: 33868
diff changeset
   138
            ks.deleteEntry("6578658");
b0c063e32440 8144559: sun/security/mscapi/SignUsingNONEwithRSA.sh failed intermittently
rhalade
parents: 33868
diff changeset
   139
        }
9533
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   140
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   141
    }
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   142
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   143
    private static KeyPair getKeysFromKeyStore() throws Exception {
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   144
        KeyStore ks = KeyStore.getInstance("Windows-MY", "SunMSCAPI");
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   145
        ks.load(null, null);
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   146
        System.out.println("Loaded keystore: Windows-MY");
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   147
33868
9c1bde39fe18 8139436: sun.security.mscapi.KeyStore might load incomplete data
clanger
parents: 12700
diff changeset
   148
        Enumeration<String> e = ks.aliases();
9533
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   149
        PrivateKey privateKey = null;
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   150
        PublicKey publicKey = null;
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   151
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   152
        while (e.hasMoreElements()) {
33868
9c1bde39fe18 8139436: sun.security.mscapi.KeyStore might load incomplete data
clanger
parents: 12700
diff changeset
   153
            String alias = e.nextElement();
9533
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   154
            if (alias.equals("6578658")) {
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   155
                System.out.println("Loaded entry: " + alias);
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   156
                privateKey = (PrivateKey) ks.getKey(alias, null);
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   157
                publicKey = (PublicKey) ks.getCertificate(alias).getPublicKey();
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   158
            }
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   159
        }
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   160
        if (privateKey == null || publicKey == null) {
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   161
            throw new Exception("Cannot load the keys need to run this test");
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   162
        }
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   163
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   164
        return new KeyPair(publicKey, privateKey);
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   165
    }
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   166
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   167
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   168
    private static KeyPair generateKeys() throws Exception {
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   169
        KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA");
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   170
        keyGen.initialize(1024, null);
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   171
        KeyPair pair = keyGen.generateKeyPair();
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   172
        PrivateKey privateKey = pair.getPrivate();
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   173
        PublicKey publicKey = pair.getPublic();
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   174
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   175
        if (privateKey == null || publicKey == null) {
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   176
            throw new Exception("Cannot load the keys need to run this test");
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   177
        }
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   178
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   179
        return new KeyPair(publicKey, privateKey);
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   180
    }
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   181
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   182
    private static void signAllUsing(String providerName, PrivateKey privateKey)
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   183
            throws Exception {
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   184
        Signature sig1 = Signature.getInstance("NONEwithRSA", providerName);
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   185
        if (sig1 == null) {
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   186
            throw new Exception("'NONEwithRSA' is not supported");
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   187
        }
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   188
        if (sig1.getProvider() != null) {
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   189
            System.out.println("Using NONEwithRSA signer from the " +
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   190
                sig1.getProvider().getName() + " JCE provider");
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   191
        } else {
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   192
            System.out.println(
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   193
                "Using NONEwithRSA signer from the internal JCE provider");
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   194
        }
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   195
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   196
        System.out.println("Using key: " + privateKey);
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   197
        generatedSignatures.clear();
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   198
        for (byte[] hash : precomputedHashes) {
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   199
            sig1.initSign(privateKey);
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   200
            sig1.update(hash);
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   201
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   202
            try {
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   203
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   204
                byte [] sigBytes = sig1.sign();
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   205
                System.out.println("\nGenerated RSA signature over a " +
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   206
                    hash.length + "-byte hash (signature length: " +
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   207
                    sigBytes.length * 8 + " bits)");
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   208
                System.out.println(String.format("0x%0" +
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   209
                    (sigBytes.length * 2) + "x",
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   210
                    new java.math.BigInteger(1, sigBytes)));
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   211
                generatedSignatures.add(sigBytes);
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   212
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   213
            } catch (SignatureException se) {
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   214
                System.out.println("Error generating RSA signature: " + se);
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   215
            }
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   216
        }
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   217
    }
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   218
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   219
    private static void verifyAllUsing(String providerName, PublicKey publicKey)
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   220
            throws Exception {
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   221
        Signature sig1 = Signature.getInstance("NONEwithRSA", providerName);
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   222
        if (sig1.getProvider() != null) {
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   223
            System.out.println("\nUsing NONEwithRSA verifier from the " +
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   224
                sig1.getProvider().getName() + " JCE provider");
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   225
        } else {
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   226
            System.out.println(
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   227
                "\nUsing NONEwithRSA verifier from the internal JCE provider");
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   228
        }
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   229
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   230
        System.out.println("Using key: " + publicKey);
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   231
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   232
        int i = 0;
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   233
        for (byte[] hash : precomputedHashes) {
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   234
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   235
            byte[] sigBytes = generatedSignatures.get(i++);
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   236
            System.out.println("\nVerifying RSA Signature over a " +
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   237
                hash.length + "-byte hash (signature length: " +
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   238
                sigBytes.length * 8 + " bits)");
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   239
            System.out.println(String.format("0x%0" +
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   240
                (sigBytes.length * 2) + "x",
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   241
                new java.math.BigInteger(1, sigBytes)));
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   242
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   243
            sig1.initVerify(publicKey);
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   244
            sig1.update(hash);
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   245
            if (sig1.verify(sigBytes)) {
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   246
                System.out.println("Verify PASSED");
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   247
            } else {
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   248
                throw new Exception("Verify FAILED");
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   249
            }
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   250
        }
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   251
    }
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents:
diff changeset
   252
}