Commit 1b74de0d authored by Kenny Root's avatar Kenny Root Committed by Android Git Automerger
Browse files

am c176521c: Merge "CipherTest: add tests for null parameters in init"

* commit 'c176521c':
  CipherTest: add tests for null parameters in init
parents f36ad155 c176521c
......@@ -895,6 +895,8 @@ public final class CipherTest extends TestCase {
}
}
test_Cipher_init_NullParameters(c, encryptMode, encryptKey);
c.init(encryptMode, encryptKey, encryptSpec);
assertEquals(cipherID + " getBlockSize() encryptMode",
getExpectedBlockSize(algorithm, encryptMode, providerName), c.getBlockSize());
......@@ -985,6 +987,45 @@ public final class CipherTest extends TestCase {
}
}
/**
* Try various .init(...) calls with null parameters to make sure it is
* handled.
*/
private void test_Cipher_init_NullParameters(Cipher c, int encryptMode, Key encryptKey)
throws Exception {
try {
c.init(encryptMode, encryptKey, (AlgorithmParameterSpec) null);
} catch (InvalidAlgorithmParameterException e) {
if (!isPBE(c.getAlgorithm())) {
throw e;
}
}
try {
c.init(encryptMode, encryptKey, (AlgorithmParameterSpec) null, (SecureRandom) null);
} catch (InvalidAlgorithmParameterException e) {
if (!isPBE(c.getAlgorithm())) {
throw e;
}
}
try {
c.init(encryptMode, encryptKey, (AlgorithmParameters) null);
} catch (InvalidAlgorithmParameterException e) {
if (!isPBE(c.getAlgorithm())) {
throw e;
}
}
try {
c.init(encryptMode, encryptKey, (AlgorithmParameters) null, (SecureRandom) null);
} catch (InvalidAlgorithmParameterException e) {
if (!isPBE(c.getAlgorithm())) {
throw e;
}
}
}
public void testInputPKCS1Padding() throws Exception {
for (String provider : RSA_PROVIDERS) {
testInputPKCS1Padding(provider);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment