~brian-thomason/+junk/bouncycastle

« back to all changes in this revision

Viewing changes to test/src/org/bouncycastle/crypto/test/BlowfishTest.java

  • Committer: Brian Thomason
  • Date: 2011-12-20 17:20:32 UTC
  • Revision ID: brian.thomason@canonical.com-20111220172032-rdtm13jgdxtksacr
Initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package org.bouncycastle.crypto.test;
 
2
 
 
3
import org.bouncycastle.crypto.engines.BlowfishEngine;
 
4
import org.bouncycastle.crypto.params.KeyParameter;
 
5
import org.bouncycastle.util.encoders.Hex;
 
6
import org.bouncycastle.util.test.SimpleTest;
 
7
 
 
8
/**
 
9
 * blowfish tester - vectors from http://www.counterpane.com/vectors.txt
 
10
 */
 
11
public class BlowfishTest
 
12
    extends CipherTest
 
13
{
 
14
    static SimpleTest[]  tests = 
 
15
            {
 
16
                new BlockCipherVectorTest(0, new BlowfishEngine(),
 
17
                        new KeyParameter(Hex.decode("0000000000000000")),
 
18
                        "0000000000000000", "4EF997456198DD78"),
 
19
                new BlockCipherVectorTest(1, new BlowfishEngine(),
 
20
                        new KeyParameter(Hex.decode("FFFFFFFFFFFFFFFF")),
 
21
                        "FFFFFFFFFFFFFFFF", "51866FD5B85ECB8A"),
 
22
                new BlockCipherVectorTest(2, new BlowfishEngine(),
 
23
                        new KeyParameter(Hex.decode("3000000000000000")),
 
24
                        "1000000000000001", "7D856F9A613063F2"),
 
25
                new BlockCipherVectorTest(3, new BlowfishEngine(),
 
26
                        new KeyParameter(Hex.decode("1111111111111111")),
 
27
                        "1111111111111111", "2466DD878B963C9D"),
 
28
                new BlockCipherVectorTest(4, new BlowfishEngine(),
 
29
                        new KeyParameter(Hex.decode("0123456789ABCDEF")),
 
30
                        "1111111111111111", "61F9C3802281B096"),
 
31
                new BlockCipherVectorTest(5, new BlowfishEngine(),
 
32
                        new KeyParameter(Hex.decode("FEDCBA9876543210")),
 
33
                        "0123456789ABCDEF", "0ACEAB0FC6A0A28D"),
 
34
                new BlockCipherVectorTest(6, new BlowfishEngine(),
 
35
                        new KeyParameter(Hex.decode("7CA110454A1A6E57")),
 
36
                        "01A1D6D039776742", "59C68245EB05282B"),
 
37
                new BlockCipherVectorTest(7, new BlowfishEngine(),
 
38
                        new KeyParameter(Hex.decode("0131D9619DC1376E")),
 
39
                        "5CD54CA83DEF57DA", "B1B8CC0B250F09A0"),
 
40
            };
 
41
 
 
42
    BlowfishTest()
 
43
    {
 
44
        super(tests, new BlowfishEngine(), new KeyParameter(new byte[16]));
 
45
    }
 
46
 
 
47
    public String getName()
 
48
    {
 
49
        return "Blowfish";
 
50
    }
 
51
 
 
52
    public static void main(
 
53
        String[]    args)
 
54
    {
 
55
        runTest(new BlowfishTest());
 
56
    }
 
57
}