目录
结构体定义
测试用基本量
DRBG-HMAC-SHA1测试数据
结构体定义
//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-HMAC-SHA1测试数据
typedef DRBGTV drbg_hmac_sha1_tv;
drbg_hmac_sha1_tv drbg_hmac_sha1[] =
{
{/* 测试向量************************************************************/
/* inf */ (char*)"NIST提供HMAC DRBG SHA1测试向量", DRBG_HMAC_SHA1, FALSE,
/* EntropyInput */ &Entropy_055,
/* Entropy1 (Reseed1) */ &Entropy1_055,
/* Entropy2 (Reseed2) */ &Entropy2_055,
/* Nonce */ &Nonce05,
/* PersonalizationString*/ &Empty,
/* AdditionalInput 1 */ &Empty,
/* AdditionalInput 2 */ &Empty,
/* rnd_val 1 */ 40,
"5A7D3B44 9F481CB3 8DF79AD2 B1FCC01E"
"57F8135E 8C0B22CD 0630BFB0 127FB540 8C8EFC17 A929896E",
/* rnd_val 2 */ 40,
"82CF772E C3E84B00 FC74F5DF 104EFBFB"
"2428554E 9CE367D0 3AEADE37 827FA8E9 CB6A0819 6115D948",
},
{/* 测试向量************************************************************/
/* inf */ (char*)"NIST提供HMAC DRBG SHA1测试向量", DRBG_HMAC_SHA1, FALSE,
/* EntropyInput */ &Entropy_055,
/* Entropy1 (Reseed1) */ &Entropy1_055,
/* Entropy2 (Reseed2) */ &Entropy2_055,
/* Nonce */ &Nonce05,
/* PersonalizationString*/ &Empty,
/* AdditionalInput1 */ &Additional1_055,
/* AdditionalInput2 */ &Additional2_055,
/* rnd_val 1 */ 40,
"C7AAAC58 3C6EF630 0714C2CC 5D06C148 "
"CFFB4044 9AD0BB26 FAC0497B 5C57E161 E36681BC C930CE80",
/* rnd_val 2 */ 40,
"6EBD2B7B 5E0A2AD7 A24B1BF9 A1DBA47D"
"43271719 B9C37B7F E81BA940 45A14A7C B514B446 666EA5A7",
},
{/* 测试向量************************************************************/
/* inf */ (char*)"NIST提供HMAC DRBG SHA1测试向量", DRBG_HMAC_SHA1, FALSE,
/* EntropyInput */ &Entropy_055,
/* Entropy1 (Reseed1) */ &Entropy1_055,
/* Entropy2 (Reseed2) */ &Entropy2_055,
/* Nonce */ &Nonce05,
/* PersonalizationString*/ &Personal_055,
/* AdditionalInput1 */ &Empty,
/* AdditionalInput2 */ &Empty,
/* rnd_val 1 */ 40,
"B3BD0524 6CBA12A6 4735A4E3 FDE599BC"
"1BE30F43 9BD06020 8EEA7D71 F9D123DF 47B3CE06 9D98EDE6",
/* rnd_val 2 */ 40,
"B5DADA38 0E2872DF 935BCA55 B882C8C9"
"376902AB 63976547 2B71ACEB E2EA8B1B 6B49629C B67317E0",
},
{/* 测试向量************************************************************/
/* inf */ (char*)"NIST提供HMAC DRBG SHA1测试向量", DRBG_HMAC_SHA1, FALSE,
/* EntropyInput */ &Entropy_055,
/* Entropy1 (Reseed1) */ &Entropy1_055,
/* Entropy2 (Reseed2) */ &Entropy2_055,
/* Nonce */ &Nonce05,
/* PersonalizationString*/ &Personal_055,
/* AdditionalInput1 */ &Additional1_055,
/* AdditionalInput2 */ &Additional2_055,
/* rnd_val 1 */ 40,
"1F8FEC7B C7CFA9A8 80345D28 0B13C632"
"B852770A 6DFC302E AD4CE3F5 54C79B0D 44239EBA 56A7EA2D",
/* rnd_val 2 */ 40,
"AF97CDE1 E8AB322A 2EACA8E6 F4E5BF78"
"A11BDEF7 DC91215D 44B107B4 D5A77901 59250976 5280F969",
},
{/* 测试向量************************************************************/
/* inf */ (char*)"NIST提供HMAC DRBG SHA1测试向量", DRBG_HMAC_SHA1, TRUE,
/* EntropyInput */ &Entropy_055,
/* Entropy1 (Reseed1) */ &Entropy1_055,
/* Entropy2 (Reseed2) */ &Entropy2_055,
/* Nonce */ &Nonce05,
/* PersonalizationString*/ &Empty,
/* AdditionalInput1 */ &Empty,
/* AdditionalInput2 */ &Empty,
/* rnd_val 1 */ 40,
"FEC4597F 06A3A8CC 8529D595 57B9E661"
"053809C0 BC0EFC28 2ABD8760 5CC90CBA 9B8633DC B1DAE02E",
/* rnd_val 2 */ 40,
"84ADD5E2 D2041C01 723A4DE4 335B13EF"
"DF16B0E5 1A0AD39B D15E862E 644F31E4 A2D7D843 E57C5968",
},
{/* 测试向量************************************************************/
/* inf */ (char*)"NIST提供HMAC DRBG SHA1测试向量", DRBG_HMAC_SHA1, TRUE,
/* EntropyInput */ &Entropy_055,
/* Entropy1 (Reseed1) */ &Entropy1_055,
/* Entropy2 (Reseed2) */ &Entropy2_055,
/* Nonce */ &Nonce05,
/* PersonalizationString*/ &Empty,
/* AdditionalInput1 */ &Additional1_055,
/* AdditionalInput2 */ &Additional2_055,
/* rnd_val 1 */ 40,
"A1BA8FA5 8BB5013F 43F7B6ED 52B4539F"
"A16DC779 57AEE815 B9C07004 C7E992EB 8C7E5919 64AFEEA2",
/* rnd_val 2 */ 40,
"84264A73 A818C95C 2F424B37 D3CC990B"
"046FB50C 2DC64A16 4211889A 010F2471 A0912FFE A1BF0195",
},
{/* 测试向量************************************************************/
/* inf */ (char*)"NIST提供HMAC DRBG SHA1测试向量", DRBG_HMAC_SHA1, TRUE,
/* EntropyInput */ &Entropy_055,
/* Entropy1 (Reseed1) */ &Entropy1_055,
/* Entropy2 (Reseed2) */ &Entropy2_055,
/* Nonce */ &Nonce05,
/* PersonalizationString*/ &Personal_055,
/* AdditionalInput1 */ &Empty,
/* AdditionalInput2 */ &Empty,
/* rnd_val 1 */ 40,
"6C37FDD7 29AA40F8 0BC6AB08 CA7CC649"
"794F6998 B57081E4 220F22C5 C283E2C9 1B8E305A B869C625",
/* rnd_val 2 */ 40,
"CAF57DCF EA393B92 36BF691F A456FEA7"
"FDF1DF83 61482CA5 4D5FA723 F4C88B4F A504BF03 277FA783",
},
{/* 测试向量************************************************************/
/* inf */ (char*)"NIST提供HMAC DRBG SHA1测试向量", DRBG_HMAC_SHA1, TRUE,
/* EntropyInput */ &Entropy_055,
/* Entropy1 (Reseed1) */ &Entropy1_055,
/* Entropy2 (Reseed2) */ &Entropy2_055,
/* Nonce */ &Nonce05,
/* PersonalizationString*/ &Personal_055,
/* AdditionalInput1 */ &Additional1_055,
/* AdditionalInput2 */ &Additional2_055,
/* rnd_val 1 */ 40,
"BD07C25C FD7C5E3A 4EAA6E2E DC5AB7EA"
"4942A091 3471FDA5 5C6DDD2C 03EFA3B9 643AB3BB 22F6C9F2",
/* rnd_val 2 */ 40,
"D1A9C1A2 2C84FC23 FF2227EF 98EC8BA9"
"DF2A209B A1DB0980 9F57BFEA E5B3E5F1 46C75F2D 8DBB5E4A",
},
};