本文主要是介绍确定性随机数发生器测试向量——DRBG-HMAC-SHA384,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
目录
结构体定义
测试用基本量
DRBG-HMAC-SHA384测试数据
结构体定义
//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-SHA384测试数据
typedef DRBGTV drbg_hmac_sha384_tv;
drbg_hmac_sha384_tv drbg_hmac_sha384[] =
{
{/* 测试向量************************************************************/
/* inf */ (char*)"NIST提供HMAC DRBG SHA384测试向量", DRBG_HMAC_SHA384, FALSE,
/* EntropyInput */ &Entropy_111,
/* Entropy1 (Reseed1) */ &Entropy1_111,
/* Entropy2 (Reseed2) */ &Entropy2_111,
/* Nonce */ &Nonce12,
/* PersonalizationString*/ &Empty,
/* AdditionalInput 1 */ &Empty,
/* AdditionalInput 2 */ &Empty,
/* rnd_val 1 */ 96,
"FF08EED5 0F04D543 FAE5C9C8 FB31D784 89FE82C9 F77F60ED"
"A91A86E5 5EFADB6B 3431BF08 86BC1A63 C44FAD9B 9715C092"
"6C24AA45 76A94444 23BF6B55 8CEA09FD BADCE2A5 C05BD480"
"F8DEF079 75826DAA 53EF71EC 7E28CB38 1D10A7B0 C09A1D15",
/* rnd_val 2 */ 96,
"1B3D9FAB 561E4C87 B78EABAC 0773E0CE 6AF93E9B B67B7719"
"C6176752 7000351D D7D6910F 3AA375B7 70D38CF2 0270CBB1"
"147AE249 F9DADB7A 5B4B6380 12C14ECA DCA32FBD DA8ED4BF"
"73586EE5 DC9D543F 210437D4 866F7A2E FD326447 CAF4F68C",
},
{/* 测试向量************************************************************/
/* inf */ (char*)"NIST提供HMAC DRBG SHA384测试向量", DRBG_HMAC_SHA384, FALSE,
/* EntropyInput */ &Entropy_111,
/* Entropy1 (Reseed1) */ &Entropy1_111,
/* Entropy2 (Reseed2) */ &Entropy2_111,
/* Nonce */ &Nonce12,
/* PersonalizationString*/ &Empty,
/* AdditionalInput1 */ &Additional1_111,
/* AdditionalInput2 */ &Additional2_111,
/* rnd_val 1 */ 96,
"52DCD4A4 07EE8506 D9CFF5B0 1F938959 73D45E58 52AFA29A"
"8F11ADFC CDF21274 57C3BAB6 D6A0EC28 7DAB83C6 1011D311"
"D3CC40D6 FE744874 4A13E811 ABE42206 9118240B 09B4E330"
"FB7EB1E1 C1871B73 92C5B7EF A753EDA2 260D41ED A4B0A8EE",
/* rnd_val 2 */ 96,
"A8E2404D 14F6AE1F A9B66686 3D4C0265 2B806170 3F958798"
"870032C9 D6D3CA10 302DC1C5 FE0F5B21 1F760EFB 4177684B"
"A5056D84 B35B9FCC E4C44818 080346AD CC9AC610 E4719575"
"B0D1713D DF30C671 99EA0A17 B1592E9B 75390462 D3059C35",
},
{/* 测试向量************************************************************/
/* inf */ (char*)"NIST提供HMAC DRBG SHA384测试向量", DRBG_HMAC_SHA384, FALSE,
/* EntropyInput */ &Entropy_111,
/* Entropy1 (Reseed1) */ &Entropy1_111,
/* Entropy2 (Reseed2) */ &Entropy2_111,
/* Nonce */ &Nonce12,
/* PersonalizationString*/ &Personal_111,
/* AdditionalInput1 */ &Empty,
/* AdditionalInput2 */ &Empty,
/* rnd_val 1 */ 96,
"03AB8BCE 4D1DBBB6 36C5C5B7 E1C58499 FEB1C619 CDD11D35"
"CD6CF6BB 8F20EF27 B6F5F905 4FF900DB 9EBF7BF3 0ED4DCBB"
"BC8D5B51 C965EA22 6FFEE2CA 5AB2EFD0 0754DC32 F357BF7A"
"E42275E0 F7704DC4 4E50A522 0AD05AB6 98A22640 AC634829",
/* rnd_val 2 */ 96,
"B907E771 44FD55A5 4E9BA1A6 A0EED0AA C780020C 41A15DD8"
"9A6C1638 30BA1D09 4E6A1710 0FF71EE3 0A96E1EE 04D2A966"
"03832A4E 404F1966 C2B5F4CB 61B9927E 8D12AC1E 1A24CF23"
"88C14E8E C96C3518 1EAEE32A AA46330D EAAFE5E7 CE783C74",
},
{/* 测试向量************************************************************/
/* inf */ (char*)"NIST提供HMAC DRBG SHA384测试向量", DRBG_HMAC_SHA384, FALSE,
/* EntropyInput */ &Entropy_111,
/* Entropy1 (Reseed1) */ &Entropy1_111,
/* Entropy2 (Reseed2) */ &Entropy2_111,
/* Nonce */ &Nonce12,
/* PersonalizationString*/ &Personal_111,
/* AdditionalInput1 */ &Additional1_111,
/* AdditionalInput2 */ &Additional2_111,
/* rnd_val 1 */ 96,
"3918F6DF 5E50B922 CDD7D0FB 87967822 33141EEE 8A14AB69"
"B2B3970A F1D30D9F 344225A1 5384869B 208ADB4B 5674C6DA"
"0C9ED74F 56BC8FB4 8145FB36 90FDA956 1AD6038A 5B1E0BA2"
"AC09FCC5 D35E5898 3570F37C CE516D76 407A2342 F802CCB9",
/* rnd_val 2 */ 96,
"BFFE3657 BE463125 BC247C54 B3A5B608 A7198008 78F5058A"
"34ECAC69 2837F275 F0449FB1 5B04C2F1 2F12A189 87FF1E5B"
"10370288 FF0074CA 6D99DD0B 5912AE3A B2875B18 201626E6"
"1D2E3A0C FF95F45E 49B02FB8 CFBDE860 0B222872 82E01DF3",
},
{/* 测试向量************************************************************/
/* inf */ (char*)"NIST提供HMAC DRBG SHA384测试向量", DRBG_HMAC_SHA384, TRUE,
/* EntropyInput */ &Entropy_111,
/* Entropy1 (Reseed1) */ &Entropy1_111,
/* Entropy2 (Reseed2) */ &Entropy2_111,
/* Nonce */ &Nonce12,
/* PersonalizationString*/ &Empty,
/* AdditionalInput1 */ &Empty,
/* AdditionalInput2 */ &Empty,
/* rnd_val 1 */ 96,
"0DC4AC80 D862FBB4 83980077 5BF1E7D3 7AE1E195 A9A30C44"
"3A4229B2 8D277E2A BE8E7E41 AC5A870E F3824657 4203FD0D"
"0C68069F 3DE0F533 57F8B80A FE695876 C731D774 E80CCDA5"
"8927FE45 F6168BE8 BC56F876 8ED2065D 0C5829D7 8694EDCF",
/* rnd_val 2 */ 96,
"018413E2 105E8803 FA13F8E8 65D538B4 747B3297 2577F180"
"70A3F1B6 49986781 027DC908 210BAD0F 0E1DA470 A0450EFD"
"0EC93DC0 06D24E95 BC6BA656 7AB36074 A29F2C93 B836FAF9"
"62F80560 E44D759F F920BCFA 83EF4595 16F7196D 0885C522",
},
{/* 测试向量************************************************************/
/* inf */ (char*)"NIST提供HMAC DRBG SHA384测试向量", DRBG_HMAC_SHA384, TRUE,
/* EntropyInput */ &Entropy_111,
/* Entropy1 (Reseed1) */ &Entropy1_111,
/* Entropy2 (Reseed2) */ &Entropy2_111,
/* Nonce */ &Nonce12,
/* PersonalizationString*/ &Empty,
/* AdditionalInput1 */ &Additional1_111,
/* AdditionalInput2 */ &Additional2_111,
/* rnd_val 1 */ 96,
"61AA7FC4 4CD9D28E 5A19092C 5ADBA05D F7A4EADC FBBB920F"
"2A2EF8DC 1692F203 EC3EAC8D 38FD917D 13CA80AC A874003E"
"CD556DD9 954C5802 4AA6B155 1049E612 D548C6EA CACC5C26"
"0CACCD88 47CFE880 8B5B57D2 F3405ECD 1DD84756 585E8FBE",
/* rnd_val 2 */ 96,
"8659E679 E61EF663 2374C514 07F7DDA2 7DC0CE8D 8A444EB8"
"CA912CE1 3BB20D88 9E880E65 71913D67 2498DE90 2B71CEDA"
"5D644344 C63CD4D9 43CB6872 30867D60 F4712AEC 962EB77C"
"CDB141F6 678C622A 65A0B2B3 E3DBD812 891EA5FC F09D2F19",
},
{/* 测试向量************************************************************/
/* inf */ (char*)"NIST提供HMAC DRBG SHA384测试向量", DRBG_HMAC_SHA384, TRUE,
/* EntropyInput */ &Entropy_111,
/* Entropy1 (Reseed1) */ &Entropy1_111,
/* Entropy2 (Reseed2) */ &Entropy2_111,
/* Nonce */ &Nonce12,
/* PersonalizationString*/ &Personal_111,
/* AdditionalInput1 */ &Empty,
/* AdditionalInput2 */ &Empty,
/* rnd_val 1 */ 96,
"804A3AD7 20F4FCE8 738D0632 514FEF16 430CB7D6 3A8DF1A5"
"F02A3CE3 BD7ED6A6 68B69E63 E2BB93F0 96EE753D 6194A0F1"
"A3271106 36530096 36337D22 167CC440 2D019AC2 16FA574F"
"091CF6EA 283568D7 37A77BE3 8E8F0938 2C69E76B 142ABC3A",
/* rnd_val 2 */ 96,
"73B8E55C 75320217 6A17B9B9 754A9FE6 F23B0186 1FCD4059"
"6AEAA301 AF1AEF8A F0EAF22F BF34541E FFAB1431 666ACACC"
"759338C7 E2867281 9D53CFEF 10A3E19D AFBD5329 5F1980A9"
"F491504A 27255067 84B7AC82 6D92C838 A8668171 CAAA86E7",
},
{/* 测试向量************************************************************/
/* inf */ (char*)"NIST提供HMAC DRBG SHA384测试向量", DRBG_HMAC_SHA384, TRUE,
/* EntropyInput */ &Entropy_111,
/* Entropy1 (Reseed1) */ &Entropy1_111,
/* Entropy2 (Reseed2) */ &Entropy2_111,
/* Nonce */ &Nonce12,
/* PersonalizationString*/ &Personal_111,
/* AdditionalInput1 */ &Additional1_111,
/* AdditionalInput2 */ &Additional2_111,
/* rnd_val 1 */ 96,
"5EDACD29 898A1E8F B0E32CCD 77EF56C6 CBD0D9BD 7027CFF5"
"3FEF9050 047682C6 9CE18B27 31CEDEF6 7E9066B9 4EDD2CAF"
"6683302E 3FB51FF8 6767A6FD B607BFD8 744DA141 E67E8326"
"7850F789 7C927DE7 D4A27EEA 9A7A8131 C4C22D76 9CCA49E0",
/* rnd_val 2 */ 96,
"EFE5120A 69A85539 27016001 03492DFF 3D7F253E 83765107"
"E2301DFA 51DCB14C 2F61DB1B 0030BF70 CCA6FB38 9BD34914"
"8929CC00 CCC8CA6F B9138FD4 5BB0A9BA 136D0E2B 9CE54D63"
"4BC4D139 B238A097 1883C693 B9958354 A2CAFAFE 3654958D",
},
};
这篇关于确定性随机数发生器测试向量——DRBG-HMAC-SHA384的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!