/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
// explicit import to override the Provider class in this package
// need internal Sun classes for FIPS tricks
/**
* to obtain implementations, etc.
*
* @author Andreas Sterbenz
*/
final class JsseJce {
// Flag indicating whether EC crypto is available.
// If null, then we have not checked yet.
// If yes, then all the EC based crypto we need is available.
// Flag indicating whether Kerberos crypto is available.
// If true, then all the Kerberos-based crypto we need is available.
private final static boolean kerberosAvailable;
static {
boolean temp;
try {
new PrivilegedExceptionAction<Void>() {
// Test for Kerberos using the bootstrap class loader
null);
return null;
}
});
temp = true;
} catch (Exception e) {
temp = false;
}
}
static {
// force FIPS flag initialization
// Because isFIPS() is synchronized and cryptoProvider is not modified
// after it completes, this also eliminates the need for any further
// synchronization when accessing cryptoProvider
} else {
// Setup a ProviderList that can be used by the trust manager
// during certificate chain validation. All the crypto must be
// from the FIPS provider, but we also allow the required
// certificate related services from the SUN provider.
throw new RuntimeException
("FIPS mode: SUN provider must be installed");
}
}
}
super("SunCertificates", 1.0d, "SunJSSE internal");
// copy certificate related services from the Sun provider
}
}
return null;
}
});
}
}
/**
* JCE transformation string for RSA with PKCS#1 v1.5 padding.
* Can be used for encryption, decryption, signing, verifying.
*/
/**
* JCE transformation string for the stream cipher RC4.
*/
/**
* JCE transformation string for DES in CBC mode without padding.
*/
/**
* JCE transformation string for (3-key) Triple DES in CBC mode
* without padding.
*/
/**
* JCE transformation string for AES in CBC mode
* without padding.
*/
/**
* JCA identifier string for DSA, i.e. a DSA with SHA-1.
*/
/**
* JCA identifier string for ECDSA, i.e. a ECDSA with SHA-1.
*/
/**
* JCA identifier string for Raw DSA, i.e. a DSA signature without
* hashing where the application provides the SHA-1 hash of the data.
* Note that the standard name is "NONEwithDSA" but we use "RawDSA"
* for compatibility.
*/
/**
* JCA identifier string for Raw ECDSA, i.e. a DSA signature without
* hashing where the application provides the SHA-1 hash of the data.
*/
/**
* JCA identifier string for Raw RSA, i.e. a RSA PKCS#1 v1.5 signature
* without hashing where the application provides the hash of the data.
* Used for RSA client authentication with a 36 byte hash.
*/
/**
* an signature using RSA with PKCS#1 v1.5 padding signing a
* concatenation of an MD5 and SHA-1 digest.
*/
private JsseJce() {
// no instantiation of this class
}
synchronized static boolean isEcAvailable() {
if (ecAvailable == null) {
try {
ecAvailable = true;
} catch (Exception e) {
ecAvailable = false;
}
}
return ecAvailable;
}
synchronized static void clearEcAvailable() {
ecAvailable = null;
}
static boolean isKerberosAvailable() {
return kerberosAvailable;
}
/**
* Return an JCE cipher implementation for the specified algorithm.
*/
throws NoSuchAlgorithmException {
try {
if (cryptoProvider == null) {
} else {
}
} catch (NoSuchPaddingException e) {
throw new NoSuchAlgorithmException(e);
}
}
/**
* Return an JCA signature implementation for the specified algorithm.
* The algorithm string should be one of the constants defined
* in this class.
*/
throws NoSuchAlgorithmException {
if (cryptoProvider == null) {
} else {
// reference equality
if (algorithm == SIGNATURE_SSLRSA) {
// The SunPKCS11 provider currently does not support this
// special algorithm. We allow a fallback in this case because
// the SunJSSE implementation does the actual crypto using
// a NONEwithRSA signature obtained from the cryptoProvider.
// Calling Signature.getInstance() and catching the
// exception would be cleaner, but exceptions are a little
// expensive. So we check directly via getService().
try {
} catch (NoSuchProviderException e) {
throw new NoSuchAlgorithmException(e);
}
}
}
}
}
throws NoSuchAlgorithmException {
if (cryptoProvider == null) {
} else {
}
}
throws NoSuchAlgorithmException {
if (cryptoProvider == null) {
} else {
}
}
throws NoSuchAlgorithmException {
if (cryptoProvider == null) {
} else {
}
}
throws NoSuchAlgorithmException {
if (cryptoProvider == null) {
} else {
}
}
throws NoSuchAlgorithmException {
if (cryptoProvider == null) {
} else {
}
}
if (cryptoProvider == null) {
return new SecureRandom();
}
// Try "PKCS11" first. If that is not supported, iterate through
// the provider and return the first working implementation.
try {
} catch (NoSuchAlgorithmException e) {
// ignore
}
try {
} catch (NoSuchAlgorithmException ee) {
// ignore
}
}
}
throw new KeyManagementException("FIPS mode: no SecureRandom "
}
return getMessageDigest("MD5");
}
return getMessageDigest("SHA");
}
try {
if (cryptoProvider == null) {
} else {
}
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException
}
}
if (key instanceof RSAPublicKey) {
} else {
}
}
if (key instanceof RSAPublicKey) {
}
try {
} catch (Exception e) {
}
}
}
}
}
}
// In FIPS mode, set thread local providers; otherwise a no-op.
// Must be paired with endFipsProvider.
if (fipsProviderList == null) {
return null;
} else {
}
}
if (fipsProviderList != null) {
}
}
}