Mercurial > hg > shenandoah-preopenjdk-archive > openjdk8 > jdk
changeset 7276:918d9ac17740
6750584: Cipher.wrap/unwrap methods should define UnsupportedOperationException
Reviewed-by: mullan
author | ascarpino |
---|---|
date | Thu, 30 May 2013 14:11:32 -0700 |
parents | 6cb09d3cd309 |
children | b47044426bcd |
files | src/share/classes/javax/crypto/Cipher.java src/share/classes/javax/crypto/CipherSpi.java |
diffstat | 2 files changed, 44 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/share/classes/javax/crypto/Cipher.java Wed May 29 20:54:43 2013 -0700 +++ b/src/share/classes/javax/crypto/Cipher.java Thu May 30 14:11:32 2013 -0700 @@ -1158,6 +1158,9 @@ * determined from the given key, or if the given key has a keysize that * exceeds the maximum allowable keysize (as determined from the * configured jurisdiction policy files). + * @throws UnsupportedOperationException if (@code opmode} is + * {@code WRAP_MODE} or {@code UNWRAP_MODE} but the mode is not implemented + * by the underlying {@code CipherSpi}. */ public final void init(int opmode, Key key) throws InvalidKeyException { init(opmode, key, JceSecurity.RANDOM); @@ -1208,6 +1211,9 @@ * determined from the given key, or if the given key has a keysize that * exceeds the maximum allowable keysize (as determined from the * configured jurisdiction policy files). + * @throws UnsupportedOperationException if (@code opmode} is + * {@code WRAP_MODE} or {@code UNWRAP_MODE} but the mode is not implemented + * by the underlying {@code CipherSpi}. */ public final void init(int opmode, Key key, SecureRandom random) throws InvalidKeyException @@ -1285,6 +1291,9 @@ * algorithm parameters imply a cryptographic strength that would exceed * the legal limits (as determined from the configured jurisdiction * policy files). + * @throws UnsupportedOperationException if (@code opmode} is + * {@code WRAP_MODE} or {@code UNWRAP_MODE} but the mode is not implemented + * by the underlying {@code CipherSpi}. */ public final void init(int opmode, Key key, AlgorithmParameterSpec params) throws InvalidKeyException, InvalidAlgorithmParameterException @@ -1343,6 +1352,9 @@ * algorithm parameters imply a cryptographic strength that would exceed * the legal limits (as determined from the configured jurisdiction * policy files). + * @throws UnsupportedOperationException if (@code opmode} is + * {@code WRAP_MODE} or {@code UNWRAP_MODE} but the mode is not implemented + * by the underlying {@code CipherSpi}. */ public final void init(int opmode, Key key, AlgorithmParameterSpec params, SecureRandom random) @@ -1416,6 +1428,9 @@ * algorithm parameters imply a cryptographic strength that would exceed * the legal limits (as determined from the configured jurisdiction * policy files). + * @throws UnsupportedOperationException if (@code opmode} is + * {@code WRAP_MODE} or {@code UNWRAP_MODE} but the mode is not implemented + * by the underlying {@code CipherSpi}. */ public final void init(int opmode, Key key, AlgorithmParameters params) throws InvalidKeyException, InvalidAlgorithmParameterException @@ -1474,6 +1489,9 @@ * algorithm parameters imply a cryptographic strength that would exceed * the legal limits (as determined from the configured jurisdiction * policy files). + * @throws UnsupportedOperationException if (@code opmode} is + * {@code WRAP_MODE} or {@code UNWRAP_MODE} but the mode is not implemented + * by the underlying {@code CipherSpi}. */ public final void init(int opmode, Key key, AlgorithmParameters params, SecureRandom random) @@ -1552,6 +1570,9 @@ * in the given certificate has a keysize that exceeds the maximum * allowable keysize (as determined by the configured jurisdiction policy * files). + * @throws UnsupportedOperationException if (@code opmode} is + * {@code WRAP_MODE} or {@code UNWRAP_MODE} but the mode is not implemented + * by the underlying {@code CipherSpi}. */ public final void init(int opmode, Certificate certificate) throws InvalidKeyException @@ -1619,6 +1640,9 @@ * in the given certificate has a keysize that exceeds the maximum * allowable keysize (as determined by the configured jurisdiction policy * files). + * @throws UnsupportedOperationException if (@code opmode} is + * {@code WRAP_MODE} or {@code UNWRAP_MODE} but the mode is not implemented + * by the underlying {@code CipherSpi}. */ public final void init(int opmode, Certificate certificate, SecureRandom random) @@ -2410,6 +2434,9 @@ * @exception InvalidKeyException if it is impossible or unsafe to * wrap the key with this cipher (e.g., a hardware protected key is * being passed to a software-only cipher). + * + * @throws UnsupportedOperationException if the corresponding method in the + * {@code CipherSpi} is not supported. */ public final byte[] wrap(Key key) throws IllegalBlockSizeException, InvalidKeyException { @@ -2451,6 +2478,9 @@ * @exception InvalidKeyException if <code>wrappedKey</code> does not * represent a wrapped key of type <code>wrappedKeyType</code> for * the <code>wrappedKeyAlgorithm</code>. + * + * @throws UnsupportedOperationException if the corresponding method in the + * {@code CipherSpi} is not supported. */ public final Key unwrap(byte[] wrappedKey, String wrappedKeyAlgorithm,
--- a/src/share/classes/javax/crypto/CipherSpi.java Wed May 29 20:54:43 2013 -0700 +++ b/src/share/classes/javax/crypto/CipherSpi.java Thu May 30 14:11:32 2013 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -347,6 +347,9 @@ * initializing this cipher, or requires * algorithm parameters that cannot be * determined from the given key. + * @throws UnsupportedOperationException if {@code opmode} is + * {@code WRAP_MODE} or {@code UNWRAP_MODE} is not implemented + * by the cipher. */ protected abstract void engineInit(int opmode, Key key, SecureRandom random) @@ -399,6 +402,9 @@ * parameters are inappropriate for this cipher, * or if this cipher requires * algorithm parameters and <code>params</code> is null. + * @throws UnsupportedOperationException if {@code opmode} is + * {@code WRAP_MODE} or {@code UNWRAP_MODE} is not implemented + * by the cipher. */ protected abstract void engineInit(int opmode, Key key, AlgorithmParameterSpec params, @@ -452,6 +458,9 @@ * parameters are inappropriate for this cipher, * or if this cipher requires * algorithm parameters and <code>params</code> is null. + * @throws UnsupportedOperationException if {@code opmode} is + * {@code WRAP_MODE} or {@code UNWRAP_MODE} is not implemented + * by the cipher. */ protected abstract void engineInit(int opmode, Key key, AlgorithmParameters params, @@ -863,6 +872,8 @@ * @exception InvalidKeyException if it is impossible or unsafe to * wrap the key with this cipher (e.g., a hardware protected key is * being passed to a software-only cipher). + * + * @throws UnsupportedOperationException if this method is not supported. */ protected byte[] engineWrap(Key key) throws IllegalBlockSizeException, InvalidKeyException @@ -899,6 +910,8 @@ * @exception InvalidKeyException if <code>wrappedKey</code> does not * represent a wrapped key of type <code>wrappedKeyType</code> for * the <code>wrappedKeyAlgorithm</code>. + * + * @throws UnsupportedOperationException if this method is not supported. */ protected Key engineUnwrap(byte[] wrappedKey, String wrappedKeyAlgorithm,