author | rehn |
Fri, 07 Jul 2017 23:04:06 +0200 | |
changeset 46643 | cb5f289ba033 |
parent 39759 | 427916042881 |
permissions | -rw-r--r-- |
39759
427916042881
8161718: Copyright/License updates to corba, jdk
bchristi
parents:
37909
diff
changeset
|
1 |
/* |
37909 | 2 |
* Copyright (c) 2014, 2016, 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 |
/** |
|
29 |
* Enum for representing the ucrypto mechanisms. |
|
30 |
* |
|
35302
e4d2275861c3
8136494: Update "@since 1.9" to "@since 9" to match java.version.specification
iris
parents:
31270
diff
changeset
|
31 |
* @since 9 |
27182 | 32 |
*/ |
33 |
// Check /usr/include/libsoftcrypto.h for updates |
|
34 |
public enum UcryptoMech { |
|
31270
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
35 |
|
37909 | 36 |
CRYPTO_AES_ECB(new ServiceDesc[] |
31270
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
37 |
{ 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
|
38 |
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
|
39 |
"AES"), |
37909 | 40 |
sd("Cipher", "AES_128/ECB/NoPadding", "com.oracle.security.ucrypto.NativeCipher$AesEcbNoPadding", |
31270
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
41 |
"2.16.840.1.101.3.4.1.1", "OID.2.16.840.1.101.3.4.1.1"), |
37909 | 42 |
sd("Cipher", "AES_192/ECB/NoPadding", "com.oracle.security.ucrypto.NativeCipher$AesEcbNoPadding", |
31270
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
43 |
"2.16.840.1.101.3.4.1.21", "OID.2.16.840.1.101.3.4.1.21"), |
37909 | 44 |
sd("Cipher", "AES_256/ECB/NoPadding", "com.oracle.security.ucrypto.NativeCipher$AesEcbNoPadding", |
31270
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
45 |
"2.16.840.1.101.3.4.1.41", "OID.2.16.840.1.101.3.4.1.41") |
27182 | 46 |
}), |
37909 | 47 |
CRYPTO_AES_CBC(new ServiceDesc[] |
31270
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
48 |
{ 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
|
49 |
sd("Cipher", "AES/CBC/PKCS5Padding", "com.oracle.security.ucrypto.NativeCipherWithJavaPadding$AesCbcPKCS5"), |
37909 | 50 |
sd("Cipher", "AES_128/CBC/NoPadding", "com.oracle.security.ucrypto.NativeCipher$AesCbcNoPadding", |
31270
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
51 |
"2.16.840.1.101.3.4.1.2", "OID.2.16.840.1.101.3.4.1.2"), |
37909 | 52 |
sd("Cipher", "AES_192/CBC/NoPadding", "com.oracle.security.ucrypto.NativeCipher$AesCbcNoPadding", |
31270
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
53 |
"2.16.840.1.101.3.4.1.22", "OID.2.16.840.1.101.3.4.1.22"), |
37909 | 54 |
sd("Cipher", "AES_256/CBC/NoPadding", "com.oracle.security.ucrypto.NativeCipher$AesCbcNoPadding", |
31270
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
55 |
"2.16.840.1.101.3.4.1.42", "OID.2.16.840.1.101.3.4.1.42") |
27182 | 56 |
}), |
37909 | 57 |
// CRYPTO_AES_CBC_PAD(null), // Support added since S11.1; however we still use CRYPTO_AES_CBC due to known bug |
58 |
CRYPTO_AES_CTR(new ServiceDesc[] |
|
31270
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
59 |
{ sd("Cipher", "AES/CTR/NoPadding", "com.oracle.security.ucrypto.NativeCipher$AesCtrNoPadding") }), |
37909 | 60 |
// CRYPTO_AES_CCM(null), // Need Java API for CK_AES_CCM_PARAMS |
61 |
CRYPTO_AES_GCM(new ServiceDesc[] |
|
31270
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
62 |
{ sd("Cipher", "AES/GCM/NoPadding", "com.oracle.security.ucrypto.NativeGCMCipher$AesGcmNoPadding"), |
37909 | 63 |
sd("Cipher", "AES_128/GCM/NoPadding", "com.oracle.security.ucrypto.NativeGCMCipher$AesGcmNoPadding", |
31270
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
64 |
"2.16.840.1.101.3.4.1.6", "OID.2.16.840.1.101.3.4.1.6"), |
37909 | 65 |
sd("Cipher", "AES_192/GCM/NoPadding", "com.oracle.security.ucrypto.NativeGCMCipher$AesGcmNoPadding", |
31270
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
66 |
"2.16.840.1.101.3.4.1.26", "OID.2.16.840.1.101.3.4.1.26"), |
37909 | 67 |
sd("Cipher", "AES_256/GCM/NoPadding", "com.oracle.security.ucrypto.NativeGCMCipher$AesGcmNoPadding", |
31270
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
68 |
"2.16.840.1.101.3.4.1.46", "OID.2.16.840.1.101.3.4.1.46") |
27182 | 69 |
}), |
37909 | 70 |
// CRYPTO_AES_GMAC(null), // No support from Solaris |
71 |
CRYPTO_AES_CFB128(new ServiceDesc[] |
|
31270
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
72 |
{ sd("Cipher", "AES/CFB128/NoPadding", "com.oracle.security.ucrypto.NativeCipher$AesCfb128NoPadding"), |
37909 | 73 |
sd("Cipher", "AES/CFB128/PKCS5Padding", "com.oracle.security.ucrypto.NativeCipherWithJavaPadding$AesCfb128PKCS5") |
74 |
}), |
|
75 |
||
76 |
CRYPTO_RSA_PKCS(new ServiceDesc[] |
|
31270
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", |
37909 | 78 |
"RSA") |
79 |
}), |
|
80 |
CRYPTO_RSA_X_509(new ServiceDesc[] |
|
31270
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
81 |
{ sd("Cipher", "RSA/ECB/NoPadding", "com.oracle.security.ucrypto.NativeRSACipher$NoPadding") }), |
37909 | 82 |
CRYPTO_MD5_RSA_PKCS(new ServiceDesc[] |
31270
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
83 |
{ sd("Signature", "MD5withRSA", "com.oracle.security.ucrypto.NativeRSASignature$MD5", |
37909 | 84 |
"1.2.840.113549.1.1.4", "OID.1.2.840.113549.1.1.4") |
85 |
}), |
|
86 |
CRYPTO_SHA1_RSA_PKCS(new ServiceDesc[] |
|
31270
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
87 |
{ sd("Signature", "SHA1withRSA", "com.oracle.security.ucrypto.NativeRSASignature$SHA1", |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
88 |
"1.2.840.113549.1.1.5", "OID.1.2.840.113549.1.1.5", |
37909 | 89 |
"1.3.14.3.2.29") |
90 |
}), |
|
91 |
CRYPTO_SHA256_RSA_PKCS(new ServiceDesc[] |
|
31270
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
92 |
{ sd("Signature", "SHA256withRSA", "com.oracle.security.ucrypto.NativeRSASignature$SHA256", |
37909 | 93 |
"1.2.840.113549.1.1.11", "OID.1.2.840.113549.1.1.11") |
94 |
}), |
|
95 |
CRYPTO_SHA384_RSA_PKCS(new ServiceDesc[] |
|
31270
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
96 |
{ sd("Signature", "SHA384withRSA", "com.oracle.security.ucrypto.NativeRSASignature$SHA384", |
37909 | 97 |
"1.2.840.113549.1.1.12", "OID.1.2.840.113549.1.1.12") |
98 |
}), |
|
99 |
CRYPTO_SHA512_RSA_PKCS(new ServiceDesc[] |
|
31270
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
100 |
{ sd("Signature", "SHA512withRSA", "com.oracle.security.ucrypto.NativeRSASignature$SHA512", |
37909 | 101 |
"1.2.840.113549.1.1.13", "OID.1.2.840.113549.1.1.13") |
102 |
}), |
|
27182 | 103 |
|
37909 | 104 |
CRYPTO_MD5(new ServiceDesc[] |
105 |
{ sd("MessageDigest", "MD5", "com.oracle.security.ucrypto.NativeDigest$MD5") }), |
|
106 |
CRYPTO_SHA1(new ServiceDesc[] |
|
107 |
{ sd("MessageDigest", "SHA", "com.oracle.security.ucrypto.NativeDigest$SHA1", "SHA-1", "SHA1") }), |
|
108 |
CRYPTO_SHA224(new ServiceDesc[] |
|
109 |
{ sd("MessageDigest", "SHA-224", "com.oracle.security.ucrypto.NativeDigest$SHA224", |
|
110 |
"2.16.840.1.101.3.4.2.4", "OID.2.16.840.1.101.3.4.2.4") |
|
111 |
}), |
|
112 |
CRYPTO_SHA256(new ServiceDesc[] |
|
113 |
{ sd("MessageDigest", "SHA-256", "com.oracle.security.ucrypto.NativeDigest$SHA256", |
|
114 |
"2.16.840.1.101.3.4.2.1", "OID.2.16.840.1.101.3.4.2.1") |
|
115 |
}), |
|
116 |
CRYPTO_SHA384(new ServiceDesc[] |
|
117 |
{ sd("MessageDigest", "SHA-384", "com.oracle.security.ucrypto.NativeDigest$SHA384", |
|
118 |
"2.16.840.1.101.3.4.2.2", "OID.2.16.840.1.101.3.4.2.2") |
|
119 |
}), |
|
120 |
CRYPTO_SHA512(new ServiceDesc[] |
|
121 |
{ sd("MessageDigest", "SHA-512", "com.oracle.security.ucrypto.NativeDigest$SHA512", |
|
122 |
"2.16.840.1.101.3.4.2.3", "OID.2.16.840.1.101.3.4.2.3") |
|
123 |
}), |
|
124 |
CRYPTO_SHA3_224(new ServiceDesc[] |
|
125 |
{ sd("MessageDigest", "SHA3-224", "com.oracle.security.ucrypto.NativeDigest$SHA3_224", |
|
126 |
"2.16.840.1.101.3.4.2.7", "OID.2.16.840.1.101.3.4.2.7") |
|
127 |
}), |
|
128 |
CRYPTO_SHA3_256(new ServiceDesc[] |
|
129 |
{ sd("MessageDigest", "SHA3-256", "com.oracle.security.ucrypto.NativeDigest$SHA3_256", |
|
130 |
"2.16.840.1.101.3.4.2.8", "OID.2.16.840.1.101.3.4.2.8") |
|
131 |
}), |
|
132 |
CRYPTO_SHA3_384(new ServiceDesc[] |
|
133 |
{ sd("MessageDigest", "SHA3-384", "com.oracle.security.ucrypto.NativeDigest$SHA3_384", |
|
134 |
"2.16.840.1.101.3.4.2.9", "OID.2.16.840.1.101.3.4.2.9") |
|
135 |
}), |
|
136 |
CRYPTO_SHA3_512(new ServiceDesc[] |
|
137 |
{ sd("MessageDigest", "SHA3-512", "com.oracle.security.ucrypto.NativeDigest$SHA3_512", |
|
138 |
"2.16.840.1.101.3.4.2.10", "OID.2.16.840.1.101.3.4.2.10") |
|
139 |
}); |
|
140 |
||
141 |
private int mech = 0; |
|
31270
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
142 |
private final ServiceDesc[] serviceDescs; |
27182 | 143 |
|
31270
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
144 |
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
|
145 |
return new ServiceDesc(type, algo, cn, aliases); |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
146 |
} |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
147 |
|
37909 | 148 |
UcryptoMech(ServiceDesc[] serviceDescs) { |
31270
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
149 |
this.serviceDescs = serviceDescs; |
27182 | 150 |
} |
151 |
||
37909 | 152 |
public void setValue(int nativeMechValue) { |
153 |
this.mech = nativeMechValue; |
|
154 |
} |
|
155 |
||
27182 | 156 |
public int value() { return mech; } |
31270
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
28240
diff
changeset
|
157 |
public ServiceDesc[] getServiceDescriptions() { return serviceDescs; } |
27182 | 158 |
} |