Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.bouncycastle.crypto.test;
 
a basic test that takes a cipher, key parameter, and an input and output string. This test wraps the engine in a buffered block cipher with padding disabled.
    extends SimpleTest
    int                 id;
    BlockCipher         engine;
    CipherParameters    param;
    byte[]              input;
    byte[]              output;
    public BlockCipherVectorTest(
        int                 id,
        BlockCipher         engine,
        CipherParameters    param,
        String              input,
        String              output)
    {
        this. = id;
        this. = engine;
        this. = param;
        this. = Hex.decode(input);
        this. = Hex.decode(output);
    }
    public String getName()
    {
        return .getAlgorithmName() + " Vector Test " + ;
    }
    public void performTest()
        throws Exception
    {
        BufferedBlockCipher cipher = new BufferedBlockCipher();
        cipher.init(true);
        byte[]  out = new byte[.];
        int len1 = cipher.processBytes(, 0, .out, 0);
        cipher.doFinal(outlen1);
        if (!areEqual(out))
        {
            fail("failed - " + "expected " + new String(Hex.encode()) + " got " + new String(Hex.encode(out)));
        }
        cipher.init(false);
        int len2 = cipher.processBytes(, 0, .out, 0);
        cipher.doFinal(outlen2);
        if (!areEqual(out))
        {
            fail("failed reversal got " + new String(Hex.encode(out)));
        }
    }
New to GrepCode? Check out our FAQ X