001: package org.bouncycastle.crypto.test;
002:
003: import org.bouncycastle.crypto.engines.CamelliaEngine;
004: import org.bouncycastle.crypto.params.KeyParameter;
005: import org.bouncycastle.util.encoders.Hex;
006: import org.bouncycastle.util.test.SimpleTest;
007: import org.bouncycastle.util.test.TestResult;
008:
009: /**
010: * Camellia tester - vectors from https://www.cosic.esat.kuleuven.be/nessie/testvectors/ and RFC 3713
011: */
012: public class CamelliaTest extends CipherTest {
013: static SimpleTest[] tests = {
014: new BlockCipherVectorTest(
015: 0,
016: new CamelliaEngine(),
017: new KeyParameter(Hex
018: .decode("00000000000000000000000000000000")),
019: "80000000000000000000000000000000",
020: "07923A39EB0A817D1C4D87BDB82D1F1C"),
021: new BlockCipherVectorTest(
022: 1,
023: new CamelliaEngine(),
024: new KeyParameter(Hex
025: .decode("80000000000000000000000000000000")),
026: "00000000000000000000000000000000",
027: "6C227F749319A3AA7DA235A9BBA05A2C"),
028: new BlockCipherVectorTest(
029: 2,
030: new CamelliaEngine(),
031: new KeyParameter(Hex
032: .decode("0123456789abcdeffedcba9876543210")),
033: "0123456789abcdeffedcba9876543210",
034: "67673138549669730857065648eabe43"),
035: //
036: // 192 bit
037: //
038: new BlockCipherVectorTest(
039: 3,
040: new CamelliaEngine(),
041: new KeyParameter(
042: Hex
043: .decode("0123456789abcdeffedcba98765432100011223344556677")),
044: "0123456789abcdeffedcba9876543210",
045: "b4993401b3e996f84ee5cee7d79b09b9"),
046: new BlockCipherVectorTest(
047: 4,
048: new CamelliaEngine(),
049: new KeyParameter(
050: Hex
051: .decode("000000000000000000000000000000000000000000000000")),
052: "00040000000000000000000000000000",
053: "9BCA6C88B928C1B0F57F99866583A9BC"),
054: new BlockCipherVectorTest(
055: 5,
056: new CamelliaEngine(),
057: new KeyParameter(
058: Hex
059: .decode("949494949494949494949494949494949494949494949494")),
060: "636EB22D84B006381235641BCF0308D2",
061: "94949494949494949494949494949494"),
062: //
063: // 256 bit
064: //
065: new BlockCipherVectorTest(
066: 6,
067: new CamelliaEngine(),
068: new KeyParameter(
069: Hex
070: .decode("0123456789abcdeffedcba987654321000112233445566778899aabbccddeeff")),
071: "0123456789abcdeffedcba9876543210",
072: "9acc237dff16d76c20ef7c919e3a7509"),
073: new BlockCipherVectorTest(
074: 7,
075: new CamelliaEngine(),
076: new KeyParameter(
077: Hex
078: .decode("4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A")),
079: "057764FE3A500EDBD988C5C3B56CBA9A",
080: "4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A"),
081: new BlockCipherVectorTest(
082: 8,
083: new CamelliaEngine(),
084: new KeyParameter(
085: Hex
086: .decode("0303030303030303030303030303030303030303030303030303030303030303")),
087: "7968B08ABA92193F2295121EF8D75C8A",
088: "03030303030303030303030303030303"), };
089:
090: CamelliaTest() {
091: super (tests, new CamelliaEngine(), new KeyParameter(
092: new byte[32]));
093: }
094:
095: public String getName() {
096: return "Camellia";
097: }
098:
099: public static void main(String[] args) {
100: CamelliaTest test = new CamelliaTest();
101: TestResult result = test.perform();
102:
103: System.out.println(result);
104: }
105: }
|