src/java.base/share/classes/sun/security/util/SignatureUtil.java
author valeriep
Thu, 11 Jul 2019 20:11:47 +0000
changeset 55667 6521aec1c26e
parent 54483 ac20c3bdc55d
permissions -rw-r--r--
8225745: NoSuchAlgorithmException exception for SHA256withECDSA with RSASSA-PSS support Summary: Fixed SignatureUtil and ECDSA signature impl to handle EC parameters Reviewed-by: weijun
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
50204
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
     1
/*
54483
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
     2
 * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
50204
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
     4
 *
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
    10
 *
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
    15
 * accompanied this code).
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
    16
 *
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
    20
 *
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
    23
 * questions.
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
    24
 */
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
    25
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
    26
package sun.security.util;
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
    27
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
    28
import java.io.IOException;
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
    29
import java.security.*;
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
    30
import java.security.spec.*;
55667
6521aec1c26e 8225745: NoSuchAlgorithmException exception for SHA256withECDSA with RSASSA-PSS support
valeriep
parents: 54483
diff changeset
    31
import java.util.Locale;
50204
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
    32
import sun.security.rsa.RSAUtil;
54483
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
    33
import jdk.internal.access.SharedSecrets;
50204
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
    34
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
    35
/**
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
    36
 * Utility class for Signature related operations. Currently used by various
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
    37
 * internal PKI classes such as sun.security.x509.X509CertImpl,
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
    38
 * sun.security.pkcs.SignerInfo, for setting signature parameters.
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
    39
 *
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
    40
 * @since   11
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
    41
 */
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
    42
