Lines Matching refs:key

38  * This class implements a key factory for PBE keys according to PKCS#5,
100 * Generates a <code>SecretKey</code> object from the provided key
101 * specification (key material).
103 * @param keySpec the specification (key material) of the secret key
105 * @return the secret key
107 * @exception InvalidKeySpecException if the given key specification
108 * is inappropriate for this key factory to produce a public key.
114 throw new InvalidKeySpecException("Invalid key spec");
120 * Returns a specification (key material) of the given key
123 * @param key the key
125 * @param keySpec the requested format in which the key material shall be
128 * @return the underlying key specification (key material) in the
131 * @exception InvalidKeySpecException if the requested key specification is
132 * inappropriate for the given key, or the given key cannot be processed
133 * (e.g., the given key has an unrecognized algorithm or format).
135 protected KeySpec engineGetKeySpec(SecretKey key, Class keySpecCl)
137 if ((key instanceof SecretKey)
138 && (validTypes.contains(key.getAlgorithm().toUpperCase()))
139 && (key.getFormat().equalsIgnoreCase("RAW"))) {
141 // Check if requested key spec is amongst the valid ones
144 byte[] passwdBytes = key.getEncoded();
155 throw new InvalidKeySpecException("Invalid key spec");
158 throw new InvalidKeySpecException("Invalid key "
166 * <code>SecretKey</code> object of this key factory.
168 * @param key the key whose provider is unknown or untrusted
170 * @return the translated key
172 * @exception InvalidKeyException if the given key cannot be processed by
173 * this key factory.
175 protected SecretKey engineTranslateKey(SecretKey key)
179 if ((key != null) &&
180 (validTypes.contains(key.getAlgorithm().toUpperCase())) &&
181 (key.getFormat().equalsIgnoreCase("RAW"))) {
183 // Check if key originates from this factory
184 if (key instanceof com.sun.crypto.provider.PBEKey) {
185 return key;
188 // Convert key to spec
190 (key, PBEKeySpec.class);
192 // Create key from spec, and return it
195 throw new InvalidKeyException("Invalid key format/algorithm");
199 throw new InvalidKeyException("Cannot translate key: "