use of java.security.AlgorithmParameters in project robovm by robovm.
the class JCEStreamCipher method engineGetParameters.
protected AlgorithmParameters engineGetParameters() {
if (engineParams == null) {
if (pbeSpec != null) {
try {
AlgorithmParameters engineParams = AlgorithmParameters.getInstance(pbeAlgorithm, BouncyCastleProvider.PROVIDER_NAME);
engineParams.init(pbeSpec);
return engineParams;
} catch (Exception e) {
return null;
}
}
}
return engineParams;
}
use of java.security.AlgorithmParameters in project robovm by robovm.
the class myAlgPG method testAlgorithmParameterGenerator10.
/**
* Test for <code>generateParameters()</code> method
* Assertion: returns AlgorithmParameters object
*/
public void testAlgorithmParameterGenerator10() throws NoSuchAlgorithmException {
if (!DSASupported) {
fail(validAlgName + " algorithm is not supported");
return;
}
AlgorithmParameterGenerator apg = AlgorithmParameterGenerator.getInstance(validAlgName);
apg.init(512);
AlgorithmParameters ap = apg.generateParameters();
assertEquals("Incorrect algorithm", ap.getAlgorithm().toUpperCase(), apg.getAlgorithm().toUpperCase());
}
use of java.security.AlgorithmParameters in project robovm by robovm.
the class AlgorithmParameterGenerator2Test method checkResult.
private void checkResult(AlgorithmParameterGenerator algParGen) throws InvalidAlgorithmParameterException {
AlgorithmParameters param = algParGen.generateParameters();
assertNull("Not null parameters", param);
AlgorithmParameterSpec pp = null;
algParGen.init(pp, new SecureRandom());
algParGen.init(pp);
try {
algParGen.init(pp, null);
fail("IllegalArgumentException must be thrown");
} catch (IllegalArgumentException e) {
}
pp = new tmpAlgorithmParameterSpec("Proba");
algParGen.init(pp, new SecureRandom());
algParGen.init(pp);
algParGen.init(0, null);
algParGen.init(0, new SecureRandom());
try {
algParGen.init(-10, null);
fail("IllegalArgumentException must be thrown");
} catch (IllegalArgumentException e) {
}
try {
algParGen.init(-10, new SecureRandom());
fail("IllegalArgumentException must be thrown");
} catch (IllegalArgumentException e) {
}
}
use of java.security.AlgorithmParameters in project robovm by robovm.
the class AlgorithmParametersTest method testOAEPProvider.
/**
* Tests OAEP AlgorithmParameters provider
*/
public void testOAEPProvider() throws Exception {
AlgorithmParameters params = AlgorithmParameters.getInstance("OAEP");
assertEquals("Algorithm", "OAEP", params.getAlgorithm());
}
use of java.security.AlgorithmParameters in project robovm by robovm.
the class AlgorithmParametersTest method test_getParameterSpecLjava_lang_Class.
/**
* java.security.AlgorithmParameters#getParameterSpec(Class)
*/
public void test_getParameterSpecLjava_lang_Class() throws Exception {
final MyAlgorithmParameterSpec myParamSpec = new MyAlgorithmParameterSpec();
MyAlgorithmParameters paramSpi = new MyAlgorithmParameters() {
protected AlgorithmParameterSpec engineGetParameterSpec(Class paramSpec) {
return myParamSpec;
}
};
AlgorithmParameters params = new DummyAlgorithmParameters(paramSpi, p, "algorithm");
//
try {
params.getParameterSpec(null);
fail("No expected InvalidParameterSpecException");
} catch (InvalidParameterSpecException e) {
// expected
}
try {
params.getParameterSpec(MyAlgorithmParameterSpec.class);
fail("No expected InvalidParameterSpecException");
} catch (InvalidParameterSpecException e) {
// expected
}
//
// test: corresponding spi method is invoked
//
params.init(new MyAlgorithmParameterSpec());
assertSame(myParamSpec, params.getParameterSpec(MyAlgorithmParameterSpec.class));
//
// test: if paramSpec is null
// Regression test for HARMONY-2733
//
paramSpi = new MyAlgorithmParameters() {
protected AlgorithmParameterSpec engineGetParameterSpec(Class paramSpec) {
// null is passed to spi-provider
assertNull(paramSpec);
return null;
}
};
params = new DummyAlgorithmParameters(paramSpi, p, "algorithm");
params.init(new MyAlgorithmParameterSpec());
assertNull(params.getParameterSpec(null));
}
Aggregations