Welcome to mirror list, hosted at ThFree Co, Russian Federation.

RC2Test.java « test « crypto « bouncycastle « org « java « test « src « core - gitlab.com/quite/humla-spongycastle.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3c4e569bb8d85eea3c5b354bf335fa0f8210e22f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package org.bouncycastle.crypto.test;

import org.bouncycastle.crypto.engines.RC2Engine;
import org.bouncycastle.crypto.params.KeyParameter;
import org.bouncycastle.crypto.params.RC2Parameters;
import org.bouncycastle.util.encoders.Hex;

/**
 * RC2 tester - vectors from  ftp://ftp.isi.edu/in-notes/rfc2268.txt
 *
 * RFC 2268 "A Description of the RC2(r) Encryption Algorithm"
 */
public class RC2Test
    extends CipherTest
{
    static BlockCipherVectorTest[] tests =
    {
        new BlockCipherVectorTest(0, new RC2Engine(),
                new RC2Parameters(Hex.decode("0000000000000000"), 63),
                "0000000000000000", "ebb773f993278eff"),

        new BlockCipherVectorTest(1, new RC2Engine(),
                new RC2Parameters(Hex.decode("ffffffffffffffff"), 64),
                "ffffffffffffffff", "278b27e42e2f0d49"),

        new BlockCipherVectorTest(2, new RC2Engine(),
                new RC2Parameters(Hex.decode("3000000000000000"), 64),
                "1000000000000001", "30649edf9be7d2c2"),

        new BlockCipherVectorTest(3, new RC2Engine(),
                new RC2Parameters(Hex.decode("88"), 64),
                "0000000000000000", "61a8a244adacccf0"),

        new BlockCipherVectorTest(4, new RC2Engine(),
                new RC2Parameters(Hex.decode("88bca90e90875a"), 64),
                "0000000000000000", "6ccf4308974c267f"),

        new BlockCipherVectorTest(5, new RC2Engine(),
                new RC2Parameters(Hex.decode("88bca90e90875a7f0f79c384627bafb2"), 64),
                "0000000000000000", "1a807d272bbe5db1"),

        new BlockCipherVectorTest(6, new RC2Engine(),
                new RC2Parameters(Hex.decode("88bca90e90875a7f0f79c384627bafb2"), 128),
                "0000000000000000", "2269552ab0f85ca6"),

        new BlockCipherVectorTest(7, new RC2Engine(),
                new RC2Parameters(Hex.decode("88bca90e90875a7f0f79c384627bafb216f80a6f85920584c42fceb0be255daf1e"), 129),
                "0000000000000000", "5b78d3a43dfff1f1")
    };

    RC2Test()
    {
        super(tests, new RC2Engine(), new KeyParameter(new byte[16]));
    }

    public String getName()
    {
        return "RC2";
    }

    public static void main(
        String[]    args)
    {
        runTest(new RC2Test());
    }
}