src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/RSASignature.java
author valeriep
Mon, 21 May 2018 23:40:52 +0000
changeset 50204 3195a713e24d
parent 47216 71c04702a3d5
child 50715 46492a773912
permissions -rw-r--r--
8146293: Add support for RSASSA-PSS Signature algorithm Summary: add RSASSA-PSS key and signature support to SunRsaSign provider Reviewed-by: wetmore
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
50204
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents: 47216
diff changeset
     2
 * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2596
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2596
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2596
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2596
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2596
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package sun.security.mscapi;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.nio.ByteBuffer;
50204
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents: 47216
diff changeset
    29
import java.security.*;
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents: 47216
diff changeset
    30
import java.security.spec.AlgorithmParameterSpec;
2596
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
    31
import java.math.BigInteger;
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
    32
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
    33
import sun.security.rsa.RSAKeyFactory;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * RSA signature implementation. Supports RSA signing using PKCS#1 v1.5 padding.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * Objects should be instantiated by calling Signature.getInstance() using the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * following algorithm names:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 *
9533
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
    41
 *  . "NONEwithRSA"
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 *  . "SHA1withRSA"
9524
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 9508
diff changeset
    43
 *  . "SHA256withRSA"
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 9508
diff changeset
    44
 *  . "SHA384withRSA"
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 9508
diff changeset
    45
 *  . "SHA512withRSA"
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 *  . "MD5withRSA"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 *  . "MD2withRSA"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 *
9533
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
    49
 * NOTE: RSA keys must be at least 512 bits long.
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
    50
 *
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
    51
 * NOTE: NONEwithRSA must be supplied with a pre-computed message digest.
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
    52
 *       Only the following digest algorithms are supported: MD5, SHA-1,
12700
9c9ad46c7c40 7169496: Problem with the SHA-224 support for SunMSCAPI provider
valeriep
parents: 12685
diff changeset
    53
 *       SHA-256, SHA-384, SHA-512 and a special-purpose digest
12685
8a448b5b9006 4963723: Implement SHA-224
valeriep
parents: 11521
diff changeset
    54
 *       algorithm which is a concatenation of SHA-1 and MD5 digests.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * @since   1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * @author  Stanley Man-Kit Ho
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
abstract class RSASignature extends java.security.SignatureSpi
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    // message digest implementation we use
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    private final MessageDigest messageDigest;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
9524
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 9508
diff changeset
    64
    // message digest name
9533
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
    65
    private String messageDigestAlgorithm;
