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

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

热度:89   发布时间:2024-01-12 01:15:58.0

目录

结构体定义

测试用基本量

drbg_ctr_aes256测试数据


结构体定义

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

typedef DRBGCTRTV drbg_ctr_aes256_tv;

drbg_ctr_aes256_tv drbg_ctr_aes256[] = /* no_df use_df 测试数据合在一起*/

{

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

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

              /* EntropyInput                  */    &Entropy_048

              /* Entropy1 (Reseed1)  */    &Entropy1_048

              /* Entropy2 (Reseed2)  */    &Entropy2_048

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

              /* PersonalizationString*/   &Empty,

              /* AdditionalInput 1    */    &Empty,

              /* AdditionalInput 2    */    &Empty,

              /*  no df rnd_val 1             */    32,

              "06155023 4D158C5E C95595FE 04EF7A25 767F2E24 CC2BC479 D09D86DC 9ABCFDE7",

              /*  no df rnd_val 2             */    32,

              "1A9FBCBC 8DA36DFF 2ABE2032 96170FDB 97C3297F 67FCB679 AC719C9F D00253B0",

              /* use df rnd_val 1       */    32,

              "E686DD55 F758FD91 BA7CB726 FE0B573A 180AB674 39FFBDFE 5EC28FB3 7A16A53B",

              /* use df rnd_val 2       */    32,

              "8DA6CC59 E703CED0 7D58D96E 5B6D7836 C3259973 5B734F88 C1A73B53 C7A6D82E",

       },

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

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

              /* EntropyInput                  */    &Entropy_048,

              /* Entropy1 (Reseed1)  */    &Entropy1_048

              /* Entropy2 (Reseed2)  */    &Entropy2_048

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

              /* PersonalizationString*/   &Empty,

              /* AdditionalInput1            */    &Additional1_048,

              /* AdditionalInput2            */    &Additional2_048

              /*  no df rnd_val 1             */    32,

              "93A8EF3A C44E4A3D 587DF216 EB6FE3B7 75EE3E94 4CAAC70F 35B56004 AE24B7B8",

              /*  no df rnd_val 2             */    32,

              "8911B73C 1EC1626F 37F221B1 2929BD5D 20B67373 768048E8 A1E0737E DF0F22D6",

              /* use df rnd_val 1       */    32,

              "498D25F7 124327CD FEBAF7F0 1559AFF8 4813F609 74BA5BD8 96C0CD5F 88BA5E32",

              /* use df rnd_val 2       */    32,

              "81DAAF98 00C34FF0 A104E51D 87E36F5B 17EB14B9 ABC5064C ADDA976E C4F77D34",

       },

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

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

              /* EntropyInput                  */    &Entropy_048,

              /* Entropy1 (Reseed1)  */    &Entropy1_048,

              /* Entropy2 (Reseed2)  */    &Entropy2_048,

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

              /* PersonalizationString*/   &Personal_048,

              /* AdditionalInput1            */    &Empty

              /* AdditionalInput2            */    &Empty

              /*  no df rnd_val 1             */    32,

              "5DE6AA50 022F01DF 045B3FDA 58A2AD77 9132F66F B04CE0C2 B0FA0721 F686D3E4",

              /*  no df rnd_val 2             */    32,

              "1DD89F20 7997AE24 C8EB7550 21A90AA1 3CA67FFC 6881D577 1A9745F8 0C7FD207",

              /* use df rnd_val 1       */    32,

              "99BB703C DD820609 903F1241 EA856E27 A54C2B75 EEA7775B 68093FCD 47B52E7F",

              /* use df rnd_val 2       */    32,

              "BB2A0F5F 0CA6D306 34BA6068 EB94AAE8 701437DB 7223A1B5 AFE87715 47DA3CEE",

       },

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

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

              /* EntropyInput                  */    &Entropy_048,

              /* Entropy1 (Reseed1)  */    &Entropy1_048,

              /* Entropy2 (Reseed2)  */    &Entropy2_048,

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

              /* PersonalizationString*/   &Personal_048,

              /* AdditionalInput1            */    &Additional1_048

              /* AdditionalInput2            */    &Additional2_048,

              /*  no df rnd_val 1             */    32,

              "35CE8218 C03B7592 FAF29D19 72273983 6CEEF066 6E058ABF 8B837AB5 E5E743D9",

              /*  no df rnd_val 2             */    32,

              "836CA0F7 75468B8A ABCD3129 FE2A2227 B2251DCC 22A0BFA0 175EAB7C A29892BA",

              /* use df rnd_val 1       */    32,

              "47111E14 6562E9AA 2FB2A1B0 95D37A81 65AF8FC7 CA611D63 2BE7D4C1 45C83900",

              /* use df rnd_val 2       */    32,

              "98A28E3B 1BA363C9 DAF0F688 7A1CF52B 833D3354 D77A7C10 837DD63D D2E645F8",

       },

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

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

              /* EntropyInput                  */    &Entropy_048,

              /* Entropy1 (Reseed1)  */    &Entropy1_048,

              /* Entropy2 (Reseed2)  */    &Entropy2_048,

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

              /* PersonalizationString*/   &Empty,

              /* AdditionalInput1            */    &Empty,

              /* AdditionalInput2            */    &Empty,

              /*  no df rnd_val 1             */    32,

              "893EB3AE 65F69FE3 1D7EFC8E E1583348 C1723F25 9F66875A 213CD971 2706FBA1",

              /*  no df rnd_val 2             */    32,

              "67219E23 0FEF83C0 DF3B2020 1C8F9B5D DFF62224 D9CEF23A 6C96474C 2D1A51CD",

              /* use df rnd_val 1       */    32,

              "D1E9C737 B6EBAED7 65A0D4E4 C6EAEBE2 67F5E919 3680FDFF A62F4865 B3F009EC",

              /* use df rnd_val 2       */    32,

              "259DC78C CFAEC421 0C30AF81 5E4F75A5 662B7DA4 B41013BD C00302DF B6076492",

       },

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

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

              /* EntropyInput                  */    &Entropy_048,

              /* Entropy1 (Reseed1)  */    &Entropy1_048,

              /* Entropy2 (Reseed2)  */    &Entropy2_048,

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

              /* PersonalizationString*/   &Empty,

              /* AdditionalInput1            */    &Additional1_048,

              /* AdditionalInput2            */    &Additional2_048,

              /*  no df rnd_val 1             */    32,

              "499B4951 9CB0C1A7 13CA0E5B 82DF4D11 6C370752 3D483563 BEBE9407 8C2A5E01",

              /*  no df rnd_val 2             */    32,

              "353B67AA E68C0CC6 3C5567B4 86F2B27C 121469A2 757951E0 9429E33F 0758F3AD",

              /* use df rnd_val 1       */    32,

              "71BB3F9C 9CEAF4E6 C92A83EB 4C722501 0EE150AC 75E23F5F 77AD5073 EF24D88A",

              /* use df rnd_val 2       */    32,

              "386DEBBB F091BBF0 502957B0 329938FB 836B82E5 94A2F5FD D5EB28D4 E35528F4",

       },

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

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

              /* EntropyInput                  */    &Entropy_048,

              /* Entropy1 (Reseed1)  */    &Entropy1_048,

              /* Entropy2 (Reseed2)  */    &Entropy2_048,

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

              /* PersonalizationString*/   &Personal_048,

              /* AdditionalInput1            */    &Empty,

              /* AdditionalInput2            */    &Empty,

              /*  no df rnd_val 1             */    32,

              "1CD51D0A A03AA992 782B53B5 96297930 DD0541DC 3B05C9AD 35998E53 DB960664",

              /*  no df rnd_val 2             */    32,

              "3A4E58FC 06DD9AAB B85480E7 896AF882 0B43F969 FDC38628 EBA7F06C D9A063D8",

              /* use df rnd_val 1       */    32,

              "1A2E3FEE 9056E98D 375525FD C2B63B95 B47CE51F CF594D80 4BD5A17F 2E01139B",

              /* use df rnd_val 2       */    32,

              "601F9538 4F0D8594 6301D1EA CE8F645A 825CE38F 1E2565B0 C0C43944 8E9CA8AC",

       },

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

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

              /* EntropyInput                  */    &Entropy_048,

              /* Entropy1 (Reseed1)  */    &Entropy1_048,

              /* Entropy2 (Reseed2)  */    &Entropy2_048,

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

              /* PersonalizationString*/   &Personal_048,

              /* AdditionalInput1            */    &Additional1_048,

              /* AdditionalInput2            */    &Additional2_048,

              /*  no df rnd_val 1             */    32,

              "DBAFEF48 988EF939 5298F5E3 4CF7A6A4 FBD2256C 52A8C8C7 80B848BB B90EA521",

              /*  no df rnd_val 2             */    32,

              "50A6509D 314E1C24 26ADD435 2D1B3CF4 6C9896F5 7E4148A9 4DBCA894 63F22239",

              /* use df rnd_val 1       */    32,

              "EAE6BCE7 81807E52 4D26605E A1980779 32D01EEB 445B9AC6 C5D99C10 1D29F46E",

              /* use df rnd_val 2       */    32,

              "738E99C9 5AF59519 AAD37FF3 D5180986 ADEBAB6E 95836725 097E50A8 D1D0BD28",

       },

};