Exemplo n.º 1
0
        public void KSubkeys_CalculatesKSubkeys256Bits_Calculated()
        {
            SerpentKey key = new SerpentKey(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2 });

            uint[] expectedK =
            {
                0x9CC4EFD9, 0xBCDA4067, 0x42A8336B, 0x659DC341, 0xE414CC38,  0xB622948, 0x9584ED73, 0x3E9FAAFC, 0xDC8C7121,
                0x8367EDB1, 0xF1B5DF70, 0x3F2AE123, 0x3479363C, 0x8B0D25F6, 0xF1315832, 0xAA85A420, 0xF7D88434, 0x2D1199D5,
                0x73EA9677, 0x9A2AB600, 0x3BE1585A, 0x8F7FF83A, 0x7D8EF79E, 0xE42E6852, 0x7ED807A6, 0x4921FD66, 0xCB0C7D26,
                0x8A669379, 0x6792D710, 0x54D21B48, 0xA54F1C80, 0x29186AF9, 0x347438A5, 0x82CFF33F, 0x2923FAF6, 0xC1FB406F,
                0xBB99C1BA, 0x34F3536C, 0x6FED5707, 0xA9BA8636, 0x3B34344C, 0x49039573, 0xDAA7BCCD, 0x4815A8E9, 0xC833FFC1,
                0x8B0C16E1, 0x71653D00, 0xC80B3C39, 0x5D129D64, 0xDEEDD92C, 0x155CE281, 0x429D8B39, 0x9EB866DC, 0x4E421839,
                0x566D0460, 0x392E0B99, 0x959FCA48, 0xB8F8552A, 0x805929E5, 0x5EFD9EFA,  0xE606233, 0x1A16AA3C, 0x8C693440,
                0x2DF88221, 0x6A3BABFF, 0x801FA722, 0xE8D97C77, 0xE9838279, 0xEA20C2D9, 0x2E7A1988, 0x950D5A29, 0x5345C44E,
                0x81A86840, 0xEFD55318, 0xB2DA3282, 0x24663BAA, 0xD22C1D46, 0x82597CF8, 0x1685D3E8, 0x55665496, 0xD060EF15,
                0x8FC2A54,  0xBE2DD2A1,   0x9209B1, 0xF863CDBA, 0xF3D219E0, 0x52D08424, 0xA93E5012, 0x7D58072B, 0xFEBD6C91,
                0xC4649294, 0x8E824297, 0x10D585FE, 0xEA7EFE7E, 0x43135043, 0xDAD8E404, 0x958081B8, 0xA5305A66, 0xDEE56CEE,
                0x7C7C3588, 0x61DFCA93, 0x1BC70D34, 0xBD810B47, 0x53EA17F8, 0x6DDEE585, 0x361B95BD, 0x3EDE4C01, 0x411D4B00,
                0x2CE208B2, 0x92BE6B0C, 0xAD558406, 0x13653D37, 0x77105DDE, 0x1FD6D002, 0x19D5BA51, 0x1E1BE5AA, 0xB43798AB,
                0xA6FA439A, 0x764F63D6, 0x466AFA05, 0x9E40FA68, 0x700F1446,  0xA352FB3, 0x91BCC831, 0x179C6B56, 0x55B6B9F1,
                0x86DAAFF6, 0xF471154D, 0x2305036C, 0xD017F429, 0x891B7EFE, 0x7F809F02,
            };
            for (int i = 0; i < 33; i++)
            {
                Assert.AreEqual(expectedK[i * 4], key.K[i].W0);
                Assert.AreEqual(expectedK[i * 4 + 1], key.K[i].W1);
                Assert.AreEqual(expectedK[i * 4 + 2], key.K[i].W2);
                Assert.AreEqual(expectedK[i * 4 + 3], key.K[i].W3);
            }
        }
Exemplo n.º 2
0
        public void KSubkeys_CalculatesKSubkeys128Bits_Calculated()
        {
            SerpentKey key = new SerpentKey(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6 });

            uint[] expectedK =
            {
                0xA2EF541D, 0xC449F386, 0xEC53B8B8, 0x81C197D5,   0x176BA1, 0xB8358A0D, 0x60C0A564, 0x60F5C236, 0xC04D4EC5,
                0xA450E07E, 0x965A7EC5, 0xDFA51182, 0xF4E4CAA4,  0x4E41940, 0x7CCB58F2, 0xBEA3C180, 0x40ED2082, 0x37F5B486,
                0xA6DD6C3F, 0x554E7891,  0x2D5CABB, 0x4623C4F2, 0x31C5FA32, 0x2FEEB1E1,  0x9B4D3D2, 0x9CF2F5A5, 0xADF1461C,
                0x4D03997D, 0xE10FEE3C,  0xF1309EE, 0x5767BA98, 0x12F97C79, 0x216AEFF9, 0xCA0414B4, 0x2612F173, 0x4776FB2B,
                0xB24388B1, 0x1E3F1F59, 0x26E08461, 0x9AB04177, 0xF2249B91, 0xD0650A8C,  0xD74B56C, 0x2A580957, 0x4ABECE61,
                0x79533FB8, 0xBF79B93B, 0xA3F29A37, 0x7AFFC9D8, 0xFBF9E56D,  0x1F472B7, 0xF8601142, 0x7E84A5EA, 0x5F3194AD,
                0x3711DD01, 0xAE0785D5, 0x983DDA3B, 0x698E2FE9, 0xF8D02B32, 0x49782D4F, 0xB5619BEB, 0xF497DA9B, 0x568D6A8D,
                0xEA8099E5, 0xC85A284F, 0x74942A27, 0x46955156, 0xEE2EFE58, 0x4DA6AAC6, 0x466B252E, 0xCA4C83B8, 0x469B12BF,
                0x504704CB, 0x4A774BA1, 0x599D351B, 0xBDA750CD, 0xB2E167E5, 0xC1F1AE2F, 0x6D1C4A58, 0x1CBFB63C, 0xD8A5945F,
                0xF2EA7789, 0x4B97F002, 0x214A5797, 0x2EFB83CC, 0xC112C633, 0x7D910E46, 0x5E461CBE, 0xE20C1D5E, 0x915238D4,
                0x4D20DB14, 0xE8C4C03D, 0xC72F5BAF, 0xB4ED98EA, 0xD21FF0C6, 0x41C0B964, 0xBB73830A, 0xC787DFC2, 0x98BD0B26,
                0xA4064FEC, 0x568E8306, 0xBD392FF9, 0x9BDAA879, 0xA63755DB, 0xF962A2A7, 0x63993561, 0xA767A3C1, 0x7858D9E8,
                0xCE552125, 0x2303166B, 0x6DDC8751, 0x723A787C, 0xABDD7614, 0x8A00BE5D, 0x3C6BCD67, 0xC479606C, 0x1FA1E06D,
                0x8856779A, 0xB192222E, 0xDCDFEA0A, 0xA787E06F, 0xE8644376, 0x456ECF00,  0x9199C11, 0xCAA2FE90, 0x276A5CE0,
                0x5708A628, 0x4C315702, 0xC3444571, 0x54833C6D, 0xB91E1844, 0xFABB390B
            };
            for (int i = 0; i < 33; i++)
            {
                Assert.AreEqual(expectedK[i * 4], key.K[i].W0);
                Assert.AreEqual(expectedK[i * 4 + 1], key.K[i].W1);
                Assert.AreEqual(expectedK[i * 4 + 2], key.K[i].W2);
                Assert.AreEqual(expectedK[i * 4 + 3], key.K[i].W3);
            }
        }
