3909N/A * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * This class provides the functionality of an exemption mechanism, examples 0N/A * of which are <i>key recovery</i>, <i>key weakening</i>, and 0N/A * <i>key escrow</i>. 0N/A * <p>Applications or applets that use an exemption mechanism may be granted 0N/A * stronger encryption capabilities than those which don't. 0N/A // The provider implementation (delegate) 0N/A // The name of the exemption mechanism. 0N/A // Flag which indicates whether this ExemptionMechanism 0N/A // result is generated successfully. 0N/A // State information 0N/A // Store away the key at init() time for later comparison. 0N/A * Creates a ExemptionMechanism object. 0N/A * @param exmechSpi the delegate 0N/A * @param provider the provider 0N/A * @param mechanism the exemption mechanism 0N/A * Returns the exemption mechanism name of this 0N/A * <code>ExemptionMechanism</code> object. 0N/A * <p>This is the same name that was specified in one of the 0N/A * <code>getInstance</code> calls that created this 0N/A * <code>ExemptionMechanism</code> object. 0N/A * @return the exemption mechanism name of this 0N/A * <code>ExemptionMechanism</code> object. 0N/A * Returns an <code>ExemptionMechanism</code> object that implements the 0N/A * specified exemption mechanism algorithm. 0N/A * <p> This method traverses the list of registered security Providers, 0N/A * starting with the most preferred Provider. 0N/A * A new ExemptionMechanism object encapsulating the 0N/A * ExemptionMechanismSpi implementation from the first 0N/A * Provider that supports the specified algorithm is returned. 0N/A * <p> Note that the list of registered providers may be retrieved via 0N/A * the {@link Security#getProviders() Security.getProviders()} method. 0N/A * @param algorithm the standard name of the requested exemption 3465N/A * See the ExemptionMechanism section in the 3465N/A * Java Cryptography Architecture Standard Algorithm Name Documentation</a> 0N/A * for information about standard exemption mechanism names. 0N/A * @return the new <code>ExemptionMechanism</code> object. 0N/A * @exception NullPointerException if <code>algorithm</code> 0N/A * @exception NoSuchAlgorithmException if no Provider supports an 0N/A * ExemptionMechanismSpi implementation for the 0N/A * specified algorithm. 0N/A * @see java.security.Provider 0N/A * Returns an <code>ExemptionMechanism</code> object that implements the 0N/A * specified exemption mechanism algorithm. 0N/A * <p> A new ExemptionMechanism object encapsulating the 0N/A * ExemptionMechanismSpi implementation from the specified provider 0N/A * is returned. The specified provider must be registered 0N/A * in the security provider list. 0N/A * <p> Note that the list of registered providers may be retrieved via 0N/A * the {@link Security#getProviders() Security.getProviders()} method. 0N/A * @param algorithm the standard name of the requested exemption mechanism. 3465N/A * See the ExemptionMechanism section in the 3465N/A * Java Cryptography Architecture Standard Algorithm Name Documentation</a> 0N/A * for information about standard exemption mechanism names. 0N/A * @param provider the name of the provider. 0N/A * @return the new <code>ExemptionMechanism</code> object. 0N/A * @exception NullPointerException if <code>algorithm</code> 0N/A * @exception NoSuchAlgorithmException if an ExemptionMechanismSpi 0N/A * implementation for the specified algorithm is not 0N/A * available from the specified provider. 0N/A * @exception NoSuchProviderException if the specified provider is not 0N/A * registered in the security provider list. 0N/A * @exception IllegalArgumentException if the <code>provider</code> 0N/A * @see java.security.Provider 0N/A * Returns an <code>ExemptionMechanism</code> object that implements the 0N/A * specified exemption mechanism algorithm. 0N/A * <p> A new ExemptionMechanism object encapsulating the 0N/A * ExemptionMechanismSpi implementation from the specified Provider 0N/A * object is returned. Note that the specified Provider object 0N/A * does not have to be registered in the provider list. 0N/A * @param algorithm the standard name of the requested exemption mechanism. 3465N/A * See the ExemptionMechanism section in the 3465N/A * Java Cryptography Architecture Standard Algorithm Name Documentation</a> 0N/A * for information about standard exemption mechanism names. 0N/A * @param provider the provider. 0N/A * @return the new <code>ExemptionMechanism</code> object. 0N/A * @exception NullPointerException if <code>algorithm</code> 0N/A * @exception NoSuchAlgorithmException if an ExemptionMechanismSpi 0N/A * implementation for the specified algorithm is not available 0N/A * from the specified Provider object. 0N/A * @exception IllegalArgumentException if the <code>provider</code> 0N/A * @see java.security.Provider 0N/A * Returns the provider of this <code>ExemptionMechanism</code> object. 0N/A * @return the provider of this <code>ExemptionMechanism</code> object. 0N/A * Returns whether the result blob has been generated successfully by this 0N/A * exemption mechanism. 0N/A * <p>The method also makes sure that the key passed in is the same as 0N/A * the one this exemption mechanism used in initializing and generating 0N/A * @param key the key the crypto is going to use. 0N/A * @return whether the result blob of the same key has been generated 0N/A * successfully by this exemption mechanism; false if <code>key</code> 0N/A * @exception ExemptionMechanismException if problem(s) encountered 0N/A * while determining whether the result blob has been generated successfully 0N/A * by this exemption mechanism object. 0N/A // Check if the key passed in is the same as the one 0N/A // this exemption mechanism used. 0N/A * Returns the length in bytes that an output buffer would need to be in 0N/A * order to hold the result of the next 0N/A * {@link #genExemptionBlob(byte[]) genExemptionBlob} 0N/A * operation, given the input length <code>inputLen</code> (in bytes). 0N/A * <p>The actual output length of the next 0N/A * {@link #genExemptionBlob(byte[]) genExemptionBlob} 0N/A * call may be smaller than the length returned by this method. 0N/A * @param inputLen the input length (in bytes) 0N/A * @return the required output buffer size (in bytes) 0N/A * @exception IllegalStateException if this exemption mechanism is in a 0N/A * wrong state (e.g., has not yet been initialized) 0N/A "ExemptionMechanism not initialized");
0N/A "Input size must be equal to " +
"or greater than zero");
0N/A * Initializes this exemption mechanism with a key. 0N/A * <p>If this exemption mechanism requires any algorithm parameters 0N/A * that cannot be derived from the given <code>key</code>, the 0N/A * underlying exemption mechanism implementation is supposed to 0N/A * generate the required parameters itself (using provider-specific 0N/A * default values); in the case that algorithm parameters must be 0N/A * specified by the caller, an <code>InvalidKeyException</code> is raised. 0N/A * @param key the key for this exemption mechanism 0N/A * @exception InvalidKeyException if the given key is inappropriate for 0N/A * this exemption mechanism. 0N/A * @exception ExemptionMechanismException if problem(s) encountered in the 0N/A * process of initializing. 0N/A * Initializes this exemption mechanism with a key and a set of algorithm 0N/A * <p>If this exemption mechanism requires any algorithm parameters 0N/A * and <code>params</code> is null, the underlying exemption 0N/A * mechanism implementation is supposed to generate the required 0N/A * parameters itself (using provider-specific default values); in the case 0N/A * that algorithm parameters must be specified by the caller, an 0N/A * <code>InvalidAlgorithmParameterException</code> is raised. 0N/A * @param key the key for this exemption mechanism 0N/A * @param params the algorithm parameters 0N/A * @exception InvalidKeyException if the given key is inappropriate for 0N/A * this exemption mechanism. 0N/A * @exception InvalidAlgorithmParameterException if the given algorithm 0N/A * parameters are inappropriate for this exemption mechanism. 0N/A * @exception ExemptionMechanismException if problem(s) encountered in the 0N/A * process of initializing. 0N/A * Initializes this exemption mechanism with a key and a set of algorithm 0N/A * <p>If this exemption mechanism requires any algorithm parameters 0N/A * and <code>params</code> is null, the underlying exemption mechanism 0N/A * implementation is supposed to generate the required parameters itself 0N/A * (using provider-specific default values); in the case that algorithm 0N/A * parameters must be specified by the caller, an 0N/A * <code>InvalidAlgorithmParameterException</code> is raised. 0N/A * @param key the key for this exemption mechanism 0N/A * @param params the algorithm parameters 0N/A * @exception InvalidKeyException if the given key is inappropriate for 0N/A * this exemption mechanism. 0N/A * @exception InvalidAlgorithmParameterException if the given algorithm 0N/A * parameters are inappropriate for this exemption mechanism. 0N/A * @exception ExemptionMechanismException if problem(s) encountered in the 0N/A * process of initializing. 0N/A * Generates the exemption mechanism key blob. 0N/A * @return the new buffer with the result key blob. 0N/A * @exception IllegalStateException if this exemption mechanism is in 0N/A * a wrong state (e.g., has not been initialized). 0N/A * @exception ExemptionMechanismException if problem(s) encountered in the 0N/A * process of generating. 0N/A "ExemptionMechanism not initialized");
0N/A * Generates the exemption mechanism key blob, and stores the result in 0N/A * the <code>output</code> buffer. 0N/A * <p>If the <code>output</code> buffer is too small to hold the result, 0N/A * a <code>ShortBufferException</code> is thrown. In this case, repeat this 0N/A * call with a larger output buffer. Use 0N/A * {@link #getOutputSize(int) getOutputSize} to determine how big 0N/A * the output buffer should be. 0N/A * @param output the buffer for the result 0N/A * @return the number of bytes stored in <code>output</code> 0N/A * @exception IllegalStateException if this exemption mechanism is in 0N/A * a wrong state (e.g., has not been initialized). 0N/A * @exception ShortBufferException if the given output buffer is too small 0N/A * to hold the result. 0N/A * @exception ExemptionMechanismException if problem(s) encountered in the 0N/A * process of generating. 0N/A (
"ExemptionMechanism not initialized");
0N/A * Generates the exemption mechanism key blob, and stores the result in 0N/A * the <code>output</code> buffer, starting at <code>outputOffset</code> 0N/A * <p>If the <code>output</code> buffer is too small to hold the result, 0N/A * a <code>ShortBufferException</code> is thrown. In this case, repeat this 0N/A * call with a larger output buffer. Use 0N/A * {@link #getOutputSize(int) getOutputSize} to determine how big 0N/A * the output buffer should be. 0N/A * @param output the buffer for the result 0N/A * @param outputOffset the offset in <code>output</code> where the result 0N/A * @return the number of bytes stored in <code>output</code> 0N/A * @exception IllegalStateException if this exemption mechanism is in 0N/A * a wrong state (e.g., has not been initialized). 0N/A * @exception ShortBufferException if the given output buffer is too small 0N/A * to hold the result. 0N/A * @exception ExemptionMechanismException if problem(s) encountered in the 0N/A * process of generating. 0N/A (
"ExemptionMechanism not initialized");
0N/A * Ensures that the key stored away by this ExemptionMechanism 0N/A * object will be wiped out when there are no more references to it. 0N/A // Are there anything else we could do?