当前位置: 代码迷 >> 综合 >> 确定性随机数发生器测试向量——DRBG-CTR-AES192
  详细解决方案

确定性随机数发生器测试向量——DRBG-CTR-AES192

热度:23   发布时间:2024-01-12 01:15:44.0

目录

结构体定义

测试用基本量

drbg_ctr_aes192测试数据


结构体定义

//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_ctr_aes192测试数据

typedef DRBGCTRTV drbg_ctr_aes192_tv;

drbg_ctr_aes192_tv drbg_ctr_aes192[] = /* no_df use_df 测试数据合在一起*/

{

       { /* 测试向量************************************************************/

              /* inf */ (char*)"NIST提供CTR DRBG AES192测试向量", DRBG_CTR_AES192, FALSE,

              /* EntropyInput                  */    &Entropy_040

              /* Entropy1 (Reseed1)  */    &Entropy1_040

              /* Entropy2 (Reseed2)  */    &Entropy2_040

              /* Nonce                      */    &Nonce12, //no df时不需要nonce

              /* PersonalizationString*/   &Empty,

              /* AdditionalInput 1    */    &Empty,

              /* AdditionalInput 2    */    &Empty,

              /*  no df rnd_val 1             */    32,

              "01E0793E 6C7464FA FE1F6CF9 B7466A8A C4841737 9CBAA104 13DBCD98 E1977019",

              /*  no df rnd_val 2             */    32,

              "88CE7B6C 16365EEA 6FEE02BF BAE2DF4D 93AB03B9 CF8807E5 BEAD31D4 FB721DC9",

              /* use df rnd_val 1       */    32,

              "1A646BB1 D38BD2AE A30CF5C5 D812A624 B50D3ECA 99E508B2 5B5448A8 B96C0F2E",

              /* use df rnd_val 2       */    32,

              "0920CB32 A773E0FF 4BBBF90A CB1D7044 E15B629A FB3C7F9F E26673E3 E7BE4727",

       },

       { /* 测试向量************************************************************/ 

              /* inf */ (char*)"NIST提供CTR DRBG AES192测试向量", DRBG_CTR_AES192, FALSE,

              /* EntropyInput                  */    &Entropy_040,

              /* Entropy1 (Reseed1)  */    &Entropy1_040

              /* Entropy2 (Reseed2)  */    &Entropy2_040

              /* Nonce                      */    &Nonce12, //no df时不需要nonce,

              /* PersonalizationString*/   &Empty,

              /* AdditionalInput1            */    &Additional1_040,

              /* AdditionalInput2            */    &Additional2_040

              /*  no df rnd_val 1             */    32,

              "3A298716 7FF43CD7 94A9778F 3932A2E9 AA7C9518 24C82924 C7324560 4B0BEFA5",

              /*  no df rnd_val 2             */    32,

              "A963857B 976F18FD 1F1B3301 DA08E8E8 4694AAFB 55EA2B10 196BEE84 77570853",

              /* use df rnd_val 1       */    32,

              "6157D6C6 22896303 FE8E748C 18F2CE2E DF5C8A30 B8BBC26F D44C683D 7B150A97",

              /* use df rnd_val 2       */    32,

              "1F6DBD50 693817A1 9EF22622 3AB727E1 67158848 35CA0C5B 3B46D570 B4DD975A",

       },

       { /* 测试向量************************************************************/ 

              /* inf */ (char*)"NIST提供CTR DRBG AES192测试向量", DRBG_CTR_AES192, FALSE,  

              /* EntropyInput                  */    &Entropy_040,

              /* Entropy1 (Reseed1)  */    &Entropy1_040,

              /* Entropy2 (Reseed2)  */    &Entropy2_040,

              /* Nonce                      */    &Nonce12, //no df时不需要nonce,

              /* PersonalizationString*/   &Personal_040,

              /* AdditionalInput1            */    &Empty

              /* AdditionalInput2            */    &Empty

              /*  no df rnd_val 1             */    32,

              "517150FF D52BD344 DE78992B A224930C 98FC9FAC 541236E8 D199A476 B960B301",

              /*  no df rnd_val 2             */    32,

              "1F46912D 4DEA17B8 6500AA70 836A5076 24C090C5 C440EB07 D46A05AE 4822113D",

              /* use df rnd_val 1       */    32,

              "E231244B 3235B085 C8160442 4357E852 01E3828B 5C455686 79A5555F 867AAC8C",

              /* use df rnd_val 2       */    32,

              "DDD0F7BC CADADAA3 1A676522 59CE569A 271DD85C F66C3D6A 7E9FAED6 1F38D219",

       },

       { /* 测试向量************************************************************/ 

              /* inf */ (char*)"NIST提供CTR DRBG AES192测试向量", DRBG_CTR_AES192, FALSE

              /* EntropyInput                  */    &Entropy_040,

              /* Entropy1 (Reseed1)  */    &Entropy1_040,

              /* Entropy2 (Reseed2)  */    &Entropy2_040,

              /* Nonce                      */    &Nonce12, //no df时不需要nonce,

              /* PersonalizationString*/   &Personal_040,

              /* AdditionalInput1            */    &Additional1_040

              /* AdditionalInput2            */    &Additional2_040,

              /*  no df rnd_val 1             */    32,

              "ABB31FC6 61357CEB BCAE1E1C AEAA2E20 2F391044 9C5033B4 8FD3A23B DB7EA158",

              /*  no df rnd_val 2             */    32,

              "08C0521E BC9871E9 DC055DA1 B79E2FF0 DCE28C18 9E83156F F3D71586 21F5675A",

              /* use df rnd_val 1       */    32,

              "242D0B6B 9598779C 5CF5A50E DFD61C2C 95D383BC 493AC202 845FAC96 D276C092",

              /* use df rnd_val 2       */    32,

              "D2892F04 52967041 4F098DA2 6684CB1E 9460F3A6 ED58BFC8 383A300B DAF284AD",

       },

       { /* 测试向量************************************************************/ 

              /* inf */ (char*)"NIST提供CTR DRBG AES192测试向量", DRBG_CTR_AES192, TRUE

              /* EntropyInput                  */    &Entropy_040,

              /* Entropy1 (Reseed1)  */    &Entropy1_040,

              /* Entropy2 (Reseed2)  */    &Entropy2_040,

              /* Nonce                      */    &Nonce12, //no df时不需要nonce,

              /* PersonalizationString*/   &Empty,

              /* AdditionalInput1            */    &Empty,

              /* AdditionalInput2            */    &Empty,

              /*  no df rnd_val 1             */    32,

              "2A63138E AC6C8BD5 AFDBEA16 C751A239 24A5C5C3 63452EF1 8259D96F EA6D6334",

              /*  no df rnd_val 2             */    32,

              "7B737A56 AD339224 EA513F69 F7D4253E 832B6B48 A82AFA53 28C8E061 7F55AB54",

              /* use df rnd_val 1       */    32,

              "D1C68E36 9E5AE5CF B6564317 13DC972E 54B87DA6 326D0D49 D1C11653 70049FDB",

              /* use df rnd_val 2       */    32,

              "615A2637 1F46583E A33ED757 09D0EE55 5C62EC04 433648A7 C62FD43D 2764D52F",

       },

       { /* 测试向量************************************************************/ 

              /* inf */ (char*)"NIST提供CTR DRBG AES192测试向量", DRBG_CTR_AES192, TRUE,

              /* EntropyInput                  */    &Entropy_040,

              /* Entropy1 (Reseed1)  */    &Entropy1_040,

              /* Entropy2 (Reseed2)  */    &Entropy2_040,

              /* Nonce                      */    &Nonce12, //no df时不需要nonce,

              /* PersonalizationString*/   &Empty,

              /* AdditionalInput1            */    &Additional1_040,

              /* AdditionalInput2            */    &Additional2_040,

              /*  no df rnd_val 1             */    32,

              "771B1F40 BFCE49D0 9CFF56F8 9B171066 B07B6F07 BDFEAD61 04A5DCDA 011F2C68",

              /*  no df rnd_val 2             */    32,

              "E2F2D79B 95699645 125E327B 6E277ADE 061CA509 70E25CD3 7F42347E 371D3A24",

              /* use df rnd_val 1       */    32,

              "85C9EBEB 01415602 991037DC B4E75C58 FF1638B6 98519565 25BA9FD2 BAB2F5DC",

              /* use df rnd_val 2       */    32,

              "52D60B92 95D030CD 5DF0740F 6298F7FB 0BCE9363 56179511 4A3C3FAF 3782C843",

       },

       { /* 测试向量************************************************************/ 

              /* inf */ (char*)"NIST提供CTR DRBG AES192测试向量", DRBG_CTR_AES192, TRUE,

              /* EntropyInput                  */    &Entropy_040,

              /* Entropy1 (Reseed1)  */    &Entropy1_040,

              /* Entropy2 (Reseed2)  */    &Entropy2_040,

              /* Nonce                      */    &Nonce12, //no df时不需要nonce,

              /* PersonalizationString*/   &Personal_040,

              /* AdditionalInput1            */    &Empty,

              /* AdditionalInput2            */    &Empty,

              /*  no df rnd_val 1             */    32,

              "77562EBE 8EECDF9E DB9A2E88 640D8DFF 9F2A5E99 20B30313 DC33D3A8 CE3BAB41",

              /*  no df rnd_val 2             */    32,

              "1BB94DB5 81E84F96 37933BE7 81749070 62F0E95F 7AA30739 EC6FB059 6B74CFFD",

              /* use df rnd_val 1       */    32,

              "F780D4A2 C25CF8EE 7407D948 EC0B724A 4235D8B2 0E650813 92755CA7 912AD7C0",

              /* use df rnd_val 2       */    32,

              "BA14617F 915BA964 CB79276B DADC840C 14B631BB D1A59097 054FA6DF F863B238",

       },

       { /* 测试向量************************************************************/ 

              /* inf */ (char*)"NIST提供CTR DRBG AES192测试向量", DRBG_CTR_AES192, TRUE,

              /* EntropyInput                  */    &Entropy_040,

              /* Entropy1 (Reseed1)  */    &Entropy1_040,

              /* Entropy2 (Reseed2)  */    &Entropy2_040,

              /* Nonce                      */    &Nonce12, //no df时不需要nonce,

              /* PersonalizationString*/   &Personal_040,

              /* AdditionalInput1            */    &Additional1_040,

              /* AdditionalInput2            */    &Additional2_040,

              /*  no df rnd_val 1             */    32,

              "4C36423F DDD11096 DB6A62DA B872B607 F51ACB6E AA1A8FAD BA9A955E 08C2C136",

              /*  no df rnd_val 2             */    32,

              "D859C7BF 0D15D50D 81A65FEA B7D34605 1123E19F 64141105 43EA6D6F EE50EDEB",

              /* use df rnd_val 1       */    32,

              "01AFE09F 7BA5D683 8BCAB837 75F9C286 E6132674 06560F2C 069DB758 98DE5D3F",

              /* use df rnd_val 2       */    32,

              "28730443 3D9D7301 8DB647F8 459775BD 4EB52AF0 85D764AF A52D1DEE D8DACCDD",

       },

};