void doit ( void) { /* * SP300-38B #D.1 */ /* * Example 1 */ test_cmac (HL ("2b7e151628aed2a6abf7158809cf4f3c"), HL (""), HL ("bb1d6929e95937287fa37d129b756746")); /* * Example 2 */ test_cmac (HL ("2b7e151628aed2a6abf7158809cf4f3c"), HL ("6bc1bee22e409f96e93d7e117393172a"), HL ("070a16b46b4d4144f79bdd9dd04a287c")); /* * Example 3 */ test_cmac (HL ("2b7e151628aed2a6abf7158809cf4f3c"), HL ("6bc1bee22e409f96e93d7e117393172a" "ae2d8a571e03ac9c9eb76fac45af8e51" "30c81c46a35ce411"), HL ("dfa66747de9ae63030ca32611497c827")); /* * Example 4 */ test_cmac (HL ("2b7e151628aed2a6abf7158809cf4f3c"), HL ("6bc1bee22e409f96e93d7e117393172a" "ae2d8a571e03ac9c9eb76fac45af8e51" "30c81c46a35ce411e5fbc1191a0a52ef" "f69f2445df4f9b17ad2b417be66c3710"), HL ("51f0bebf7e3b9d92fc49741779363cfe")); }
void GEMENI_charsent() { unsigned long r = s->log[s->lc]; if (UCA0IFG & UCTXIFG) { s->nch++; switch (s->nch) { case 1: UCA0TXBUF = SL(r) << 5 |TL(r)<<4|KL(r)<<3|PL(r)<<2|WL(r)<<1|HL(r); break; case 2: UCA0TXBUF = RL(r)<<6 | AL(r)<<5 | OL(r)<<4 | STAR(r)<<3; break; case 3: UCA0TXBUF = ER(r)<<3 | UR(r)<<2 | FR(r)<<1 | RR(r); break; case 4: UCA0TXBUF = PR(r)<<6 | BR(r)<<5 | LR(r)<<4 | GR(r)<<3 | TR(r)<<2 | SR(r)<<1 | DRS(r); break; case 5: UCA0TXBUF = POUND(r)<<1 | ZRS(r); break; default: s->lc++; if (s->lc != s->nc-1) { s->nch = 0; UCA0TXBUF = 1 << 7; // first packet, no fn or '#' } else { s->flags &= ~CSEND; } } } }
int test_main(void) { #if HAVE_LIBGMP test_size(0, 1); test_size(1, 1); test_size(0x7f, 1); test_size(0x80, 2); test_size(0x81, 2); test_size(0xff, 2); test_size(0x100, 2); test_size(0x101, 2); test_size(0x1111, 2); test_size(0x7fff, 2); test_size(0x8000, 3); test_size(0x8001, 3); test_size(- 1, 1); /* ff */ test_size(- 0x7f, 1); /* 81 */ test_size(- 0x80, 1); /* 80 */ test_size(- 0x81, 2); /* ff7f */ test_size(- 0xff, 2); /* ff01 */ test_size(- 0x100, 2); /* ff00 */ test_size(- 0x101, 2); /* feff */ test_size(- 0x1111, 2); /* eeef */ test_size(- 0x7fff, 2); /* 8001 */ test_size(- 0x8000, 2); /* 8000 */ test_size(- 0x8001, 3); /* ff7fff */ test_bignum("0", HL("00")); test_bignum("010203040506", HL("010203040506")); test_bignum("80010203040506", HL("0080010203040506")); test_bignum( "-1", HL( "ff")); test_bignum( "-7f", HL( "81")); test_bignum( "-80", HL( "80")); test_bignum( "-81", HL( "ff7f")); test_bignum("-7fff", HL( "8001")); test_bignum("-8000", HL( "8000")); test_bignum("-8001", HL("ff7fff")); SUCCESS(); #else /* !HAVE_LIBGMP */ SKIP(); #endif /* !HAVE_LIBGMP */ }
void doit (void) { /* From NIST spec 800-38a on AES modes, * * http://csrc.nist.gov/CryptoToolkit/modes/800-38_Series_Publications/SP800-38A.pdf * * F.5 CTR Example Vectors */ /* F.5.1 CTR-AES128.Encrypt */ test_uncipher_ctr(&nettle_aes128, HL("2b7e151628aed2a6abf7158809cf4f3c"), HL("6bc1bee22e409f96e93d7e117393172a" "ae2d8a571e03ac9c9eb76fac45af8e51" "30c81c46a35ce411e5fbc1191a0a52ef" "f69f2445df4f9b17ad2b417be66c3710"), H("874d6191b620e3261bef6864990db6ce" "9806f66b7970fdff8617187bb9fffdff" "5ae4df3edbd5d35e5b4f09020db03eab" "1e031dda2fbe03d1792170a0f3009cee"), H("f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff")); }
void doit(void) { derive_knas_keys(EIA0_ALG_ID, HL("70D7071AA016A087F9D888AD51F3A83E2C83443AB27843B35BD1B4923615091C"), H("64BA839B29C451085C552F4DE9D278B263CB5BDD7FC21A38120637B2A9E5CD39"), H("A66A2D198AF2A8D6A5FF2FAA51676037DF204187C61EDD3AAA70F3B7D8B59E8B")); derive_knas_keys(EIA1_128_ALG_ID, HL("70D7071AA016A087F9D888AD51F3A83E2C83443AB27843B35BD1B4923615091C"), H("DF8FEBA477891617C42FB16F750E572C9E59ED7564879150F6BB0DAEF5932E89"), H("EA1158BA3F387BC96C967BC32FB43F65AE172A3267343479CAA826034A90A250")); derive_knas_keys(EIA2_128_ALG_ID, HL("70D7071AA016A087F9D888AD51F3A83E2C83443AB27843B35BD1B4923615091C"), H("99D63BD2D43AF81EBB7599F7E8F8B3E81CF7897F31D6270C19C4836070FE11F0"), H("FC7A3850D19AE29EC7000B9DF98787F11A4329FD23FD3A93C9D2D92D853EC9DB")); derive_knas_keys(EIA0_ALG_ID, HL("9EA141DA4B24CDEBC8F5FB3F61A0511216681F121199B23EBCFACC75B358BE43"), H("1E48E1B5EDF98DEDF339DE686544AA1088C8E5616EDB706201837AA106D37691"), H("C83DC420F97AA42D1B8488FA5D8F74865D833416D5851556100B41FEC8E38139")); derive_knas_keys(EIA1_128_ALG_ID, HL("9EA141DA4B24CDEBC8F5FB3F61A0511216681F121199B23EBCFACC75B358BE43"), H("207700CD92B4635B439E40176F92F7ADA824B9D699ABE15F86F3346C25343A33"), H("FAA39E382611CDFED52042E72AF8CECDF92CCD799141857B77B6901741E486B2")); derive_knas_keys(EIA2_128_ALG_ID, HL("9EA141DA4B24CDEBC8F5FB3F61A0511216681F121199B23EBCFACC75B358BE43"), H("2A6854D25282FFD738FA8BBCFDCE853C0C4DFB9F559DCBB71D5120DB2CAC66A6"), H("5EDCAE62A35BC42399C55F64ECAE7B17524BED1ED1601218D2772E55DDFAD959")); derive_knas_keys(EIA0_ALG_ID, HL("546A79BC6D1613A72A4D631EE0351D66036B2A0C44A3831BE6D365E24F023013"), H("7F684F909A5910DED6E4B4CE02AC92DF4690EB3788068600E9CB2C3EF8F0956E"), H("51F3B142D357371726873FAC5E853CE0EEEFC52A695DE45FA6F4A23D20C13155")); derive_knas_keys(EIA1_128_ALG_ID, HL("546A79BC6D1613A72A4D631EE0351D66036B2A0C44A3831BE6D365E24F023013"), H("B6B222E9C07C56D15176C8E95EC1805561492682E4B9CD7228237A6C78702347"), H("4DC5ABF6896DA460473288D16DE83C480388C6FD9E803C7EA88090F311354A15")); derive_knas_keys(EIA2_128_ALG_ID, HL("546A79BC6D1613A72A4D631EE0351D66036B2A0C44A3831BE6D365E24F023013"), H("7BD2A0864452D3D9EDE3B2E38A9958777F231AC4F4B9AF3FC8CE0E1EAAB425A7"), H("89E8049EBE9374F238B0F3278EEA47D9BF8877111D99D6378FFF66FEBB06F3F8")); }
int K1(int iRT, int zO_P, int Do, int vxlI, int j1i, int a, int JUdI, int X, int pOY) { if (Bba - QJ0E >= + ! HL(- z(302957500, ! (k9j) != eJvv + (G((ShI * (dAd)), 2084374456, - (1394734516) - 578517423, 420911301)), (zqg)), xdqI, P, (rnkx(+ V2(2141821581, ! pSOs((10986324), - + XAO > E7 == N() <= Sl() / 264945842 >= TE + qV < (1458692725) % XYqq), - ! ! M, 1551887947, XnwB()), Tn(782235838 == uQZ > podo(1337746681, ! 224880727), ! eca < ZTyn, 484572022, + ! ! v4v))) >= - w8w5(290173308 * k5, 1725371014, 1216256323, o2DU) > 50666347 != SnrK) % KPt + dDQ3) ; else return K; while (! 1985392826) return J2st(x23, 142371013); return AJkU / 1202235129; { int lLU; int S9; int ZYL; int SjH; int Uor; int nv; int _JYO; ceH_; } ; }
void doit (void) { do_derive_kenb(0xDB1A3569, HL("238E457E0F758BADBCA8D34BB2612C10428D426757CB5553B2B184FA64BFC549"), H("8EB1BF0083BD79281EF7034BF677E9EC529F196E15287514A2D122ACF713B8E8")); do_derive_kenb(0x001FB39C, HL("564CB4D2007E4F293B67D9B29392A64ADD4C776B133D895AF6499AA6882AAB62"), H("009010688F85855E218339DE6C5BD7B6394958DA12DDFBF7559E978CE43408F1")); do_derive_kenb(0x00000012, HL("FA77E41F693C2A6E71455CB8687E6E6058EF91E2F5ABD1BD3C496179481F308C"), H("0AFE81266DE52B8C8F1C3F4FE799BE883F364B018E7368C41F14DD6D050E13E1")); do_derive_kenb(0xFE56A1D3, HL("FA77E41F693C2A6E71455CB8687E6E6058EF91E2F5ABD1BD3C496179481F308C"), H("3622874B06C683586A009DEC81DBE28BDD8E3E6E67A2C22C31630EC97641828E")); do_derive_kenb(0xFE56A1D3, HL("70D7071AA016A087F9D888AD51F3A83E2C83443AB27843B35BD1B4923615091C"), H("E59BE6F0FBEFA1207DA3FF05D0F82014100E7A63A11EEBFE4F8AA92E7CF8B847")); do_derive_kenb(0xAABBCCDD, HL("70D7071AA016A087F9D888AD51F3A83E2C83443AB27843B35BD1B4923615091C"), H("158781A2FDF2CE53ABFA186D22EB751DECB8273471DC792B5016C9016947D1AE")); }
void doit (void) { /* Test suite from 3GPP TS33.401 #Appendix C.2 * For EPS implementation verification, byte alignment test data sets * (2, 5 and 8) can be used, as EPS RRC and EPS NAS messages are byte aligned. * The non byte aligned test data sets may be used to verify implementations * that support non byte aligned messages. */ /* Test set 2 #C.2.2 */ eia2_encrypt( 1, 0x398a59b4, 0x1a, HL("d3c5d592327fb11c4035c6680af8c6d1"), H("484583d5afe082ae"), 64, HL("b93787e6") ); /* Test set 5 #C.2.5 */ eia2_encrypt( 1, 0x36af6144, 0x0f, HL("83fd23a244a74cf358da3019f1722635"), H("35c68716633c66fb750c266865d53c11ea05b1e9fa49c8398d48e1efa5909d39" "47902837f5ae96d5a05bc8d61ca8dbef1b13a4b4abfe4fb1006045b674bb5472" "9304c382be53a5af05556176f6eaa2ef1d05e4b083181ee674cda5a485f74d7a"), 768, HL("e657e182") ); /* Test set 8 #C.2.8 */ eia2_encrypt( 1, 0x296f393c, 0x0b, HL("b3120ffdb2cf6af4e73eaf2ef4ebec69"), H("00000000000000000101010101010101e0958045f3a0bba4e3968346f0a3b8a7" "c02a018ae640765226b987c913e6cbf083570016cf83efbc61c082513e21561a" "427c009d28c298eface78ed6d56c2d4505ad032e9c04dc60e73a81696da665c6" "c48603a57b45ab33221585e68ee3169187fb0239528632dd656c807ea3248b7b" "46d002b2b5c7458eb85b9ce95879e0340859055e3b0abbc3eace8719caa80265" "c97205d5dc4bcc902fe1839629ed71328a0f0449f588557e6898860e042aecd8" "4b2404c212c9222da5bf8a89ef6797870cf50771a60f66a2ee62853657addf04" "cdde07fa414e11f12b4d81b9b4e8ac538ea30666688d881f6c348421992f31b9" "4f8806ed8fccff4c9123b89642527ad613b109bf75167485f1268bf884b4cd23" "d29a0934925703d634098f7767f1be7491e708a8bb949a3873708aef4a36239e" "50cc08235cd5ed6bbe578668a17b58c1171d0b90e813a9e4f58a89d719b11042" "d6360b1b0f52deb730a58d58faf46315954b0a872691475977dc88c0d733feff" "54600a0cc1d0300aaaeb94572c6e95b01ae90de04f1dce47f87e8fa7bebf77e1" "dbc20d6ba85cb9143d518b285dfa04b698bf0cf7819f20fa7a288eb0703d995c" "59940c7c66de57a9b70f82379b70e2031e450fcfd2181326fcd28d8823baaa80" "df6e0f443559647539fd8907c0ffd9d79c130ed81c9afd9b7e848c9fed38443d" "5d380e53fbdb8ac8c3d3f06876054f122461107de92fea09c6f6923a188d53af" "e54a10f60e6e9d5a03d996b5fbc820f8a637116a27ad04b444a0932dd60fbd12" "671c11e1c0ec73e789879faa3d42c64d20cd1252742a3768c25a901585888ece" "e1e612d9936b403b0775949a66cdfd99a29b1345baa8d9d5400c91024b0a6073" "63b013ce5de9ae869d3b8d95b0570b3c2d391422d32450cbcfae96652286e96d" "ec1214a9346527980a8192eac1c39a3aaf6f15351da6be764df89772ec0407d0" "6e4415befae7c92580df9bf507497c8f2995160d4e218daacb02944abf83340c" "e8be1686a960faf90e2d90c55cc6475babc3171a80a363174954955d7101dab1" "6ae8179167e21444b443a9eaaa7c91de36d118c39d389f8dd4469a846c9a262b" "f7fa18487a79e8de11699e0b8fdf557cb48719d453ba713056109b93a218c896" "75ac195fb4fb06639b3797144955b3c9327d1aec003d42ecd0ea98abf19ffb4a" "f3561a67e77c35bf15c59c2412da881db02b1bfbcebfac5152bc99bc3f1d15f7" "71001b7029fedb028f8b852bc4407eb83f891c9ca733254fdd1e9edb56919ce9" "fea21c174072521c18319a54b5d4efbebddf1d8b69b1cbf25f489fcc98137254" "7cf41d008ef0bca1926f934b735e090b3b251eb33a36f82ed9b29cf4cb944188" "fa0e1e38dd778f7d1c9d987b28d132dfb9731fa4f4b416935be49de30516af35" "78581f2f13f561c0663361941eab249a4bc123f8d15cd711a956a1bf20fe6eb7" "8aea2373361da0426c79a530c3bb1de0c99722ef1fde39ac2b00a0a8ee7c800a" "08bc2264f89f4effe627ac2f0531fb554f6d21d74c590a70adfaa390bdfbb3d6" "8e46215cab187d2368d5a71f5ebec081cd3b20c082dbe4cd2faca28773795d6b" "0c10204b659a939ef29bbe1088243624429927a7eb576dd3a00ea5e01af5d475" "83b2272c0c161a806521a16ff9b0a722c0cf26b025d5836e2258a4f7d4773ac8" "01e4263bc294f43def7fa8703f3a4197463525887652b0b2a4a2a7cf87f00914" "871e25039113c7e1618da34064b57a43c463249fb8d05e0f26f4a6d84972e7a9" "054824145f91295cdbe39a6f920facc659712b46a54ba295bbe6a90154e91b33" "985a2bcd420ad5c67ec9ad8eb7ac6864db272a516bc94c2839b0a8169a6bf58e" "1a0c2ada8c883b7bf497a49171268ed15ddd2969384e7ff4bf4aab2ec9ecc652" "9cf629e2df0f08a77a65afa12aa9b505df8b287ef6cc91493d1caa39076e28ef" "1ea028f5118de61ae02bb6aefc3343a050292f199f401857b2bead5e6ee2a1f1" "91022f9278016f047791a9d18da7d2a6d27f2e0e51c2f6ea30e8ac49a0604f4c" "13542e85b68381b9fdcfa0ce4b2d341354852d360245c536b612af71f3e77c90" "95ae2dbde504b265733dabfe10a20fc7d6d32c21ccc72b8b3444ae663d65922d" "17f82caa2b865cd88913d291a65899026ea1328439723c198c36b0c3c8d085bf" "af8a320fde334b4a4919b44c2b95f6e8ecf73393f7f0d2a40e60b1d406526b02" "2ddc331810b1a5f7c347bd53ed1f105d6a0d30aba477e178889ab2ec55d558de" "ab2630204336962b4db5b663b6902b89e85b31bc6af50fc50accb3fb9b57b663" "297031378db47896d7fbaf6c600add2c67f936db037986db856eb49cf2db3f7d" "a6d23650e438f1884041b013119e4c2ae5af37cccdfb68660738b58b3c59d1c0" "248437472aba1f35ca1fb90cd714aa9f635534f49e7c5bba81c2b6b36fdee21c" "a27e347f793d2ce944edb23c8c9b914be10335e350feb5070394b7a4a15c0ca1" "20283568b7bfc254fe838b137a2147ce7c113a3a4d65499d9e86b87dbcc7f03b" "bd3a3ab1aa243ece5ba9bcf25f82836cfe473b2d83e7a7201cd0b96a72451e86" "3f6c3ba664a6d073d1f7b5ed990865d978bd3815d06094fc9a2aba5221c22d5a" "b996389e3721e3af5f05beddc2875e0dfaeb39021ee27a41187cbb45ef40c3e7" "3bc03989f9a30d12c54ba7d2141da8a875493e65776ef35f97debc2286cc4af9" "b4623eee902f840c52f1b8ad658939aef71f3f72b9ec1de21588bd35484ea444" "36343ff95ead6ab1d8afb1b2a303df1b71e53c4aea6b2e3e9372be0d1bc99798" "b0ce3cc10d2a596d565dba82f88ce4cff3b33d5d24e9c0831124bf1ad54b7925" "32983dd6c3a8b7d0"), 16448, HL("ebd5ccb0") ); /* Test set 1 #C.2.1 */ #if defined(EIA2_NON_BYTE_ALIGNED_SUPPORTED) eia2_encrypt( 0, 0x38a6f056, 0x18, HL("2bd6459f82c5b300952c49104881ff48"), H("3332346263393840"), 58, HL("118c6eb8") ); /* Test set 3 #C.2.3 */ eia2_encrypt( 1, 0x36af6144, 0x18, HL("7e5e94431e11d73828d739cc6ced4573"), H("b3d3c9170a4e1632f60f861013d22d84b726b6a278d802d1eeaf1321ba5929dc"), 254, HL("1f60b01d") ); /* Test set 4 #C.2.4 */ eia2_encrypt( 0, 0xc7590ea9, 0x17, HL("d3419be821087acd02123a9248033359"), H("bbb057038809496bcff86d6fbc8ce5b135a06b166054f2d565be8ace75dc851e" "0bcdd8f07141c495872fb5d8c0c66a8b6da556663e4e461205d84580bee5bc7e"), 511, HL("6846a2f0") ); /* Test set 6 #C.2.6 */ eia2_encrypt( 0, 0x36af6144, 0x18, HL("6832a65cff4473621ebdd4ba26a921fe"), H("d3c53839626820717765667620323837636240981ba6824c1bfb1ab485472029" "b71d808ce33e2cc3c0b5fc1f3de8a6dc"), 768, HL("f0668c1e") ); /* Test set 7 #C.2.7 */ eia2_encrypt( 1, 0x7827fab2, 0x05, HL("5d0a80d8134ae19677824b671e838af4"), H("70dedf2dc42c5cbd3a96f8a0b11418b3608d5733604a2cd36aabc70ce3193bb5" "153be2d3c06dfdb2d16e9c357158be6a41d6b861e491db3fbfeb518efcf048d7" "d58953730ff30c9ec470ffcd663dc34201c36addc0111c35b38afee7cfdb582e" "3731f8b4baa8d1a89c06e81199a9716227be344efcb436ddd0f096c064c3b5e2" "c399993fc77394f9e09720a811850ef23b2ee05d9e6173609d86e1c0c18ea51a" "012a00bb413b9cb8188a703cd6bae31cc67b34b1b00019e6a2b2a690f02671fe" "7c9ef8dec0094e533763478d58d2c5f5b827a0148c5948a96931acf84f465a64" "e62ce74007e991e37ea823fa0fb21923b79905b733b631e6c7d6860a3831ac35" "1a9c730c52ff72d9d308eedbab21fde143a0ea17e23edc1f74cbb3638a2033aa" "a15464eaa733385dbbeb6fd73509b857e6a419dca1d8907af977fbac4dfa35ec"), 2558, HL("f4cc8fa3") ); #endif }
void doit (void) { /* Test suite from 3GPP TS33.401 #Appendix C.1 */ /* Test set 1 #C.1.1 */ eea2_encrypt( 1, 0x398a59b4, 0x15, HL("d3c5d592327fb11c4035c6680af8c6d1"), H("981ba6824c1bfb1ab485472029b71d808ce33e2cc3c0b5fc1f3de8a6dc66b1f0"), 253, H("e9fed8a63d155304d71df20bf3e82214b20ed7dad2f233dc3c22d7bdeeed8e78") ); /* Test set 2 #C.1.2 */ eea2_encrypt( 1, 0xc675a64b, 0x0c, HL("2bd6459f82c440e0952c49104805ff48"), H("7ec61272743bf1614726446a6c38ced166f6ca76eb5430044286346cef130f92" "922b03450d3a9975e5bd2ea0eb55ad8e1b199e3ec4316020e9a1b285e7627953" "59b7bdfd39bef4b2484583d5afe082aee638bf5fd5a606193901a08f4ab41aab" "9b134880"), 798, H("5961605353c64bdca15b195e288553a910632506d6200aa790c4c806c99904cf" "2445cc50bb1cf168a49673734e081b57e324ce5259c0e78d4cd97b870976503c" "0943f2cb5ae8f052c7b7d392239587b8956086bcab18836042e2e6ce42432a17" "105c53d0") ); /* Test set 3 #C.1.3 */ eea2_encrypt( 0, 0x544d49cd, 0x04, HL("0a8b6bd8d9b08b08d64e32d1817777fb"), H("fd40a41d370a1f65745095687d47ba1d36d2349e23f644392c8ea9c49d40c132" "71aff264d0f24800"), 310, H("75750d37b4bba2a4dedb34235bd68c6645acdaaca48138a3b0c471e2a7041a57" "6423d2927287f000") ); /* Test set 4 #C.1.4 */ eea2_encrypt( 1, 0x72d8c671, 0x10, HL("aa1f95aea533bcb32eb63bf52d8f831a"), H("fb1b96c5c8badfb2e8e8edfde78e57f2ad81e74103fc430a534dcc37afcec70e" "1517bb06f27219dae49022ddc47a068de4c9496a951a6b09edbdc864c7adbd74" "0ac50c022f3082bafd22d78197c5d508b977bca13f32e652e74ba728576077ce" "628c535e87dc6077ba07d29068590c8cb5f1088e082cfa0ec961302d69cf3d44"), 1022, H("dfb440acb3773549efc04628aeb8d8156275230bdc690d94b00d8d95f28c4b56" "307f60f4ca55eba661ebba72ac808fa8c49e26788ed04a5d606cb418de74878b" "9a22f8ef29590bc4eb57c9faf7c41524a885b8979c423f2f8f8e0592a9879201" "be7ff9777a162ab810feb324ba74c4c156e04d39097209653ac33e5a5f2d8864") ); /* Test set 5 #C.1.5 */ eea2_encrypt( 1, 0xc675a64b, 0x0c, HL("9618ae46891f86578eebe90ef7a1202e"), H("8daa17b1ae050529c6827f28c0ef6a1242e93f8b314fb18a77f790ae049fedd6" "12267fecaefc450174d76d9f9aa7755a30cd90a9a5874bf48eaf70eea3a62a25" "0a8b6bd8d9b08b08d64e32d1817777fb544d49cd49720e219dbf8bbed33904e1" "fd40a41d370a1f65745095687d47ba1d36d2349e23f644392c8ea9c49d40c132" "71aff264d0f24841d6465f0996ff84e65fc517c53efc3363c38492a8"), 1245, H("919c8c33d66789703d05a0d7ce82a2aeac4ee76c0f4da050335e8a84e7897ba5" "df2f36bd513e3d0c8578c7a0fcf043e03aa3a39fbaad7d15be074faa5d9029f7" "1fb457b647834714b0e18f117fca10677945096c8c5f326ba8d6095eb29c3e36" "cf245d1622aafe921f7566c4f5d644f2f1fc0ec684ddb21349747622e209295d" "27ff3f95623371d49b147c0af486171f22cd04b1cbeb2658223e6938") ); /* Test set 6 #C.1.6 */ eea2_encrypt( 0, 0xaca4f50f, 0x0b, HL("54f4e2e04c83786eec8fb5abe8e36566"), H("40981ba6824c1bfb4286b299783daf442c099f7ab0f58d5c8e46b104f08f01b4" "1ab485472029b71d36bd1a3d90dc3a41b46d51672ac4c9663a2be063da4bc8d2" "808ce33e2cccbfc634e1b259060876a0fbb5a437ebcc8d31c19e4454318745e3" "fa16bb11adae248879fe52db2543e53cf445d3d828ce0bf5c560593d97278a59" "762dd0c2c9cd68d4496a792508614014b13b6aa51128c18cd6a90b87978c2ff1" "cabe7d9f898a411bfdb84f68f6727b1499cdd30df0443ab4a66653330bcba110" "5e4cec034c73e605b4310eaaadcfd5b0ca27ffd89d144df4792759427c9cc1f8" "cd8c87202364b8a687954cb05a8d4e2d99e73db160deb180ad0841e96741a5d5" "9fe4189f15420026fe4cd12104932fb38f735340438aaf7eca6fd5cfd3a195ce" "5abe65272af607ada1be65a6b4c9c0693234092c4d018f1756c6db9dc8a6d80b" "888138616b681262f954d0e7711748780d92291d86299972db741cfa4f37b8b5" "6cdb18a7ca8218e86e4b4b716a4d04371fbec262fc5ad0b3819b187b97e55b1a" "4d7c19ee24c8b4d7723cfedf045b8acae4869517d80e50615d9035d5d9c5a40a" "f602280b542597b0cb18619eeb35925759d195e100e8e4aa0c38a3c2abe0f3d8" "ff04f3c33c295069c23694b5bbeacdd542e28e8a94edb9119f412d054be1fa72" "00b09000"), 3861, H("5cb72c6edc878f1566e10253afc364c9fa540d914db94cbee275d0917ca6af0d" "77acb4ef3bbe1a722b2ef5bd1d4b8e2aa5024ec1388a201e7bce7920aec61589" "5f763a5564dcc4c482a2ee1d8bfecc4498eca83fbb75f9ab530e0dafbede2fa5" "895b82991b6277c529e0f2529d7f79606be96706296dedfa9d7412b616958cb5" "63c678c02825c30d0aee77c4c146d2765412421a808d13cec819694c75ad572e" "9b973d948b81a9337c3b2a17192e22c2069f7ed1162af44cdea817603665e807" "ce40c8e0dd9d6394dc6e31153fe1955c47afb51f2617ee0c5e3b8ef1ad7574ed" "343edc2743cc94c990e1f1fd264253c178dea739c0befeebcd9f9b76d49c1015" "c9fecf50e53b8b5204dbcd3eed863855dabcdcc94b31e318021568855c8b9e52" "a981957a112827f978ba960f1447911b317b5511fbcc7fb13ac153db74251117" "e4861eb9e83bffffc4eb7755579038e57924b1f78b3e1ad90bab2a07871b72db" "5eef96c334044966db0c37cafd1a89e5646a3580eb6465f121dce9cb88d85b96" "cf23ccccd4280767bee8eeb23d8652461db6493103003baf89f5e18261ea43c8" "4a92ebffffe4909dc46c5192f825f770600b9602c557b5f8b431a79d45977dd9" "c41b863da9e142e90020cfd074d6927b7ab3b6725d1a6f3f98b9c9daa8982aff" "06782800") ); }
int test_main(void) { /* From Applied Cryptography */ test_des(H("01234567 89ABCDEF"), 1, HL("01234567 89ABCDE7"), H("C9574425 6A5ED31D")); test_des(H("01 01 01 01 01 01 01 80"), 1, HL("00 00 00 00 00 00 00 00"), H("9C C6 2D F4 3B 6E ED 74")); test_des(H("80 01 01 01 01 01 01 01"), 1, HL("00 00 00 00 00 00 00 40"), H("A3 80 E0 2A 6B E5 46 96")); test_des(H("08 19 2A 3B 4C 5D 6E 7F"), 1, HL("00 00 00 00 00 00 00 00"), H("25 DD AC 3E 96 17 64 67")); test_des(H("01 23 45 67 89 AB CD EF"), 1, DES_BLOCK_SIZE, "Now is t", H("3F A4 0E 8A 98 4D 48 15")); /* Same key, but with one bad parity bit, */ test_des(H("01 23 45 66 89 AB CD EF"), 0, DES_BLOCK_SIZE, "Now is t", H("3F A4 0E 8A 98 4D 48 15")); /* Parity check */ if (des_check_parity(HL("01 01 01 01 01 01 01 00"))) FAIL(); /* The four weak keys */ test_weak(H("01 01 01 01 01 01 01 01")); test_weak(H("FE FE FE FE FE FE FE FE")); test_weak(H("1F 1F 1F 1F 0E 0E 0E 0E")); test_weak(H("E0 E0 E0 E0 F1 F1 F1 F1")); /* Same weak key, but different parity. */ test_weak(H("E0 E0 E0 E0 F0 F1 F1 F1")); /* The six pairs of semiweak keys */ test_weak(H("01 FE 01 FE 01 FE 01 FE")); test_weak(H("FE 01 FE 01 FE 01 FE 01")); test_weak(H("1F E0 1F E0 0E F1 0E F1")); test_weak(H("E0 1F E0 1F F1 0E F1 0E")); test_weak(H("01 E0 01 E0 01 F1 01 F1")); test_weak(H("E0 01 E0 01 F1 01 F1 01")); test_weak(H("1F FE 1F FE 0E FE 0E FE")); test_weak(H("FE 1F FE 1F FE 0E FE 0E")); test_weak(H("01 1F 01 1F 01 0E 01 0E")); test_weak(H("1F 01 1F 01 0E 01 0E 01")); test_weak(H("E0 FE E0 FE F1 FE F1 FE")); test_weak(H("FE E0 FE E0 FE F1 FE F1")); SUCCESS(); }
int test_main(void) { test_hash(&nettle_md5, 0, "", H("D41D8CD98F00B204 E9800998ECF8427E")); test_hash(&nettle_md5, 1, "a", H("0CC175B9C0F1B6A8 31C399E269772661")); test_hash(&nettle_md5, 3, "abc", H("900150983cd24fb0 D6963F7D28E17F72")); test_hash(&nettle_md5, 14, "message digest", H("F96B697D7CB7938D 525A2F31AAF161D0")); test_hash(&nettle_md5, 26, "abcdefghijklmnopqrstuvwxyz", H("C3FCD3D76192E400 7DFB496CCA67E13B")); test_hash(&nettle_md5, 62, "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz" "0123456789", H("D174AB98D277D9F5 A5611C2C9F419D9F")); test_hash(&nettle_md5, 80, "1234567890123456789012345678901234567890" "1234567890123456789012345678901234567890", H("57EDF4A22BE3C955 AC49DA2E2107B67A")); /* Additional test vector, from Daniel Kahn Gillmor */ test_hash(&nettle_md5, LDATA("38"), H("a5771bce93e200c3 6f7cd9dfd0e5deaa")); /* Collisions, reported by Xiaoyun Wang1, Dengguo Feng2, Xuejia Lai3, Hongbo Yu1, http://eprint.iacr.org/2004/199. */ #define M0 \ /* vv */ \ "d131dd02 c5e6eec4 693d9a06 98aff95c 2fcab5 87 12467eab 4004583e b8fb7f89" \ "55ad3406 09f4b302 83e48883 25 71 415a 085125e8 f7cdc99f d91dbd f2 80373c5b" \ /* ^^ ^^ */ #define M1 \ /* vv */ \ "d131dd02 c5e6eec4 693d9a06 98aff95c 2fcab5 07 12467eab 4004583e b8fb7f89" \ "55ad3406 09f4b302 83e48883 25 f1 415a 085125e8 f7cdc99f d91dbd 72 80373c5b" \ /* ^^ ^^ */ #define N0 \ /* vv */ \ "960b1dd1 dc417b9c e4d897f4 5a6555d5 35739a c7 f0ebfd0c 3029f166 d109b18f" \ "75277f79 30d55ceb 22e8adba 79 cc 155c ed74cbdd 5fc5d36d b19b0a d8 35cca7e3" \ /* ^^ ^^ */ #define N1 \ /* vv */ \ "960b1dd1 dc417b9c e4d897f4 5a6555d5 35739a 47 f0ebfd0c 3029f166 d109b18f" \ "75277f79 30d55ceb 22e8adba 79 4c 155c ed74cbdd 5fc5d36d b19b0a 58 35cca7e3" \ /* ^^ ^^ */ /* Note: The checksum in the paper, 1f160396 efc71ff4 bcff659f bf9d0fa3, is incorrect. */ #define H0 "a4c0d35c 95a63a80 5915367d cfe6b751" #define N2 \ /* vv */ \ "d8823e31 56348f5b ae6dacd4 36c919c6 dd53e2 b4 87da03fd 02396306 d248cda0" \ "e99f3342 0f577ee8 ce54b670 80 a8 0d1e c69821bc b6a88393 96f965 2b 6ff72a70" \ /* ^^ ^^ */ #define N3 \ /* vv */ \ "d8823e31 56348f5b ae6dacd4 36c919c6 dd53e2 34 87da03fd 02396306 d248cda0" \ "e99f3342 0f577ee8 ce54b670 80 28 0d1e c69821bc b6a88393 96f965 ab 6ff72a70" \ /* ^^ ^^ */ /* Note: Also different from the checksum in the paper */ #define H1 "79054025 255fb1a2 6e4bc422 aef54eb4" test_hash(&nettle_md5, HL(M0 N0), H(H0)); test_hash(&nettle_md5, HL(M1 N1), H(H0)); test_hash(&nettle_md5, HL(M0 N2), H(H1)); test_hash(&nettle_md5, HL(M1 N3), H(H1)); SUCCESS(); }
// The function exists in both "ConEmuC/ConEmuC.cpp" and "ConEmuCD/Actions.cpp" // Version in "ConEmuC/ConEmuC.cpp" shows arguments from main(int argc, char** argv) // Version in "ConEmuCD/Actions.cpp" perhaps would not be ever called int DoParseArgs(LPCWSTR asCmdLine) { char szLine[80]; char szCLVer[32]; HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE); CONSOLE_SCREEN_BUFFER_INFO csbi = {}; GetConsoleScreenBufferInfo(hOut, &csbi); struct Highlighter { HANDLE hOut; WORD defAttr; Highlighter(HANDLE ahOut, WORD adefAttr, WORD fore) : hOut(ahOut), defAttr(adefAttr) { SetConsoleTextAttribute(hOut, fore|(defAttr & 0xF0)); }; ~Highlighter() { SetConsoleTextAttribute(hOut, defAttr); }; }; #undef HL #define HL(fore) Highlighter hl(hOut, csbi.wAttributes, fore) #if defined(__GNUC__) lstrcpyn(szCLVer, "GNUC"); #elif defined(_MSC_VER) _wsprintfA(szCLVer, SKIPCOUNT(szCLVer) "VC %u.%u", (int)(_MSC_VER / 100), (int)(_MSC_VER % 100)); #else lstrcpyn(szCLVer, "<Unknown CL>"); #endif _wsprintfA(szLine, SKIPCOUNT(szLine) "main arguments (count %i) {%s}\n", gn_argc, szCLVer); { HL(10); _printf(szLine); } for (int j = 0; j < gn_argc; j++) { if (j >= 999) { HL(12); _printf("*** TOO MANY ARGUMENTS ***\n"); break; } _wsprintfA(szLine, SKIPCOUNT(szLine) " %u: ", j); { HL(2); _printf(szLine); } if (!gp_argv) { HL(12); _printf("*NULL"); } else if (!gp_argv[j]) { HL(12); _printf("<NULL>"); } else { { HL(8); _printf("`"); } { HL(15); _printf(gp_argv[j]); } { HL(8); _printf("`"); } } _printf("\n"); } { HL(10); _printf("Parsing command"); } { HL(8); _printf("\n `"); } { HL(15); _wprintf(asCmdLine); } { HL(8); _printf("`\n"); } int iShellCount = 0; LPWSTR* ppszShl = CommandLineToArgvW(asCmdLine, &iShellCount); int i = 0; CEStr szArg; { HL(10); _printf("ConEmu `NextArg` splitter\n"); } while (NextArg(&asCmdLine, szArg) == 0) { if (szArg.mb_Quoted) DemangleArg(szArg, true); _wsprintfA(szLine, SKIPCOUNT(szLine) " %u: ", ++i); { HL(2); _printf(szLine); } { HL(8); _printf("`"); } { HL(15); _wprintf(szArg); } { HL(8); _printf("`\n"); } } _wsprintfA(szLine, SKIPCOUNT(szLine) " Total arguments parsed: %u\n", i); { HL(8); _printf(szLine); } { HL(10); _printf("Standard shell splitter\n"); } for (int j = 0; j < iShellCount; j++) { _wsprintfA(szLine, SKIPCOUNT(szLine) " %u: ", j); { HL(2); _printf(szLine); } { HL(8); _printf("`"); } { HL(15); _wprintf(ppszShl[j]); } { HL(8); _printf("`\n"); } } _wsprintfA(szLine, SKIPCOUNT(szLine) " Total arguments parsed: %u\n", iShellCount); { HL(8); _printf(szLine); } LocalFree(ppszShl); return i; }
int test_main(void) { /* http://www.ecrypt.eu.org/stream/svn/viewcvs.cgi/ecrypt/trunk/submissions/salsa20/full/verified.test-vectors?logsort=rev&rev=210&view=markup */ test_salsa20(HL("80000000 00000000 00000000 00000000"), H("00000000 00000000"), HL("00000000 00000000"), H("4DFA5E48 1DA23EA0")); test_salsa20(HL("00000000 00000000 00000000 00000000"), H("80000000 00000000"), HL("00000000 00000000"), H("B66C1E44 46DD9557")); test_salsa20(HL("0053A6F94C9FF24598EB3E91E4378ADD"), H("0D74DB42A91077DE"), HL("00000000 00000000"), H("05E1E7BE B697D999")); test_salsa20(HL("80000000 00000000 00000000 00000000" "00000000 00000000 00000000 00000000"), H("00000000 00000000"), HL("00000000 00000000"), H("E3BE8FDD 8BECA2E3")); test_salsa20(HL("00000000 00000000 00000000 00000000" "00000000 00000000 00000000 00000000"), H("80000000 00000000"), HL("00000000 00000000"), H("2ABA3DC45B494700")); test_salsa20(HL("0053A6F94C9FF24598EB3E91E4378ADD" "3083D6297CCF2275C81B6EC11467BA0D"), H("0D74DB42A91077DE"), HL("00000000 00000000"), H("F5FAD53F 79F9DF58")); test_salsa20_stream(HL("80000000000000000000000000000000"), H("00000000 00000000"), H("4DFA5E481DA23EA09A31022050859936" "DA52FCEE218005164F267CB65F5CFD7F" "2B4F97E0FF16924A52DF269515110A07" "F9E460BC65EF95DA58F740B7D1DBB0AA" "DA9C1581F429E0A00F7D67E23B730676" "783B262E8EB43A25F55FB90B3E753AEF" "8C6713EC66C51881111593CCB3E8CB8F" "8DE124080501EEEB389C4BCB6977CF95" "7D5789631EB4554400E1E025935DFA7B" "3E9039D61BDC58A8697D36815BF1985C" "EFDF7AE112E5BB81E37ECF0616CE7147" "FC08A93A367E08631F23C03B00A8DA2F" "B375703739DACED4DD4059FD71C3C47F" "C2F9939670FAD4A46066ADCC6A564578" "3308B90FFB72BE04A6B147CBE38CC0C3" "B9267C296A92A7C69873F9F263BE9703"), H("F7A274D268316790A67EC058F45C0F2A" "067A99FCDE6236C0CEF8E056349FE54C" "5F13AC74D2539570FD34FEAB06C57205" "3949B59585742181A5A760223AFA22D4")); test_salsa20_stream(HL("48494A4B4C4D4E4F5051525354555657" "58595A5B5C5D5E5F6061626364656667"), H("0000000000000000"), H("53AD3698A011F779AD71030F3EFBEBA0" "A7EE3C55789681B1591EF33A7BE521ED" "68FC36E58F53FFD6E1369B00E390E973" "F656ACB097E0D603BE59A0B8F7975B98" "A04698274C6AC6EC03F66ED3F94C08B7" "9FFDBF2A1610E6F5814905E73AD6D0D2" "8164EEB8450D8ED0BB4B644761B43512" "52DD5DDF00C31E3DABA0BC17691CCFDC" "B826C7F071E796D34E3BFFB3C96E76A1" "209388392806947C7F19B86D379FA3AE" "DFCD19EBF49803DACC6E577E5B97B0F6" "D2036B6624D8196C96FCF02C865D30C1" "B505D41E2C207FA1C0A0E93413DDCFFC" "9BECA8030AFFAC2466E56482DA0EF428" "E63880B5021D3051F18679505A2B9D4F" "9B2C5A2D271D276DE3F51DBEBA934436"), H("7849651A820B1CDFE36D5D6632716534" "E0635EDEFD538122D80870B60FB055DB" "637C7CA2B78B116F83AFF46E40F8F71D" "4CD6D2E1B750D5E011D1DF2E80F7210A")); SUCCESS(); }
void doit (void) { /* RFC 4231 */ /* Test case 1 #4.2 */ do_kdf(HL("0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b" "0b0b0b0b"), HL("4869205468657265"), HL("b0344c61d8db38535ca8afceaf0bf12b" "881dc200c9833da726e9376c2e32cff7")); /* Test case 2 #4.3 */ do_kdf(HL("4a656665"), HL("7768617420646f2079612077616e7420" "666f72206e6f7468696e673f"), HL("5bdcc146bf60754e6a042426089575c7" "5a003f089d2739839dec58b964ec3843")); /* Test case 3 #4.4 */ do_kdf(HL("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaa"), HL("dddddddddddddddddddddddddddddddd" "dddddddddddddddddddddddddddddddd" "dddddddddddddddddddddddddddddddd" "dddd"), HL("773ea91e36800e46854db8ebd09181a7" "2959098b3ef8c122d9635514ced565fe")); /* Test case 4 #4.5 */ do_kdf(HL("0102030405060708090a0b0c0d0e0f10" "111213141516171819"), HL("cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd" "cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd" "cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd" "cdcd"), HL("82558a389a443c0ea4cc819899f2083a" "85f0faa3e578f8077a2e3ff46729665b")); /* Test case 5 #4.6 */ do_kdf(HL("0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c" "0c0c0c0c"), HL("546573742057697468205472756e6361" "74696f6e"), HL("a3b6167473100ee06e0c796c2955552b")); /* Test case 6 #4.7 */ do_kdf(HL("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaa"), HL("54657374205573696e67204c61726765" "72205468616e20426c6f636b2d53697a" "65204b6579202d2048617368204b6579" "204669727374"), HL("60e431591ee0b67f0d8a26aacbf5b77f" "8e0bc6213728c5140546040f0ee37f54")); /* Test case 6 #4.7 */ do_kdf(HL("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaa"), HL("54686973206973206120746573742075" "73696e672061206c6172676572207468" "616e20626c6f636b2d73697a65206b65" "7920616e642061206c61726765722074" "68616e20626c6f636b2d73697a652064" "6174612e20546865206b6579206e6565" "647320746f2062652068617368656420" "6265666f7265206265696e6720757365" "642062792074686520484d414320616c" "676f726974686d2e"), HL("9b09ffa71b942fcb27635fbcd5b0e944" "bfdc63644f0713938a7f51535c3a35e2")); }