jdk/src/windows/classes/sun/security/mscapi/SunMSCAPI.java
author ascarpino
Tue, 07 Jan 2014 14:35:57 -0800
changeset 22121 b1aa108cccb5
parent 20485 8af87f3d549c
child 23582 d5fa3327ab3a
permissions -rw-r--r--
8030823: Security Providers need to have their version numbers updated for JDK9 Reviewed-by: xuelei, wetmore
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
22121
b1aa108cccb5 8030823: Security Providers need to have their version numbers updated for JDK9
ascarpino
parents: 20485
diff changeset
     2
 * Copyright (c) 2005, 2014, 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: 3353
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: 3353
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: 3353
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3353
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3353
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.security.AccessController;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.security.PrivilegedAction;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.security.Provider;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.util.HashMap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.util.Map;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import sun.security.action.PutAllAction;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * A Cryptographic Service Provider for the Microsoft Crypto API.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
public final class SunMSCAPI extends Provider {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    private static final long serialVersionUID = 8622598936488630849L; //TODO
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    private static final String INFO = "Sun's Microsoft Crypto API provider";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    static {
51
6fe31bc95bbc 6600143: Remove another 450 unnecessary casts
martin
parents: 2
diff changeset
    50
        AccessController.doPrivileged(new PrivilegedAction<Void>() {
6fe31bc95bbc 6600143: Remove another 450 unnecessary casts
martin
parents: 2
diff changeset
    51
            public Void run() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
                System.loadLibrary("sunmscapi");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
                return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
        });
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    public SunMSCAPI() {
22121
b1aa108cccb5 8030823: Security Providers need to have their version numbers updated for JDK9
ascarpino
parents: 20485
diff changeset
    59
        super("SunMSCAPI", 1.9d, INFO);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
        // if there is no security manager installed, put directly into
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
        // the provider. Otherwise, create a temporary map and use a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
        // doPrivileged() call at the end to transfer the contents
10336
0bb1999251f8 7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents: 9533
diff changeset
    64
        final Map<Object, Object> map =
0bb1999251f8 7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents: 9533
diff changeset
    65
                (System.getSecurityManager() == null)
0bb1999251f8 7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents: 9533
diff changeset
    66
                ? this : new HashMap<Object, Object>();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
         * Secure random
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        map.put("SecureRandom.Windows-PRNG", "sun.security.mscapi.PRNG");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
         * Key store
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        map.put("KeyStore.Windows-MY", "sun.security.mscapi.KeyStore$MY");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        map.put("KeyStore.Windows-ROOT", "sun.security.mscapi.KeyStore$ROOT");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
         * Signature engines
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
         */
9533
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
    82
        // 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
    83
        // 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
    84
        // SHA-256, SHA-384, SHA-512 and a special-purpose digest
12685
8a448b5b9006 4963723: Implement SHA-224
valeriep
parents: 10336
diff changeset
    85
        // algorithm which is a concatenation of SHA-1 and MD5 digests.
9533
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
    86
        map.put("Signature.NONEwithRSA",
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
    87
            "sun.security.mscapi.RSASignature$Raw");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        map.put("Signature.SHA1withRSA",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
            "sun.security.mscapi.RSASignature$SHA1");
9524
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 5506
diff changeset
    90
        map.put("Signature.SHA256withRSA",
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 5506
diff changeset
    91
            "sun.security.mscapi.RSASignature$SHA256");
12685
8a448b5b9006 4963723: Implement SHA-224
valeriep
parents: 10336
diff changeset
    92
        map.put("Alg.Alias.Signature.1.2.840.113549.1.1.11",     "SHA256withRSA");
8a448b5b9006 4963723: Implement SHA-224
valeriep
parents: 10336
diff changeset
    93
        map.put("Alg.Alias.Signature.OID.1.2.840.113549.1.1.11", "SHA256withRSA");
9524
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 5506
diff changeset
    94
        map.put("Signature.SHA384withRSA",
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 5506
diff changeset
    95
            "sun.security.mscapi.RSASignature$SHA384");
12685
8a448b5b9006 4963723: Implement SHA-224
valeriep
parents: 10336
diff changeset
    96
        map.put("Alg.Alias.Signature.1.2.840.113549.1.1.12",     "SHA384withRSA");
8a448b5b9006 4963723: Implement SHA-224
valeriep
parents: 10336
diff changeset
    97
        map.put("Alg.Alias.Signature.OID.1.2.840.113549.1.1.12", "SHA384withRSA");
8a448b5b9006 4963723: Implement SHA-224
valeriep
parents: 10336
diff changeset
    98
9524
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 5506
diff changeset
    99
        map.put("Signature.SHA512withRSA",
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 5506
diff changeset
   100
            "sun.security.mscapi.RSASignature$SHA512");
12685
8a448b5b9006 4963723: Implement SHA-224
valeriep
parents: 10336
diff changeset
   101
        map.put("Alg.Alias.Signature.1.2.840.113549.1.1.13",     "SHA512withRSA");
8a448b5b9006 4963723: Implement SHA-224
valeriep
parents: 10336
diff changeset
   102
        map.put("Alg.Alias.Signature.OID.1.2.840.113549.1.1.13", "SHA512withRSA");
8a448b5b9006 4963723: Implement SHA-224
valeriep
parents: 10336
diff changeset
   103
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        map.put("Signature.MD5withRSA",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
            "sun.security.mscapi.RSASignature$MD5");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        map.put("Signature.MD2withRSA",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
            "sun.security.mscapi.RSASignature$MD2");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        // supported key classes
9533
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   110
        map.put("Signature.NONEwithRSA SupportedKeyClasses",
13cc5e8eb9f1 6578658: Request for raw RSA (NONEwithRSA) Signature support in SunMSCAPI
vinnie
parents: 9524
diff changeset
   111
            "sun.security.mscapi.Key");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        map.put("Signature.SHA1withRSA SupportedKeyClasses",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
            "sun.security.mscapi.Key");
9524
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 5506
diff changeset
   114
        map.put("Signature.SHA256withRSA SupportedKeyClasses",
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 5506
diff changeset
   115
            "sun.security.mscapi.Key");
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 5506
diff changeset
   116
        map.put("Signature.SHA384withRSA SupportedKeyClasses",
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 5506
diff changeset
   117
            "sun.security.mscapi.Key");
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 5506
diff changeset
   118
        map.put("Signature.SHA512withRSA SupportedKeyClasses",
8417d0e74ac5 6753664: Support SHA256 (and higher) in SunMSCAPI
vinnie
parents: 5506
diff changeset
   119
            "sun.security.mscapi.Key");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        map.put("Signature.MD5withRSA SupportedKeyClasses",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
            "sun.security.mscapi.Key");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        map.put("Signature.MD2withRSA SupportedKeyClasses",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
            "sun.security.mscapi.Key");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
         * Key Pair Generator engines
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        map.put("KeyPairGenerator.RSA",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
            "sun.security.mscapi.RSAKeyPairGenerator");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        map.put("KeyPairGenerator.RSA KeySize", "1024");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
         * Cipher engines
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        map.put("Cipher.RSA", "sun.security.mscapi.RSACipher");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        map.put("Cipher.RSA/ECB/PKCS1Padding",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
            "sun.security.mscapi.RSACipher");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        map.put("Cipher.RSA SupportedModes", "ECB");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        map.put("Cipher.RSA SupportedPaddings", "PKCS1PADDING");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        map.put("Cipher.RSA SupportedKeyClasses", "sun.security.mscapi.Key");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        if (map != this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
            AccessController.doPrivileged(new PutAllAction(this, map));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
}