diff options
-rw-r--r-- | src/tests/data/bn/dsa_gen.vec | 86 | ||||
-rw-r--r-- | src/tests/test_bigint.cpp | 46 |
2 files changed, 130 insertions, 2 deletions
diff --git a/src/tests/data/bn/dsa_gen.vec b/src/tests/data/bn/dsa_gen.vec new file mode 100644 index 000000000..a8c9a5396 --- /dev/null +++ b/src/tests/data/bn/dsa_gen.vec @@ -0,0 +1,86 @@ +# From NIST FIPS 186-3 CAVS test vectors (May 04 08:50:52 2011) + +[160,1024] +P = 0x861F667D91F69347EB4D9CAD32E092F9780353D67DAA25119C85E9E3D69E90E9C61ACD34AC08872EA48F01883D40F009DD9B23C74D45A8AEC24BDAA8697F6E622319D0DED28F870218B2036DA2C135D4873DBBDCFFD1873F258041B342C116A14093647FC969A7C68EFF42F56F38F6ED7A036B9C8FC70B1B8AA97E4058D2E94D +Q = 0xD6176BD352652861DE08EE21A2D6597622E522B9 +Seed = 492270A5D1B3D74CC16928C3E80032C297F8C422 + +P = 0xB5CF7916632405A72A407979949EE858C91ADFCABFAA6CCA0E5456090B0D8EB7F36C34F23DFE1759C4A3ADCD776629D871214560E5E11B2F79792F040042987091C55951060BCB5FDF7CB93FED8B45FEA26376E7682FC601DF883DC7E272489B83181AAC7340A1EB0A0FC97F53AC80F3F965CD8ABCD7AA5FE1D2E38A357CB9F1 +Q = 0xAB1A788BCE3C557A965A5BFA6908FAA665FDEB7D +Seed = 1F5DA0AF598EEADEE6E6665BF880E63D8B609BA2 + +P = 0xD91E0AFBBB6EEF8229588BFD59DF6D47BA4BFF14104D7D182F403204DCA5DD859F8DA96FAA74523B323F705E7B4D62425D7A6CD7052C1045E6A2E79745F4625BBA2B22B3DED86E9F903298E28F8E8CE365D67E37227C04F5C80F223251060BD291F338629E4F58BABCCC14CE9F46AF474F7A5C8BA22E0587F84157DDDDA7BB7D +Q = 0xFA0CD4B34387D320D483B3DC4728A9359B17992F +Seed = B378CFBD34B4101C4DCE33538822ED25AF4D6230 + +P = 0xACD5CFD97AF56F5D5699BF71791DB35DA14BD07517F119D01D0873DA5A96A375A527D7E5D530E20BB81ED377A1095AEF5618C75C30BDAAF1CEE0B16E1A911F95CF452ED06CB3A608E5B9A09C25C37572CE0C139F4FF9F4E89D3E13A5E372936120664341CF9F70CD327029E09C74108472B5A28AD274EB4C39FF03464242A435 +Q = 0xF30876D39C441114685E3998776063AAA7F9C0D1 +Seed = 828BC9726EED9C6FA7D7F03AA582122CCDFFD5F9 + +P = 0xF68008A9E020F4161C55BA692305E424A21D6E76E3D98B5A55DAB72EE839A67969FBEC3A54A210874FFA0A8A3CF7067FB9394896EA9E4C46E67EB957E708329DA3C19B093F95CE3A0A0370C29850E2DEB1A6B4AE764BFE8A9D84A430048DC2526C70E0BD22597483B49842A3688964AA50F19DD0F389B866D6CE1704F71BAC79 +Q = 0xC7CAD94C843BCFD0B0695888C0E1C3AF00BC60E9 +Seed = 48C8F626EB22A9D258E6AAED900D923B56C508D7 + +[224,2048] +P = 0xA5EF01F3071E73BE30C896A6C88BADF224AC0B1B88B376DE04248247FEDC70E20AC70D34CACF753222AD0C55E84DB1DC0A50868E636632D0A95AA327556EE9D5CE310FDD299C39DED7F36B211168D227665A7DE25B537C575B417C56B18594FE03692294F52970C698D8C6E0978A4553B8BAE97A9FD2FAAE33677923E444E97D4097A6EBD0CD0E31414EBE9C9DE375ABB661731B2C5C62F3A42A2B7AA71EE114F8DAE22E3D903E57A410974CA156A083DCA96A9613600521F3B08509B6B482CE4426C8CA37770BEC7E5B173B8C02E06664314061CD6D4D898EA17F4D53FB547F9175DA912211AB65E0DBC2B8DD3CA420B9B4012638295176037F4DEED25F9DEB +Q = 0x94444E45DBB89CF4BE000EBEB98CAFD87F41DAA548C7449C46B1B63D +Seed = 2F4BDC8EFBA78904D7DC8A0EB98F8486D066ACDBDE25FEE5BCE25AD1 + +P = 0xC6C220912B0616E7829172851BF9A8FB9B1C2292735C9C3975EDD524EE3673712883E393A84AF03650DD723CA193E43BE7D5137D261261049716B825506937CACD7B74305F775AE54CB74C7E6092A969774D5DA32E2C1B7DEE77AD6D0138BCC8F5429A05605451C3F0B874744CA0FCEE9A9B784B0026A2666CF5E13629A4BD9891E4F14B79F4D294F04FAD4A7A72B4757F4EEF235C64F8C27E1BDBA5A5FA6502D7F73846320E5CEF7F9CE10DD0A3614E677C7A3F17603325BD7ECA045BBE7EBF782102A345B108EB294C989E8285EEB7AB100FB16690459C8546F6D1881605BFAC08C278FE31FC3DC7C98E21B3F038D898633ADF3EE0230C28747A00000BA8D3 +Q = 0xB8D4E4D471E6B14B63991E6356A7F744F3622BCFCE9E095AFEB0C119 +Seed = 502527B06F584CEF9EDB968756CAF6E482311A588DE45D9D92CB34E3 + +P = 0xD84646E7A6CD94F6B59AE0E9E4C2771E4427577DE02427DB99D47B1900991C042E157767AA8D18ED52F42C01E705D54928CFCBF413098AECD354A39B821ACDCE2ECAC983F555DF4758481823F43E36BFFB02AC176855672D8BAF66DA26CF92435AD98A69ECD57F13B3849383A3C54665A55BA85283AC12272B66EDCC2396A393E43CDF87BF80B29A6E140F36201A5A3B347D82D4967AF3812985326AD09BD0C9BE5984CB7A5AA1113B31E05A78C6F4D5047637E1CA897F8B35E42BBAF070F6C14DD556511735A8623353EA8533BEC1D986446FC287001A123567D7E05A6EF993764F4CB5695C683BCC406EDF4723271A01CCC34AB99947336EAE39FB7BEBC89F +Q = 0xFE79458D0457CC9BBF370B17D8E4FAB9D3B3205F48604603314DB6CF +Seed = 0DBBF5222F3D29D54F7A7BC90A7E3EB07BC82FAE3B552477CD88CE90 + +P = 0xF408E95EE670A7CEB27C1A174F159715122D6B4456C0C3F32073327FEC52D4C34D2ECA26B63DC0D6AE20E34AFE068CD03ADAD89E01D9A0CDDB9EDF1761EE0A51855224794E92BA43A5FD624BAC1047C58C873AE25314789CFE6FBD5748E0A65D0E30142A149B0BC649ECCAFA8A2C1543958681A3DC85A15FC237F440D969342BA31E4FB555FA90B3B614493BA504AB99906CABFF6179650F595DAF53A6D1496A72D32729AB0B365EEA98967C76B2B6C04F07290DB285436ED4EB982D5844144A19668CA1F2676354C0C1E53E609392295B1F45954DCEF84AA88085A50E5F1C81148F961ACA6483FF79DDA88F699110551EADB82DD2F663BABA206E837ECD9785 +Q = 0xD9A392273802CA33861F15FFFDCE180B65E0E14AB8CB2C2E2077816B +Seed = C31E2BC7D927AD49F6840521A2AA0B7E6371C773EED271329AE41213 + +P = 0xC645528A39035BEA1B8EE9C2BDF513A6B6F5BFE707D4931FAAE1D1DA638BE8531F15D78D5B6A7A83EA309D9B2AA8B128425DE6F85D4D7E7758A1FA7A3E16E33541BEB060010BF7DB432C99F417BEA5C36E290378889E91578B1ABCDFF7A46531CBA7A960280AB71546EFCD375151FF4E80735FB77D8D41341D9CBCAE341338167B69A4361BE34FF92F1DB6F0643CDF2ECA9D6C49E53A8FB0A7D1C3131540F032424A16DBFB6CFA8A2B1F4B6EC50989734931CB586EC6A55716E238ED52E9781B1F7EB10D47CD75B4814AAB68AA823C6659C30A968623FE017EAAD87079FA886B2DC5219DBFEFAD2BC2A37E100E26E781722BB35C0FE0CA448B2527AC3166943B +Q = 0xD9AC70A4BEFC93B9DDB7A2AB31D620BE75E980EC0AA09870544CB509 +Seed = F99A828DFB37C71A12D1FFD19DC0178A5BCE26BA457EF43D8FB8FFA3 + +[256,2048] +P = 0x8E2266D5CB5B1E9AD34AC6380E3D166FD4D60DADC6DFA1BE8492A5642C91FDF7E81B9634A4EEFF59E7E93B1B0E8F49DED45A72788866DFF71B1329FEEB4B6CDBF2C7166C7CBCA20B04300AE127C9940233E891712AC905ED6B43495717A2998EA8C4EEF4EC6C32DC9E774E8E66476F17D9C39ABAC59E8B583B1107B679E0BED078476E933A90CFCF80C89B831C0E054F86EAC7CA848E059662D938A4E12947E2E73B1FFEDD7125DD54BA463217ABC9C5F3399132AEC77B946C806429F6F812C10716D57DDE7B5D45CB2E5EB6E4DBB81D5A465054FA17E613CBE01AFB49EA593F33F1A696A774941CA1FF6F208577FE529F5E7592F39698C63BF6AE9D56CD2D93 +Q = 0xB19C6D094E1210C92910F49AA083957FBE68C0CA4602896F50123FD776786275 +Seed = F770A4598FF756931FC529764513B103CE57D85F4AD8C5CF297C9B4D48241C5B + +P = 0xB636E5970383CECAB68840CCA8A909A29325C3924E2C187DD034222F9E1A43341061CA620F82787BD349FB8F380FC3F0ADB84BE116C695529114AECEE8A0A1B09E7EBB6888E6DA71F48EEFB3E9990E2D7BD36C1AA24FB10E011A193D6B5A1B226CF97FAB302E237ECB1DC824264DBA2E2285930005717C4E9A12CC1A1AC336C20619C4D06EC4E1E02E0D1D2D285661A7472D30C4282646506487CBE6A5C988EE8402D474713A7D8213EEB19A0719996BBFD3835EB8832EEAD5A3A340E61C52F00DDE1C98655A13839AD215D8F43C8E482317AF8B086C3D555FC8DBB2F595F2563520A0C6387661774E1E6CA5FE2626B26A2C4F99B7AFF043A091434DFD3275B7 +Q = 0xFE9F06FA1901182AB00BF063BFF8FD4F736922CE830FD50FEE47EBBD21E291E9 +Seed = 3A66A430F23374CE3D2E758881C411C23DAD4A8CD6AD697056D24B8CFCC8C353 + +P = 0x8D636640981C2CE1935BD16AD3AA3CE2A6EFA26F23F07CEDA92766F80E82FA035C6CF44DC41E08FEA242C5CD5846D839BDF0C11D3A29EBACA00AAD844CD33A80448F1F96CEBE66B9963F7E3B5C976E29DC430BC5DDF5D2C198EB736339ADC14D5C8A3D22533D7C6A861B6A8B31C55E46804E4C2F95E2E9CC2BBB23BBC833995A7AFE619127D28FA53B0712B17DA4786F9116CC39E2C6254845E85513C220E368FE9C92BC71EABFA831062F01E66E8A970F043112CA0AF175F64D13FCFF2F087FFF9198A9FE9732001AB49B2A48D0E39F99D036698703AA853AC02C65F3D559935A72C8BBC6AB2FA59FF9A2FCD837A4675229ABED23D42BADC12A60B34A3BF0F5 +Q = 0xB5F3C535E7F48D3251D353B73B3A05C4BDB4591A8C2F2BA4A6A945A889F5AEFF +Seed = 77EB88F087BFBBC312BCA7572BAFD36F2A7ACA2E4D7378DD923B0B277F3D730F + +P = 0x8FA95228B848A9533375E4789C88BB7DF505C4478ED3C79545C5D2B04F0E0EFBAC8D3F603603A48B203E1CC67DED22B840AC21BC41B7AB78C73A9CD0773148CA7C87A5A51564164F683E8F8A77B97CF7D91F989AA3668819BCA8F54E0EC8F10C78ECD26982048CF0AB0446A6DE154BBED8891BE916627D470061811CAF51BEF1B5BE8EF2B560CF981C2A097B3769BED61D6EE9B66221E956FE2C49F1809A2D5F6996BE7B39F41AFEA5184A73C049F3ABBD28FDDBF37BCAE6C4AA4A7255464C2EEE915C44B8D90D76E5D9E3D8E6CF4AC7C5D9436D19CCC27C5BC1B65DBB56723B5E77624489652313F9DA2CE38554401FDBD61C78F2A4FA69BCC2F5AAFFBFED2D +Q = 0xED3F52BCE81572D126B27FB1E9C02346AE523532AF82B79943565593D6F46D45 +Seed = E0ED96BF5E7D78754B5095ED766A1BBC4338EAA8F3D00E9906EF51A8798BC1C2 + +P = 0xA80F2481A814D07EB47A7C67E24BC3F8F1CCEBC6CF684A0BC9FBB0054CC24CEF24872315B566630D5147184980B4BCE3F0849660C84B22DFACB785446C0F6314B7A53A92CF821BCCEB325E03DC9E404832146D34FF8A9B112ED0E69EFE69C6195DE03373E590EBA88FC5B9D337D6566DC7E82E326A28343F644779F6784159EB3D33F2DDF1157A02F2F91D0897A4E8AD53F614186A5FE043187510316904BD956966E10735D6EF01C195B7DD7FD245A83C18AF7908FEF0BCED2F454E1954F2A32C35658F4E0F5811A3D06C81CCA715537DEBABBBC65BA4DD0E7FB0C08397622F039A51DF69F5B10DDA61F57BBB84C55F25EACD0F3D8B40AE016ED0BA856837E7 +Q = 0x9E3B5A7939082C95069902D3833DF8421871CA2DAB8A34F7BE6CD39151291D07 +Seed = C7BB440D973189CA07464B037FD309F68EC38BABA390988A2E986ECEE281E2F5 + +[256,3072] + +P = 0xA9A1BBDAF47BBF939394BE1A09C926F8454868724EA0E250C85391799107C8AD071CCA629B2176545EFD6627884426C3DC22D4A6DB9C2A598A2AAA0E073DA4B85A92D169FFB304106A1B0F7735DECA6982C2683AC968BEF6570FB07DDFF0B0EA899BA88295EB167BE900E41A6C8DF073BDFC986DE3ED164F3D723ED6A53EC920F27809B5B881C7A79DF6CA6C27F1E2A9B862B43DFC31CCCE1FA2FE5D52DDF309092BA6E74EF5BAF34BB958EE47D406454913DB0174B644F5494B88D550B648234268296816D5F13FCB0C9EC941CCEC2F89063546002FC595A823FBBF32935D04B7887A8BC551BCF09EE0DCDCFAFC92D3A905EF80105F578249164438689487AC029E1226017B8EF8237C47F1F760A7483EA9BDF5620C5A43A07E0C3AF5380DBBB6460C52838ED212554BA77817C695D6BEACFC07819899C5F402E947CABF8D066AB2814B00B8D8EDAE3D80EDE581C45D7BF61F6D04C570328852090FF294CD91D2471C3226C55995C508348549606731A534487F81F29FAD798653CBCFA450BF +Q = 0xA0CB348B7AB4557E615F6EB6456897DC1EFC788789C412171C1C694A10A31387 +Seed = B167BEEDE890505C69F3671195F5E3242C03BF9CE89EBCD6D2231E95DAFCE2ED + +P = 0xE4B20E906D7100659E348C25170E8B2005CAFCB505F61B11CE00289185090725A36279D4F30B6E1C461CC6FF791DA04E040DD1E59846F77256517D06C7F026AE98E5B257CFD5D439F18AE33846903114EBE1C14474C01B2763995F90FEB4B498465F0B666348FDB6748C469B156A62A6C3460713E33FA510E0F25199448DED51D8C9F03CC496BE3753601F4A36D2492308824C00036A2B2474AA1C9E715C0AAB1D8EAE4ED7968953BC3B55C9640F0297AB702314AAD32F44E58AC033497205FE512FE0B07B316ED131760CD430F9D721C2C1381785E49B93CDC711C330CEB5A214F0EDD97074528E0DE4C88BB5EEB105BB062270ED2E2E50FA960698285A2B43B067C49C92469E39582B49E457418E0C59772753ED5F41A1E1A50C943536FD359D517A28A4B6CAC7CA24A9ED27879E5E750782F40B09D2BF7B13823F1A8BA52C3A02B1BBDF8C96BE27F8738F0EE719D5ED8348EF7570057A926BC361B254586CA372CF1C47AB5BE2611D754B9D4A74CB3E45FC94522CB64C2F7934CCD7C81023 +Q = 0xC688DD65FB0C5B9D9E535C77598D918909EB955FB925C4E30616C25C65C7F4D7 +Seed = C4AE29DB448E0B111E9FCD8626DA16C1CC47229E64BAF2CB93D4927B1F9C1E8B + +P = 0xC8FEF9916D26FD6104164BE6C3104E1041828C7CD158F2FD4079329E7540EE385B64E66A717850BB728B2CD731B7B1E60F29B0C5CBA3F7C81EB5324A5B7EC27DC3DE8687932FB195B32F4E3E4AFCE237E50F821BDAF80FD93A9EE4337C0495D34EA74067565D297FBBC175091F439FE2E4FA6606469F86BB11A09DDB448E63F8E4F03E9068DD34C2602B9377E7D91A683C5866125621F039DFE1E7DA25184A1753FBEFCD5DF01EA522394ED6FB263712E1B1D54D2F5AA1D3F651D37B7BD35648D6D80D5658B89DA15E89271A143808AA43BB9CE832FE373538BF88DE0637E12B36C37E6C1AAE1D4FB1AB6A1AB43C07262CC4D3C2EB116184ECF64C7C6431AA4ED22537B074BAEA4DACCD1163121DC0523B94C7819D6F22B119D1573BE012092D5B69267FF355DEE653CAB4ED575824FE53435DC8A92624A1DAA7A578E58206FC7BB56048FBB9874C62B5C680AF4DF7C881D9D93D725DDC586BBF004D49184C94F01E4A938EC24B42926827ED4BCCFEA87288686F38BC04FB24B376637BB10A45 +Q = 0xE28110722C105D8A453F7F15CA89BBB5E27783F35BDD3A8D2EFA3C0358293F75 +Seed = 1915C7D89BF0856CE36D417055822F180E173CD78E032C8FB30D0E8EDCB261DB + +P = 0x8E6C12B3B028AEAF88F21075C96BD8DE0DE9D31FA75D6BA3B349DB4163C7F80D5A53DC7118151F5B904834AF045A9C824EFDAAB2D5449D2E805F7AD0AA60D0AC260DA9C3182A25A215723B7C85873888395532B8E7ABC4E93903E3A99911063EF56E8BB25C3DE19C0B5A16C451A9EF4500BA60D7210458248E6D51CB2BC56F2CC9164DA87695F6CD8450CB07DE604F7390A78C1A3BD8083ADB572B2FA9AFE5CB0DF877D415004D50F1338F3BD3394272BA595510740DDE8C636FC63E7FED469717E6DC418E93B4BE3A136CDCE039557A01ECB1CFD31DC8699D02328E252C4DF020D1DC23B13BC8D1B8C8791D779CCEE874EDBF1E42E8CB6C319DC0043A7583E4FE7A1677B7ACF7B0DAAC11DB0F5DEE9CB90AE35DCBE582716625A934B45979BA8ECE0DD541C8D5D2E2452F047967766D9A1FE9A825811E278769BD26407E8F838AF5BD60F34072B6776E3AB2369B1994A1232B8F6BE8438D4BB7F4F50873866E55AF79BC10B4061574F2BAAA254D7097D40691B926FBC244A7A227FCDDB4B783 +Q = 0x8BE8E9C283397DE23A1F718E91BCB44341893D269C2F55BB55131AE60D4827DD +Seed = 2159910828C9E9923393CD1426326BEF50FC8AB823641D628B4FBA027B6A43C6 + +P = 0xEE110644C8EFEEF9F1DC19E42DBE4A32FB85E43ABF3B4A2972443F5E6F3852A71401C76DE97233977FFB9F139471FF51F1DCCC60DE0746031DD09233F017013B80D2DD7D5C5BE4EB2F9D55D7DF41DBB75EACEF314D739BC54C1E4D47356AFB8E72222EA95D9081679DC55B0376818F54E94C23C44F723C081B35025C06F6F3E67FF53A04F0A668FBBE3A421F23C48466468DD9D3E61E87EF8ED4D74FFEA4CF07DEA19157CF0370FB67778F9ADA58FA0771A538A66CAA022221ED7E8407CC65793290028AEDEEC7A4EDE15D96577F573B08D4CF630FF54BCF7B3237872645704547E10B0646D9192A795A88DF547B2B1DB54FA11F5BE42487E8BB78E19795B82553892666E9B0E9D0001C3CD4AD8CFA4580C1E79CFA719C00BE114D2D1FD6EB29BF7A58DE95F3C0977AEB128B0D0E31C1F34AB30D0DEC1AD74A3EBFAFE6D48784AE66A592E84A460E43A2A23A6DF6FAE65D83B03D794D044D0176A75415AA9B3A5E1EBF9930C2F5EEDBE00E633A1367E382203165219A3D4476A2096600E005C3 +Q = 0x927F85A4CF3768EAD1D8F21E884386A95DA784F4904C8D5F9EFC701C5AA01703 +Seed = F4F0FA605C985CFA4D5D3D8731B96406CA261A10BDBCE3E6145E9D12C041DA15 diff --git a/src/tests/test_bigint.cpp b/src/tests/test_bigint.cpp index cee7b5b8b..3d9fd7139 100644 --- a/src/tests/test_bigint.cpp +++ b/src/tests/test_bigint.cpp @@ -6,7 +6,7 @@ #include "tests.h" -#if defined(BOTAN_HAS_BIGINT) +#if defined(BOTAN_HAS_NUMBERTHEORY) #include <botan/bigint.h> #include <botan/numthry.h> #include <botan/reducer.h> @@ -17,7 +17,7 @@ namespace Botan_Tests { namespace { -#if defined(BOTAN_HAS_BIGINT) +#if defined(BOTAN_HAS_NUMBERTHEORY) using Botan::BigInt; @@ -508,6 +508,48 @@ class BigInt_InvMod_Test : public Text_Based_Test BOTAN_REGISTER_TEST("bn_invmod", BigInt_InvMod_Test); +class DSA_ParamGen_Test : public Text_Based_Test + { + public: + DSA_ParamGen_Test() : Text_Based_Test("bn/dsa_gen.vec", {"P","Q","Seed"}) {} + + Test::Result run_one_test(const std::string& header, const VarMap& vars) override + { + const std::vector<byte> seed = get_req_bin(vars, "Seed"); + const Botan::BigInt P = get_req_bn(vars, "P"); + const Botan::BigInt Q = get_req_bn(vars, "Q"); + + const std::vector<std::string> header_parts = Botan::split_on(header, ','); + + if(header_parts.size() != 2) + throw Test_Error("Unexpected header '" + header + "' in DSA param gen test"); + + const size_t p_bits = Botan::to_u32bit(header_parts[1]); + const size_t q_bits = Botan::to_u32bit(header_parts[0]); + + Test::Result result("DSA Parameter Generation"); + + // These tests are very slow so skip in normal runs + if(Test::soak_level() <= 5 && p_bits > 1024) + return result; + + Botan::BigInt gen_P, gen_Q; + if(Botan::generate_dsa_primes(Test::rng(), gen_P, gen_Q, p_bits, q_bits, seed)) + { + result.test_eq("P", gen_P, P); + result.test_eq("Q", gen_Q, Q); + } + else + { + result.test_failure("Seed did not generate a DSA parameter"); + } + + return result; + } + }; + +BOTAN_REGISTER_TEST("dsa_param", DSA_ParamGen_Test); + #endif } |