/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2005 Sun Microsystems Inc. All Rights Reserved
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at opensso/legal/CDDLv1.0.txt.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* $Id: JCEEncryption.java,v 1.3 2008/10/20 17:24:43 beomsuk Exp $
*
*/
/*
* Portions Copyrighted 2010-2014 ForgeRock AS
*/
/**
* <p>
* This class provides encryption and decryption facility for the SDK based on
* the existence of a JCE provider in the runtime. Unlike
* <code>JSSEncryption</code>, this class can only handle a fixed algorithm
* for key generation and encryption which is <code>PBEWithMD5AndDES</code>.
* Since different JCE providers such as IAIK use slightly different names for
* this algorithm, this class provides the facility to over-ride this hardcoded
* value by setting the system properties for each of these algorithms. The
* property name for specifying the key generation algorithm is
* <code>amKeyGenDescriptor</code> and that for specifying encryption
* algorithm is <code>amCryptoDescriptor</code>.
* </p>
* <p>
* <b>NOTE:</b> The facility of overriding key generation and encryption
* algorithms must be used very carefully. In particular, this facility is not
* meant to force the use of an algorithm different from the specified default
* algorithm <code>PBEWithMD5AndDES</code> since that will result in
* incompatibility between the <code>JSSEncryption</code> if it is being used
* by any peer entity such as agent or server. This would not be a problem if
* all entities in the network were configured to use this encryption provider
* and all had the same implementation of the specified algorithms available.
*/
"amCryptoDescriptor";
"PBEWithMD5AndDES";
"amCryptoDescriptor.provider";
"SunJCE";
"amKeyGenDescriptor";
"PBEWithMD5AndDES";
"amKeyGenDescriptor.provider";
"SunJCE";
static {
}
private static final int CACHE_SIZE = Integer.getInteger(CRYPTO_CACHE_SIZE_PROPERTY_NAME, DEFAULT_CACHE_SIZE);
/**
* Stores a per-thread copy of the underlying cipher, fetched from the standard {@link Cipher} implementation,
* preferring the Sun JCE provider if available.
*/
private static final CipherProvider cipherProvider = Providers.cipherProvider(CRYPTO_DESCRIPTOR, CRYPTO_DESCRIPTOR_PROVIDER, CACHE_SIZE);
/**
* Method declaration
*
* @param clearText
*/
return pbeEncrypt(clearText);
}
/**
* Method declaration
*
* @param encText
*/
return pbeDecrypt(encText);
}
/**
* Method declaration
*
* @param clearText
*/
return null;
}
if (_initialized) {
try {
byte type[] = new byte[2];
} else {
}
}
}
}
} else {
}
}
return result;
}
/**
* Method declaration
*
* @param type
* @param iv
* @param share
*/
for (int i = 0; i < 8; i++) {
}
}
return data;
}
/**
* Method declaration
*
* @param cipherText
*/
if (_initialized) {
try {
byte share[] = cipherText;
+ share[0]);
}
return null;
}
} else {
}
}
}
}
} else {
}
}
return result;
}
/**
* Method declaration
*
* @param share
*/
}
return data;
}
/**
* Sets password-based key to use
*/
_initialized = true;
}
0x01, 0x01 };
private volatile boolean _initialized = false;
}