Lines Matching defs:key

36  * This class implements the DES key factory of the Sun provider.
51 * Generates a <code>SecretKey</code> object from the provided key
52 * specification (key material).
54 * @param keySpec the specification (key material) of the secret key
56 * @return the secret key
58 * @exception InvalidKeySpecException if the given key specification
59 * is inappropriate for this key factory to produce a public key.
68 ("Inappropriate key specification");
80 * Returns a specification (key material) of the given key
83 * @param key the key
85 * @param keySpec the requested format in which the key material shall be
88 * @return the underlying key specification (key material) in the
91 * @exception InvalidKeySpecException if the requested key specification is
92 * inappropriate for the given key, or the given key cannot be processed
93 * (e.g., the given key has an unrecognized algorithm or format).
95 protected KeySpec engineGetKeySpec(SecretKey key, Class keySpec)
100 if ((key instanceof SecretKey)
101 && (key.getAlgorithm().equalsIgnoreCase("DES"))
102 && (key.getFormat().equalsIgnoreCase("RAW"))) {
104 // Check if requested key spec is amongst the valid ones
107 return new DESKeySpec(key.getEncoded());
111 ("Inappropriate key specification");
116 ("Inappropriate key format/algorithm");
120 throw new InvalidKeySpecException("Secret key has wrong size");
127 * <code>SecretKey</code> object of this key factory.
129 * @param key the key whose provider is unknown or untrusted
131 * @return the translated key
133 * @exception InvalidKeyException if the given key cannot be processed by
134 * this key factory.
136 protected SecretKey engineTranslateKey(SecretKey key)
141 if ((key != null) &&
142 (key.getAlgorithm().equalsIgnoreCase("DES")) &&
143 (key.getFormat().equalsIgnoreCase("RAW"))) {
145 // Check if key originates from this factory
146 if (key instanceof com.sun.crypto.provider.DESKey) {
147 return key;
149 // Convert key to spec
151 = (DESKeySpec)engineGetKeySpec(key, DESKeySpec.class);
152 // Create key from spec, and return it
157 ("Inappropriate key format/algorithm");
161 throw new InvalidKeyException("Cannot translate key");