Exemplo n.º 3
0
        public void KSubkeys_CalculatesKSubkeys192Bits_Calculated()
        {
            SerpentKey key = new SerpentKey(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4 });

            uint[] expectedK =
            {
                0x1BEE46F3, 0x35BEC5CE, 0x7CB4AEF8, 0xC8E3BF13, 0xA2DE951D, 0x1963E6BC, 0xBBADB22C, 0x50B27BEA, 0x385905EF,
                0xC82FBFAC, 0xA5D390BA, 0x60F98822, 0x99FDD928, 0x44B7AF6A, 0x807E6E72, 0xDC808869, 0x3C853DE2, 0xB812D4A4,
                0xB59EF192, 0x98FF9963, 0xCE384F2E, 0xF609CC01, 0xF850AAFC, 0x3B5FE119, 0xF16901DF, 0xA91418D0, 0xE699E18B,
                0xE5D2B76B, 0xFD12E015, 0x7CF42C5E, 0x7689BC86, 0xD98248FF, 0x51CA0648, 0x45009367, 0x52ED860E, 0x970608DA,
                0xF7976401, 0x8B36B735, 0x3385C0F3, 0x3C83F654, 0x3DD9D7A5, 0xDAE7477B, 0x769D6ED2, 0x82507DBF, 0xF6EBB470,
                0x86EB1A25, 0x771C5D56,  0xF98987D, 0xD6D16756,  0xF26271A, 0xF0558EEE, 0xF77DC432, 0x281DC884, 0x50D8089E,
                0xDD2139B6, 0x5092B3AE, 0x44CFD1C1, 0xFAA1F18B, 0xE509CE5C, 0x5C98E04A, 0x574AB74E, 0x2358151B, 0xD8E62288,
                0x4AC8ABC9, 0xE32A28C4, 0x22A7912D, 0xD97FB35F, 0x9CD407FF, 0x89F167C4, 0xEF9F20C0,  0xE6E7B4B, 0x7FC16BD1,
                0xC9A9988F, 0x9FA9EF77, 0xE0AAE0F2, 0x752938E1, 0x37FFF988, 0x28073128, 0xE4A6C473, 0xF9B4709E, 0xE4EB8489,
                0x73E19776, 0x84E904D4,  0x36F387D, 0x85919577, 0x9CC6A364, 0x67CCE8C8,  0xF3E1400, 0xB07F9E02, 0xAAEE1D24,
                0x467D9BF7, 0xBB3BF7A9, 0x2C0F0998, 0xBD33EB8F, 0x5E6F4F1D, 0x7D0BCC49, 0x3E093812, 0xFD3ECF6A, 0xA2E65735,
                0xF87DC47D, 0xB1752B33, 0xA675F114, 0x6619C141, 0xE841980B, 0xEB7B0CB9, 0xF355B983, 0x7876D448, 0xDBA15007,
                0xA674D369, 0x2D6C955F, 0xDE2CDC15, 0x51BD6CA9, 0x86C55FD9, 0x88EC39D1, 0xDA5D0895, 0xD235D63C, 0x4F495D03,
                0x91A7E0EE, 0xB048BD65, 0xF47B0E20, 0xEF040244, 0xFD22988C, 0x870A2034, 0xA8D64A85, 0xFA5EC9B2, 0xF5E33C22,
                0x7B990188, 0x6D49F998, 0x158EEBB4, 0xF7977BD4, 0xA52884B6, 0x6E6B36B4,
            };
            for (int i = 0; i < 33; i++)
            {
                Assert.AreEqual(expectedK[i * 4], key.K[i].W0);
                Assert.AreEqual(expectedK[i * 4 + 1], key.K[i].W1);
                Assert.AreEqual(expectedK[i * 4 + 2], key.K[i].W2);
                Assert.AreEqual(expectedK[i * 4 + 3], key.K[i].W3);
            }
        }