diff options
Diffstat (limited to 'libraries/spongycastle/core/src/test/java/org/spongycastle/crypto/test/CipherTest.java')
-rw-r--r-- | libraries/spongycastle/core/src/test/java/org/spongycastle/crypto/test/CipherTest.java | 117 |
1 files changed, 0 insertions, 117 deletions
diff --git a/libraries/spongycastle/core/src/test/java/org/spongycastle/crypto/test/CipherTest.java b/libraries/spongycastle/core/src/test/java/org/spongycastle/crypto/test/CipherTest.java deleted file mode 100644 index 6bd4c21f4..000000000 --- a/libraries/spongycastle/core/src/test/java/org/spongycastle/crypto/test/CipherTest.java +++ /dev/null @@ -1,117 +0,0 @@ -package org.spongycastle.crypto.test; - -import org.spongycastle.crypto.BlockCipher; -import org.spongycastle.crypto.DataLengthException; -import org.spongycastle.crypto.params.KeyParameter; -import org.spongycastle.util.test.SimpleTest; - -public abstract class CipherTest - extends SimpleTest -{ - private SimpleTest[] _tests; - private BlockCipher _engine; - private KeyParameter _validKey; - -// protected CipherTest( -// SimpleTest[] tests) -// { -// _tests = tests; -// } - - protected CipherTest( - SimpleTest[] tests, - BlockCipher engine, - KeyParameter validKey) - { - _tests = tests; - _engine = engine; - _validKey = validKey; - } - - public abstract String getName(); - - public void performTest() - throws Exception - { - for (int i = 0; i != _tests.length; i++) - { - _tests[i].performTest(); - } - - if (_engine != null) - { - // - // state tests - // - byte[] buf = new byte[128]; - - try - { - _engine.processBlock(buf, 0, buf, 0); - - fail("failed initialisation check"); - } - catch (IllegalStateException e) - { - // expected - } - - bufferSizeCheck((_engine)); - } - } - - private void bufferSizeCheck( - BlockCipher engine) - { - byte[] correctBuf = new byte[engine.getBlockSize()]; - byte[] shortBuf = new byte[correctBuf.length / 2]; - - engine.init(true, _validKey); - - try - { - engine.processBlock(shortBuf, 0, correctBuf, 0); - - fail("failed short input check"); - } - catch (DataLengthException e) - { - // expected - } - - try - { - engine.processBlock(correctBuf, 0, shortBuf, 0); - - fail("failed short output check"); - } - catch (DataLengthException e) - { - // expected - } - - engine.init(false, _validKey); - - try - { - engine.processBlock(shortBuf, 0, correctBuf, 0); - - fail("failed short input check"); - } - catch (DataLengthException e) - { - // expected - } - - try - { - engine.processBlock(correctBuf, 0, shortBuf, 0); - - fail("failed short output check"); - } - catch (DataLengthException e) - { - // expected - } - } -} |