use of java.security.spec.InvalidParameterSpecException in project j2objc by google.
the class AlgorithmParameters method init.
/**
* Initializes this parameter object using the parameters
* specified in <code>paramSpec</code>.
*
* @param paramSpec the parameter specification.
*
* @exception InvalidParameterSpecException if the given parameter
* specification is inappropriate for the initialization of this parameter
* object, or if this parameter object has already been initialized.
*/
public final void init(AlgorithmParameterSpec paramSpec) throws InvalidParameterSpecException {
if (this.initialized)
throw new InvalidParameterSpecException("already initialized");
paramSpi.engineInit(paramSpec);
this.initialized = true;
}
use of java.security.spec.InvalidParameterSpecException in project platform_frameworks_base by android.
the class AndroidKeyStoreUnauthenticatedAESCipherSpi method initAlgorithmSpecificParameters.
@Override
protected final void initAlgorithmSpecificParameters(AlgorithmParameters params) throws InvalidAlgorithmParameterException {
if (!mIvRequired) {
if (params != null) {
throw new InvalidAlgorithmParameterException("Unsupported parameters: " + params);
}
return;
}
// IV is used
if (params == null) {
if (!isEncrypting()) {
// IV must be provided by the caller
throw new InvalidAlgorithmParameterException("IV required when decrypting" + ". Use IvParameterSpec or AlgorithmParameters to provide it.");
}
return;
}
if (!"AES".equalsIgnoreCase(params.getAlgorithm())) {
throw new InvalidAlgorithmParameterException("Unsupported AlgorithmParameters algorithm: " + params.getAlgorithm() + ". Supported: AES");
}
IvParameterSpec ivSpec;
try {
ivSpec = params.getParameterSpec(IvParameterSpec.class);
} catch (InvalidParameterSpecException e) {
if (!isEncrypting()) {
// IV must be provided by the caller
throw new InvalidAlgorithmParameterException("IV required when decrypting" + ", but not found in parameters: " + params, e);
}
mIv = null;
return;
}
mIv = ivSpec.getIV();
if (mIv == null) {
throw new InvalidAlgorithmParameterException("Null IV in AlgorithmParameters");
}
}
use of java.security.spec.InvalidParameterSpecException in project robovm by robovm.
the class InvalidParameterSpecExceptionTest method testInvalidParameterSpecException03.
/**
* Test for <code>InvalidParameterSpecException(String)</code> constructor
* Assertion: constructs InvalidParameterSpecException when <code>msg</code>
* is null
*/
public void testInvalidParameterSpecException03() {
String msg = null;
InvalidParameterSpecException tE = new InvalidParameterSpecException(msg);
assertNull("getMessage() must return null.", tE.getMessage());
assertNull("getCause() must return null", tE.getCause());
}
use of java.security.spec.InvalidParameterSpecException in project robovm by robovm.
the class InvalidParameterSpecExceptionTest method testInvalidParameterSpecException02.
/**
* Test for <code>InvalidParameterSpecException(String)</code> constructor
* Assertion: constructs InvalidParameterSpecException with detail message
* msg. Parameter <code>msg</code> is not null.
*/
public void testInvalidParameterSpecException02() {
InvalidParameterSpecException tE;
for (int i = 0; i < msgs.length; i++) {
tE = new InvalidParameterSpecException(msgs[i]);
assertEquals("getMessage() must return: ".concat(msgs[i]), tE.getMessage(), msgs[i]);
assertNull("getCause() must return null", tE.getCause());
}
}
use of java.security.spec.InvalidParameterSpecException in project android_frameworks_base by DirtyUnicorns.
the class AndroidKeyStoreUnauthenticatedAESCipherSpi method initAlgorithmSpecificParameters.
@Override
protected final void initAlgorithmSpecificParameters(AlgorithmParameters params) throws InvalidAlgorithmParameterException {
if (!mIvRequired) {
if (params != null) {
throw new InvalidAlgorithmParameterException("Unsupported parameters: " + params);
}
return;
}
// IV is used
if (params == null) {
if (!isEncrypting()) {
// IV must be provided by the caller
throw new InvalidAlgorithmParameterException("IV required when decrypting" + ". Use IvParameterSpec or AlgorithmParameters to provide it.");
}
return;
}
if (!"AES".equalsIgnoreCase(params.getAlgorithm())) {
throw new InvalidAlgorithmParameterException("Unsupported AlgorithmParameters algorithm: " + params.getAlgorithm() + ". Supported: AES");
}
IvParameterSpec ivSpec;
try {
ivSpec = params.getParameterSpec(IvParameterSpec.class);
} catch (InvalidParameterSpecException e) {
if (!isEncrypting()) {
// IV must be provided by the caller
throw new InvalidAlgorithmParameterException("IV required when decrypting" + ", but not found in parameters: " + params, e);
}
mIv = null;
return;
}
mIv = ivSpec.getIV();
if (mIv == null) {
throw new InvalidAlgorithmParameterException("Null IV in AlgorithmParameters");
}
}
Aggregations