/*
* 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.
*/
/**
* SecretKeyFactory implementation class. This class currently supports
* DES, DESede, AES, ARCFOUR, and Blowfish.
*
* @author Andreas Sterbenz
* @since 1.5
*/
// token instance
// algorithm name
super();
}
static {
// we don't implement RC2 or IDEA, but we want to be able to generate
}
}
if (l == null) {
if (l == null) {
return PCKK_HMAC;
return PCKK_SSLMAC;
}
}
}
}
/**
* Convert an arbitrary key of algorithm into a P11Key of provider.
* Used in engineTranslateKey(), P11Cipher.init(), and P11Mac.init().
*/
throws InvalidKeyException {
}
/**
* Convert an arbitrary key of algorithm w/ custom attributes into a
* P11Key of provider.
* Used in P11KeyStore.storeSkey.
*/
throws InvalidKeyException {
token.ensureValid();
throw new InvalidKeyException("Key must not be null");
}
throw new InvalidKeyException("Key must be a SecretKey");
}
long algoType;
} else {
if (algoType != keyAlgorithmType) {
// ignore key algorithm for MACs
} else {
throw new InvalidKeyException
("Key algorithm must be " + algo);
}
}
}
if (extraAttrs != null) {
try {
extraAttrs));
} catch (PKCS11Exception p11e) {
throw new InvalidKeyException
("Cannot duplicate the PKCS11 key", p11e);
} finally {
}
}
return p11Key;
}
}
return p11Key;
}
throw new InvalidKeyException("Encoded format must be RAW");
}
return p11Key;
}
for (int i = 0; i < 8; i++) {
}
}
throws InvalidKeyException {
int keyLength = n;
try {
switch ((int)keyType) {
case (int)CKK_DES:
break;
case (int)CKK_DES3:
if (keyLength == 112) {
} else {
}
break;
case (int)CKK_AES:
break;
case (int)CKK_RC4:
break;
case (int)CKK_BLOWFISH:
token);
break;
case (int)CKK_GENERIC_SECRET:
case (int)PCKK_TLSPREMASTER:
case (int)PCKK_TLSRSAPREMASTER:
case (int)PCKK_TLSMASTER:
break;
case (int)PCKK_SSLMAC:
case (int)PCKK_HMAC:
if (n == 0) {
throw new InvalidKeyException
("MAC keys must not be empty");
}
break;
default:
throw new InvalidKeyException("Unknown algorithm " +
}
} catch (InvalidAlgorithmParameterException iape) {
iape);
} catch (ProviderException pe) {
}
try {
if (extraAttrs != null) {
} else {
}
return p11Key;
} catch (PKCS11Exception e) {
throw new InvalidKeyException("Could not create key", e);
} finally {
}
}
// see JCE spec
throws InvalidKeySpecException {
token.ensureValid();
throw new InvalidKeySpecException("KeySpec must not be null");
}
if (keySpec instanceof SecretKeySpec) {
try {
} catch (InvalidKeyException e) {
throw new InvalidKeySpecException(e);
}
if (keySpec instanceof DESKeySpec) {
return engineGenerateSecret(keySpec);
}
if (keySpec instanceof DESedeKeySpec) {
return engineGenerateSecret(keySpec);
}
}
throw new InvalidKeySpecException
}
try {
throw new InvalidKeySpecException
("Could not obtain key bytes");
}
byte[] k = key.getEncoded();
return k;
} catch (InvalidKeyException e) {
throw new InvalidKeySpecException(e);
}
}
// see JCE spec
throws InvalidKeySpecException {
token.ensureValid();
throw new InvalidKeySpecException
("key and keySpec must not be null");
}
try {
}
} catch (InvalidKeyException e) {
throw new InvalidKeySpecException(e);
}
try {
}
} catch (InvalidKeyException e) {
throw new InvalidKeySpecException(e);
}
}
throw new InvalidKeySpecException
}
// see JCE spec
throws InvalidKeyException {
}
}