9524
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 9508
diff changeset
    66
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 9508
diff changeset
    67
    // flag indicating whether the digest has been reset
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    private boolean needsReset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    // the signing key
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    private Key privateKey = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    // the verification key
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    private Key publicKey = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
9533
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
    76
    /**
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
    77
     * Constructs a new RSASignature. Used by Raw subclass.
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
    78
     */
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
    79
    RSASignature() {
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
    80
        messageDigest = null;
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
    81
        messageDigestAlgorithm = null;
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
    82
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
9524
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 9508
diff changeset
    84
    /**
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 9508
diff changeset
    85
     * Constructs a new RSASignature. Used by subclasses.
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 9508
diff changeset
    86
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    RSASignature(String digestName) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
            messageDigest = MessageDigest.getInstance(digestName);
9524
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 9508
diff changeset
    91
            // Get the digest's canonical name
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 9508
diff changeset
    92
            messageDigestAlgorithm = messageDigest.getAlgorithm();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        } catch (NoSuchAlgorithmException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
           throw new ProviderException(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        needsReset = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
9533
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   101
    // Nested class for NONEwithRSA signatures
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   102
    public static final class Raw extends RSASignature {
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   103
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   104
        // the longest supported digest is 512 bits (SHA-512)
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   105
        private static final int RAW_RSA_MAX = 64;
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   106
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   107
        private final byte[] precomputedDigest;
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   108
        private int offset = 0;
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   109
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   110
        public Raw() {
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   111
            precomputedDigest = new byte[RAW_RSA_MAX];
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   112
        }
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   113
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   114
        // Stores the precomputed message digest value.
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   115
        @Override
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   116
        protected void engineUpdate(byte b) throws SignatureException {
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   117
            if (offset >= precomputedDigest.length) {
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   118
                offset = RAW_RSA_MAX + 1;
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   119
                return;
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   120
            }
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   121
            precomputedDigest[offset++] = b;
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   122
        }
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   123
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   124
        // Stores the precomputed message digest value.
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   125
        @Override
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   126
        protected void engineUpdate(byte[] b, int off, int len)
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   127
                throws SignatureException {
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   128
            if (offset + len > precomputedDigest.length) {
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   129
                offset = RAW_RSA_MAX + 1;
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   130
                return;
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   131
            }
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   132
            System.arraycopy(b, off, precomputedDigest, offset, len);
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   133
            offset += len;
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   134
        }
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   135
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   136
        // Stores the precomputed message digest value.
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   137
        @Override
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   138
        protected void engineUpdate(ByteBuffer byteBuffer) {
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   139
            int len = byteBuffer.remaining();
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   140
            if (len <= 0) {
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   141
                return;
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   142
            }
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   143
            if (offset + len > precomputedDigest.length) {
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   144
                offset = RAW_RSA_MAX + 1;
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   145
                return;
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   146
            }
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   147
            byteBuffer.get(precomputedDigest, offset, len);
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   148
            offset += len;
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   149
        }
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   150
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   151
        @Override
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   152
        protected void resetDigest(){
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   153
            offset = 0;
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   154
        }
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   155
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   156
        // Returns the precomputed message digest value.
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   157
        @Override
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   158
        protected byte[] getDigestValue() throws SignatureException {
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   159
            if (offset > RAW_RSA_MAX) {
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   160
                throw new SignatureException("Message digest is too long");
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   161
            }
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   162
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   163
            // Determine the digest algorithm from the digest length
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   164
            if (offset == 20) {
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   165
                setDigestName("SHA1");
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   166
            } else if (offset == 36) {
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   167
                setDigestName("SHA1+MD5");
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   168
            } else if (offset == 32) {
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   169
                setDigestName("SHA-256");
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   170
            } else if (offset == 48) {
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   171
                setDigestName("SHA-384");
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   172
            } else if (offset == 64) {
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   173
                setDigestName("SHA-512");
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   174
            } else if (offset == 16) {
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   175
                setDigestName("MD5");
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   176
            } else {
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   177
                throw new SignatureException(
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   178
                    "Message digest length is not supported");
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   179
            }
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   180
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   181
            byte[] result = new byte[offset];
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   182
            System.arraycopy(precomputedDigest, 0, result, 0, offset);
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   183
            offset = 0;
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   184
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   185
            return result;
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   186
        }
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   187
    }
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   188
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    public static final class SHA1 extends RSASignature {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        public SHA1() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
            super("SHA1");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
9524
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 9508
diff changeset
   195
    public static final class SHA256 extends RSASignature {
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 9508
diff changeset
   196
        public SHA256() {
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 9508
diff changeset
   197
            super("SHA-256");
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 9508
diff changeset
   198
        }
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 9508
diff changeset
   199
    }
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 9508
diff changeset
   200
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 9508
diff changeset
   201
    public static final class SHA384 extends RSASignature {
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 9508
diff changeset
   202
        public SHA384() {
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 9508
diff changeset
   203
            super("SHA-384");
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 9508
diff changeset
   204
        }
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 9508
diff changeset
   205
    }
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 9508
diff changeset
   206
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 9508
diff changeset
   207
    public static final class SHA512 extends RSASignature {
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 9508
diff changeset
   208
        public SHA512() {
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 9508
diff changeset
   209
            super("SHA-512");
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 9508
diff changeset
   210
        }
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 9508
diff changeset
   211
    }
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 9508
diff changeset
   212
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    public static final class MD5 extends RSASignature {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        public MD5() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
            super("MD5");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    public static final class MD2 extends RSASignature {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        public MD2() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
            super("MD2");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
9524
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 9508
diff changeset
   225
    // initialize for signing. See JCA doc
50204
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents: 47216
diff changeset
   226
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
    protected void engineInitVerify(PublicKey key)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        throws InvalidKeyException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        // This signature accepts only RSAPublicKey
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        if ((key instanceof java.security.interfaces.RSAPublicKey) == false) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
            throw new InvalidKeyException("Key type not supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        java.security.interfaces.RSAPublicKey rsaKey =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
            (java.security.interfaces.RSAPublicKey) key;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        if ((key instanceof sun.security.mscapi.RSAPublicKey) == false) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
            // convert key to MSCAPI format
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
2596
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   242
            BigInteger modulus = rsaKey.getModulus();
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   243
            BigInteger exponent =  rsaKey.getPublicExponent();
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   244
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   245
            // Check against the local and global values to make sure
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   246
            // the sizes are ok.  Round up to the nearest byte.
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   247
            RSAKeyFactory.checkKeyLengths(((modulus.bitLength() + 7) & ~7),
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   248
                exponent, -1, RSAKeyPairGenerator.KEY_SIZE_MAX);
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   249
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   250
            byte[] modulusBytes = modulus.toByteArray();
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   251
            byte[] exponentBytes = exponent.toByteArray();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
            // Adjust key length due to sign bit
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
            int keyBitLength = (modulusBytes[0] == 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
                ? (modulusBytes.length - 1) * 8
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
                : modulusBytes.length * 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
            byte[] keyBlob = generatePublicKeyBlob(
2596
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   259
                keyBitLength, modulusBytes, exponentBytes);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
9508
310b4f6c8e61 6732372: Some MSCAPI native methods not returning correct exceptions.
vinnie
parents: 9505
diff changeset
   261
            try {
310b4f6c8e61 6732372: Some MSCAPI native methods not returning correct exceptions.
vinnie
parents: 9505
diff changeset
   262
                publicKey = importPublicKey(keyBlob, keyBitLength);
310b4f6c8e61 6732372: Some MSCAPI native methods not returning correct exceptions.
vinnie
parents: 9505
diff changeset
   263
310b4f6c8e61 6732372: Some MSCAPI native methods not returning correct exceptions.
vinnie
parents: 9505
diff changeset
   264
            } catch (KeyStoreException e) {
310b4f6c8e61 6732372: Some MSCAPI native methods not returning correct exceptions.
vinnie
parents: 9505
diff changeset
   265
                throw new InvalidKeyException(e);
310b4f6c8e61 6732372: Some MSCAPI native methods not returning correct exceptions.
vinnie
parents: 9505
diff changeset
   266
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
            publicKey = (sun.security.mscapi.RSAPublicKey) key;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
9524
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 9508
diff changeset
   272
        this.privateKey = null;
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 9508
diff changeset
   273
        resetDigest();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
9524
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 9508
diff changeset
   276
    // initialize for signing. See JCA doc
50204
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents: 47216
diff changeset
   277
    @Override
9524
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 9508
diff changeset
   278
    protected void engineInitSign(PrivateKey key) throws InvalidKeyException
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        // This signature accepts only RSAPrivateKey
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        if ((key instanceof sun.security.mscapi.RSAPrivateKey) == false) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
            throw new InvalidKeyException("Key type not supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        privateKey = (sun.security.mscapi.RSAPrivateKey) key;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
2596
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   286
        // Check against the local and global values to make sure
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   287
        // the sizes are ok.  Round up to nearest byte.
11521
d7698e6c5f51 7106773: 512 bits RSA key cannot work with SHA384 and SHA512
xuelei
parents: 10336
diff changeset
   288
        RSAKeyFactory.checkKeyLengths(((privateKey.length() + 7) & ~7),
2596
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   289
            null, RSAKeyPairGenerator.KEY_SIZE_MIN,
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   290
            RSAKeyPairGenerator.KEY_SIZE_MAX);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
9524
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 9508
diff changeset
   292
        this.publicKey = null;
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 9508
diff changeset
   293
        resetDigest();
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 9508
diff changeset
   294
    }
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 9508
diff changeset
   295
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 9508
diff changeset
   296
    /**
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 9508
diff changeset
   297
     * Resets the message digest if needed.
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 9508
diff changeset
   298
     */
9533
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   299
    protected void resetDigest() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
        if (needsReset) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
            messageDigest.reset();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
            needsReset = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
9533
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   306
    protected byte[] getDigestValue() throws SignatureException {
9524
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 9508
diff changeset
   307
        needsReset = false;
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 9508
diff changeset
   308
        return messageDigest.digest();
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 9508
diff changeset
   309
    }
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 9508
diff changeset
   310
9533
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   311
    protected void setDigestName(String name) {
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   312
        messageDigestAlgorithm = name;
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   313
    }
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   314
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
     * Updates the data to be signed or verified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     * using the specified byte.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
     * @param b the byte to use for the update.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     * @exception SignatureException if the engine is not initialized
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
     * properly.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
     */
50204
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents: 47216
diff changeset
   324
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
    protected void engineUpdate(byte b) throws SignatureException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
        messageDigest.update(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
        needsReset = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
     * Updates the data to be signed or verified, using the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
     * specified array of bytes, starting at the specified offset.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     * @param b the array of bytes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
     * @param off the offset to start from in the array of bytes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
     * @param len the number of bytes to use, starting at offset
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
     * @exception SignatureException if the engine is not initialized
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
     * properly
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
     */
50204
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents: 47216
diff changeset
   342
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
    protected void engineUpdate(byte[] b, int off, int len)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
        throws SignatureException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
        messageDigest.update(b, off, len);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
        needsReset = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
     * Updates the data to be signed or verified, using the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
     * specified ByteBuffer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
     * @param input the ByteBuffer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
     */
50204
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents: 47216
diff changeset
   356
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
    protected void engineUpdate(ByteBuffer input)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
        messageDigest.update(input);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
        needsReset = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
     * Returns the signature bytes of all the data
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
     * updated so far.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
     * The format of the signature depends on the underlying
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
     * signature scheme.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
     * @return the signature bytes of the signing operation's result.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
     * @exception SignatureException if the engine is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
     * initialized properly or if this signature algorithm is unable to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
     * process the input data provided.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
     */
50204
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents: 47216
diff changeset
   375
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
    protected byte[] engineSign() throws SignatureException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
9524
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 9508
diff changeset
   378
        byte[] hash = getDigestValue();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
9533
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   380
        // Omit the hash OID when generating a Raw signature
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   381
        boolean noHashOID = this instanceof Raw;
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   382
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
        // Sign hash using MS Crypto APIs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
9533
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   385
        byte[] result = signHash(noHashOID, hash, hash.length,
9524
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 9508
diff changeset
   386
            messageDigestAlgorithm, privateKey.getHCryptProvider(),
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
            privateKey.getHCryptKey());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
        // Convert signature array from little endian to big endian
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
        return convertEndianArray(result);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
     * Convert array from big endian to little endian, or vice versa.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
    private byte[] convertEndianArray(byte[] byteArray)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
        if (byteArray == null || byteArray.length == 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
            return byteArray;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
        byte [] retval = new byte[byteArray.length];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
        // make it big endian
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
        for (int i=0;i < byteArray.length;i++)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
            retval[i] = byteArray[byteArray.length - i - 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
        return retval;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
     * Sign hash using Microsoft Crypto API with HCRYPTKEY.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
     * The returned data is in little-endian.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
     */
9533
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   414
    private native static byte[] signHash(boolean noHashOID, byte[] hash,
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   415
        int hashSize, String hashAlgorithm, long hCryptProv, long hCryptKey)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
            throws SignatureException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
     * Verify a signed hash using Microsoft Crypto API with HCRYPTKEY.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
    private native static boolean verifySignedHash(byte[] hash, int hashSize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
        String hashAlgorithm, byte[] signature, int signatureSize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
        long hCryptProv, long hCryptKey) throws SignatureException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
     * Verifies the passed-in signature.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
     * @param sigBytes the signature bytes to be verified.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
     * @return true if the signature was verified, false if not.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
     * @exception SignatureException if the engine is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
     * initialized properly, the passed-in signature is improperly
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
     * encoded or of the wrong type, if this signature algorithm is unable to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
     * process the input data provided, etc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
     */
50204
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents: 47216
diff changeset
   437
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
    protected boolean engineVerify(byte[] sigBytes)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
        throws SignatureException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
    {
9524
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 9508
diff changeset
   441
        byte[] hash = getDigestValue();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
        return verifySignedHash(hash, hash.length,
9524
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 9508
diff changeset
   444
            messageDigestAlgorithm, convertEndianArray(sigBytes),
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
            sigBytes.length, publicKey.getHCryptProvider(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
            publicKey.getHCryptKey());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
     * Sets the specified algorithm parameter to the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
     * value. This method supplies a general-purpose mechanism through
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
     * which it is possible to set the various parameters of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
     * A parameter may be any settable parameter for the algorithm, such as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
     * a parameter size, or a source of random bits for signature generation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
     * (if appropriate), or an indication of whether or not to perform
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
     * a specific but optional computation. A uniform algorithm-specific
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
     * naming scheme for each parameter is desirable but left unspecified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
     * at this time.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
     * @param param the string identifier of the parameter.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
     * @param value the parameter value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
     * @exception InvalidParameterException if <code>param</code> is an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
     * invalid parameter for this signature algorithm engine,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
     * the parameter is already set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
     * and cannot be set again, a security exception occurs, and so on.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
     * @deprecated Replaced by {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
     * #engineSetParameter(java.security.spec.AlgorithmParameterSpec)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
     * engineSetParameter}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
     */
50204
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents: 47216
diff changeset
   473
    @Override
10336
0bb1999251f8 7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents: 9533
diff changeset
   474
    @Deprecated
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
    protected void engineSetParameter(String param, Object value)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
        throws InvalidParameterException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
        throw new InvalidParameterException("Parameter not supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
50204
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents: 47216
diff changeset
   481
    /**
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents: 47216
diff changeset
   482
     * Sets this signature engine with the specified algorithm parameter.
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents: 47216
diff changeset
   483
     *
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents: 47216
diff changeset
   484
     * @param params the parameters
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents: 47216
diff changeset
   485
     *
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents: 47216
diff changeset
   486
     * @exception InvalidAlgorithmParameterException if the given
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents: 47216
diff changeset
   487
     * parameter is invalid
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents: 47216
diff changeset
   488
     */
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents: 47216
diff changeset
   489
    @Override
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents: 47216
diff changeset
   490
    protected void engineSetParameter(AlgorithmParameterSpec params)
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents: 47216
diff changeset
   491
        throws InvalidAlgorithmParameterException
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents: 47216
diff changeset
   492
    {
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents: 47216
diff changeset
   493
        if (params != null) {
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents: 47216
diff changeset
   494
            throw new InvalidAlgorithmParameterException("No parameter accepted");
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents: 47216
diff changeset
   495
        }
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents: 47216
diff changeset
   496
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
     * Gets the value of the specified algorithm parameter.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
     * This method supplies a general-purpose mechanism through which it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
     * is possible to get the various parameters of this object. A parameter
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
     * may be any settable parameter for the algorithm, such as a parameter
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
     * size, or  a source of random bits for signature generation (if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
     * appropriate), or an indication of whether or not to perform a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
     * specific but optional computation. A uniform algorithm-specific
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
     * naming scheme for each parameter is desirable but left unspecified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
     * at this time.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
     * @param param the string name of the parameter.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
     * @return the object that represents the parameter value, or null if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
     * there is none.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
     * @exception InvalidParameterException if <code>param</code> is an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
     * invalid parameter for this engine, or another exception occurs while
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
     * trying to get this parameter.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
     * @deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
     */
50204
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents: 47216
diff changeset
   520
    @Override
10336
0bb1999251f8 7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents: 9533
diff changeset
   521
    @Deprecated
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
    protected Object engineGetParameter(String param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
        throws InvalidParameterException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
        throw new InvalidParameterException("Parameter not supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
    /**
50204
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents: 47216
diff changeset
   529
     * Gets the algorithm parameter from this signature engine.
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents: 47216
diff changeset
   530
     *
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents: 47216
diff changeset
   531
     * @return the parameter, or null if no parameter is used.
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents: 47216
diff changeset
   532
     */
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents: 47216
diff changeset
   533
    @Override
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents: 47216
diff changeset
   534
    protected AlgorithmParameters engineGetParameters() {
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents: 47216
diff changeset
   535
        return null;
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents: 47216
diff changeset
   536
    }
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents: 47216
diff changeset
   537
3195a713e24d 8146293: Add support for RSASSA-PSS Signature algorithm
valeriep
parents: 47216
diff changeset
   538
    /**
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
     * Generates a public-key BLOB from a key's components.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
     */
9505
3bbc6ff8a905 6888925: SunMSCAPI's Cipher can't use RSA public keys obtained from other sources.
vinnie
parents: 5506
diff changeset
   541
    // used by RSACipher
3bbc6ff8a905 6888925: SunMSCAPI's Cipher can't use RSA public keys obtained from other sources.
vinnie
parents: 5506
diff changeset
   542
    static native byte[] generatePublicKeyBlob(
9508
310b4f6c8e61 6732372: Some MSCAPI native methods not returning correct exceptions.
vinnie
parents: 9505
diff changeset
   543
        int keyBitLength, byte[] modulus, byte[] publicExponent)
310b4f6c8e61 6732372: Some MSCAPI native methods not returning correct exceptions.
vinnie
parents: 9505
diff changeset
   544
            throws InvalidKeyException;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
     * Imports a public-key BLOB.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
     */
9505
3bbc6ff8a905 6888925: SunMSCAPI's Cipher can't use RSA public keys obtained from other sources.
vinnie
parents: 5506
diff changeset
   549
    // used by RSACipher
9508
310b4f6c8e61 6732372: Some MSCAPI native methods not returning correct exceptions.
vinnie
parents: 9505
diff changeset
   550
    static native RSAPublicKey importPublicKey(byte[] keyBlob, int keySize)
310b4f6c8e61 6732372: Some MSCAPI native methods not returning correct exceptions.
vinnie
parents: 9505
diff changeset
   551
        throws KeyStoreException;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
}