目录
结构体定义
测试用基本量
drbg_hash_sha512测试数据
结构体定义
//DRBG测试中用, 因测试使用数据有很多相同之处
typedef struct dat_st
{
int len;
char * dat;
}tvstr;
//DRBG的测试向量
typedef struct drbg_test_vector_st
{
char * inf; //测试向量的附加信息说明
int alg; //DRBG算法
int prflag; //prediction_resistance_flag: 1 = ENABLED; 0 = NOT ENABLED
tvstr * entropy_init; //EntropyInput 初始化时的熵
tvstr * entropy_reseed1;//EntropyInput1 (for Reseed1) 第次reseed时的熵
tvstr * entropy_reseed2;//EntropyInput2 (for Reseed2) 第次reseed时的熵
tvstr * nonce; //Nonce
tvstr * personal; //PersonalizationString
tvstr * additional1; //AdditionalInput 1
tvstr * additional2; //AdditionalInput 2
int rlen1;
char * gen_rnd1; //generate rand val 1
int rlen2;
char * gen_rnd2; //generate rand val 1
}DRBGTV;//DRBG的测试向量
测试用基本量
tvstr Entropy_032 =
{
32,
"00010203 04050607"
"08090A0B 0C0D0E0F 10111213 14151617 18191A1B 1C1D1E1F",
};
tvstr Entropy_040 =
{
40,
"00010203 04050607 08090A0B 0C0D0E0F"
"10111213 14151617 18191A1B 1C1D1E1F 20212223 24252627",
};
tvstr Entropy_048 =
{
48,
"00010203 04050607 08090A0B 0C0D0E0F 10111213 14151617"
"18191A1B 1C1D1E1F 20212223 24252627 28292A2B 2C2D2E2F",
};
tvstr Entropy1_032 =
{
32,
"80818283 84858687"
"88898A8B 8C8D8E8F 90919293 94959697 98999A9B 9C9D9E9F",
};
tvstr Entropy1_040 =
{
40,
"80818283 84858687 88898A8B 8C8D8E8F"
"90919293 94959697 98999A9B 9C9D9E9F A0A1A2A3 A4A5A6A7",
};
tvstr Entropy1_048 =
{
48,
"80818283 84858687 88898A8B 8C8D8E8F 90919293 94959697"
"98999A9B 9C9D9E9F A0A1A2A3 A4A5A6A7 A8A9AAAB ACADAEAF",
};
tvstr Entropy2_032 =
{
32,
"C0C1C2C3 C4C5C6C7"
"C8C9CACB CCCDCECF D0D1D2D3 D4D5D6D7 D8D9DADB DCDDDEDF",
};
tvstr Entropy2_040 =
{
40,
"C0C1C2C3 C4C5C6C7 C8C9CACB CCCDCECF"
"D0D1D2D3 D4D5D6D7 D8D9DADB DCDDDEDF E0E1E2E3 E4E5E6E7",
};
tvstr Entropy2_048 =
{
48,
"C0C1C2C3 C4C5C6C7 C8C9CACB CCCDCECF D0D1D2D3 D4D5D6D7"
"D8D9DADB DCDDDEDF E0E1E2E3 E4E5E6E7 E8E9EAEB ECEDEEEF",
};
tvstr Personal_032 =
{
32,
"40414243 44454647"
"48494A4B 4C4D4E4F 50515253 54555657 58595A5B 5C5D5E5F",
};
tvstr Personal_040 =
{
40,
"40414243 44454647 48494A4B 4C4D4E4F"
"50515253 54555657 58595A5B 5C5D5E5F 60616263 64656667",
};
tvstr Personal_048 =
{
48,
"40414243 44454647 48494A4B 4C4D4E4F 50515253 54555657"
"58595A5B 5C5D5E5F 60616263 64656667 68696A6B 6C6D6E6F",
};
tvstr Additional1_032 =
{
32,
"60616263 64656667"
"68696A6B 6C6D6E6F 70717273 74757677 78797A7B 7C7D7E7F",
};
tvstr Additional1_040 =
{
40,
"60616263 64656667 68696A6B 6C6D6E6F"
"70717273 74757677 78797A7B 7C7D7E7F 80818283 84858687",
};
tvstr Additional1_048 =
{
48,
"60616263 64656667 68696A6B 6C6D6E6F 70717273 74757677"
"78797A7B 7C7D7E7F 80818283 84858687 88898A8B 8C8D8E8F",
};
tvstr Additional2_032 =
{
32,
"A0A1A2A3 A4A5A6A7"
"A8A9AAAB ACADAEAF B0B1B2B3 B4B5B6B7 B8B9BABB BCBDBEBF",
};
tvstr Additional2_040 =
{
40,
"A0A1A2A3 A4A5A6A7 A8A9AAAB ACADAEAF"
"B0B1B2B3 B4B5B6B7 B8B9BABB BCBDBEBF C0C1C2C3 C4C5C6C7",
};
tvstr Additional2_048 =
{
48,
"A0A1A2A3 A4A5A6A7 A8A9AAAB ACADAEAF B0B1B2B3 B4B5B6B7"
"B8B9BABB BCBDBEBF C0C1C2C3 C4C5C6C7 C8C9CACB CCCDCECF",
};
tvstr Entropy_055=
{
55,
"000102 03040506"
"0708090A 0B0C0D0E 0F101112 13141516 1718191A 1B1C1D1E"
"1F202122 23242526 2728292A 2B2C2D2E 2F303132 33343536",
};
tvstr Entropy_111 =
{
111,
"000102 03040506 0708090A 0B0C0D0E"
"0F101112 13141516 1718191A 1B1C1D1E 1F202122 23242526"
"2728292A 2B2C2D2E 2F303132 33343536 3738393A 3B3C3D3E"
"3F404142 43444546 4748494A 4B4C4D4E 4F505152 53545556"
"5758595A 5B5C5D5E 5F606162 63646566 6768696A 6B6C6D6E",
};
tvstr Entropy1_055 =
{
55,
"808182 83848586"
"8788898A 8B8C8D8E 8F909192 93949596 9798999A 9B9C9D9E"
"9FA0A1A2 A3A4A5A6 A7A8A9AA ABACADAE AFB0B1B2 B3B4B5B6",
};
tvstr Entropy1_111 =
{
111,
"808182 83848586 8788898A 8B8C8D8E"
"8F909192 93949596 9798999A 9B9C9D9E 9FA0A1A2 A3A4A5A6"
"A7A8A9AA ABACADAE AFB0B1B2 B3B4B5B6 B7B8B9BA BBBCBDBE"
"BFC0C1C2 C3C4C5C6 C7C8C9CA CBCCCDCE CFD0D1D2 D3D4D5D6"
"D7D8D9DA DBDCDDDE DFE0E1E2 E3E4E5E6 E7E8E9EA EBECEDEE",
};
tvstr Entropy2_055 =
{
55,
"C0C1C2 C3C4C5C6"
"C7C8C9CA CBCCCDCE CFD0D1D2 D3D4D5D6 D7D8D9DA DBDCDDDE"
"DFE0E1E2 E3E4E5E6 E7E8E9EA EBECEDEE EFF0F1F2 F3F4F5F6",
};
tvstr Entropy2_111 =
{
111,
"C0C1C2 C3C4C5C6 C7C8C9CA CBCCCDCE"
"CFD0D1D2 D3D4D5D6 D7D8D9DA DBDCDDDE DFE0E1E2 E3E4E5E6"
"E7E8E9EA EBECEDEE EFF0F1F2 F3F4F5F6 F7F8F9FA FBFCFDFE"
"FF000102 03040506 0708090A 0B0C0D0E 0F101112 13141516"
"1718191A 1B1C1D1E 1F202122 23242526 2728292A 2B2C2D2E",
};
tvstr Nonce05 = { 5, "20 21222324" }; //用于DRBG-HASH-SHA1
tvstr Nonce07 = { 7, "202122 23242526"}; //用于DRBG-HASH-SHA224
tvstr Nonce08 = { 8, "20212223 24252627"}; //用于DRBG-HASH-SHA256等
tvstr Nonce12 = {12, "20212223 24252627 28292A2B"}; //用于DRBG-HASH-SHA384等
tvstr Nonce16 = {16, "20212223 24252627 28292A2B 2C2D2E2F"};//用于DRBG-HASH-SHA512等
tvstr Personal_055 =
{
55,
"404142 43444546"
"4748494A 4B4C4D4E 4F505152 53545556 5758595A 5B5C5D5E"
"5F606162 63646566 6768696A 6B6C6D6E 6F707172 73747576",
};
tvstr Personal_111 =
{
111,
"404142 43444546 4748494A 4B4C4D4E"
"4F505152 53545556 5758595A 5B5C5D5E 5F606162 63646566"
"6768696A 6B6C6D6E 6F707172 73747576 7778797A 7B7C7D7E"
"7F808182 83848586 8788898A 8B8C8D8E 8F909192 93949596"
"9798999A 9B9C9D9E 9FA0A1A2 A3A4A5A6 A7A8A9AA ABACADAE",
};
tvstr Additional1_055 =
{
55,
"606162 63646566"
"6768696A 6B6C6D6E 6F707172 73747576 7778797A 7B7C7D7E"
"7F808182 83848586 8788898A 8B8C8D8E 8F909192 93949596",
};
tvstr Additional1_111 =
{
111,
"606162 63646566 6768696A 6B6C6D6E"
"6F707172 73747576 7778797A 7B7C7D7E 7F808182 83848586"
"8788898A 8B8C8D8E 8F909192 93949596 9798999A 9B9C9D9E"
"9FA0A1A2 A3A4A5A6 A7A8A9AA ABACADAE AFB0B1B2 B3B4B5B6"
"B7B8B9BA BBBCBDBE BFC0C1C2 C3C4C5C6 C7C8C9CA CBCCCDCE"
};
tvstr Additional2_055 =
{
55,
"A0A1A2 A3A4A5A6"
"A7A8A9AA ABACADAE AFB0B1B2 B3B4B5B6 B7B8B9BA BBBCBDBE"
"BFC0C1C2 C3C4C5C6 C7C8C9CA CBCCCDCE CFD0D1D2 D3D4D5D6",
};
tvstr Additional2_111 =
{
111,
"A0A1A2 A3A4A5A6 A7A8A9AA ABACADAE"
"AFB0B1B2 B3B4B5B6 B7B8B9BA BBBCBDBE BFC0C1C2 C3C4C5C6"
"C7C8C9CA CBCCCDCE CFD0D1D2 D3D4D5D6 D7D8D9DA DBDCDDDE"
"DFE0E1E2 E3E4E5E6 E7E8E9EA EBECEDEE EFF0F1F2 F3F4F5F6"
"F7F8F9FA FBFCFDFE FF000102 03040506 0708090A 0B0C0D0E"
};
tvstr Empty = { 0, NULL,};
drbg_hash_sha512测试数据
typedef DRBGTV hash_drbg_sha512_tv;
hash_drbg_sha512_tv drbg_hash_sha512[] =
{
{ /* 测试向量************************************************************/
/* inf */ (char*)"NIST提供Hash DRBG SHA512测试向量", DRBG_HASH_SHA512, FALSE,
/* EntropyInput */ &Entropy_111,
/* Entropy1 (Reseed1) */ &Entropy1_111,
/* Entropy2 (Reseed2) */ &Entropy2_111,
/* Nonce */ &Nonce16,
/* PersonalizationString*/ &Empty,
/* AdditionalInput 1 */ &Empty,
/* AdditionalInput 2 */ &Empty,
/* rnd_val 1 */ 128,
"170CC707 C71C69CE"
"45C43CBA FF521014 0572D478 59521BA1 3141BADD 2E5B9A7B"
"3E802062 5CD8893F D6A4739C 581ED5BE 7FA3148A 05D7F54A"
"E9EADAE8 F1A7194D F94B6B75 5B948E0C 27E1747F 02F663D6"
"B514A0F5 86F94E53 D32169E1 CCC6211A D0348124 19B6BA8F"
"3C829304 898393BF 39E57E2F EDF775FC 6E5EB0E3 07EDCA0B",
/* rnd_val 2 */ 128,
"D515B92B 1811F5AA"
"D02AAC9B 39DFA5B8 B1A95048 7D3429B1 081D0FEC 28D57686"
"D85BC6B4 5AB8B84C 54DD80B2 82591F55 07ED9B3F B1CDEEFD"
"58AD5A98 12ED929C 779B0F54 BADF2CAF BACFACB3 ECACC127"
"C7640CBB 67154F54 5A622BE0 A9B552A2 4208313B FA491F53"
"AAA3074B DC48BC5B DB3FF0E2 D05BB477 B59F87E3 A1EAB3E6",
},
{ /* 测试向量************************************************************/
/* inf */ (char*)"NIST提供Hash DRBG SHA512测试向量", DRBG_HASH_SHA512, FALSE,
/* EntropyInput */ &Entropy_111,
/* Entropy1 (Reseed1) */ &Entropy1_111,
/* Entropy2 (Reseed2) */ &Entropy2_111,
/* Nonce */ &Nonce16,
/* PersonalizationString*/ &Empty,
/* AdditionalInput1 */ &Additional1_111,
/* AdditionalInput2 */ &Additional2_111,
/* rnd_val 1 */ 128,
"3EF283D8 E1A5F5A8"
"D5D8AD9C 45577576 DD018161 387C97B3 2EB5A104 A9649E9E"
"DC85F9E4 DF40A823 A66E5494 CB3FB655 99D81A02 E415704C"
"A738D2C8 D5020C42 08F364A8 750251A8 74AF6FFD 88638094"
"8B7138A6 81E093B5 32A6E67E 9F3AC97E 1364A1E2 BC8E1121"
"5771CA69 4D933FCF 86CD3500 121AD1AF 66821B61 92BE3C97",
/* rnd_val 2 */ 128,
"8EB0575C E1500BB0"
"52259F8A 995DC7AE F54FBD38 E9CE6AEA F3F05FA7 0768AF36"
"99A24D90 BF60E3E6 509B4326 A5473B2C E98DE137 DB06EF9F"
"03A125BF 1367DEFB 8098633F A2EF8493 454F6792 F1F94C52"
"5282EEC9 D0352D93 B966966B AA85DBAC 596B3240 E2E28D35"
"E71E7B73 05C92473 AE706480 E9061CD8 DA37F147 700B67B8",
},
{ /* 测试向量************************************************************/
/* inf */ (char*)"NIST提供Hash DRBG SHA512测试向量", DRBG_HASH_SHA512, FALSE,
/* EntropyInput */ &Entropy_111,
/* Entropy1 (Reseed1) */ &Entropy1_111,
/* Entropy2 (Reseed2) */ &Entropy2_111,
/* Nonce */ &Nonce16,
/* PersonalizationString*/ &Personal_111,
/* AdditionalInput1 */ &Empty,
/* AdditionalInput2 */ &Empty,
/* rnd_val 1 */ 128,
"B72E446C 3985DA7B"
"F5009134 C2C59BAF 7918AEA7 27FAC3CA 39C31DD6 45357AC9"
"168DA218 027BD5D8 642C1306 895765A0 4757EF52 F4D81C55"
"8DE70751 3FE96C08 56E390B1 45F5B016 A3649D07 A1A9F5C6"
"DF1E27A8 830451DB FA12AB97 70A998D7 AD7D3EB3 488328FF"
"874E6C12 94A60539 199C9A99 C75BFE5F A0446DAE 248E0DCB",
/* rnd_val 2 */ 128,
"557C2284 16B46E30"
"A3E703F6 A5270130 7003615D 0DFCD1D4 F5E1F147 BAB4461F"
"4AF69FE4 13AAA932 F537BA0B BEF93FA0 BA6EE187 8B86312A"
"E9259DEC 73D73F27 345DFCFC F7D18E29 CF66DE2C 0615AF35"
"A6C9218C E1EF2DA9 4C865A47 7A64FAC3 9D21D344 F19F8344"
"53C68BC1 5FD929B2 B9B32D71 0E145F08 DA0FBD5E 0924061C",
},
{ /* 测试向量************************************************************/
/* inf */ (char*)"NIST提供Hash DRBG SHA512测试向量", DRBG_HASH_SHA512, FALSE,
/* EntropyInput */ &Entropy_111,
/* Entropy1 (Reseed1) */ &Entropy1_111,
/* Entropy2 (Reseed2) */ &Entropy2_111,
/* Nonce */ &Nonce16,
/* PersonalizationString*/ &Personal_111,
/* AdditionalInput1 */ &Additional1_111,
/* AdditionalInput2 */ &Additional2_111,
/* rnd_val 1 */ 128,
"DA126CF9 5C6BF97E"
"2F731F21 37A907AC C70FD7AC 9EBACD1C 6E31C740 29B052E3"
"AABC48F3 B00993F2 B2381F76 50A55322 A968C86E 05DE88E6"
"367F6EF8 9A601DB4 342E9086 C7AC13B5 E56C32E9 E668040B"
"73847893 C5BFD38A 1CF44F34 8B4EEE4C D68ADB7E 7B8C837F"
"19BC4F90 2761F7CF F24AB1D7 04FD11C4 E929D855 3753B55D",
/* rnd_val 2 */ 128,
"400B977C E8A2BB6A"
"84C6FD1C F9014596 85ABF540 8CFF4588 CEDF52E2 D2DC300A"
"A9B4FAED 8CD0161C 2172B1FD 26925319 5883D6EB F21020F2"
"C20E5F2C 81AE60C8 595B834A 229B1F5B 726C1125 717E6207"
"8886EF38 E61E3270 7AD5F811 6C6393DF B6E7C7AE 0E8E92BB"
"D7E0C3D0 4BBA02F5 169F2F56 9A581589 15FEE4C9 D28D45DB",
},
{ /* 测试向量************************************************************/
/* inf */ (char*)"NIST提供Hash DRBG SHA512测试向量", DRBG_HASH_SHA512, TRUE,
/* EntropyInput */ &Entropy_111,
/* Entropy1 (Reseed1) */ &Entropy1_111,
/* Entropy2 (Reseed2) */ &Entropy2_111,
/* Nonce */ &Nonce16,
/* PersonalizationString*/ &Empty,
/* AdditionalInput1 */ &Empty,
/* AdditionalInput2 */ &Empty,
/* rnd_val 1 */ 128,
"F93CA685 5590A77F"
"07354097 E90E0266 48B6115D F008FFED BD9D9811 F54E8286"
"EF00FDD6 BA1E58DF 2535E3FB DD9A9BA3 754A97F3 6EE83322"
"1582060A 1F37FCE4 EE882663 6B28EAD5 89593F4C A8B64738"
"8F24EB3F 0A347969 68D21BDE E6F81FD5 DF93536F 935937B8"
"025EC8CB F57DDB0C 61F2E414 63CC1516 D657DA28 29C6BF90",
/* rnd_val 2 */ 128,
"4817618F 48C60FB1"
"CE5BFBDA 0CAF4591 882A31F6 EE3FE0F7 8779992A 06EC60F3"
"7FB9A8D6 108C231F 0A927754 B0599FA4 FA27A4E2 5E065EF0"
"3085B892 979DC0E7 A1080883 CAEBFDFD 3665A8F2 D061C521"
"F7D6E3DA 2AF8B97B 6B43B6EC 831AF515 070A83BB B9AC95ED"
"4EF49B75 6A2377A5 F0833D84 7E27A88D DB0C2CE4 AD782E7B",
},
{ /* 测试向量************************************************************/
/* inf */ (char*)"NIST提供Hash DRBG SHA512测试向量", DRBG_HASH_SHA512, TRUE,
/* EntropyInput */ &Entropy_111,
/* Entropy1 (Reseed1) */ &Entropy1_111,
/* Entropy2 (Reseed2) */ &Entropy2_111,
/* Nonce */ &Nonce16,
/* PersonalizationString*/ &Empty,
/* AdditionalInput1 */ &Additional1_111,
/* AdditionalInput2 */ &Additional2_111,
/* rnd_val 1 */ 128,
"0455DD4A D7DBACB2"
"410BE58D F7248D76 5A4547AB AEE1743B 0BCAD37E BD06DA7C"
"F7CE5E22 16E52532 7E9E2005 EBEF2CE5 3BD733B1 8128627D"
"3FD61530 89373AF2 606A1584 646A0EA4 88BFEF45 228699A0"
"89CEA8AE C44502D8 6D9591F3 552C688B 7F7B45FC B0C3C2B9"
"43C1CD8A 6FC63DF4 D81C3DA5 43C9CF28 43855EA8 4E4F959C",
/* rnd_val 2 */ 128,
"C047D46D 7F614E4E"
"4A7952C7 9A451F8F 7ACA3799 67E2977C 401C626A 2ED70D74"
"A6366057 9A354115 BC8C8C8C C3AEA305 0686A0CF CDB6FA9C"
"F78D4C21 65BAF851 C6F9B1CD 16A2E14C 15C6DAAC 56C16E75"
"FC84A14D 58B41622 E88B0F1B 1995587F D8BAA999 CBA98025"
"4C8AB9A9 691DF7B8 4D88B639 A9A3106D EABEB637 48B99C09",
},
{ /* 测试向量************************************************************/
/* inf */ (char*)"NIST提供Hash DRBG SHA512测试向量", DRBG_HASH_SHA512, TRUE,
/* EntropyInput */ &Entropy_111,
/* Entropy1 (Reseed1) */ &Entropy1_111,
/* Entropy2 (Reseed2) */ &Entropy2_111,
/* Nonce */ &Nonce16,
/* PersonalizationString*/ &Personal_111,
/* AdditionalInput1 */ &Empty,
/* AdditionalInput2 */ &Empty,
/* rnd_val 1 */ 128,
"22EB93A6 7911DA73"
"85D9180C 78127DE1 A04FF713 114C07C9 C615F7CC 5EF72744"
"A2DDCD7C 3CB85E65 DED8EF5F 240FBDCB EBBDE2BA AC8ECF7D"
"CBC8AC33 3E54607A D41DC495 D83DF72A 05EF55B1 27C1441C"
"9A0EFFDA 2C7954DB 6C2D0434 2EB812E5 E0B11D6C 395F41ED"
"A2702ECE 5BA479E2 DFA18F95 30974926 36C12FE3 0CE5C968",
/* rnd_val 2 */ 128,
"E66698CF BF1B3F2E"
"919C0303 6E584EAA 81CF1C66 66240AF0 5F706370 43733954"
"D8A1E5A6 6A04C53C 6900FDC1 45D4A3A8 0A31F586 8ACE9AC9"
"4E14E205 1F624A05 EEA1F8B6 84AA5410 BCE315E7 6EA07C71"
"5D6F3473 1320FF0D CF78D795 E6EFA2DF 92B98BE6 36CDFBA2"
"9008DD39 2112AEC2 02F2E481 CB9D83F9 87FEA69C D1B368BB",
},
{ /* 测试向量************************************************************/
/* inf */ (char*)"NIST提供Hash DRBG SHA512测试向量", DRBG_HASH_SHA512, TRUE,
/* EntropyInput */ &Entropy_111,
/* Entropy1 (Reseed1) */ &Entropy1_111,
/* Entropy2 (Reseed2) */ &Entropy2_111,
/* Nonce */ &Nonce16,
/* PersonalizationString*/ &Personal_111,
/* AdditionalInput1 */ &Additional1_111,
/* AdditionalInput2 */ &Additional2_111,
/* rnd_val 1 */ 128,
"7596A763 72308BD5"
"A5613439 934678B3 5521A94D 81ABFE63 A21ACF61 ABB88B61"
"E86A12C3 7F308F2B BBE32BE4 B38D03AE 80838649 4D70EF52"
"E9E1365D D18B7784 CAB826F3 1D47579E 4D57F69D 8BF3152B"
"95741946 CEBE5857 1DF58ED3 9980D9AF 44E69F01 E8989759"
"8E401711 01A0E330 2838E0AD 9E849C01 988993CF 9F6E5263",
/* rnd_val 2 */ 128,
"DBE5EE36 FCD85301"
"303E1C36 17C1AC5E 23C08885 D0BEFAAD 0C85A0D8 9F85B9F1"
"6ECE3D88 A24EB965 04F2F13E FA704962 1782F5DE 2C416A0D"
"294CCFE5 3545C4E3 09C48E1E 285A2B82 9A574B72 B3C2FBE1"
"34D01E37 06B486F2 401B9820 E17298A3 42666918 E15B8462"
"87F8C5AF 2D96B20F AF3D0BB3 92E15F4A 06CDB0DE CD1B6AD7",
},
};