author | dsamersoff |
Thu, 23 Jul 2015 15:25:30 +0000 | |
changeset 32020 | d21ec07fde32 |
parent 31270 | e6470b24700d |
child 35302 | e4d2275861c3 |
permissions | -rw-r--r-- |
31270
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
1 |
/** |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
2 |
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. |
27182 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. Oracle designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
24 |
*/ |
|
25 |
||
26 |
package com.oracle.security.ucrypto; |
|
27 |
||
28 |
import java.util.HashMap; |
|
29 |
||
30 |
/** |
|
31 |
* Enum for representing the ucrypto mechanisms. |
|
32 |
* |
|
33 |
* @since 1.9 |
|
34 |
*/ |
|
35 |
// Check /usr/include/libsoftcrypto.h for updates |
|
36 |
public enum UcryptoMech { |
|
31270
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
37 |
|
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
38 |
CRYPTO_AES_ECB(1, new ServiceDesc[] |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
39 |
{ sd("Cipher", "AES/ECB/NoPadding", "com.oracle.security.ucrypto.NativeCipher$AesEcbNoPadding"), |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
40 |
sd("Cipher", "AES/ECB/PKCS5Padding", "com.oracle.security.ucrypto.NativeCipherWithJavaPadding$AesEcbPKCS5", |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
41 |
"AES"), |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
42 |
sd("Cipher", "AES_128/ECB/NoPadding", "com.oracle.security.ucrypto.NativeCipher$Aes128EcbNoPadding", |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
43 |
"2.16.840.1.101.3.4.1.1", "OID.2.16.840.1.101.3.4.1.1"), |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
44 |
sd("Cipher", "AES_192/ECB/NoPadding", "com.oracle.security.ucrypto.NativeCipher$Aes192EcbNoPadding", |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
45 |
"2.16.840.1.101.3.4.1.21", "OID.2.16.840.1.101.3.4.1.21"), |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
46 |
sd("Cipher", "AES_256/ECB/NoPadding", "com.oracle.security.ucrypto.NativeCipher$Aes256EcbNoPadding", |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
47 |
"2.16.840.1.101.3.4.1.41", "OID.2.16.840.1.101.3.4.1.41") |
27182 | 48 |
}), |
31270
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
49 |
CRYPTO_AES_CBC(2, new ServiceDesc[] |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
50 |
{ sd("Cipher", "AES/CBC/NoPadding", "com.oracle.security.ucrypto.NativeCipher$AesCbcNoPadding"), |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
51 |
sd("Cipher", "AES/CBC/PKCS5Padding", "com.oracle.security.ucrypto.NativeCipherWithJavaPadding$AesCbcPKCS5"), |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
52 |
sd("Cipher", "AES_128/CBC/NoPadding", "com.oracle.security.ucrypto.NativeCipher$Aes128CbcNoPadding", |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
53 |
"2.16.840.1.101.3.4.1.2", "OID.2.16.840.1.101.3.4.1.2"), |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
54 |
sd("Cipher", "AES_192/CBC/NoPadding", "com.oracle.security.ucrypto.NativeCipher$Aes192CbcNoPadding", |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
55 |
"2.16.840.1.101.3.4.1.22", "OID.2.16.840.1.101.3.4.1.22"), |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
56 |
sd("Cipher", "AES_256/CBC/NoPadding", "com.oracle.security.ucrypto.NativeCipher$Aes256CbcNoPadding", |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
57 |
"2.16.840.1.101.3.4.1.42", "OID.2.16.840.1.101.3.4.1.42") |
27182 | 58 |
}), |
59 |
CRYPTO_AES_CBC_PAD(3, null), // No support from Solaris yet |
|
31270
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
60 |
CRYPTO_AES_CTR(4, new ServiceDesc[] |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
61 |
{ sd("Cipher", "AES/CTR/NoPadding", "com.oracle.security.ucrypto.NativeCipher$AesCtrNoPadding") }), |
27182 | 62 |
CRYPTO_AES_CCM(5, null), // Cannot support due to lack of Java API which corresponds to CK_AES_CCM_PARAMS |
31270
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
63 |
CRYPTO_AES_GCM(6, new ServiceDesc[] |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
64 |
{ sd("Cipher", "AES/GCM/NoPadding", "com.oracle.security.ucrypto.NativeGCMCipher$AesGcmNoPadding"), |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
65 |
sd("Cipher", "AES_128/GCM/NoPadding", "com.oracle.security.ucrypto.NativeGCMCipher$Aes128GcmNoPadding", |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
66 |
"2.16.840.1.101.3.4.1.6", "OID.2.16.840.1.101.3.4.1.6"), |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
67 |
sd("Cipher", "AES_192/GCM/NoPadding", "com.oracle.security.ucrypto.NativeGCMCipher$Aes192GcmNoPadding", |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
68 |
"2.16.840.1.101.3.4.1.26", "OID.2.16.840.1.101.3.4.1.26"), |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
69 |
sd("Cipher", "AES_256/GCM/NoPadding", "com.oracle.security.ucrypto.NativeGCMCipher$Aes256GcmNoPadding", |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
70 |
"2.16.840.1.101.3.4.1.46", "OID.2.16.840.1.101.3.4.1.46") |
27182 | 71 |
}), |
72 |
CRYPTO_AES_GMAC(7, null), // No support from Solaris yet |
|
31270
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
73 |
CRYPTO_AES_CFB128(8, new ServiceDesc[] |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
74 |
{ sd("Cipher", "AES/CFB128/NoPadding", "com.oracle.security.ucrypto.NativeCipher$AesCfb128NoPadding"), |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
75 |
sd("Cipher", "AES/CFB128/PKCS5Padding", "com.oracle.security.ucrypto.NativeCipherWithJavaPadding$AesCfb128PKCS5") }), |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
76 |
CRYPTO_RSA_PKCS(31, new ServiceDesc[] |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
77 |
{ sd("Cipher", "RSA/ECB/PKCS1Padding", "com.oracle.security.ucrypto.NativeRSACipher$PKCS1Padding", |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
78 |
"RSA") }), |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
79 |
CRYPTO_RSA_X_509(32, new ServiceDesc[] |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
80 |
{ sd("Cipher", "RSA/ECB/NoPadding", "com.oracle.security.ucrypto.NativeRSACipher$NoPadding") }), |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
81 |
CRYPTO_MD5_RSA_PKCS(33, new ServiceDesc[] |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
82 |
{ sd("Signature", "MD5withRSA", "com.oracle.security.ucrypto.NativeRSASignature$MD5", |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
83 |
"1.2.840.113549.1.1.4", "OID.1.2.840.113549.1.1.4") }), |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
84 |
CRYPTO_SHA1_RSA_PKCS(34, new ServiceDesc[] |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
85 |
{ sd("Signature", "SHA1withRSA", "com.oracle.security.ucrypto.NativeRSASignature$SHA1", |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
86 |
"1.2.840.113549.1.1.5", "OID.1.2.840.113549.1.1.5", |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
87 |
"1.3.14.3.2.29") }), |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
88 |
CRYPTO_SHA256_RSA_PKCS(35, new ServiceDesc[] |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
89 |
{ sd("Signature", "SHA256withRSA", "com.oracle.security.ucrypto.NativeRSASignature$SHA256", |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
90 |
"1.2.840.113549.1.1.11", "OID.1.2.840.113549.1.1.11") }), |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
91 |
CRYPTO_SHA384_RSA_PKCS(36, new ServiceDesc[] |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
92 |
{ sd("Signature", "SHA384withRSA", "com.oracle.security.ucrypto.NativeRSASignature$SHA384", |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
93 |
"1.2.840.113549.1.1.12", "OID.1.2.840.113549.1.1.12") }), |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
94 |
CRYPTO_SHA512_RSA_PKCS(37, new ServiceDesc[] |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
95 |
{ sd("Signature", "SHA512withRSA", "com.oracle.security.ucrypto.NativeRSASignature$SHA512", |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
96 |
"1.2.840.113549.1.1.13", "OID.1.2.840.113549.1.1.13") }); |
27182 | 97 |
|
31270
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
98 |
private final int mech; |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
99 |
private final ServiceDesc[] serviceDescs; |
27182 | 100 |
|
31270
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
101 |
private static ServiceDesc sd(String type, String algo, String cn, String... aliases) { |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
102 |
return new ServiceDesc(type, algo, cn, aliases); |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
103 |
} |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
104 |
|
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
105 |
UcryptoMech(int mech, ServiceDesc[] serviceDescs) { |
27182 | 106 |
this.mech = mech; |
31270
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
107 |
this.serviceDescs = serviceDescs; |
27182 | 108 |
} |
109 |
||
110 |
public int value() { return mech; } |
|
31270
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
111 |
public ServiceDesc[] getServiceDescriptions() { return serviceDescs; } |
27182 | 112 |
} |