-
Type:
CSR
-
Resolution: Approved
-
Priority:
P4
-
Component/s: security-libs
-
None
-
behavioral
-
minimal
-
Updating the JavaDoc comment for javax.crypto.Mac.update(ByteBuffer) and javax.crypto.MacSpi.engineUpdate(ByteBuffer) methods to indicate the possibility of an IAE/NPE being thrown in certain circumstances (when the ByteBuffer argument is null).
-
Java API
-
SE
Summary
Document existing exception for the javax.crypto.Mac.update(ByteBuffer input) javax.crypto.MacSpi.engineUpdate(ByteBuffer input) methods when input parameter is null.
Problem
See Summary (above).
Solution
Add @throws to indicate that an IllegalArgumentException may be thrown for javax.crypto.Mac.update(ByteBuffer input) and NullPointerException may be thrown for javax.crypto.MacSpi.engineUpdate(ByteBuffer input). Also replaced existing @exception to @throws for both classes.
Specification
-
javax.crypto.Mac class:
@@ -421,11 +421,11 @@ /** * Initializes this {@code Mac} object with the given key. * * @param key the key. *
-
* @exception InvalidKeyException if the given key is inappropriate for
-
public final void init(Key key) throws InvalidKeyException { try { if (spi != null) { @@ -449,13 +449,13 @@ * algorithm parameters. * * @param key the key. * @param params the algorithm parameters. ** @throws InvalidKeyException if the given key is inappropriate for * initializing this MAC. */
-
* @exception InvalidKeyException if the given key is inappropriate for
-
* @throws InvalidKeyException if the given key is inappropriate for * initializing this MAC.
-
* @exception InvalidAlgorithmParameterException if the given algorithm
-
public final void init(Key key, AlgorithmParameterSpec params) throws InvalidKeyException, InvalidAlgorithmParameterException { if (spi != null) { @@ -474,11 +474,11 @@ /** * Processes the given byte. * * @param input the input byte to be processed. ** @throws InvalidAlgorithmParameterException if the given algorithm * parameters are inappropriate for this MAC. */
-
* @exception IllegalStateException if this {@code Mac} has not been
-
public final void update(byte input) throws IllegalStateException { chooseFirstProvider(); if (!initialized) { @@ -490,11 +490,11 @@ /** * Processes the given array of bytes. * * @param input the array of bytes to be processed. ** @throws IllegalStateException if this {@code Mac} has not been * initialized. */
-
* @exception IllegalStateException if this {@code Mac} has not been
-
public final void update(byte[] input) throws IllegalStateException { chooseFirstProvider(); if (!initialized) { @@ -511,11 +511,11 @@ * * @param input the input buffer. * @param offset the offset in {@code input} where the input starts. * @param len the number of bytes to process. ** @throws IllegalStateException if this {@code Mac} has not been * initialized. */
-
* @exception IllegalStateException if this {@code Mac} has not been
-
public final void update(byte[] input, int offset, int len) throws IllegalStateException { chooseFirstProvider(); @@ -536,12 +536,13 @@ * Upon return, the buffer's position will be equal to its limit; * its limit will not have changed. * * @param input the ByteBuffer ** @throws IllegalStateException if this {@code Mac} has not been * initialized. */
-
* @exception IllegalStateException if this {@code Mac} has not been
-
* @throws IllegalStateException if this {@code Mac} has not been * initialized. -
public final void update(ByteBuffer input) { chooseFirstProvider(); if (!initialized) { @@ -567,11 +568,11 @@ * it must be reinitialized via a call to {@code init(Key)} or * {@code init(Key, AlgorithmParameterSpec)}. * * @return the MAC result. ** @throws IllegalArgumentException if {@code input} is null * @since 1.5 */
-
* @exception IllegalStateException if this {@code Mac} has not been
-
public final byte[] doFinal() throws IllegalStateException { chooseFirstProvider(); if (!initialized) { @@ -601,13 +602,13 @@ * * @param output the buffer where the MAC result is stored * @param outOffset the offset in {@code output} where the MAC is * stored ** @throws IllegalStateException if this {@code Mac} has not been * initialized. */
-
* @exception ShortBufferException if the given output buffer is too small
-
* @throws ShortBufferException if the given output buffer is too small * to hold the result
-
* @exception IllegalStateException if this {@code Mac} has not been
-
public final void doFinal(byte[] output, int outOffset) throws ShortBufferException, IllegalStateException { @@ -639,11 +640,11 @@ * {@code init(Key, AlgorithmParameterSpec)}. * * @param input data in bytes * @return the MAC result. ** @throws IllegalStateException if this {@code Mac} has not been * initialized. */
-
* @exception IllegalStateException if this {@code Mac} has not been
-
public final byte[] doFinal(byte[] input) throws IllegalStateException { chooseFirstProvider(); @@ -676,11 +677,11 @@ /** * Returns a clone if the provider implementation is cloneable. * * @return a clone if the provider implementation is cloneable. ** @throws IllegalStateException if this {@code Mac} has not been * initialized. */
-
* @exception CloneNotSupportedException if this is called on a
-
public final Object clone() throws CloneNotSupportedException { chooseFirstProvider(); Mac that = (Mac)super.clone();* @throws CloneNotSupportedException if this is called on a * delegate that does not support {@code Cloneable}. */
-
-
javax.crypto.MacSpi class:
@@ -63,13 +63,13 @@ * parameters. * * @param key the (secret) key. * @param params the algorithm parameters. *
-
* @exception InvalidKeyException if the given key is inappropriate for
-
* @throws InvalidKeyException if the given key is inappropriate for * initializing this MAC.
-
* @exception InvalidAlgorithmParameterException if the given algorithm
-
protected abstract void engineInit(Key key, AlgorithmParameterSpec params) throws InvalidKeyException, InvalidAlgorithmParameterException ; @@ -99,10 +99,13 @@ * * <p>Subclasses should consider overriding this method if they can * process ByteBuffers more efficiently than byte arrays. * * @param input the ByteBuffer* @throws InvalidAlgorithmParameterException if the given algorithm * parameters are inappropriate for this MAC. */ -
* -
* @throws NullPointerException if {@code input} is null -
protected void engineUpdate(ByteBuffer input) { if (!input.hasRemaining()) { return; @@ -143,11 +146,11 @@ /** * Returns a clone if the implementation is cloneable. * * @return a clone if the implementation is cloneable. ** * @since 1.5 */
-
* @exception CloneNotSupportedException if this is called
-
public Object clone() throws CloneNotSupportedException { if (this instanceof Cloneable) { return super.clone();* @throws CloneNotSupportedException if this is called * on an implementation that does not support {@code Cloneable}. */
-
- csr of
-
JDK-6205692 (spec) javax.crypto.MacSpi.engineUpdate(ByteBuffer input): NPE should be specified
-
- Closed
-