public class SignatureUtil {
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
    43
54483
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
    44
    private static String checkName(String algName) throws ProviderException {
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
    45
        if (algName.indexOf(".") == -1) {
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
    46
            return algName;
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
    47
        }
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
    48
        // convert oid to String
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
    49
        try {
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
    50
            return Signature.getInstance(algName).getAlgorithm();
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
    51
        } catch (Exception e) {
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
    52
            throw new ProviderException("Error mapping algorithm name", e);
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
    53
        }
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
    54
    }
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
    55
50204
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
    56
    // Utility method of creating an AlgorithmParameters object with
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
    57
    // the specified algorithm name and encoding
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
    58
    private static AlgorithmParameters createAlgorithmParameters(String algName,
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
    59
            byte[] paramBytes) throws ProviderException {
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
    60
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
    61
        try {
54483
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
    62
            algName = checkName(algName);
50204
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
    63
            AlgorithmParameters result =
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
    64
                AlgorithmParameters.getInstance(algName);
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
    65
            result.init(paramBytes);
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
    66
            return result;
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
    67
        } catch (NoSuchAlgorithmException | IOException e) {
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
    68
            throw new ProviderException(e);
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
    69
        }
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
    70
    }
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
    71
54483
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
    72
    // Utility method for converting the specified AlgorithmParameters object
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
    73
    // into an AlgorithmParameterSpec object.
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
    74
    public static AlgorithmParameterSpec getParamSpec(String sigName,
50204
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
    75
            AlgorithmParameters params)
54483
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
    76
            throws ProviderException {
50204
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
    77
55667
6521aec1c26e 8225745: NoSuchAlgorithmException exception for SHA256withECDSA with RSASSA-PSS support
valeriep
parents: 54483
diff changeset
    78
        sigName = checkName(sigName).toUpperCase(Locale.ENGLISH);
54483
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
    79
        AlgorithmParameterSpec paramSpec = null;
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
    80
        if (params != null) {
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
    81
            // AlgorithmParameters.getAlgorithm() may returns oid if it's
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
    82
            // created during DER decoding. Convert to use the standard name
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
    83
            // before passing it to RSAUtil
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
    84
            if (params.getAlgorithm().indexOf(".") != -1) {
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
    85
                try {
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
    86
                    params = createAlgorithmParameters(sigName,
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
    87
                        params.getEncoded());
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
    88
                } catch (IOException e) {
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
    89
                    throw new ProviderException(e);
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
    90
                }
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
    91
            }
55667
6521aec1c26e 8225745: NoSuchAlgorithmException exception for SHA256withECDSA with RSASSA-PSS support
valeriep
parents: 54483
diff changeset
    92
6521aec1c26e 8225745: NoSuchAlgorithmException exception for SHA256withECDSA with RSASSA-PSS support
valeriep
parents: 54483
diff changeset
    93
            if (sigName.indexOf("RSA") != -1) {
6521aec1c26e 8225745: NoSuchAlgorithmException exception for SHA256withECDSA with RSASSA-PSS support
valeriep
parents: 54483
diff changeset
    94
                paramSpec = RSAUtil.getParamSpec(params);
6521aec1c26e 8225745: NoSuchAlgorithmException exception for SHA256withECDSA with RSASSA-PSS support
valeriep
parents: 54483
diff changeset
    95
            } else if (sigName.indexOf("ECDSA") != -1) {
6521aec1c26e 8225745: NoSuchAlgorithmException exception for SHA256withECDSA with RSASSA-PSS support
valeriep
parents: 54483
diff changeset
    96
                try {
6521aec1c26e 8225745: NoSuchAlgorithmException exception for SHA256withECDSA with RSASSA-PSS support
valeriep
parents: 54483
diff changeset
    97
                    paramSpec = params.getParameterSpec(ECParameterSpec.class);
6521aec1c26e 8225745: NoSuchAlgorithmException exception for SHA256withECDSA with RSASSA-PSS support
valeriep
parents: 54483
diff changeset
    98
                } catch (Exception e) {
6521aec1c26e 8225745: NoSuchAlgorithmException exception for SHA256withECDSA with RSASSA-PSS support
valeriep
parents: 54483
diff changeset
    99
                    throw new ProviderException("Error handling EC parameters", e);
6521aec1c26e 8225745: NoSuchAlgorithmException exception for SHA256withECDSA with RSASSA-PSS support
valeriep
parents: 54483
diff changeset
   100
                }
6521aec1c26e 8225745: NoSuchAlgorithmException exception for SHA256withECDSA with RSASSA-PSS support
valeriep
parents: 54483
diff changeset
   101
            } else {
6521aec1c26e 8225745: NoSuchAlgorithmException exception for SHA256withECDSA with RSASSA-PSS support
valeriep
parents: 54483
diff changeset
   102
                throw new ProviderException
6521aec1c26e 8225745: NoSuchAlgorithmException exception for SHA256withECDSA with RSASSA-PSS support
valeriep
parents: 54483
diff changeset
   103
                    ("Unrecognized algorithm for signature parameters " +
6521aec1c26e 8225745: NoSuchAlgorithmException exception for SHA256withECDSA with RSASSA-PSS support
valeriep
parents: 54483
diff changeset
   104
                     sigName);
6521aec1c26e 8225745: NoSuchAlgorithmException exception for SHA256withECDSA with RSASSA-PSS support
valeriep
parents: 54483
diff changeset
   105
            }
50204
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
   106
        }
54483
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
   107
        return paramSpec;
50204
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
   108
    }
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
   109
54483
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
   110
    // Utility method for converting the specified parameter bytes into an
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
   111
    // AlgorithmParameterSpec object.
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
   112
    public static AlgorithmParameterSpec getParamSpec(String sigName,
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
   113
            byte[] paramBytes)
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
   114
            throws ProviderException {
55667
6521aec1c26e 8225745: NoSuchAlgorithmException exception for SHA256withECDSA with RSASSA-PSS support
valeriep
parents: 54483
diff changeset
   115
        sigName = checkName(sigName).toUpperCase(Locale.ENGLISH);
54483
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
   116
        AlgorithmParameterSpec paramSpec = null;
55667
6521aec1c26e 8225745: NoSuchAlgorithmException exception for SHA256withECDSA with RSASSA-PSS support
valeriep
parents: 54483
diff changeset
   117
50204
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
   118
        if (paramBytes != null) {
55667
6521aec1c26e 8225745: NoSuchAlgorithmException exception for SHA256withECDSA with RSASSA-PSS support
valeriep
parents: 54483
diff changeset
   119
            if (sigName.indexOf("RSA") != -1) {
6521aec1c26e 8225745: NoSuchAlgorithmException exception for SHA256withECDSA with RSASSA-PSS support
valeriep
parents: 54483
diff changeset
   120
                AlgorithmParameters params =
6521aec1c26e 8225745: NoSuchAlgorithmException exception for SHA256withECDSA with RSASSA-PSS support
valeriep
parents: 54483
diff changeset
   121
                    createAlgorithmParameters(sigName, paramBytes);
6521aec1c26e 8225745: NoSuchAlgorithmException exception for SHA256withECDSA with RSASSA-PSS support
valeriep
parents: 54483
diff changeset
   122
                paramSpec = RSAUtil.getParamSpec(params);
6521aec1c26e 8225745: NoSuchAlgorithmException exception for SHA256withECDSA with RSASSA-PSS support
valeriep
parents: 54483
diff changeset
   123
            } else if (sigName.indexOf("ECDSA") != -1) {
6521aec1c26e 8225745: NoSuchAlgorithmException exception for SHA256withECDSA with RSASSA-PSS support
valeriep
parents: 54483
diff changeset
   124
                try {
6521aec1c26e 8225745: NoSuchAlgorithmException exception for SHA256withECDSA with RSASSA-PSS support
valeriep
parents: 54483
diff changeset
   125
                    Provider p = Signature.getInstance(sigName).getProvider();
6521aec1c26e 8225745: NoSuchAlgorithmException exception for SHA256withECDSA with RSASSA-PSS support
valeriep
parents: 54483
diff changeset
   126
                    paramSpec = ECUtil.getECParameterSpec(p, paramBytes);
6521aec1c26e 8225745: NoSuchAlgorithmException exception for SHA256withECDSA with RSASSA-PSS support
valeriep
parents: 54483
diff changeset
   127
                } catch (Exception e) {
6521aec1c26e 8225745: NoSuchAlgorithmException exception for SHA256withECDSA with RSASSA-PSS support
valeriep
parents: 54483
diff changeset
   128
                    throw new ProviderException("Error handling EC parameters", e);
6521aec1c26e 8225745: NoSuchAlgorithmException exception for SHA256withECDSA with RSASSA-PSS support
valeriep
parents: 54483
diff changeset
   129
                }
6521aec1c26e 8225745: NoSuchAlgorithmException exception for SHA256withECDSA with RSASSA-PSS support
valeriep
parents: 54483
diff changeset
   130
                // ECUtil discards exception and returns null, so we need to check
6521aec1c26e 8225745: NoSuchAlgorithmException exception for SHA256withECDSA with RSASSA-PSS support
valeriep
parents: 54483
diff changeset
   131
                // the returned value
6521aec1c26e 8225745: NoSuchAlgorithmException exception for SHA256withECDSA with RSASSA-PSS support
valeriep
parents: 54483
diff changeset
   132
                if (paramSpec == null) {
6521aec1c26e 8225745: NoSuchAlgorithmException exception for SHA256withECDSA with RSASSA-PSS support
valeriep
parents: 54483
diff changeset
   133
                    throw new ProviderException("Error handling EC parameters");
6521aec1c26e 8225745: NoSuchAlgorithmException exception for SHA256withECDSA with RSASSA-PSS support
valeriep
parents: 54483
diff changeset
   134
                }
6521aec1c26e 8225745: NoSuchAlgorithmException exception for SHA256withECDSA with RSASSA-PSS support
valeriep
parents: 54483
diff changeset
   135
            } else {
54483
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
   136
                throw new ProviderException
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
   137
                     ("Unrecognized algorithm for signature parameters " +
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
   138
                      sigName);
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
   139
            }
50204
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
   140
        }
54483
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
   141
        return paramSpec;
50204
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
   142
    }
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
   143
54483
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
   144
    // Utility method for initializing the specified Signature object
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
   145
    // for verification with the specified key and params (may be null)
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
   146
    public static void initVerifyWithParam(Signature s, PublicKey key,
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
   147
            AlgorithmParameterSpec params)
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
   148
            throws ProviderException, InvalidAlgorithmParameterException,
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
   149
            InvalidKeyException {
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
   150
        SharedSecrets.getJavaSecuritySignatureAccess().initVerify(s, key, params);
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
   151
    }
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
   152
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
   153
    // Utility method for initializing the specified Signature object
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
   154
    // for verification with the specified Certificate and params (may be null)
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
   155
    public static void initVerifyWithParam(Signature s,
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
   156
            java.security.cert.Certificate cert,
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
   157
            AlgorithmParameterSpec params)
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
   158
            throws ProviderException, InvalidAlgorithmParameterException,
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
   159
            InvalidKeyException {
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
   160
        SharedSecrets.getJavaSecuritySignatureAccess().initVerify(s, cert, params);
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
   161
    }
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
   162
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
   163
    // Utility method for initializing the specified Signature object
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
   164
    // for signing with the specified key and params (may be null)
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
   165
    public static void initSignWithParam(Signature s, PrivateKey key,
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
   166
            AlgorithmParameterSpec params, SecureRandom sr)
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
   167
            throws ProviderException, InvalidAlgorithmParameterException,
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
   168
            InvalidKeyException {
ac20c3bdc55d 8216039: TLS with BC and RSASSA-PSS breaks ECDHServerKeyExchange
valeriep
parents: 53069
diff changeset
   169
        SharedSecrets.getJavaSecuritySignatureAccess().initSign(s, key, params, sr);
50204
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
   170
    }
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents:
diff changeset
   171
}