/**
* The exception that is thrown when a padding mechanism is expected for the
* input data, but the input data does not have the proper padding bytes.
- *
- * @since Android 1.0
*/
public class BadPaddingException extends GeneralSecurityException {
*
* @param msg
* the message
- * @since Android 1.0
*/
public BadPaddingException(String msg) {
super(msg);
/**
* Creates a new instance of {@code BadPaddingException} with no message.
- *
- * @since Android 1.0
*/
public BadPaddingException() {
}
* to be processed at a time can be optionally specified by appending it to the
* mode name. e.g. <i>"AES/CFB8/NoPadding"</i>. If no number is specified, a
* provider specific default value is used.
- * </p>
- *
- * @since Android 1.0
*/
public class Cipher {
/**
* Constant for decryption operation mode.
- *
- * @since Android 1.0
*/
public static final int DECRYPT_MODE = 2;
/**
* Constant for encryption operation mode.
- *
- * @since Android 1.0
*/
public static final int ENCRYPT_MODE = 1;
/**
* Constant indicating that the key to be unwrapped is a private key.
- *
- * @since Android 1.0
*/
public static final int PRIVATE_KEY = 2;
/**
* Constant indicating that the key to be unwrapped is a public key.
- *
- * @since Android 1.0
*/
public static final int PUBLIC_KEY = 1;
/**
* Constant indicating that the key to be unwrapped is a secret key.
- *
- * @since Android 1.0
*/
public static final int SECRET_KEY = 3;
/**
* Constant for key unwrapping operation mode.
- *
- * @since Android 1.0
*/
public static final int UNWRAP_MODE = 4;
/**
* Constant for key wrapping operation mode.
- *
- * @since Android 1.0
*/
public static final int WRAP_MODE = 3;
/**
* Creates a new Cipher instance.
- *
+ *
* @param cipherSpi
* the implementation delegate of the cipher.
* @param provider
* @throws NullPointerException
* if either cipherSpi is {@code null} or provider is {@code
* null} and {@code cipherSpi} is a {@code NullCipherSpi}.
- * @since Android 1.0
*/
protected Cipher(CipherSpi cipherSpi, Provider provider,
String transformation) {
* transformation. The first found provider providing the transformation is
* used to create the cipher. If no provider is found an exception is
* thrown.
- *
+ *
* @param transformation
* the name of the transformation to create a cipher for.
* @return a cipher for the requested transformation.
* @throws NoSuchPaddingException
* if no installed provider can provide the padding scheme in
* the <i>transformation</i>.
- * @since Android 1.0
*/
public static final Cipher getInstance(String transformation)
throws NoSuchAlgorithmException, NoSuchPaddingException {
/**
* Creates a new cipher for the specified transformation provided by the
* specified provider.
- *
+ *
* @param transformation
* the name of the transformation to create a cipher for.
* @param provider
* is not available.
* @throws IllegalArgumentException
* if the specified provider is {@code null}.
- * @since Android 1.0
*/
public static final Cipher getInstance(String transformation,
String provider) throws NoSuchAlgorithmException,
/**
* Creates a new cipher for the specified transformation.
- *
+ *
* @param transformation
* the name of the transformation to create a cipher for.
* @param provider
* is not available.
* @throws IllegalArgumentException
* if the provider is {@code null}.
- * @since Android 1.0
*/
public static final Cipher getInstance(String transformation,
Provider provider) throws NoSuchAlgorithmException,
/**
* Returns the provider of this cipher instance.
- *
+ *
* @return the provider of this cipher instance.
- * @since Android 1.0
*/
public final Provider getProvider() {
return provider;
* <p>
* This is the name of the <i>transformation</i> argument used in the
* {@code getInstance} call creating this object.
- * </p>
- *
+ *
* @return the name of the algorithm of this cipher instance.
- * @since Android 1.0.
*/
public final String getAlgorithm() {
return transformation;
/**
* Returns this ciphers block size (in bytes).
- *
+ *
* @return this ciphers block size.
- * @since Android 1.0
*/
public final int getBlockSize() {
return spiImpl.engineGetBlockSize();
/**
* Returns the length in bytes an output buffer needs to be when this cipher
* is updated with {@code inputLen} bytes.
- *
+ *
* @param inputLen
* the number of bytes of the input.
* @return the output buffer length for the input length.
* @throws IllegalStateException
* if this cipher instance is in an invalid state.
- * @since Android 1.0
*/
public final int getOutputSize(int inputLen) {
if (mode == 0) {
/**
* Returns the <i>initialization vector</i> for this cipher instance.
- *
+ *
* @return the <i>initialization vector</i> for this cipher instance.
- * @since Android 1.0
*/
public final byte[] getIV() {
return spiImpl.engineGetIV();
* These may be a the same parameters that were used to create this cipher
* instance, or may be a combination of default and random parameters,
* depending on the underlying cipher implementation.
- *
+ *
* @return the parameters that where used to create this cipher instance, or
* {@code null} if this cipher instance does not have any
* parameters.
- * @since Android 1.0
*/
public final AlgorithmParameters getParameters() {
return spiImpl.engineGetParameters();
/**
* Returns the exemption mechanism associated with this cipher.
- *
+ *
* @return currently {@code null}
- * @since Android 1.0
*/
public final ExemptionMechanism getExemptionMechanism() {
//FIXME implement getExemptionMechanism
* The cipher is initialized for the specified operational mode (one of:
* encryption, decryption, key wrapping or key unwrapping) depending on
* {@code opmode}.
- * </p>
+ * <p>
* If this cipher instance needs any algorithm parameters or random values
* that the specified key can not provide, the underlying implementation of
* this cipher is supposed to generate the required parameters (using its
* init} methods, the state of the instance is overridden, meaning that it
* is equivalent to creating a new instance and calling its {@code init}
* method.
- * </p>
- *
+ *
* @param opmode
* the operation this cipher instance should be initialized for
* (one of: {@code ENCRYPT_MODE}, {@code DECRYPT_MODE}, {@code
* @throws InvalidKeyException
* if the specified key can not be used to initialize this
* cipher instance.
- * @since Android 1.0
*/
public final void init(int opmode, Key key) throws InvalidKeyException {
if (sec_rand == null) {
* The cipher is initialized for the specified operational mode (one of:
* encryption, decryption, key wrapping or key unwrapping) depending on
* {@code opmode}.
- * </p>
+ * <p>
* If this cipher instance needs any algorithm parameters or random values
* that the specified key can not provide, the underlying implementation of
* this cipher is supposed to generate the required parameters (using its
* When a cipher instance is initialized by a call to any of the {@code
* init} methods, the state of the instance is overridden, means it is
* equivalent to creating a new instance and calling it {@code init} method.
- * </p>
- *
+ *
* @param opmode
* the operation this cipher instance should be initialized for
* (one of: {@code ENCRYPT_MODE}, {@code DECRYPT_MODE}, {@code
* cipher instance.
* @throws InvalidParameterException
* if the specified opmode is invalid.
- * @since Android 1.0
*/
public final void init(int opmode, Key key, SecureRandom random)
throws InvalidKeyException {
* <p>
* The cipher is initialized for the specified operational mode (one of:
* encryption, decryption, key wrapping or key unwrapping).
- * </p>
+ * <p>
* If this cipher instance needs any algorithm parameters and {@code params}
* is {@code null}, the underlying implementation of this cipher is supposed
* to generate the required parameters (using its provider or random
* When a cipher instance is initialized by a call to any of the {@code
* init} methods, the state of the instance is overridden, means it is
* equivalent to creating a new instance and calling it {@code init} method.
- * </p>
- *
+ *
* @param opmode
* the operation this cipher instance should be initialized for
* (one of: {@code ENCRYPT_MODE}, {@code DECRYPT_MODE}, {@code
* @throws InvalidAlgorithmParameterException
* it the specified parameters are inappropriate for this
* cipher.
- * @since Android 1.0
*/
public final void init(int opmode, Key key, AlgorithmParameterSpec params)
throws InvalidKeyException, InvalidAlgorithmParameterException {
* init} methods, the state of the instance is overridden, meaning that it
* is equivalent to creating a new instance and calling it {@code init}
* method.
- *
+ *
* @param opmode
* the operation this cipher instance should be initialized for
* (one of: {@code ENCRYPT_MODE}, {@code DECRYPT_MODE}, {@code
* cipher.
* @throws InvalidParameterException
* if the specified {@code opmode} is invalid.
- * @since Android 1.0
*/
public final void init(int opmode, Key key, AlgorithmParameterSpec params,
SecureRandom random) throws InvalidKeyException,
* The cipher is initialized for the specified operation (one of:
* encryption, decryption, key wrapping or key unwrapping) depending on
* {@code opmode}.
- * </p>
+ * <p>
* If this cipher instance needs any algorithm parameters and {@code params}
* is {@code null}, the underlying implementation of this cipher is supposed
* to generate the required parameters (using its provider or random
* init} methods, the state of the instance is overridden, meaning that it
* is equivalent to creating a new instance and calling it {@code init}
* method.
- * </p>
- *
+ *
* @param opmode
* the operation this cipher instance should be initialized for
* (one of: {@code ENCRYPT_MODE}, {@code DECRYPT_MODE}, {@code
* @throws InvalidAlgorithmParameterException
* it the specified parameters are inappropriate for this
* cipher.
- * @since Android 1.0
*/
public final void init(int opmode, Key key, AlgorithmParameters params)
throws InvalidKeyException, InvalidAlgorithmParameterException {
* The cipher will be initialized for the specified operation (one of:
* encryption, decryption, key wrapping or key unwrapping) depending on
* {@code opmode}.
- * </p>
+ * <p>
* If this cipher instance needs any algorithm parameters and {@code params}
* is {@code null}, the underlying implementation of this cipher is supposed
* to generate the required parameters (using its provider or random
* When a cipher instance is initialized by a call to any of the {@code
* init} methods, the state of the instance is overridden, means it is
* equivalent to creating a new instance and calling it {@code init} method.
- * </p>
- *
+ *
* @param opmode
* the operation this cipher instance should be initialized for
* (one of: {@code ENCRYPT_MODE}, {@code DECRYPT_MODE}, {@code
* cipher.
* @throws InvalidParameterException
* if the specified {@code opmode} is invalid.
- * @since Android 1.0
*/
public final void init(int opmode, Key key, AlgorithmParameters params,
SecureRandom random) throws InvalidKeyException,
* When a cipher instance is initialized by a call to any of the {@code
* init} methods, the state of the instance is overridden, means it is
* equivalent to creating a new instance and calling it {@code init} method.
- *
+ *
* @param opmode
* the operation this cipher instance should be initialized for
* (one of: {@code ENCRYPT_MODE}, {@code DECRYPT_MODE}, {@code
* @throws InvalidKeyException
* if the public key in the certificate can not be used to
* initialize this cipher instance.
- * @since Android 1.0
*/
public final void init(int opmode, Certificate certificate)
throws InvalidKeyException {
* The cipher will be initialized for the specified operation (one of:
* encryption, decryption, key wrapping or key unwrapping) depending on
* {@code opmode}.
- * </p>
+ * <p>
* It the type of the certificate is X.509 and the certificate has a <i>key
* usage</i> extension field marked as critical, the specified {@code
* opmode} has the be enabled for this key, otherwise an {@code
* cipher is supposed to generate the required parameters (using its
* provider or random values). Random values are generated using {@code
* random}.
- * </p>
+ * <p>
* When a cipher instance is initialized by a call to any of the {@code
* init} methods, the state of the instance is overridden, means it is
* equivalent to creating a new instance and calling it {@code init} method.
- *
+ *
* @param opmode
* the operation this cipher instance should be initialized for
* (one of: {@code ENCRYPT_MODE}, {@code DECRYPT_MODE}, {@code
* @throws InvalidKeyException
* if the public key in the certificate can not be used to
* initialize this cipher instance.
- * @since Android 1.0
*/
public final void init(int opmode, Certificate certificate,
SecureRandom random) throws InvalidKeyException {
/**
* Continues a multi-part transformation (encryption or decryption). The
* transformed bytes are returned.
- *
+ *
* @param input
* the input bytes to transform.
* @return the transformed bytes in a new buffer, or {@code null} if the
* decryption.
* @throws IllegalArgumentException
* if the input is {@code null}.
- * @since Android 1.0
*/
public final byte[] update(byte[] input) {
if (mode != ENCRYPT_MODE && mode != DECRYPT_MODE) {
/**
* Continues a multi-part transformation (encryption or decryption). The
* transformed bytes are returned.
- *
+ *
* @param input
* the input bytes to transform.
* @param inputOffset
* if the input is {@code null}, or if {@code inputOffset} and
* {@code inputLen} do not specify a valid chunk in the input
* buffer.
- * @since Android 1.0
*/
public final byte[] update(byte[] input, int inputOffset, int inputLen) {
if (mode != ENCRYPT_MODE && mode != DECRYPT_MODE) {
* a {@code ShortBufferException} is thrown. Use
* {@link Cipher#getOutputSize getOutputSize} to check for the size of the
* output buffer.
- * </p>
- *
+ *
* @param input
* the input bytes to transform.
* @param inputOffset
* if the input is {@code null}, the output is {@code null}, or
* if {@code inputOffset} and {@code inputLen} do not specify a
* valid chunk in the input buffer.
- * @since Android 1.0
*/
public final int update(byte[] input, int inputOffset, int inputLen,
byte[] output) throws ShortBufferException {
* a {@code ShortBufferException} is thrown. Use
* {@link Cipher#getOutputSize getOutputSize} to check for the size of the
* output buffer.
- * </p>
- *
+ *
* @param input
* the input bytes to transform.
* @param inputOffset
* if the input is {@code null}, the output is {@code null}, or
* if {@code inputOffset} and {@code inputLen} do not specify a
* valid chunk in the input buffer.
- * @since Android 1.0
*/
public final int update(byte[] input, int inputOffset, int inputLen,
byte[] output, int outputOffset) throws ShortBufferException {
* bytes a {@code ShortBufferException} is thrown. Use
* {@link Cipher#getOutputSize getOutputSize} to check for the size of the
* output buffer.
- * </p>
- *
+ *
* @param input
* the input buffer to transform.
* @param output
* @throws IllegalArgumentException
* if the input buffer and the output buffer are the identical
* object.
- * @since Android 1.0
*/
public final int update(ByteBuffer input, ByteBuffer output)
throws ShortBufferException {
* <p>
* Processes any bytes that may have been buffered in previous {@code
* update} calls.
- * </p>
- *
+ *
* @return the final bytes from the transformation.
* @throws IllegalBlockSizeException
* if the size of the resulting bytes is not a multiple of the
* @throws IllegalStateException
* if this cipher instance is not initialized for encryption or
* decryption.
- * @since Android 1.0
*/
public final byte[] doFinal() throws IllegalBlockSizeException,
BadPaddingException {
* <p>
* Processes any bytes that may have been buffered in previous {@code
* update} calls.
- * </p>
+ * <p>
* The final transformed bytes are stored in the {@code output} buffer.
- *
+ *
* @param output
* the output buffer.
* @param outputOffset
* @throws IllegalStateException
* if this cipher instance is not initialized for encryption or
* decryption.
- * @since Android 1.0
*/
public final int doFinal(byte[] output, int outputOffset)
throws IllegalBlockSizeException, ShortBufferException,
* <p>
* Processes the bytes in {@code input} buffer, and any bytes that have been
* buffered in previous {@code update} calls.
- * </p>
- *
+ *
* @param input
* the input buffer.
* @return the final bytes from the transformation.
* @throws IllegalStateException
* if this cipher instance is not initialized for encryption or
* decryption.
- * @since Android 1.0
*/
public final byte[] doFinal(byte[] input) throws IllegalBlockSizeException,
BadPaddingException {
* Processes the {@code inputLen} bytes in {@code input} buffer at {@code
* inputOffset}, and any bytes that have been buffered in previous {@code
* update} calls.
- *
+ *
* @param input
* the input buffer.
* @param inputOffset
* @throws IllegalArgumentException
* if {@code inputOffset} and {@code inputLen} do not specify an
* valid chunk in the input buffer.
- * @since Android 1.0
*/
public final byte[] doFinal(byte[] input, int inputOffset, int inputLen)
throws IllegalBlockSizeException, BadPaddingException {
* Processes the {@code inputLen} bytes in {@code input} buffer at {@code
* inputOffset}, and any bytes that have been buffered in previous {@code
* update} calls.
- *
+ *
* @param input
* the input buffer.
* @param inputOffset
* @throws IllegalArgumentException
* if {@code inputOffset} and {@code inputLen} do not specify an
* valid chunk in the input buffer.
- * @since Android 1.0
*/
public final int doFinal(byte[] input, int inputOffset, int inputLen,
byte[] output) throws ShortBufferException,
* Processes the {@code inputLen} bytes in {@code input} buffer at {@code
* inputOffset}, and any bytes that have been buffered in previous {@code
* update} calls.
- * </p>
- *
+ *
* @param input
* the input buffer.
* @param inputOffset
* @throws IllegalArgumentException
* if {@code inputOffset} and {@code inputLen} do not specify an
* valid chunk in the input buffer.
- * @since Android 1.0
*/
public final int doFinal(byte[] input, int inputOffset, int inputLen,
byte[] output, int outputOffset) throws ShortBufferException,
* {@code input.position()}, and any bytes that have been buffered in
* previous {@code update} calls. The transformed bytes are placed into
* {@code output} buffer.
- * </p>
- *
+ *
* @param input
* the input buffer.
* @param output
* @throws IllegalStateException
* if this cipher instance is not initialized for encryption or
* decryption.
- * @since Android 1.0
*/
public final int doFinal(ByteBuffer input, ByteBuffer output)
throws ShortBufferException, IllegalBlockSizeException,
/**
* Wraps a key using this cipher instance.
- *
+ *
* @param key
* the key to wrap.
* @return the wrapped key.
* if this cipher instance can not wrap this key.
* @throws IllegalStateException
* if this cipher instance is not initialized for wrapping.
- * @since Android 1.0
*/
public final byte[] wrap(Key key) throws IllegalBlockSizeException,
InvalidKeyException {
/**
* Unwraps a key using this cipher instance.
- *
+ *
* @param wrappedKey
* the wrapped key to unwrap.
* @param wrappedKeyAlgorithm
* {@code wrappedKeyType} for the {@code wrappedKeyAlgorithm}.
* @throws IllegalStateException
* if this cipher instance is not initialized for unwrapping.
- * @since Android 1.0
*/
public final Key unwrap(byte[] wrappedKey, String wrappedKeyAlgorithm,
int wrappedKeyType) throws InvalidKeyException,
/**
* Returns the maximum key length for the specified transformation.
- *
+ *
* @param transformation
* the transformation name.
* @return the maximum key length, currently {@code Integer.MAX_VALUE}.
* be found.
* @throws NullPointerException
* if {@code transformation} is {@code null}.
- * @since Android 1.0
*/
public static final int getMaxAllowedKeyLength(String transformation)
throws NoSuchAlgorithmException {
/**
* Returns the maximum cipher parameter value for the specified
* transformation. If there is no maximum limit, {@code null} is returned.
- *
+ *
* @param transformation
* the transformation name.
* @return a parameter spec holding the maximum value or {@code null}.
* be found.
* @throws NullPointerException
* if {@code transformation} is {@code null}.
- * @since Android 1.0
*/
public static final AlgorithmParameterSpec getMaxAllowedParameterSpec(
String transformation) throws NoSuchAlgorithmException {
* by a {@code CipherInputStream}. For example, if a cipher initialized for
* decryption is used with a {@code CipherInputStream}, the {@code
* CipherInputStream} tries to read the data an decrypt them before returning.
- * </p>
- *
- * @since Android 1.0
*/
public class CipherInputStream extends FilterInputStream {
/**
* Creates a new {@code CipherInputStream} instance for an {@code
* InputStream} and a cipher.
- *
+ *
* @param is
* the input stream to read data from.
* @param c
* the cipher to process the data with.
- * @since Android 1.0
*/
public CipherInputStream(InputStream is, Cipher c) {
super(is);
* InputStream} without a cipher.
* <p>
* A {@code NullCipher} is created and used to process the data.
- * </p>
- *
+ *
* @param is
* the input stream to read data from.
- * @since Android 1.0
*/
protected CipherInputStream(InputStream is) {
this(is, new NullCipher());
/**
* Reads the next byte from this cipher input stream.
- *
+ *
* @return the next byte, or {@code -1} if the end of the stream is reached.
* @throws IOException
* if an error occurs.
- * @since Android 1.0
*/
@Override
public int read() throws IOException {
/**
* Reads the next {@code b.length} bytes from this input stream into buffer
* {@code b}.
- *
+ *
* @param b
* the buffer to be filled with data.
* @return the number of bytes filled into buffer {@code b}, or {@code -1}
* if the end of the stream is reached.
* @throws IOException
* if an error occurs.
- * @since Android 1.0
*/
@Override
public int read(byte[] b) throws IOException {
* <p>
* if {@code b} is {@code null}, the next {@code len} bytes are read and
* discarded.
- * </p>
- *
+ *
* @param b
* the buffer to be filled with data.
* @param off
* if an error occurs.
* @throws NullPointerException
* if the underlying input stream is {@code null}.
- * @since Android 1.0
*/
@Override
public int read(byte[] b, int off, int len) throws IOException {
* The number of bytes skipped depends on the result of a call to
* {@link CipherInputStream#available() available}. The smaller of n and the
* result are the number of bytes being skipped.
- * </p>
- * Skipping is (currently) not supported in Android.
- *
+ *
* @param n
* the number of bytes that should be skipped.
* @return the number of bytes actually skipped.
* @throws IOException
* if an error occurs
- * @since Android 1.0
*/
@Override
public long skip(long n) throws IOException {
}
/**
- * Returns the number of bytes available without blocking. It (currently)
- * always returns {@code 0} in Android.
- *
+ * Returns the number of bytes available without blocking.
+ *
* @return the number of bytes available, currently zero.
* @throws IOException
* if an error occurs
- * @since Android 1.0
*/
@Override
public int available() throws IOException {
/**
* Closes this {@code CipherInputStream}, also closes the underlying input
* stream and call {@code doFinal} on the cipher object.
- *
+ *
* @throws IOException
* if an error occurs.
- * @since Android 1.0
*/
@Override
public void close() throws IOException {
}
/**
- * Returns whether this input stream supports {@code mark} and {@code reset}
- * , which it does not.
- *
+ * Returns whether this input stream supports {@code mark} and
+ * {@code reset}, which it does not.
+ *
* @return false, since this input stream does not support {@code mark} and
* {@code reset}.
- * @since Android 1.0
*/
@Override
public boolean markSupported() {
return false;
}
}
+
* by a {@code CipherOutputStream}. For example, if a cipher initialized for
* encryption is used with a {@code CipherOutputStream}, the {@code
* CipherOutputStream} tries to encrypt the data writing it out.
- * </p>
- *
- * @since Android 1.0
*/
public class CipherOutputStream extends FilterOutputStream {
/**
* Creates a new {@code CipherOutputStream} instance for an {@code
* OutputStream} and a {@code Cipher}.
- *
+ *
* @param os
* the output stream to write data to.
* @param c
* the cipher to process the data with.
- * @since Android 1.0
*/
public CipherOutputStream(OutputStream os, Cipher c) {
super(os);
* OutputStream} without a cipher.
* <p>
* A {@code NullCipher} is created to process the data.
- * </p>
- *
+ *
* @param os
* the output stream to write the data to.
- * @since Android 1.0
*/
protected CipherOutputStream(OutputStream os) {
this(os, new NullCipher());
/**
* Writes the single byte to this cipher output stream.
- *
+ *
* @param b
* the byte to write.
* @throws IOException
* if an error occurs.
- * @since Android 1.0
*/
@Override
public void write(int b) throws IOException {
/**
* Writes the buffer of bytes to this cipher output stream.
- *
+ *
* @param b
* the buffer of bytes.
* @throws IOException
* if an error occurs.
- * @since Android 1.0
*/
@Override
public void write(byte[] b) throws IOException {
/**
* Writes the {@code len} bytes from buffer {@code b} starting at offset
* {@code off} to this cipher output stream.
- *
+ *
* @param b
* the buffer.
* @param off
* the number of bytes.
* @throws IOException
* if an error occurs.
- * @since Android 1.0
*/
@Override
public void write(byte[] b, int off, int len) throws IOException {
/**
* Flushes this cipher output stream.
- *
+ *
* @throws IOException
* if an error occurs
*/
* On the underlying cipher {@code doFinal} will be invoked, and any
* buffered bytes from the cipher are also written out, and the cipher is
* reset to its initial state. The underlying output stream is also closed.
- *
+ *
* @throws IOException
* if an error occurs.
*/
}
}
}
+
* </ul>
* The following behavior should be implemented for obtaining {@code Cipher}
* instances.
- * </p>
+ * <p>
* When one of the {@link Cipher#getInstance} factory methods is called with a
* <i>transformation</i> that is only an <i>algorithm</i>, check if the provider
* defines a {@code CipherSpi} for "algorithm", if so: return it, otherwise
* padding name and return it, otherwise throw a
* {@link NoSuchAlgorithmException}.
* </ul>
- * </p>
- *
+ *
* @see Cipher
- * @since Android 1.0
*/
public abstract class CipherSpi {
/**
* Creates a new {@code CipherSpi} instance.
- *
- * @since Android 1.0
*/
public CipherSpi() {
}
/**
* Sets the mode for this cipher.
- *
+ *
* @param mode
* the name of the cipher mode.
* @throws NoSuchAlgorithmException
* if the specified cipher mode is not supported by this
* provider.
- * @since Android 1.0
*/
protected abstract void engineSetMode(String mode)
throws NoSuchAlgorithmException;
/**
* Sets the padding method for this cipher.
- *
+ *
* @param padding
* the name of the padding method.
* @throws NoSuchPaddingException
* if the specified padding method is not supported by this
* cipher.
- * @since Android 1.0
*/
protected abstract void engineSetPadding(String padding)
throws NoSuchPaddingException;
/**
* Returns the block size of this cipher (in bytes)
- *
+ *
* @return the block size of this cipher, or zero if this cipher is not a
* block cipher.
- * @since Android 1.0
*/
protected abstract int engineGetBlockSize();
* <p>
* The actual output length of the next call to {@code update} or {@code
* doFinal} may be smaller than the length returned by this method.
- * </p>
- *
+ *
* @param inputLen
* the length of the input (in bytes).
* @return the size for a buffer (in bytes).
- * @since Android 1.0
*/
protected abstract int engineGetOutputSize(int inputLen);
/**
* Returns the Initialization Vector (IV) that was used to initialize this
* cipher or {@code null} if none was used.
- *
+ *
* @return the Initialization Vector (IV), or {@code null} if none was used.
- * @since Android 1.0
*/
protected abstract byte[] engineGetIV();
* These may be a the same parameters that were used to create this cipher
* instance, or may be a combination of default and random parameters,
* depending on the underlying cipher implementation.
- * </p>
- *
+ *
* @return the parameters that where used to create this cipher instance, or
* {@code null} if this cipher instance does not have any parameters
* at all.
- * @since Android 1.0
*/
protected abstract AlgorithmParameters engineGetParameters();
* The cipher will be initialized for the specified operation (one of:
* encryption, decryption, key wrapping or key unwrapping) depending on
* {@code opmode}.
- * </p>
+ * <p>
* If this cipher instance needs any algorithm parameters or random values
* that the specified key cannot provide, the underlying implementation of
* this cipher is supposed to generate the required parameters (using its
* When a cipher instance is initialized by a call to any of the {@code
* init} methods, the state of the instance is overridden, means it is
* equivalent to creating a new instance and calling it {@code init} method.
- * </p>
- *
+ *
* @param opmode
* the operation this cipher instance should be initialized for
* (one of: {@code ENCRYPT_MODE}, {@code DECRYPT_MODE}, {@code
* @throws InvalidKeyException
* if the specified key cannot be used to initialize this cipher
* instance.
- * @since Android 1.0
*/
protected abstract void engineInit(int opmode, Key key, SecureRandom random)
throws InvalidKeyException;
* The cipher will be initialized for the specified operation (one of:
* encryption, decryption, key wrapping or key unwrapping) depending on
* {@code opmode}.
- * </p>
+ * <p>
* If this cipher instance needs any algorithm parameters and {@code params}
* is {@code null}, the underlying implementation of this cipher is supposed
* to generate the required parameters (using its provider or random
* When a cipher instance is initialized by a call to any of the {@code
* init} methods, the state of the instance is overridden, means it is
* equivalent to creating a new instance and calling it {@code init} method.
- * </p>
- *
+ *
* @param opmode
* the operation this cipher instance should be initialized for
* (one of: {@code ENCRYPT_MODE}, {@code DECRYPT_MODE}, {@code
* @throws InvalidAlgorithmParameterException
* it the specified parameters are inappropriate for this
* cipher.
- * @since Android 1.0
*/
protected abstract void engineInit(int opmode, Key key,
AlgorithmParameterSpec params, SecureRandom random)
* The cipher will be initialized for the specified operation (one of:
* encryption, decryption, key wrapping or key unwrapping) depending on
* {@code opmode}.
- * </p>
+ * <p>
* If this cipher instance needs any algorithm parameters and {@code params}
* is {@code null}, the underlying implementation of this cipher is supposed
* to generate the required parameters (using its provider or random
* When a cipher instance is initialized by a call to any of the {@code
* init} methods, the state of the instance is overridden, means it is
* equivalent to creating a new instance and calling it {@code init} method.
- * </p>
- *
+ *
* @param opmode
* the operation this cipher instance should be initialized for
* (one of: {@code ENCRYPT_MODE}, {@code DECRYPT_MODE}, {@code
* @throws InvalidAlgorithmParameterException
* if the specified parameters are inappropriate for this
* cipher.
- * @since Android 1.0
*/
protected abstract void engineInit(int opmode, Key key,
AlgorithmParameters params, SecureRandom random)
/**
* Continues a multi-part transformation (encryption or decryption). The
* transformed bytes are returned.
- *
+ *
* @param input
* the input bytes to transform.
* @param inputOffset
* @throws IllegalArgumentException
* if the input is null, or if {@code inputOffset} and {@code
* inputLen} do not specify a valid chunk in the input buffer.
- * @since Android 1.0
*/
protected abstract byte[] engineUpdate(byte[] input, int inputOffset,
int inputLen);
* a {@code ShortBufferException} is thrown. Use
* {@link Cipher#getOutputSize getOutputSize} to check for the size of the
* output buffer.
- * </p>
- *
+ *
* @param input
* the input bytes to transform.
* @param inputOffset
* @return the number of bytes placed in output.
* @throws ShortBufferException
* if the size of the {@code output} buffer is too small.
- * @since Android 1.0
*/
protected abstract int engineUpdate(byte[] input, int inputOffset,
int inputLen, byte[] output, int outputOffset)
* bytes a {@code ShortBufferException} is thrown. Use
* {@link Cipher#getOutputSize getOutputSize} to check for the size of the
* output buffer.
- * </p>
- *
+ *
* @param input
* the input buffer to transform.
* @param output
* @return the number of bytes stored in the output buffer.
* @throws ShortBufferException
* if the size of the {@code output} buffer is too small.
- * @since Android 1.0
*/
protected int engineUpdate(ByteBuffer input, ByteBuffer output)
throws ShortBufferException {
* Processes the {@code inputLen} bytes in {@code input} buffer at {@code
* inputOffset}, and any bytes that have been buffered in previous {@code
* update} calls.
- * </p>
- *
+ *
* @param input
* the input buffer.
* @param inputOffset
* cipher block size.
* @throws BadPaddingException
* if the padding of the data does not match the padding scheme.
- * @since Android 1.0
*/
protected abstract byte[] engineDoFinal(byte[] input, int inputOffset,
int inputLen) throws IllegalBlockSizeException, BadPaddingException;
* Finishes a multi-part transformation (encryption or decryption).
* <p>
* Processes the {@code inputLen} bytes in {@code input} buffer at
- * {@code inputOffset}, and any bytes that have been buffered in previous
+ * {@code inputOffset}, and any bytes that have been buffered in previous
* {@code update} calls.
- * </p>
- *
+ *
* @param input
* the input buffer.
* @param inputOffset
* cipher block size.
* @throws BadPaddingException
* if the padding of the data does not match the padding scheme.
- * @since Android 1.0
*/
protected abstract int engineDoFinal(byte[] input, int inputOffset,
int inputLen, byte[] output, int outputOffset)
* {@code input.position()}, and any bytes that have been buffered in
* previous {@code update} calls. The transformed bytes are placed into
* {@code output} buffer.
- * </p>
- *
+ *
* @param input
* the input buffer.
* @param output
* this class (for backwards compatibility, it cannot be abstract). If this
* method is not overridden, it throws an {@code
* UnsupportedOperationException}.
- *
+ *
* @param key
* the key to wrap.
* @return the wrapped key
* cipher block size.
* @throws InvalidKeyException
* if this cipher instance cannot wrap this key.
- * @since Android 1.0
*/
protected byte[] engineWrap(Key key) throws IllegalBlockSizeException,
InvalidKeyException {
* This method has been added to this class (for backwards compatibility, it
* cannot be abstract). If this method is not overridden, it throws an
* {@code UnsupportedOperationException}.
- * </p>
- *
+ *
* @param wrappedKey
* the wrapped key to unwrap.
* @param wrappedKeyAlgorithm
* @throws NoSuchAlgorithmException
* if no provider can be found that can create a key of type
* {@code wrappedKeyType} for the {@code wrappedKeyAlgorithm}.
- * @since Android 1.0
*/
protected Key engineUnwrap(byte[] wrappedKey, String wrappedKeyAlgorithm,
int wrappedKeyType) throws InvalidKeyException,
* added to this class (for backwards compatibility, it cannot be abstract).
* If this method is not overridden, it throws an {@code
* UnsupportedOperationException}.
- *
+ *
* @param key
* the key to get the size for.
* @return the size of a specified key object in bits.
* @throws InvalidKeyException
* if the size of the key cannot be determined by this
* implementation.
- * @since Android 1.0
*/
protected int engineGetKeySize(Key key) throws InvalidKeyException {
throw new UnsupportedOperationException(
Messages.getString("crypto.12")); //$NON-NLS-1$
}
-}
+}
\ No newline at end of file
* #8 - Private-Key Information Syntax Standard</a>.
* <p>
* The definition of ASN.1 is as follows:
- * </p>
* <dl>
* EncryptedPrivateKeyInfo ::= SEQUENCE {
* <dd>encryptionAlgorithm AlgorithmIdentifier,</dd>
* <dd>algorithm OBJECT IDENTIFIER,</dd>
* <dd>parameters ANY DEFINED BY algorithm OPTIONAL }</dd>
* </dl>
- *
- * @since Android 1.0
*/
public class EncryptedPrivateKeyInfo {
// Encryption algorithm name
/**
* Creates an {@code EncryptedPrivateKeyInfo} instance from its encoded
* representation by parsing it.
- *
+ *
* @param encoded
* the encoded representation of this object
* @throws IOException
* if parsing the encoded representation fails.
* @throws NullPointerException
* if {@code encoded} is {@code null}.
- * @since Android 1.0
*/
public EncryptedPrivateKeyInfo(byte[] encoded)
throws IOException {
/**
* Creates an {@code EncryptedPrivateKeyInfo} instance from an algorithm
* name and its encrypted data.
- *
+ *
* @param encrAlgName
* the name of an algorithm.
* @param encryptedData
* null}.
* @throws IllegalArgumentException
* if {@code encryptedData} is empty.
- * @since Android 1.0
*/
public EncryptedPrivateKeyInfo(String encrAlgName, byte[] encryptedData)
throws NoSuchAlgorithmException {
/**
* Creates an {@code EncryptedPrivateKeyInfo} instance from the
* encryption algorithm parameters an its encrypted data.
- *
+ *
* @param algParams
* the encryption algorithm parameters.
* @param encryptedData
* @throws NullPointerException
* if {@code algParams} or {@code encryptedData} is
* {@code null}.
- * @since Android 1.0
*/
public EncryptedPrivateKeyInfo(AlgorithmParameters algParams,
byte[] encryptedData)
/**
* Returns the name of the encryption algorithm.
- *
+ *
* @return the name of the encryption algorithm.
- * @since Android 1.0
*/
public String getAlgName() {
return algName;
/**
* Returns the parameters used by the encryption algorithm.
- *
+ *
* @return the parameters used by the encryption algorithm.
- * @since Android 1.0
*/
public AlgorithmParameters getAlgParameters() {
return algParameters;
/**
* Returns the encrypted data of this key.
- *
+ *
* @return the encrypted data of this key, each time this method is called a
* new array is returned.
- * @since Android 1.0
*/
public byte[] getEncryptedData() {
byte[] ret = new byte[encryptedData.length];
* The cipher must be initialize in either {@code Cipher.DECRYPT_MODE} or
* {@code Cipher.UNWRAP_MODE} with the same parameters and key used for
* encrypting this.
- * </p>
- *
+ *
* @param cipher
* the cipher initialized for decrypting the encrypted data.
* @return the extracted {@code PKCS8EncodedKeySpec}.
* encrypted data.
* @throws NullPointerException
* if {@code cipher} is {@code null}.
- * @since Android 1.0
*/
public PKCS8EncodedKeySpec getKeySpec(Cipher cipher)
throws InvalidKeySpecException {
/**
* Returns the {@code PKCS8EncodedKeySpec} object extracted from the
* encrypted data.
- *
+ *
* @param decryptKey
* the key to decrypt the encrypted data with.
* @return the extracted {@code PKCS8EncodedKeySpec}.
* data.
* @throws NullPointerException
* if {@code decryptKey} is {@code null}.
- * @since Android 1.0
*/
public PKCS8EncodedKeySpec getKeySpec(Key decryptKey)
throws NoSuchAlgorithmException,
/**
* Returns the {@code PKCS8EncodedKeySpec} object extracted from the
* encrypted data.
- *
+ *
* @param decryptKey
* the key to decrypt the encrypted data with.
* @param providerName
* @throws NullPointerException
* if {@code decryptKey} or {@code providerName} is {@code null}
* .
- * @since Android 1.0
*/
public PKCS8EncodedKeySpec getKeySpec(Key decryptKey, String providerName)
throws NoSuchProviderException,
/**
* Returns the {@code PKCS8EncodedKeySpec} object extracted from the
* encrypted data.
- *
+ *
* @param decryptKey
* the key to decrypt the encrypted data with.
* @param provider
* data.
* @throws NullPointerException
* if {@code decryptKey} or {@code provider} is {@code null}.
- * @since Android 1.0
*/
public PKCS8EncodedKeySpec getKeySpec(Key decryptKey, Provider provider)
throws NoSuchAlgorithmException,
/**
* Returns the ASN.1 encoded representation of this object.
- *
+ *
* @return the ASN.1 encoded representation of this object.
* @throws IOException
* if encoding this object fails.
- * @since Android 1.0
*/
public byte[] getEncoded() throws IOException {
if (encoded == null) {
/**
* This class implements the functionality of an exemption mechanism such as
* <i>key recovery</i>, <i>key weakening</i>, or <i>key escrow</i>.
- *
- * @since Android 1.0
*/
public class ExemptionMechanism {
/**
* Creates a {@code ExemptionMechanism} instance.
- *
+ *
* @param exmechSpi
* the implementation delegate.
* @param provider
* the associated provider.
* @param mechanism
* the name of the mechanism.
- * @since Android 1.0
*/
protected ExemptionMechanism(ExemptionMechanismSpi exmechSpi,
Provider provider, String mechanism) {
/**
* Returns the name of this {@code ExemptionMechanism}.
- *
+ *
* @return the name of this {@code ExemptionMechanism}.
- * @since Android 1.0
*/
public final String getName() {
return mechanism;
/**
* Returns a new {@code ExemptionMechanism} instance that provides the
* specified exemption mechanism algorithm.
- *
+ *
* @param algorithm
* the name of the requested exemption mechanism.
* @return the new {@code ExemptionMechanism} instance.
* if the specified algorithm is not available by any provider.
* @throws NullPointerException
* if the algorithm parameter is {@code null}.
- * @since Android 1.0
*/
public static final ExemptionMechanism getInstance(String algorithm)
throws NoSuchAlgorithmException {
/**
* Returns a new {@code ExemptionMechansm} instance that provides the
* specified exemption mechanism algorithm from the specified provider.
- *
+ *
* @param algorithm
* the name of the requested exemption mechanism.
* @param provider
* if the algorithm parameter is {@code null}.
* @throws IllegalArgumentException
* if the provider parameter is {@code null}.
- * @since Android 1.0
*/
public static final ExemptionMechanism getInstance(String algorithm,
String provider) throws NoSuchAlgorithmException,
/**
* Returns a new {@code ExemptionMechanism} instance that provides the
* specified exemption mechanism algorithm from the specified provider.
- *
+ *
* @param algorithm
* the name of the requested exemption mechanism.
* @param provider
* if the algorithm parameter is {@code null}.
* @throws IllegalArgumentException
* if the provider parameter is {@code null}.
- * @since Android 1.0
*/
public static final ExemptionMechanism getInstance(String algorithm,
Provider provider) throws NoSuchAlgorithmException {
/**
* Returns the provider of this {@code ExemptionMechanism} instance.
- *
+ *
* @return the provider of this {@code ExemptionMechanism} instance.
- * @since Android 1.0
*/
public final Provider getProvider() {
return provider;
* Returns whether the result blob for this {@code ExemptionMechanism}
* instance has been generated successfully and that the specified key is
* the same as the one that was used to initialize and generate.
- *
+ *
* @param key
* the key to verify.
* @return whether the result blob for this {@code ExemptionMechanism}
* @throws ExemptionMechanismException
* if an error occurs while determining whether the result blob
* has been generated successfully.
- * @since Android 1.0
*/
public final boolean isCryptoAllowed(Key key)
throws ExemptionMechanismException {
* Returns the size in bytes for the output buffer needed to hold the output
* of the next {@link #genExemptionBlob} call, given the specified {@code
* inputLen} (in bytes).
- *
+ *
* @param inputLen
* the specified input length (in bytes).
* @return the size in bytes for the output buffer.
* @throws IllegalStateException
* if this {@code ExemptionMechanism} instance is not
* initialized.
- * @since Android 1.0
*/
public final int getOutputSize(int inputLen) throws IllegalStateException {
if (!isInit) {
/**
* Initializes this {@code ExemptionMechanism} instance with the
* specified key.
- *
+ *
* @param key
* the key to initialize this instance with.
* @throws InvalidKeyException
* if the key cannot be used to initialize this mechanism.
* @throws ExemptionMechanismException
* if error(s) occur during initialization.
- * @since Android 1.0
*/
public final void init(Key key) throws InvalidKeyException,
ExemptionMechanismException {
/**
* Initializes this {@code ExemptionMechanism} instance with the
* specified key and algorithm parameters.
- *
+ *
* @param key
* the key to initialize this instance with.
* @param param
* mechanism.
* @throws ExemptionMechanismException
* if error(s) occur during initialization.
- * @since Android 1.0
*/
public final void init(Key key, AlgorithmParameters param)
throws InvalidKeyException, InvalidAlgorithmParameterException,
/**
* Initializes this {@code ExemptionMechanism} instance with the
* specified key and algorithm parameters.
- *
+ *
* @param key
* the key to initialize this instance with.
* @param param
* mechanism.
* @throws ExemptionMechanismException
* if error(s) occur during initialization.
- * @since Android 1.0
*/
public final void init(Key key, AlgorithmParameterSpec param)
throws InvalidKeyException, InvalidAlgorithmParameterException,
/**
* Generates the result key blob for this exemption mechanism.
- *
+ *
* @return the result key blob for this exemption mechanism.
* @throws IllegalStateException
* if this {@code ExemptionMechanism} instance is not
* initialized.
* @throws ExemptionMechanismException
* if error(s) occur during generation.
- * @since Android 1.0
*/
public final byte[] genExemptionBlob() throws IllegalStateException,
ExemptionMechanismException {
/**
* Generates the result key blob for this exemption mechanism and stores it
* into the {@code output} buffer.
- *
+ *
* @param output
* the output buffer for the result key blob.
* @return the number of bytes written to the {@code output} buffer.
* if the provided buffer is too small for the result key blob.
* @throws ExemptionMechanismException
* if error(s) occur during generation.
- * @since Android 1.0
*/
public final int genExemptionBlob(byte[] output)
throws IllegalStateException, ShortBufferException,
/**
* Generates the result key blob for this exemption mechanism and stores it
* into the {@code output} buffer at offset {@code outputOffset}.
- *
+ *
* @param output
* the output buffer for the result key blob.
* @param outputOffset
* if the provided buffer is too small for the result key blob.
* @throws ExemptionMechanismException
* if error(s) occur during generation.
- * @since Android 1.0
*/
public final int genExemptionBlob(byte[] output, int outputOffset)
throws IllegalStateException, ShortBufferException,
/**
* Frees the references to the key used to initialize this instance.
- *
- * @since Android 1.0
*/
@Override
protected void finalize() {
/**
* This is the base class for {@code ExemptionMechanismException}.
- *
- * @since Android 1.0
*/
public class ExemptionMechanismException extends GeneralSecurityException {
*
* @param msg
* the exception message.
- * @since Android 1.0
*/
public ExemptionMechanismException(String msg) {
super(msg);
/**
* Creates a new {@code ExemptionMechanismException} with no message.
- *
- * @since Android 1.0
*/
public ExemptionMechanismException() {
}
/**
* The <i>Service Provider Interface</i> (<b>SPI</b>) definition for the {@code
* ExemptionMechanism} class.
- *
- * @since Android 1.0
*/
public abstract class ExemptionMechanismSpi {
/**
* Creates a new {@code ExemptionMechanismSpi} instance.
- *
- * @since Android 1.0
*/
public ExemptionMechanismSpi() {
}
/**
* Generates the result key blob for this exemption mechanism.
- *
+ *
* @return the result key blob for this exemption mechanism.
* @throws ExemptionMechanismException
* if error(s) occur during generation.
- * @since Android 1.0
*/
protected abstract byte[] engineGenExemptionBlob()
throws ExemptionMechanismException;
/**
* Generates the result key blob for this exemption mechanism and stores it
* into the {@code output} buffer at offset {@code outputOffset}.
- *
+ *
* @param output
* the output buffer for the result key blob.
* @param outputOffset
* if the provided buffer is too small for the result key blob.
* @throws ExemptionMechanismException
* if error(s) occur during generation.
- * @since Android 1.0
*/
protected abstract int engineGenExemptionBlob(byte[] output,
int outputOffset) throws ShortBufferException,
* Returns the size in bytes for the output buffer needed to hold the output
* of the next {@link #engineGenExemptionBlob} call, given the specified
* {@code inputLen} (in bytes).
- *
+ *
* @param inputLen
* the specified input length (in bytes).
* @return the size in bytes for the output buffer.
/**
* Initializes this {@code ExemptionMechanism} instance with the specified
* key.
- *
+ *
* @param key
* the key to initialize this instance with.
* @throws InvalidKeyException
* if the key cannot be used to initialize this mechanism.
* @throws ExemptionMechanismException
* if error(s) occur during initialization.
- * @since Android 1.0
*/
protected abstract void engineInit(Key key) throws InvalidKeyException,
ExemptionMechanismException;
/**
* Initializes this {@code ExemptionMechanism} instance with the specified
* key and algorithm parameters.
- *
+ *
* @param key
* the key to initialize this instance with.
* @param params
* mechanism.
* @throws ExemptionMechanismException
* if error(s) occur during initialization.
- * @since Android 1.0
*/
protected abstract void engineInit(Key key, AlgorithmParameters params)
throws InvalidKeyException, InvalidAlgorithmParameterException,
/**
* Initializes this {@code ExemptionMechanism} instance with the specified
* key and algorithm parameters.
- *
+ *
* @param key
* the key to initialize this instance with.
* @param params
* mechanism.
* @throws ExemptionMechanismException
* if error(s) occur during initialization.
- * @since Android 1.0
*/
protected abstract void engineInit(Key key, AlgorithmParameterSpec params)
throws InvalidKeyException, InvalidAlgorithmParameterException,
/**
* The exception, that is thrown when the data length provided to a block cipher
* does not match the block size of the cipher.
- *
- * @since Android 1.0
*/
public class IllegalBlockSizeException extends GeneralSecurityException {
*
* @param msg
* the message
- * @since Android 1.0
*/
public IllegalBlockSizeException(String msg) {
super(msg);
/**
* Creates a new {@code IllegalBlockSizeException}.
- *
- * @since Android 1.0
*/
public IllegalBlockSizeException() {
}
* This class provides the functionality for a key exchange protocol. This
* enables two or more parties to agree on a secret key for symmetric
* cryptography.
- *
- * @since Android 1.0
*/
public class KeyAgreement {
/**
* Creates a new {@code KeyAgreement} instance.
- *
+ *
* @param keyAgreeSpi
* the <b>SPI</b> delegate.
* @param provider
* the provider providing this KeyAgreement.
* @param algorithm
* the name of the key agreement algorithm.
- * @since Android 1.0
*/
protected KeyAgreement(KeyAgreementSpi keyAgreeSpi, Provider provider,
String algorithm) {
/**
* Returns the name of the key agreement algorithm.
- *
+ *
* @return the name of the key agreement algorithm.
- * @since Android 1.0
*/
public final String getAlgorithm() {
return algorithm;
/**
* Returns the provider for this {@code KeyAgreement} instance.
- *
+ *
* @return the provider for this {@code KeyAgreement} instance.
- * @since Android 1.0
*/
public final Provider getProvider() {
return provider;
/**
* Creates a new {@code KeyAgreement} for the specified algorithm.
- *
+ *
* @param algorithm
* the name of the key agreement algorithm to create.
* @return a key agreement for the specified algorithm.
* if no installed provider can provide the requested algorithm.
* @throws NullPointerException
* if the specified algorithm is {@code null}.
- * @since Android 1.0
*/
public static final KeyAgreement getInstance(String algorithm)
throws NoSuchAlgorithmException {
/**
* Creates a new {@code KeyAgreement} for the specified algorithm from the
* specified provider.
- *
+ *
* @param algorithm
* the name of the key agreement algorithm to create.
* @param provider
* if the specified provider does not exist.
* @throws IllegalArgumentException
* if the specified provider name is {@code null} or empty.
- * @since Android 1.0
*/
public static final KeyAgreement getInstance(String algorithm,
String provider) throws NoSuchAlgorithmException,
/**
* Create a new {@code KeyAgreement} for the specified algorithm from the
* specified provider.
- *
+ *
* @param algorithm
* the name of the key agreement algorithm to create.
* @param provider
/**
* Initializes this {@code KeyAgreement} with the specified key.
- *
+ *
* @param key
* the key to initialize this key agreement.
* @throws InvalidKeyException
* if the specified key cannot be used to initialize this key
* agreement.
- * @since Android 1.0
*/
public final void init(Key key) throws InvalidKeyException {
spiImpl.engineInit(key, rndm);//new SecureRandom());
/**
* Initializes this {@code KeyAgreement} with the specified key and the
* specified randomness source.
- *
+ *
* @param key
* the key to initialize this key agreement.
* @param random
* @throws InvalidKeyException
* if the specified key cannot be used to initialize this key
* agreement.
- * @since Android 1.0
*/
public final void init(Key key, SecureRandom random)
throws InvalidKeyException {
/**
* Initializes this {@code KeyAgreement} with the specified key and the
* algorithm parameters.
- *
+ *
* @param key
* the key to initialize this key agreement.
* @param params
* @throws InvalidAlgorithmParameterException
* if the specified parameters are invalid for this key
* agreement algorithm.
- * @since Android 1.0
*/
public final void init(Key key, AlgorithmParameterSpec params)
throws InvalidKeyException, InvalidAlgorithmParameterException {
/**
* Initializes this {@code KeyAgreement} with the specified key, algorithm
* parameters and randomness source.
- *
+ *
* @param key
* the key to initialize this key agreement.
* @param params
* @throws InvalidAlgorithmParameterException
* if the specified parameters are invalid for this key
* agreement algorithm.
- * @since Android 1.0
*/
public final void init(Key key, AlgorithmParameterSpec params,
SecureRandom random) throws InvalidKeyException,
/**
* Does the next (or the last) phase of the key agreement, using the
* specified key.
- *
+ *
* @param key
* the key received from the other party for this phase.
* @param lastPhase
* this phase,
* @throws IllegalStateException
* if this instance has not been initialized.
- * @since Android 1.0
*/
public final Key doPhase(Key key, boolean lastPhase)
throws InvalidKeyException, IllegalStateException {
/**
* Generates the shared secret.
- *
+ *
* @return the generated shared secret.
* @throws IllegalStateException
* if this key agreement is not complete.
- * @since Android 1.0
*/
public final byte[] generateSecret() throws IllegalStateException {
return spiImpl.engineGenerateSecret();
/**
* Generates the shared secret and stores it into the buffer {@code
* sharedSecred} at {@code offset}.
- *
+ *
* @param sharedSecret
* the buffer to store the shared secret.
* @param offset
* if this key agreement is not complete.
* @throws ShortBufferException
* if the specified buffer is too small for the shared secret.
- * @since Android 1.0
*/
public final int generateSecret(byte[] sharedSecret, int offset)
throws IllegalStateException, ShortBufferException {
/**
* Generates the shared secret.
- *
+ *
* @param algorithm
* the algorithm to for the {@code SecretKey}
* @return the shared secret as a {@code SecretKey} of the specified
* @throws InvalidKeyException
* if a {@code SecretKey} with the specified algorithm cannot be
* created using the generated shared secret.
- * @since Android 1.0
*/
public final SecretKey generateSecret(String algorithm)
throws IllegalStateException, NoSuchAlgorithmException,
/**
* The <i>Service Provider Interface</i> (<b>SPI</b>) definition for the
* {@code KeyAgreement} class.
- *
- * @since Android 1.0
*/
public abstract class KeyAgreementSpi {
-
+
/**
* Creates a new {@code KeyAgreementSpi} instance.
- *
- * @since Android 1.0
*/
public KeyAgreementSpi() {
}
/**
* Does the next (or the last) phase of the key agreement, using the
* specified key.
- *
+ *
* @param key
* the key received from the other party for this phase.
* @param lastPhase
* this phase,
* @throws IllegalStateException
* if this instance has not been initialized.
- * @since Android 1.0
*/
protected abstract Key engineDoPhase(Key key, boolean lastPhase)
throws InvalidKeyException, IllegalStateException;
/**
* Generates the shared secret.
- *
+ *
* @return the generated shared secret.
* @throws IllegalStateException
* if this key agreement is not complete.
- * @since Android 1.0
*/
protected abstract byte[] engineGenerateSecret()
throws IllegalStateException;
/**
* Generates the shared secret and stores it into the buffer {@code
* sharedSecred} at {@code offset}.
- *
+ *
* @param sharedSecret
* the buffer to store the shared secret.
* @param offset
* if this key agreement is not complete.
* @throws ShortBufferException
* if the specified buffer is too small for the shared secret.
- * @since Android 1.0
*/
protected abstract int engineGenerateSecret(byte[] sharedSecret, int offset)
throws IllegalStateException, ShortBufferException;
/**
* Generates the shared secret.
- *
+ *
* @param algorithm
* the algorithm to for the {@code SecretKey}
* @return the shared secret as a {@code SecretKey} of the specified
* @throws InvalidKeyException
* if a {@code SecretKey} with the specified algorithm cannot be
* created using the generated shared secret.
- * @since Android 1.0
*/
protected abstract SecretKey engineGenerateSecret(String algorithm)
throws IllegalStateException, NoSuchAlgorithmException,
/**
* Initializes this {@code KeyAgreementSpi} with the specified key and the
* specified randomness source.
- *
+ *
* @param key
* the key to initialize this key agreement.
* @param random
* @throws InvalidKeyException
* if the specified key cannot be used to initialize this key
* agreement.
- * @since Android 1.0
*/
protected abstract void engineInit(Key key, SecureRandom random)
throws InvalidKeyException;
/**
* Initializes this {@code KeyAgreementSpi} with the specified key,
* algorithm parameters and randomness source.
- *
+ *
* @param key
* the key to initialize this key agreement.
* @param params
* @throws InvalidAlgorithmParameterException
* if the specified parameters are invalid for this key
* agreement algorithm.
- * @since Android 1.0
*/
protected abstract void engineInit(Key key, AlgorithmParameterSpec params,
SecureRandom random) throws InvalidKeyException,
/**
* This class provides the public API for generating symmetric cryptographic
* keys.
- *
- * @since Android 1.0
*/
public class KeyGenerator {
/**
* Creates a new {@code KeyGenerator} instance.
- *
+ *
* @param keyGenSpi
* the implementation delegate.
* @param provider
* the implementation provider.
* @param algorithm
* the name of the algorithm.
- * @since Android 1.0
*/
protected KeyGenerator(KeyGeneratorSpi keyGenSpi, Provider provider,
String algorithm) {
/**
* Returns the name of the key generation algorithm.
- *
+ *
* @return the name of the key generation algorithm.
- * @since Android 1.0
*/
public final String getAlgorithm() {
return algorithm;
/**
* Returns the provider of this {@code KeyGenerator} instance.
- *
+ *
* @return the provider of this {@code KeyGenerator} instance.
- * @since Android 1.0
*/
public final Provider getProvider() {
return provider;
/**
* Creates a new {@code KeyGenerator} instance that provides the specified
* key algorithm,
- *
+ *
* @param algorithm
* the name of the requested key algorithm
* @return the new {@code KeyGenerator} instance.
* if the specified algorithm is not available by any provider.
* @throws NullPointerException
* if {@code algorithm} is {@code null}.
- * @since Android 1.0
*/
public static final KeyGenerator getInstance(String algorithm)
throws NoSuchAlgorithmException {
/**
* Creates a new {@code KeyGenerator} instance that provides the specified
* key algorithm from the specified provider.
- *
+ *
* @param algorithm
* the name of the requested key algorithm.
* @param provider
* if the specified provider is name is {@code null} or empty.
* @throws NullPointerException
* if the specified algorithm name is {@code null}.
- * @since Android 1.0
*/
public static final KeyGenerator getInstance(String algorithm,
String provider) throws NoSuchAlgorithmException,
/**
* Creates a new {@code KeyGenerator} instance that provides the specified
* key algorithm from the specified provider.
- *
+ *
* @param algorithm
* the name of the requested key algorithm.
* @param provider
* if the specified provider is {@code null}.
* @throws NullPointerException
* if the specified algorithm name is {@code null}.
- * @since Android 1.0
*/
public static final KeyGenerator getInstance(String algorithm,
Provider provider) throws NoSuchAlgorithmException {
/**
* Generates a secret key.
- *
+ *
* @return the generated secret key.
- * @since Android 1.0
*/
public final SecretKey generateKey() {
return spiImpl.engineGenerateKey();
/**
* Initializes this {@code KeyGenerator} instance with the specified
* algorithm parameters.
- *
+ *
* @param params
* the parameters for the key generation algorithm.
* @throws InvalidAlgorithmParameterException
* if the parameters cannot be used to initialize this key
* generator algorithm.
- * @since Android 1.0
*/
public final void init(AlgorithmParameterSpec params)
throws InvalidAlgorithmParameterException {
/**
* Initializes this {@code KeyGenerator} instance with the specified
* algorithm parameters and randomness source.
- *
+ *
* @param params
* the parameters for the key generation algorithm.
* @param random
* @throws InvalidAlgorithmParameterException
* if the parameters cannot be uses to initialize this key
* generator algorithm.
- * @since Android 1.0
*/
public final void init(AlgorithmParameterSpec params, SecureRandom random)
throws InvalidAlgorithmParameterException {
/**
* Initializes this {@code KeyGenerator} instance for the specified key size
* (in bits).
- *
+ *
* @param keysize
* the size of the key (in bits).
- * @since Android 1.0
*/
public final void init(int keysize) {
spiImpl.engineInit(keysize, rndm);//new SecureRandom());
/**
* Initializes this {@code KeyGenerator} instance for the specified key size
* (in bits) using the specified randomness source.
- *
+ *
* @param keysize
* the size of the key (in bits).
* @param random
* the randomness source for any random bytes.
- * @since Android 1.0
*/
public final void init(int keysize, SecureRandom random) {
spiImpl.engineInit(keysize, random);
/**
* Initializes this {@code KeyGenerator} with the specified randomness
* source.
- *
+ *
* @param random
* the randomness source for any random bytes.
- * @since Android 1.0
*/
public final void init(SecureRandom random) {
spiImpl.engineInit(random);
* {@code KeyGenerator} class.
*
* @see KeyGenerator
- * @since Android 1.0
*/
public abstract class KeyGeneratorSpi {
/**
* Creates a new {@code KeyGeneratorSpi} instance.
- *
- * @since Android 1.0
*/
public KeyGeneratorSpi() {
}
/**
* Generates a secret key.
- *
+ *
* @return the generated secret key.
- * @since Android 1.0
*/
protected abstract SecretKey engineGenerateKey();
/**
* Initializes this {@code KeyGeneratorSpi} instance with the specified
* algorithm parameters and randomness source.
- *
+ *
* @param params
* the parameters for the key generation algorithm.
* @param random
* @throws InvalidAlgorithmParameterException
* if the parameters cannot be uses to initialize this key
* generator algorithm.
- * @since Android 1.0
*/
protected abstract void engineInit(AlgorithmParameterSpec params,
SecureRandom random) throws InvalidAlgorithmParameterException;
/**
* Initializes this {@code KeyGenerator} instance for the specified key
* size (in bits) using the specified randomness source.
- *
+ *
* @param keysize
* the size of the key (in bits).
* @param random
* the randomness source for any random bytes.
- * @since Android 1.0
*/
protected abstract void engineInit(int keysize, SecureRandom random);
/**
* Initializes this {@code KeyGenerator} with the specified randomness
* source.
- *
+ *
* @param random
* the randomness source for any random bytes.
- * @since Android 1.0
*/
protected abstract void engineInit(SecureRandom random);
}
\ No newline at end of file
/**
* This class provides the public API for <i>Message Authentication Code</i>
* (MAC) algorithms.
- *
- * @since Android 1.0
*/
public class Mac implements Cloneable {
/**
* Creates a new {@code Mac} instance.
- *
+ *
* @param macSpi
* the implementation delegate.
* @param provider
* the implementation provider.
* @param algorithm
* the name of the MAC algorithm.
- * @since Android 1.0
*/
protected Mac(MacSpi macSpi, Provider provider, String algorithm) {
this.provider = provider;
* Returns the name of the MAC algorithm.
*
* @return the name of the MAC algorithm.
- * @since Android 1.0
*/
public final String getAlgorithm() {
return algorithm;
/**
* Returns the provider of this {@code Mac} instance.
- *
+ *
* @return the provider of this {@code Mac} instance.
- * @since Android 1.0
*/
public final Provider getProvider() {
return provider;
* @throws NoSuchAlgorithmException
* if the specified algorithm is not available by any provider.
* @throws NullPointerException
- * if {@code algorithm} is {@code null}.
- * @since Android 1.0
+ * if {@code algorithm} is {@code null} (instead of
+ * NoSuchAlgorithmException as in 1.4 release).
*/
public static final Mac getInstance(String algorithm)
throws NoSuchAlgorithmException {
* @throws IllegalArgumentException
* if the specified provider name is {@code null} or empty.
* @throws NullPointerException
- * if {@code algorithm} is {@code null}
- * @since Android 1.0.
+ * if {@code algorithm} is {@code null} (instead of
+ * NoSuchAlgorithmException as in 1.4 release).
*/
public static final Mac getInstance(String algorithm, String provider)
throws NoSuchAlgorithmException, NoSuchProviderException {
* @throws IllegalArgumentException
* if {@code provider} is {@code null}.
* @throws NullPointerException
- * if {@code algorithm} is {@code null}.
- * @since Android 1.0
+ * if {@code algorithm} is {@code null} (instead of
+ * NoSuchAlgorithmException as in 1.4 release).
*/
public static final Mac getInstance(String algorithm, Provider provider)
throws NoSuchAlgorithmException {
/**
* Returns the length of this MAC (in bytes).
- *
+ *
* @return the length of this MAC (in bytes).
*/
public final int getMacLength() {
/**
* Initializes this {@code Mac} instance with the specified key and
* algorithm parameters.
- *
+ *
* @param key
* the key to initialize this algorithm.
* @param params
* @throws InvalidAlgorithmParameterException
* if the specified parameters cannot be used to initialize this
* algorithm.
- * @since Android 1.0
*/
public final void init(Key key, AlgorithmParameterSpec params)
throws InvalidKeyException, InvalidAlgorithmParameterException {
/**
* Initializes this {@code Mac} instance with the specified key.
- *
+ *
* @param key
* the key to initialize this algorithm.
* @throws InvalidKeyException
* @throws RuntimeException
* if the specified key cannot be used to initialize this
* algorithm.
- * @since Android 1.0
*/
public final void init(Key key) throws InvalidKeyException {
if (key == null) {
/**
* Updates this {@code Mac} instance with the specified byte.
- *
+ *
* @param input
* the byte
* @throws IllegalStateException
* if this MAC is not initialized.
- * @since Android 1.0
*/
public final void update(byte input) throws IllegalStateException {
if (!isInitMac) {
/**
* Updates this {@code Mac} instance with the data from the specified buffer
* {@code input} from the specified {@code offset} and length {@code len}.
- *
+ *
* @param input
* the buffer.
* @param offset
* @throws IllegalArgumentException
* if {@code offset} and {@code len} do not specified a valid
* chunk in {@code input} buffer.
- * @since Android 1.0
*/
public final void update(byte[] input, int offset, int len)
throws IllegalStateException {
/**
* Copies the buffer provided as input for further processing.
- *
+ *
* @param input
* the buffer.
* @throws IllegalStateException
* if this MAC is not initialized.
- * @since Android 1.0
*/
public final void update(byte[] input) throws IllegalStateException {
if (!isInitMac) {
* Updates this {@code Mac} instance with the data from the specified
* buffer, starting at {@link ByteBuffer#position()}, including the next
* {@link ByteBuffer#remaining()} bytes.
- *
+ *
* @param input
* the buffer.
* @throws IllegalStateException
* if this MAC is not initialized.
- * @since Android 1.0
*/
public final void update(ByteBuffer input) {
if (!isInitMac) {
* This {@code Mac} instance is reverted to its initial state and can be
* used to start the next MAC computation with the same parameters or
* initialized with different parameters.
- * </p>
- *
+ *
* @return the generated digest.
* @throws IllegalStateException
* if this MAC is not initialized.
- * @since Android 1.0
*/
public final byte[] doFinal() throws IllegalStateException {
if (!isInitMac) {
* This {@code Mac} instance is reverted to its initial state and can be
* used to start the next MAC computation with the same parameters or
* initialized with different parameters.
- * </p>
- *
+ *
* @param output
* the output buffer
* @param outOffset
* of the output buffer.
* @throws IllegalStateException
* if this MAC is not initialized.
- * @since Android 1.0
*/
public final void doFinal(byte[] output, int outOffset)
throws ShortBufferException, IllegalStateException {
* This {@code Mac} instance is reverted to its initial state and can be
* used to start the next MAC computation with the same parameters or
* initialized with different parameters.
- * </p>
- *
+ *
* @param input
* the final bytes.
* @return the generated digest.
* @throws IllegalStateException
* if this MAC is not initialized.
- * @since Android 1.0
*/
public final byte[] doFinal(byte[] input) throws IllegalStateException {
if (!isInitMac) {
* This {@code Mac} instance is reverted to its initial state and can be
* used to start the next MAC computation with the same parameters or
* initialized with different parameters.
- * </p>
- *
- * @since Android 1.0
*/
public final void reset() {
spiImpl.engineReset();
/**
* Clones this {@code Mac} instance and the underlying implementation.
- *
+ *
* @return the cloned instance.
* @throws CloneNotSupportedException
* if the underlying implementation does not support cloning.
- * @since Android 1.0
*/
@Override
public final Object clone() throws CloneNotSupportedException {
mac.isInitMac = this.isInitMac;
return mac;
}
-}
+}
\ No newline at end of file
* Mac} class.
*
* @see Mac
- * @since Android 1.0
*/
public abstract class MacSpi {
-
+
/**
* Creates a new {@code MacSpi} instance.
- *
- * @since Android 1.0
*/
public MacSpi() {
}
/**
* Returns the length of this MAC (in bytes).
- *
+ *
* @return the length of this MAC (in bytes).
- * @since Android 1.0
*/
protected abstract int engineGetMacLength();
/**
* Initializes this {@code MacSpi} instance with the specified key and
* algorithm parameters.
- *
+ *
* @param key
* the key to initialize this algorithm.
* @param params
* @throws InvalidAlgorithmParameterException
* if the specified parameters cannot be used to initialize this
* algorithm.
- * @since Android 1.0
*/
protected abstract void engineInit(Key key, AlgorithmParameterSpec params)
throws InvalidKeyException, InvalidAlgorithmParameterException;
/**
* Updates this {@code MacSpi} instance with the specified byte.
- *
+ *
* @param input
* the byte.
- * @since Android 1.0
*/
protected abstract void engineUpdate(byte input);
* Updates this {@code MacSpi} instance with the data from the specified
* buffer {@code input} from the specified {@code offset} and length {@code
* len}.
- *
+ *
* @param input
* the buffer.
* @param offset
* the offset in the buffer.
* @param len
* the length of the data in the buffer.
- * @since Android 1.0
*/
protected abstract void engineUpdate(byte[] input, int offset, int len);
* Updates this {@code MacSpi} instance with the data from the specified
* buffer, starting at {@link ByteBuffer#position()}, including the next
* {@link ByteBuffer#remaining()} bytes.
- *
+ *
* @param input
* the buffer.
- * @since Android 1.0
*/
protected void engineUpdate(ByteBuffer input) {
if (!input.hasRemaining()) {
* This {@code MacSpi} instance is reverted to its initial state and
* can be used to start the next MAC computation with the same parameters or
* initialized with different parameters.
- * </p>
- *
+ *
* @return the generated digest.
- * @since Android 1.0
*/
protected abstract byte[] engineDoFinal();
* This {@code MacSpi} instance is reverted to its initial state and can be
* used to start the next MAC computation with the same parameters or
* initialized with different parameters.
- * </p>
- *
- * @since Android 1.0
*/
protected abstract void engineReset();
/**
* Clones this {@code MacSpi} instance.
- *
+ *
* @return the cloned instance.
* @throws CloneNotSupportedException
* if cloning is not supported.
- * @since Android 1.0
*/
@Override
public Object clone() throws CloneNotSupportedException {
/**
* The exception that is thrown when the requested padding mechanism is not
* supported.
- *
- * @since Android 1.0
*/
public class NoSuchPaddingException extends GeneralSecurityException {
*
* @param msg
* the message.
- * @since Android 1.0
*/
public NoSuchPaddingException(String msg) {
super(msg);
/**
* Creates a new {@code NoSuchPaddingException}.
- *
- * @since Android 1.0
*/
public NoSuchPaddingException() {
}
/**
* This class provides an identity cipher that does not transform the input data
* in any way. The <i>encrypted</i> data is identical to the <i>plain text</i>.
- *
- * @since Android 1.0
*/
public class NullCipher extends Cipher {
* <p>
* Since a {@code SealedObject} instance is a serializable object itself it can
* either be stored or transmitted over an insecure channel.
- * </p>
+ * <p>
* The wrapped object can later be decrypted (unsealed) using the corresponding
* key and then be deserialized to retrieve the original object.The sealed
* object itself keeps track of the cipher and corresponding parameters.
- *
- * @since Android 1.0
*/
public class SealedObject implements Serializable {
- // the value of this field was derived by using serialver utility
- /**
- * @com.intel.drl.spec_ref
- */
private static final long serialVersionUID = 4482838265551344752L;
/**
* and sealing it using the specified cipher.
* <p>
* The cipher must be fully initialized.
- * </p>
- *
+ *
* @param object
* the object to seal, can be {@code null}.
* @param c
* size.
* @throws NullPointerException
* if the cipher is {@code null}.
- * @since Android 1.0
*/
public SealedObject(Serializable object, Cipher c)
throws IOException, IllegalBlockSizeException {
/**
* Creates a new {@code SealedObject} instance by copying the data from
* the specified object.
- *
+ *
* @param so
* the object to copy.
- * @since Android 1.0
*/
protected SealedObject(SealedObject so) {
if (so == null) {
/**
* Returns the algorithm this object was sealed with.
- *
+ *
* @return the algorithm this object was sealed with.
- * @since Android 1.0
*/
public final String getAlgorithm() {
return sealAlg;
/**
* Returns the wrapped object, decrypting it using the specified key.
- *
+ *
* @param key
* the key to decrypt the data with.
* @return the encapsulated object.
* if the algorithm to decrypt the data is not available.
* @throws InvalidKeyException
* if the specified key cannot be used to decrypt the data.
- * @since Android 1.0
*/
public final Object getObject(Key key)
throws IOException, ClassNotFoundException,
/**
* Returns the wrapped object, decrypting it using the specified
* cipher.
- *
+ *
* @param c
* the cipher to decrypt the data.
* @return the encapsulated object.
* size.
* @throws BadPaddingException
* if the padding of the data does not match the padding scheme.
- * @since Android 1.0
*/
public final Object getObject(Cipher c)
throws IOException, ClassNotFoundException,
/**
* Returns the wrapped object, decrypting it using the specified key. The
* specified provider is used to retrieve the cipher algorithm.
- *
+ *
* @param key
* the key to decrypt the data.
* @param provider
* if the specified provider is not available.
* @throws InvalidKeyException
* if the specified key cannot be used to decrypt the data.
- * @since Android 1.0
*/
public final Object getObject(Key key, String provider)
throws IOException, ClassNotFoundException,
* <p>
* This interface is a <i>marker interface</i> to group secret keys and to
* provide type safety for.
- * </p>
+ * <p>
* Implementations of this interface have to overwrite the
* {@link Object#equals(Object) equals} and {@link Object#hashCode() hashCode}
* from {@link java.lang.Object} so comparison is done using the actual key data
* and not the object reference.
- *
- * @since Android 1.0
*/
public interface SecretKey extends Key {
/**
* The serialization version identifier.
- *
+ *
* @serial
- * @since Android 1.0
*/
public static final long serialVersionUID = -4795878709595146952L;
}
\ No newline at end of file
* </ul>
* Which key specifications are supported by the {@link #generateSecret} and
* {@link #getKeySpec} is provider dependent.
- * </p>
- *
- * @since Android 1.0
*/
public class SecretKeyFactory {
/**
* Creates a new {@code SecretKeyFactory}
- *
+ *
* @param keyFacSpi
* the SPI delegate.
* @param provider
* the provider providing this key factory.
* @param algorithm
* the algorithm name for the secret key.
- * @since Android 1.0
*/
protected SecretKeyFactory(SecretKeyFactorySpi keyFacSpi,
Provider provider, String algorithm) {
/**
* Returns the name of the secret key algorithm.
- *
+ *
* @return the name of the secret key algorithm.
- * @since Android 1.0
*/
public final String getAlgorithm() {
return algorithm;
/**
* Returns the provider for this {@code SecretKeyFactory} instance.
- *
+ *
* @return the provider for this {@code SecretKeyFactory} instance.
- * @since Android 1.0
*/
public final Provider getProvider() {
return provider;
/**
* Creates a new {@code SecretKeyFactory} instance for the specified key
* algorithm.
- *
+ *
* @param algorithm
* the name of the key algorithm.
* @return a secret key factory for the specified key algorithm.
* if no installed provider can provide the requested algorithm.
* @throws NullPointerException
* if the specified algorithm is {@code null}.
- * @since Android 1.0
*/
public static final SecretKeyFactory getInstance(String algorithm)
throws NoSuchAlgorithmException {
/**
* Creates a new {@code SecretKeyFactory} instance for the specified key
* algorithm from the specified {@code provider}.
- *
+ *
* @param algorithm
* the name of the key algorithm.
* @param provider
* if the specified provider does not exist.
* @throws IllegalArgumentException
* if the specified provider name is {@code null} or empty.
- * @since Android 1.0
*/
public static final SecretKeyFactory getInstance(String algorithm,
String provider) throws NoSuchAlgorithmException,
/**
* Creates a new {@code SecretKeyFactory} instance for the specified key
* algorithm from the specified provider.
- *
+ *
* @param algorithm
* the name of the key algorithm.
* @param provider
* if the specified provider is {@code null}.
* @throws NullPointerException
* is the specified algorithm name is {@code null}.
- * @since Android 1.0
*/
public static final SecretKeyFactory getInstance(String algorithm,
Provider provider) throws NoSuchAlgorithmException {
/**
* Generate a secret key from the specified key specification.
- *
+ *
* @param keySpec
* the key specification.
* @return a secret key.
* @throws InvalidKeySpecException
* if the specified key specification cannot be used to generate
* a secret key.
- * @since Android 1.0
*/
public final SecretKey generateSecret(KeySpec keySpec)
throws InvalidKeySpecException {
/**
* Returns the key specification of the specified secret key.
- *
+ *
* @param key
* the secret key to get the specification from.
* @param keySpec
* @throws InvalidKeySpecException
* if the specified secret key cannot be transformed into the
* requested key specification.
- * @since Android 1.0
*/
@SuppressWarnings("unchecked")
public final KeySpec getKeySpec(SecretKey key, Class keySpec)
/**
* Translates the specified secret key into an instance of the corresponding
* key from the provider of this key factory.
- *
+ *
* @param key
* the secret key to translate.
* @return the corresponding translated key.
* @throws InvalidKeyException
* if the specified key cannot be translated using this key
* factory.
- * @since Android 1.0
*/
public final SecretKey translateKey(SecretKey key)
throws InvalidKeyException {
/**
* The <i>Service Provider Interface</i> (<b>SPI</b>) definition for the {@code
* SecretKeyFactory} class.
- *
- * @since Android 1.0
*/
public abstract class SecretKeyFactorySpi {
/**
* Creates a new {@code SecretKeyFactorySpi} instance.
- * @since Android 1.0
*/
public SecretKeyFactorySpi() {
}
/**
* Generate a secret key from the specified key specification.
- *
+ *
* @param keySpec
* the key specification.
* @return a secret key.
* @throws InvalidKeySpecException
* if the specified key specification cannot be used to generate
* a secret key.
- * @since Android 1.0
*/
protected abstract SecretKey engineGenerateSecret(KeySpec keySpec)
throws InvalidKeySpecException;
/**
* Returns the key specification of the specified secret key.
- *
+ *
* @param key
* the secret key to get the specification from.
* @param keySpec
* @throws InvalidKeySpecException
* if the specified secret key cannot be transformed into the
* requested key specification.
- * @since Android 1.0
*/
@SuppressWarnings("unchecked")
protected abstract KeySpec engineGetKeySpec(SecretKey key, Class keySpec)
/**
* Translates the specified secret key into an instance of the corresponding
* key from the provider of this key factory.
- *
+ *
* @param key
* the secret key to translate.
* @return the corresponding translated key.
* @throws InvalidKeyException
* if the specified key cannot be translated using this key
* factory.
- * @since Android 1.0
*/
protected abstract SecretKey engineTranslateKey(SecretKey key)
throws InvalidKeyException;
/**
* The exception that is thrown when the result of an operation is attempted to
* store in a user provided buffer that is too small.
- *
- * @since Android 1.0
*/
public class ShortBufferException extends GeneralSecurityException {
*
* @param msg
* the exception message.
- * @since Android 1.0
*/
public ShortBufferException(String msg) {
super(msg);
/**
* Creates a new instance of {@code ShortBufferException}.
- *
- * @since Android 1.0
*/
public ShortBufferException() {
}
/**
* The interface for a Diffie-Hellman key.
- *
- * @since Android 1.0
*/
public interface DHKey {
/**
* Returns the parameters for this key.
- *
+ *
* @return the parameters for this key.
*/
public DHParameterSpec getParams();
/**
* The interface for a private key in the Diffie-Hellman key exchange protocol.
- *
- * @since Android 1.0
*/
public interface DHPrivateKey extends DHKey, PrivateKey {
import java.security.PublicKey;
/**
- * The interface for a public key in the Diffie-Hellman key exchange protocol.
- *
- * @since Android 1.0
+ * The interface for a public key in the Diffie-Hellman key exchange protocol.
*/
public interface DHPublicKey extends DHKey, PublicKey {
/**
* The interface to a <i>password-based-encryption</i> key.
- *
- * @since Android 1.0
*/
public interface PBEKey extends SecretKey {
/**
* Returns the iteration count, 0 if not specified.
- *
+ *
* @return the iteration count, 0 if not specified.
*/
public int getIterationCount();
/**
* Returns a copy of the salt data or null if not specified.
- *
+ *
* @return a copy of the salt data or null if not specified.
*/
public byte[] getSalt();
/**
* Returns a copy to the password.
- *
+ *
* @return a copy to the password.
*/
public char[] getPassword();
/**
* The key specification for a DES key.
- *
- * @since Android 1.0
*/
public class DESKeySpec implements KeySpec {
/**
* Creates a new <code>DESKeySpec</code> from the first 8 bytes of the
* specified key data.
- *
+ *
* @param key
* the key data.
* @throws InvalidKeyException
/**
* Creates a new <code>DESKeySpec</code> from the first 8 bytes of the
* specified key data starting at <code>offset</code>.
- *
+ *
* @param key
* the key data
* @param offset
/**
* Returns a copy of the key.
- *
+ *
* @return a copy of the key.
*/
public byte[] getKey() {
/**
* Returns whether the specified key data starting at <code>offset</code> is
* <i>parity-adjusted</i>.
- *
+ *
* @param key
* the key data.
* @param offset
/**
* Returns whether the specified key data starting at <code>offset</code> is
* weak or semi-weak.
- *
+ *
* @param key
* the key data.
* @param offset
/**
* The key specification for a triple-DES (DES-EDE) key.
- *
- * @since Android 1.0
*/
public class DESedeKeySpec implements KeySpec {
/**
* Creates a new <code>DESedeKeySpec</code> instance from the first 24 (
* {@link #DES_EDE_KEY_LEN}) bytes of the specified key data.
- *
+ *
* @param key
* the key data.
* @throws InvalidKeyException
* Creates a new <code>DESedeKeySpec</code> instance from the first 24 (
* {@link #DES_EDE_KEY_LEN} ) bytes of the specified key data starting at
* <code>offset</code>.
- *
+ *
* @param key
* the key data
* @param offset
/**
* Returns a copy of the key.
- *
+ *
* @return a copy of the key.
*/
public byte[] getKey() {
/**
* Returns whether the specified key data starting at <code>offset</code> is
* <i>parity-adjusted</i>.
- *
+ *
* @param key
* the key data.
* @param offset
/**
* The algorithm parameter specification for generating Diffie-Hellman
* parameters used in Diffie-Hellman key agreement.
- *
- * @since Android 1.0
*/
public class DHGenParameterSpec implements AlgorithmParameterSpec {
/**
* Creates a new <code>DHGenParameterSpec</code> instance with the specified
* parameters.
- *
+ *
* @param primeSize
* the size of the <i>prime modulus</i> in bits.
* @param exponentSize
/**
* Returns the size of the <i>prime modulus</i> in bits.
- *
+ *
* @return the size of the prime modulus in bits.
*/
public int getPrimeSize() {
/**
* Returns the size of the <i>random exponent</i> in bits.
- *
+ *
* @return the size of the random exponent in bits.
*/
public int getExponentSize() {
/**
* The algorithm parameter specification for the Diffie-Hellman algorithm.
- *
- * @since Android 1.0
*/
public class DHParameterSpec implements AlgorithmParameterSpec {
/**
* Creates a new <code>DHParameterSpec</code> instance with the specified
* <i>prime modulus</i> and <i>base generator</i>.
- *
+ *
* @param p
* the prime modulus.
* @param g
* Creates a new <code>DHParameterSpec</code> instance with the specified
* <i>prime modulus</i>, <i>base generator</i> and size (in bits) of the
* <i>random exponent</i>.
- *
+ *
* @param p
* the prime modulus.
* @param g
/**
* Returns the <i>prime modulus</i> of this parameter specification.
- *
+ *
* @return the prime modulus.
*/
public BigInteger getP() {
/**
* Returns the <i>base generator</i> of this parameter specification.
- *
+ *
* @return the base generator.
*/
public BigInteger getG() {
/**
* Returns the size (in bits) of the <i>random exponent</i>.
- *
+ *
* @return the size (in bits) of the random exponent.
*/
public int getL() {
/**
* The key specification for a Diffie-Hellman private key.
- *
- * @since Android 1.0
*/
public class DHPrivateKeySpec implements KeySpec {
* Creates a new <code>DHPrivateKeySpec</code> with the specified <i>private
* value</i> <code>x</code>. <i>prime modulus</i> <code>p</code> and <i>base
* generator</i> <code>g</code>.
- *
+ *
* @param x
* the private value.
* @param p
/**
* Returns the <i>private value</i> <code>x</code>.
- *
+ *
* @return the private value <code>x</code>.
*/
public BigInteger getX() {
/**
* Returns the <i>prime modulus</i> <code>p</code>.
- *
+ *
* @return the prime modulus <code>p</code>.
*/
public BigInteger getP() {
/**
* Returns the <i>base generator</i> <code>g</code>.
- *
+ *
* @return the base generator <code>g</code>.
*/
public BigInteger getG() {
return g;
}
}
+
/**
* The key specification for a Diffie-Hellman public key.
- *
- * @since Android 1.0
*/
public class DHPublicKeySpec implements KeySpec {
* Creates a new <code>DHPublicKeySpec</code> instance with the specified
* <i>public value</i> <code>y</code>, the <i>prime modulus</i>
* <code>p</code> and the <i>base generator</i> <code>g</code>.
- *
+ *
* @param y
* the public value.
* @param p
/**
* Returns the <i>public value</i> <code>y</code>.
- *
+ *
* @return the public value <code>y</code>.
*/
public BigInteger getY() {
/**
* Returns the <i>prime modulus</i> <code>p</code>.
- *
+ *
* @return the prime modulus <code>p</code>.
*/
public BigInteger getP() {
/**
* Returns the <i>base generator</i> <code>g</code>;
- *
+ *
* @return the base generator <code>g</code>;
*/
public BigInteger getG() {
/**
* Creates a new <code>IvParameterSpec</code> instance with the bytes from
* the specified buffer <i>iv</i> used as <i>initialization vector</i>.
- *
+ *
* @param iv
* the buffer used as initialization vector.
* @throws NullPointerException
* Creates a new <code>IvParameterSpec</code> instance with <code>len</code>
* bytes from the specified buffer <code>iv</code> starting at
* <code>offset</code>.
- *
+ *
* @param iv
* the buffer used as initialization vector.
* @param offset
/**
* Returns a copy of the <i>initialization vector</i> data.
- *
+ *
* @return a copy of the initialization vector data.
*/
public byte[] getIV() {
* <p>
* This padding algorithm is defined in the <a
* href="http://www.ietf.org/rfc/rfc3447.txt">PKCS #1</a> standard.
- *
- * @since Android 1.0
*/
public class OAEPParameterSpec implements AlgorithmParameterSpec {
* <i>message digest</i> algorithm name, <i>mask generation function</i>
* (<i>mgf</i>) algorithm name, <i>parameters</i> for the <i>mgf</i>
* algorithm and the <i>source of the label <code>L</code></i>.
- *
+ *
* @param mdName
* the message digest algorithm name.
* @param mgfName
/**
* Returns the algorithm name of the <i>message digest</i>.
- *
+ *
* @return the algorithm name of the message digest.
*/
public String getDigestAlgorithm() {
/**
* Returns the algorithm name of the <i>mask generation function</i>.
- *
+ *
* @return the algorithm name of the mask generation function.
*/
public String getMGFAlgorithm() {
/**
* Returns the algorithm parameter specification for the mask generation
* function algorithm.
- *
+ *
* @return the algorithm parameter specification for the mask generation
* function algorithm.
*/
/**
* Returns the source of the label <code>L</code>.
- *
+ *
* @return the source of the label <code>L</code>.
*/
public PSource getPSource() {
* <p>
* Password based encryption is described in <a
* href="http://www.ietf.org/rfc/rfc2898.txt">PKCS #5</a>.
- *
- * @since Android 1.0
*/
public class PBEKeySpec implements KeySpec {
/**
* Creates a new <code>PBEKeySpec</code> with the specified password.
- *
+ *
* @param password
* the password.
*/
/**
* Creates a new <code>PBEKeySpec</code> with the specified password, salt,
* iteration count and the desired length of the derived key.
- *
+ *
* @param password
* the password.
* @param salt
/**
* Creates a new <code>PBEKeySpec</code> with the specified password, salt
* and iteration count.
- *
+ *
* @param password
* the password.
* @param salt
/**
* Returns a copy of the password of this key specification.
- *
+ *
* @return a copy of the password of this key specification.
* @throws IllegalStateException
* if the password has been cleared before.
/**
* Returns a copy of the salt of this key specification.
- *
+ *
* @return a copy of the salt of this key specification or null if none is
* specified.
*/
/**
* Returns the iteration count of this key specification.
- *
+ *
* @return the iteration count of this key specification.
*/
public final int getIterationCount() {
/**
* Returns the desired key length of the derived key.
- *
+ *
* @return the desired key length of the derived key.
*/
public final int getKeyLength() {
/**
* The algorithm parameter specification for a <i>password based encryption</i>
- * algorithm.
+ * algorithm.
* <p>
* Password based encryption is described in <a
* href="http://www.ietf.org/rfc/rfc2898.txt">PKCS #5</a>.
- *
- * @since Android 1.0
*
*/
public class PBEParameterSpec implements AlgorithmParameterSpec {
/**
* Creates a new <code>PBEParameterSpec</code> with the specified salt and
* iteration count.
- *
+ *
* @param salt
* the salt.
* @param iterationCount
/**
* Returns a copy to the salt.
- *
+ *
* @return a copy to the salt.
*/
public byte[] getSalt() {
/**
* Returns the iteration count.
- *
+ *
* @return the iteration count.
*/
public int getIterationCount() {
/**
* The source of the label <code>L</code> as specified in <a
* href="http://www.ietf.org/rfc/rfc3447.txt"> PKCS #1</a>.
- *
- * @since Android 1.0
*/
public class PSource {
/**
* Creates a new <code>PSource</code> instance with the specified source
* algorithm identifier.
- *
+ *
* @param pSrcName
* the source algorithm identifier.
* @throws NullPointerException
/**
* Returns the source algorithm identifier.
- *
+ *
* @return the source algorithm identifier.
*/
public String getAlgorithm() {
/**
* The explicit specification of the parameter <code>P</code> used in the
* source algorithm.
- *
- * @since Android 1.0
*/
public static final class PSpecified extends PSource {
private final byte[] p;
/**
- * The instance of <code>PSpecified</code> with the default value <code>byte[0]</code> for <code>P</code>
+ * The instance of <code>PSpecified</code> with the default value
+ * <code>byte[0]</code> for <code>P</code>
*/
public static final PSpecified DEFAULT = new PSpecified();
/**
* Creates a new instance of <code>PSpecified</code> with the specified
* parameter <code>P</code>.
- *
+ *
* @param p
* the parameter <code>P</code>.
* @throws NullPointerException
/**
* Returns a copy of the value of the parameter <code>P</code>.
- *
+ *
* @return a copy of the value of the parameter <code>P</code>
*/
public byte[] getValue() {
/**
* The algorithm parameter specification for the <a
* href="http://www.ietf.org/rfc/rfc2268.txt">RC2</a> algorithm.
- *
- * @since Android 1.0
*/
public class RC2ParameterSpec implements AlgorithmParameterSpec {
/**
* Creates a new <code>RC2ParameterSpec</code> instance with the specified
* effective key length (in bits),
- *
+ *
* @param effectiveKeyBits
* the effective key length (in bits).
*/
* <p>
* The size of the <i>initialization vector</i> must be at least 8 bytes
* which are copied to protect them against modification.
- *
+ *
* @param effectiveKeyBits
* the effective key length (in bits).
* @param iv
* The size of the <i>initialization vector</i> starting at
* <code>offset</code> must be at least 8 bytes which are copied to protect
* them against modification.
- *
+ *
* @param effectiveKeyBits
* the effective key length (in bits).
* @param iv
/**
* Returns the effective key length (in bits).
- *
+ *
* @return the effective key length (in bits).
*/
public int getEffectiveKeyBits() {
/**
* Returns a copy of the initialization vector.
- *
+ *
* @return a copy of the initialization vector, or null if none specified.
*/
public byte[] getIV() {
/**
* Compares the specified object to this <code>RC2ParameterSpec</code>
* instance.
- *
+ *
* @param obj
* the object to compare.
* @return true if the effective key length and the initialization vector of
/**
* Returns the hash code of this <code>RC2ParameterSpec</code> instance.
- *
+ *
* @return the hash code.
*/
@Override
/**
* The algorithm parameter specification for the <a
* href="http://www.ietf.org/rfc/rfc2040.txt">RC5</a> algorithm.
- *
- * @since Android 1.0
*/
public class RC5ParameterSpec implements AlgorithmParameterSpec {
/**
* Creates a new <code>RC5ParameterSpec</code> instance with the specified
* version, round count an word size (in bits).
- *
+ *
* @param version
* the version.
* @param rounds
* The size of the <i>initialization vector</i> must be at least
* <code>2 * (wordSize / 8)</code> bytes which are copied to protect them
* against modification.
- *
+ *
* @param version
* the version.
* @param rounds
* The size of the <i>initialization vector</i> must be at least
* <code>offset + (2 * (wordSize / 8))</code> bytes. The bytes starting at
* <code>offset</code> are copied to protect them against modification.
- *
+ *
* @param version
* the version.
* @param rounds
/**
* Returns the version.
- *
+ *
* @return the version.
*/
public int getVersion() {
/**
* Returns the round count.
- *
+ *
* @return the round count.
*/
public int getRounds() {
/**
* Returns the word size (in bits).
- *
+ *
* @return the word size (in bits).
*/
public int getWordSize() {
/**
* Returns a copy of the initialization vector.
- *
+ *
* @return a copy of the initialization vector, or null if none specified.
*/
public byte[] getIV() {
/**
* Compares the specified object with this <code>RC5ParameterSpec</code>
* instance.
- *
+ *
* @param obj
* the object to compare.
* @return true if version, round count, word size and initializaion vector
/**
* Returns the hash code of this <code>RC5ParameterSpec</code> instance.
- *
+ *
* @return the hash code.
*/
@Override
* A key specification for a <code>SecretKey</code> and also a secret key
* implementation that is provider-independent. It can be used for raw secret
* keys that can be specified as <code>byte[]</code>.
- *
- * @since Android 1.0
*/
public class SecretKeySpec implements SecretKey, KeySpec, Serializable {
/**
* Creates a new <code>SecretKeySpec</code> for the specified key data and
* algorithm name.
- *
+ *
* @param key
* the key data.
* @param algorithm
* Creates a new <code>SecretKeySpec</code> for the key data from the
* specified buffer <code>key</code> starting at <code>offset</code> with
* length <code>len</code> and the specified <code>algorithm</code> name.
- *
+ *
* @param key
* the key data.
* @param offset
/**
* Returns the algorithm name.
- *
+ *
* @return the algorithm name.
*/
public String getAlgorithm() {
/**
* Returns the name of the format used to encode the key.
- *
+ *
* @return the format name "RAW".
*/
public String getFormat() {
/**
* Returns the encoded form of this secret key.
- *
+ *
* @return the encoded form of this secret key.
*/
public byte[] getEncoded() {
/**
* Returns the hash code of this <code>SecretKeySpec</code> object.
- *
+ *
* @return the hash code.
*/
@Override
/**
* Compares the specified object with this <code>SecretKeySpec</code>
* instance.
- *
+ *
* @param obj
* the object to compare.
* @return true if the algorithm name and key of both object are equal,