|
DESede2KeySecretKeyFactoryEngine |
|
1 /* $RCSfile: DESede2KeySecretKeyFactoryEngine.java,v $ 2 * $Revision: 1.11 $ 3 * $Date: 2003/10/04 19:18:38 $ 4 * $Author: uwe_guenther $ 5 * $State: Exp $ 6 * 7 * Created on August 13, 2001 9:45 PM 8 * 9 * Copyright (C) 2001 Uwe Guenther <uwe@cscc.de> 10 * 11 * This file is part of the jhbci JCE-ServiceProvider. The jhbci JCE- 12 * ServiceProvider is a library, written in JavaTM, that should be 13 * used in HBCI banking applications (clients and may be servers), 14 * to do cryptographic operations. 15 * 16 * The jhbci library is free software; you can redistribute it and/or 17 * modify it under the terms of the GNU Lesser General Public 18 * License as published by the Free Software Foundation; either 19 * version 2.1 of the License, or (at your option) any later version. 20 * 21 * The jhbci library is distributed in the hope that it will be useful, 22 * but WITHOUT ANY WARRANTY; without even the implied warranty of 23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 24 * Lesser General Public License for more details. 25 * 26 * You should have received a copy of the GNU Lesser General Public 27 * License along with this library; if not, write to the Free Software 28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 29 * 30 */ 31 32 package de.cscc.crypto.provider; 33 34 import java.security.InvalidKeyException; 35 import java.security.spec.InvalidKeySpecException; 36 import java.security.spec.KeySpec; 37 38 import javax.crypto.SecretKey; 39 import javax.crypto.SecretKeyFactorySpi; 40 41 /** 42 * DESede2KeySecretKeyFactoryEngine Class. 43 * 44 * @author <a href=mailto:uwe@cscc.de>Uwe Günther</a> 45 * @version $Revision: 1.11 $ 46 */ 47 public final class DESede2KeySecretKeyFactoryEngine extends SecretKeyFactorySpi { 48 49 /** The delegate for this wrapper object */ 50 private DESede2KeySecretKeyFactoryImpl factory = 51 new DESede2KeySecretKeyFactoryImpl(); 52 53 /** 54 * Creates a new DESede2KeySecretKeyFactoryEngine. 55 * 56 * @throws SecurityException if the provider self integrity check fails. 57 */ 58 public DESede2KeySecretKeyFactoryEngine() { 59 if (JHBCI.selfIntegrityChecking() == false) { 60 throw new SecurityException("JHBCI-Provider is tampered."); 61 } 62 } 63 64 /** 65 * Returns a string representation of the object. 66 * 67 * @return a string representation of the object. 68 */ 69 public String toString() { 70 return this.factory.toString(); 71 } 72 73 /** 74 * Generates a <code>SecretKey</code> object from the 75 * provided key specification (key material). 76 * 77 * @param keySpec the specification (key material) of the secret key. 78 * @return the secret key. 79 * @throws NullPointerException if keySpec is null. 80 * @throws InvalidKeySpecException if the given key specification 81 * is inappropriate for this secret-key factory to produce a secret key. 82 */ 83 protected SecretKey engineGenerateSecret(KeySpec keySpec) 84 throws InvalidKeySpecException { 85 return this.factory.generateSecret(keySpec); 86 } 87 88 /** 89 * Returns a specification (key material) of the given key object in the 90 * requested format. 91 * 92 * @param key the key. 93 * @param keySpec the requested format in which the key material shall be 94 * returned. 95 * @return the underlying key specification (key material) in the requested 96 * format. 97 * @throws NullPointerException if key or keySpec is null. 98 * @throws InvalidKeySpecException if the requested key specification is 99 * inappropriate for the given key (e.g., the algorithms associated with 100 * <code>key</code> and <code>keySpec</code> do not match, or 101 * <code>key</code> references a key on a cryptographic hardware device 102 * whereas <code>keySpec</code> is the specification of a software-based 103 * key), or the given key cannot be dealt with (e.g., the given key has 104 * an algorithm or format not supported by this secret-key factory). 105 */ 106 protected KeySpec engineGetKeySpec(SecretKey key, Class keySpec) 107 throws InvalidKeySpecException { 108 return this.factory.getKeySpec(key, keySpec); 109 } 110 111 /** 112 * Translates a key object, whose provider may be unknown or potentially 113 * untrusted, into a corresponding key object of this secret-key factory. 114 * 115 * @return they key whose provider is unknown or untrusted. 116 * @param key the key whose provider is unknown or untrusted. 117 * @throws NullPointerException if key is null. 118 * @throws InvalidKeyException if the given key cannot be processed by this 119 * secret-key factory. 120 */ 121 protected SecretKey engineTranslateKey(SecretKey key) 122 throws InvalidKeyException { 123 return this.factory.translateKey(key); 124 } 125 } 126
|
DESede2KeySecretKeyFactoryEngine |
|