use of org.apache.harmony.crypto.tests.support.MyExemptionMechanismSpi in project robovm by robovm.
the class ExemptionMechanismTest method test_getOutputSizeI.
public void test_getOutputSizeI() throws Exception {
Provider mProv = (new SpiEngUtils()).new MyProvider("MyExMechProvider", "Provider for ExemptionMechanism testing", srvExemptionMechanism.concat(".").concat(defaultAlg), ExemptionMechanismProviderClass);
ExemptionMechanism em = new ExemptionMechanism(new MyExemptionMechanismSpi(), mProv, defaultAlg) {
};
Key key = new MyExemptionMechanismSpi().new tmpKey("Proba", new byte[0]);
try {
em.getOutputSize(10);
fail("IllegalStateException expected");
} catch (IllegalStateException e) {
//failed
}
em.init(key);
assertEquals(10, em.getOutputSize(10));
}
use of org.apache.harmony.crypto.tests.support.MyExemptionMechanismSpi in project robovm by robovm.
the class ExemptionMechanismTest method test_initLjava_security_KeyLjava_security_spec_AlgorithmParameterSpec.
public void test_initLjava_security_KeyLjava_security_spec_AlgorithmParameterSpec() throws Exception {
Provider mProv = (new SpiEngUtils()).new MyProvider("MyExMechProvider", "Provider for ExemptionMechanism testing", srvExemptionMechanism.concat(".").concat(defaultAlg), ExemptionMechanismProviderClass);
ExemptionMechanism em = new ExemptionMechanism(new MyExemptionMechanismSpi(), mProv, defaultAlg) {
};
Key key = new MyExemptionMechanismSpi().new tmpKey("Proba", new byte[0]);
em.init(key, new RSAKeyGenParameterSpec(10, new BigInteger("10")));
try {
em.init(key, (AlgorithmParameterSpec) null);
fail("InvalidAlgorithmParameterException expected");
} catch (InvalidAlgorithmParameterException e) {
//expected
}
KeyGenerator kg = KeyGenerator.getInstance("DES");
kg.init(56, new SecureRandom());
key = kg.generateKey();
try {
em.init(null, new RSAKeyGenParameterSpec(10, new BigInteger("10")));
fail("InvalidKeyException expected");
} catch (InvalidKeyException e) {
//expected
}
try {
em.init(key, new RSAKeyGenParameterSpec(10, new BigInteger("10")));
fail("ExemptionMechanismException expected");
} catch (ExemptionMechanismException e) {
//expected
}
}
use of org.apache.harmony.crypto.tests.support.MyExemptionMechanismSpi in project robovm by robovm.
the class ExemptionMechanismTest method test_getName.
public void test_getName() throws Exception {
Provider mProv = (new SpiEngUtils()).new MyProvider("MyExMechProvider", "Provider for ExemptionMechanism testing", srvExemptionMechanism.concat(".").concat(defaultAlg), ExemptionMechanismProviderClass);
ExemptionMechanism em = new ExemptionMechanism(new MyExemptionMechanismSpi(), mProv, defaultAlg) {
};
Key key = new MyExemptionMechanismSpi().new tmpKey("Proba", new byte[0]);
assertEquals(defaultAlg, em.getName());
}
use of org.apache.harmony.crypto.tests.support.MyExemptionMechanismSpi in project robovm by robovm.
the class ExemptionMechanismTest method test_initLjava_security_Key.
public void test_initLjava_security_Key() throws Exception {
Provider mProv = (new SpiEngUtils()).new MyProvider("MyExMechProvider", "Provider for ExemptionMechanism testing", srvExemptionMechanism.concat(".").concat(defaultAlg), ExemptionMechanismProviderClass);
ExemptionMechanism em = new ExemptionMechanism(new MyExemptionMechanismSpi(), mProv, defaultAlg) {
};
Key key = new MyExemptionMechanismSpi().new tmpKey("Proba", new byte[0]);
em.init(key);
KeyGenerator kg = KeyGenerator.getInstance("DES");
kg.init(56, new SecureRandom());
key = kg.generateKey();
try {
em.init(null);
fail("InvalidKeyException expected");
} catch (InvalidKeyException e) {
//expected
}
try {
em.init(key);
fail("ExemptionMechanismException expected");
} catch (ExemptionMechanismException e) {
//expected
}
}
use of org.apache.harmony.crypto.tests.support.MyExemptionMechanismSpi in project robovm by robovm.
the class ExemptionMechanismTest method testGenExemptionBlob.
/**
* Test for <code>genExemptionBlob((byte[] output, int outputOffset)</code> method
*/
public void testGenExemptionBlob() throws Exception {
//Regression for HARMONY-1029
Provider mProv = (new SpiEngUtils()).new MyProvider("MyExMechProvider", "Provider for ExemptionMechanism testing", srvExemptionMechanism.concat(".").concat(defaultAlg), ExemptionMechanismProviderClass);
ExemptionMechanism em = new ExemptionMechanism(new MyExemptionMechanismSpi(), mProv, defaultAlg) {
};
Key key = new MyExemptionMechanismSpi().new tmpKey("Proba", new byte[0]);
em.init(key);
// ExemptionMechanism doesn't check parameters
// it is a responsibility of ExemptionMechanismSpi
em.genExemptionBlob(null, 0);
em.genExemptionBlob(new byte[0], 0);
em.genExemptionBlob(new byte[10], -5);
}
Aggregations