Added BLAKE2 Cryptographic Hash and Message Authentication Code

This commit is contained in:
Jeffrey Walton 2016-04-17 03:06:28 -04:00
parent a11c9e7574
commit 30c1af2858
9 changed files with 1562 additions and 0 deletions

View File

@ -25,6 +25,8 @@ bench.cpp
bench.h
bench2.cpp
bfinit.cpp
blake2.cpp
blake2.h
blowfish.cpp
blowfish.h
blumshub.cpp
@ -363,6 +365,9 @@ TestData/xtrdh342.dat
TestVectors/Readme.txt
TestVectors/aes.txt
TestVectors/all.txt
TestVectors/blake2.txt
TestVectors/blake2b.txt
TestVectors/blake2s.txt
TestVectors/camellia.txt
TestVectors/ccm.txt
TestVectors/cmac.txt

View File

@ -31,4 +31,6 @@ Test: TestVectors/gcm.txt
Test: TestVectors/cmac.txt
Test: TestVectors/eax.txt
Test: TestVectors/mars.txt
Test: TestVectors/blake2s.txt
Test: TestVectors/blake2b.txt
Test: TestVectors/hkdf.txt

4
TestVectors/blake2.txt Normal file
View File

@ -0,0 +1,4 @@
AlgorithmType: FileList
Name: blake2.txt collection
Test: TestVectors/blake2s.txt
Test: TestVectors/blake2b.txt

439
TestVectors/blake2b.txt Normal file
View File

@ -0,0 +1,439 @@
AlgorithmType: MessageDigest
Name: BLAKE2b
Source: blake2b-ref.c reference implementation
Message: ""
Digest: 786A02F742015903C6C6FD852552D272912F4740E15847618A86E217F71F5419D25E1031AFEE585313896444934EB04B903A685B1448B755D56F701AFE9BE2CE
Test: Verify
Message: "a"
Digest: 333FCB4EE1AA7C115355EC66CEAC917C8BFD815BF7587D325AEC1864EDD24E34D5ABE2C6B1B5EE3FACE62FED78DBEF802F2A85CB91D455A8F5249D330853CB3C
Test: Verify
Message: "ab"
Digest: B32C0573D242B3A987D8F66BD43266B7925CEFAB3A854950641A81EF6A3F4B97928443850545770F64ABAC2A75F18475653FA3D9A52C66A840DA3B8617AE9607
Test: Verify
Message: "abc"
Digest: BA80A53F981C4D0D6A2797B69F12F6E94C212F14685AC4B74B12BB6FDBFFA2D17D87C5392AAB792DC252D5DE4533CC9518D38AA8DBF1925AB92386EDD4009923
Test: Verify
Message: "abcd"
Digest: 26BC14024D5D6818AD7C4DEE519353C290E38B6535F16F62B6CE5C6FF346C354542496F89B84EACFFA1DA51F0AC5E643F965637CC24E0B3F819BDAE05F3932B0
Test: Verify
Message: "abcde"
Digest: F3E89A60EC4B0B1854744984E421D22B82F181BD4601FB9B1726B2662DA61C29DFF09E75814ACB2639FD79E56616E55FC135F8476F0302B3DC8D44E082EB83A8
Test: Verify
Message: "abcdef"
Digest: DDE410524E3569B303E494AA82A3AFB3E426F9DF24C1398E9FF87AAFBC2F5B7B3C1A4C9400409DE3B45D37A00E5EAE2A93CC9C4A108B00F05217D41A424D2B8A
Test: Verify
Message: "abcdefg"
Digest: 81E659403D5BFD8AA7F8EF2BEAB97C4B866A27B0D1079D1D97E6915F65D6E947F4B2EFEA807C4568FA6E201DD79C4A82D6988C71B7CC4A9673575CB3A1CB2202
Test: Verify
Message: "abcdefgh"
Digest: 38C0459C34120A885AE5EF9352AEF704E5372999BBE5606745018B15E7EE2B6C0FDE8C7DE2146E2AC59FA6CB678C2115AC8ED9EF495D88BB7E2A00595015F505
Test: Verify
Message: "abcdefghi"
Digest: FBB24D21E0FCB6223CB5F9DDE56080A5C737EC0DF3A8A2FC70CCDD64BAC5807C736B378CA0EAB12605BC982B25692F03023379ED9BC6F7294138257239F3105D
Test: Verify
Message: "abcdefghij"
Digest: 37EAD488933178900E12358D2B46A083C2E559DBCE6B13FD77B0F56A0BA46C44BB75884D0D723D3249817FBAB17618C7C8894F3BFA77BF66C3D5EBA1CB9C5B84
Test: Verify
Message: "abcdefghijk"
Digest: CCB6EEDBB75795BB7634F8698414577E0735BE8793664597630DABCBB67EE8E16519A7C62F57E5D023D3F013813ED8087807D5AA9FA485214B39611401910CEB
Test: Verify
Message: "abcdefghijkl"
Digest: 14EC8A81A970A583109B2056B4459BDCD7159EEB609F507383E818FF317817A311C41F5C2138F44D19C1777B7AFDFAA48F598D44D7B19D270A5E5AB6879381FC
Test: Verify
Message: "abcdefghijklm"
Digest: C56890954FA3EE20DFE17E21537619BA39D6F2E6F60D40791D0FD8F09EAD7BBB47C97EE9196C5D6F660FFA3172A8FDDF088E481DFB359B291E09EEDE98E9D37F
Test: Verify
Message: "abcdefghijklmn"
Digest: 8E5015F3488ABDE0AAEC69D7A549BCA3BEDC82E7244911225CB7B774EBCB43AA35233D79A4BE18FD047DEEDD727ABDFB369017CA1CF502B0C347F14FE10DD330
Test: Verify
Message: "abcdefghijklmno"
Digest: A3642E93DCF251FB21E6E889631317A65CB5A21A444D2C0438B5022E3C8E755FDB4CD94D1B7490AD88C460A6E4B86502EE23C2AC045BDDBAD5BDC603C7ACC85F
Test: Verify
Message: "abcdefghijklmnop"
Digest: 4A79717B74A9DB90C258DEDC77767072243F08C841F58CFB310BB881EE2481578CA56F20D9810E3F3833EF3A8AC26C7F31D17EFDFEAB5737BEEA6C8AC253C10B
Test: Verify
Message: "abcdefghijklmnopq"
Digest: DBE8C0C6CF9C54CA6DB23BE0EA639D1E7551FB6F24F46ACD77ACDBA2D7AAFF29959C02150AF6118D1FCAECF1CFA947B0FE0AB2F84363CC770B5E6EA3B87BECCD
Test: Verify
Message: "abcdefghijklmnopqr"
Digest: 5B6468313FC3878000C617E6CB25BB7008654E854E0C7159BE90EECA6AB2D6D008845BBF902CA626ECF37AA9ED8CCB99E1C6BE4F0DD719798A52886ED63D4965
Test: Verify
Message: "abcdefghijklmnopqrs"
Digest: F5D82AC07F8BB7364295036A91A3AC81B8C4C7640C05BA2374D8C7B6EB6D3BA2E76197B3E6496695A2C41A4C70B0C204210F7D7C98D41C6928C8D4E51C4546A7
Test: Verify
Message: "abcdefghijklmnopqrst"
Digest: 2917FDC9570F09EBFD58455D293606D7DEB9580E364DA63FE6F42F701B768842C4CFCDAFE830FF08C40BF1C016B250329C41F40CE84B675B21D15C4C1E6339E2
Test: Verify
Message: "abcdefghijklmnopqrstu"
Digest: F64C187D18BE654A8E747C2AA5A6C6ABB2118E122AED919A3F6DC9543438CD5780263BE63DF897D30AADA99D06DD1B7A9F7FD55DDD720A586F1577A2B47EB6CF
Test: Verify
Message: "abcdefghijklmnopqrstuv"
Digest: C40A1C781C90A7C398BD875876C5FF41CE9932C63E1AB170902146A3C238E7624E5AC9917CA6032D924CC2CFB67D6F1C7838B8A30F26E649E0D9F44B14921583
Test: Verify
Message: "abcdefghijklmnopqrstuvw"
Digest: ADCF991AADC33D407AA1CE56C502C8A94D52A1B2D8E009352793586EF929E7CB3525198EF615F5C577EA209BFA412FFB935EEB5396540FE3F92789E0F1CD18A9
Test: Verify
Message: "abcdefghijklmnopqrstuvwx"
Digest: 4038868236514AAAF248E8E1B4514A5CC455AC564EB8A2ADFAC374165BC21B5A3B858B82F19265E4D4DEF9DDDE8CDE73125CC2275140FF422FFEB202FAB673A6
Test: Verify
Message: "abcdefghijklmnopqrstuvwxy"
Digest: 2A9375011C21ED2D135710042879D7F98CDD8B4BABEEB4DE240002BEA2D60B3AE12F5AAD85961EBBA1C08E6DF8AAEFDAB4682B335217F1F495BB0207FE5795A2
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz"
Digest: C68EDE143E416EB7B4AAAE0D8E48E55DD529EAFED10B1DF1A61416953A2B0A5666C761E7D412E6709E31FFE221B7A7A73908CB95A4D120B8B090A87D1FBEDB4C
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0"
Digest: 42402C0D13BC383B0F98F6BC56AAE9E06CA24FE23B17F3A2A0402655CCA23BD9A021AE5F10A60824112F991D5D437D8F561A6E3DC038DC7385C702D508AE4186
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz01"
Digest: 593DFF41661E381FB6B810ADED308F709FFA3CABB57BCB71CFA1CB266FCF650F559CC72700DBCD0C25CD819F6459EED914DE3373C2A109B0E1D2CCC237036D9B
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz012"
Digest: C5ED16003CB947DE5AA7B8BEF9053E7EC7BD8673A794C404D05D0B3606247E71EEB19AB2DC8149A4DB8012FB8DCAED5E3BF00D66AAA4344BB24D836F7C74E564
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123"
Digest: FC5519D304D019DA455184E4A95C515C464F5504BC0972EBAD3404CB2DE8EA03C06127D4D6A829AB3E7651E5980D615BF0261846CD3EB0849F8AC2C1B5DF17A0
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz01234"
Digest: 0F89D344530BF74C7BD94F8B80855D7AC96757BFC242243F84ED749618239C2CA95E8A5EF3AC6124DB03767960F8BCA848BE9197BF485314AF298ABDB3878B95
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz012345"
Digest: 06772ACBA1C9273B84569D2544BAA0F5DB8B70C4DB82FC8B32D848F73F5813C25A8FE579F71D0C336E58947466BF2050C794A4394084B5D703047FC9E5EC8D33
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456"
Digest: 21023A54D7EF221EFAFABE5E2896C4B5F39AFB04D257133831BCE5F28EB6F13613E0332B5CB8EF2719E7FB68A0A12637A1F9EB8396F156736E31FB5453B3119D
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz01234567"
Digest: 9EB0B80E475625EF7E887655AB7180EFCD4FCF29F5CEFD68886DF4BAD52C535454BF2A1B2D83AB2C17446E4D8A16107553EC1B09AF02179B0AAD26DD1416A89C
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz012345678"
Digest: 050EF9C5107E4608C961D0E2DCB58743163C83BE2B9A74FF6AB9AE878BC392538F2F813CB7C82C682D2BA1D2E4C566D6D2F5F2D4B4732A4B10EDB5345DF6F3FA
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789"
Digest: 79F266FD703648FF1CFED83C4D90D2D2D9E1A3588508ED79AC85C392C38116A904A4F14EBBDAFC86812305A14FFDEC2F52766839E804099D7FA8417987D6DC25
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789a"
Digest: 39A781F638261F51FC526181DA3CD15D1C1A412C5786DC1F935DEA2EA9408011DAC52EDFF5E2A7C6225460A291174B2679AE11933ECA208E4C621FFA1A33281C
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789ab"
Digest: BD0CA0469633B20ADF20B572A0B5BE41CF187839A78288FEA4CF497BCCA035C9A2620198C6894106445B7E029C5BBAB2C5C4D6C930FF903476E9E1838A272766
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abc"
Digest: 24F1DEDA7B41F6CCE05A39EC50A1625596D7CD0CCCAAD2CE14A7497BADDFA133A23E9EF4347986B75BBFA60CC4C90E734FFE1022FD0B94673117D48B0DD2E3C8
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcd"
Digest: 72434DA63784E80B16C88102D29D07C699A8CCEF62730F1432B97961C80A56EB372E3E1CCFC09F1CD6813BB3D9844367757F13A7669A563527CA050A62D9E670
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcde"
Digest: D2D1FF188978F7D2A34113AA3D8AFA0CA0609CF0CB0B3DCF1C2F615131444B0AF8719BC5C2321F98F331CD84E88A7D4B2A68B4FD978E64073540A4700B0B2D9D
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdef"
Digest: 1532EF45EB0AE7BD3F988B70BC12A1F9EFF29A0FFD0A2AF4BEDAFA21A285A8F79EE6EA6388E7E6A18EA9895470DA59C9889EBE29C1D3D1BF0F7F171F693FCCDD
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefg"
Digest: 2D52687CBAB0D1CCB657D5538CC5881298F21DA1AA2F138FE5CBD3EDAC8FE2EDB498B0EC36707F25DD594C97CA6BDA436F366DC93454363BE0905F7522565248
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefgh"
Digest: E8C085BC7755296CD80E9B463C5D063A9D339E314062EDCC1C74E2D39CC6410A8B00E39CFCA476233A3DBD53C385810475B7AC0E6F1A28629D73A3215B7A6E4F
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghi"
Digest: 912904613781F9F0609AA9772B8D9F717CFE69248CA32C4D900B284BC0972C55D41468836F5C75CAD28766DA931175D877F7D2EFEF41854879F2489EA6775E70
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghij"
Digest: 1BD34DD552071451831B9006C8181846EB6E530C5E316E0FCBB476439D41934A2A863DB59ACD29799A66A50662A7CB00DB41E3A64F1FCF79F84D9DECB92B50B8
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijk"
Digest: EA3D8A5D28D1336C85FE46BECBAEE1D28FFF2932AFB694C7ED08F21C31D0AEBA182DE0A26953F76756D81AB45C77CD658EB95581E8B9737F0AFF36311E43786D
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijkl"
Digest: 91CBB398DD520BA68A735BCDB47E65E3A992706C9766AE2AA09740F44C09B53AC27C482FE7E0D454FF94B3AA392BA11DF6E8A28EB3A5E46E73D8ED99464813AC
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklm"
Digest: 3B6A66E761DE5A29FEDA3D69E425F3CF9E2FBECC1DB3BB2F44B8BD2DD15A958C9AAE673ED82D993A0146C6AA83D900DB8E3929AE2AEAC247B7FE58D9D4EDA7C1
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmn"
Digest: 8A5FF4679EC01E08C666AFF35716009DD21769A0C5185F428E52C2BF0D11E1F05FD1ED5E3A541A10DAED05D34E406C8D0F45F5F79C84C2BB8D3F998A66B40F77
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmno"
Digest: 44514745D4360AC227A23F666C00C6554D5B556676752061D4CA6A28A6AEDB4EA83C4BBE48980FA359D7271491E185C50F1FBEFA4EFFE51C33B45CD254880543
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnop"
Digest: AA0767179F065722816431456A438045E4B0975B0235C86D53F66F04CC521548CC44898055824E6C1CD17BA080AC693FAAED746D2FC8A89D5F38EB4EAE687ECB
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopq"
Digest: B3C95BB063162F047356C431ABC675B0332D6C1A5C28D4304C2DFD4E10B712E3D28B5F1A0FA005E93AEF8892BA4B1EC21E8E4DB990444392DA24B08E09D958B2
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqr"
Digest: A97E356EDEB533232E85143162BF539125845B7D39E088DC7D2FCFFDCA256F683D52AE8F403AB030725A820638F17DC1B960BFF389401A07A21FF991E43D4F25
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrs"
Digest: A30E60A2A4B37430656682F97C6BDCE5A6DBCDD5D0312000A8B6F9437D394F1AA58F0936700220EEC370A0322DB934223E088F8DF05597EA4E0575D61B13C094
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrst"
Digest: C7E8EC8F350E9296FA6F3650042C432D4F72D73CAAA7C6765F81D73F8580DEB7C7010828FDC0382480B0111C6429E953B26C5FAA66EC9EB13E47B960F37038FB
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstu"
Digest: 891D5B36BDC496FFEE1CFF284804F883F9CE24D0BC208E70DECFD7F8B7DA2894450AA7CC16FB17A305FDA9B12E41DECE95BC33EE383DAF896A03023CEEDF3477
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuv"
Digest: 0207452CE26960B4984C9B962BC68498734AAA832A1B3BC7A70064040A6E4C08FE951C3FFCBA5FE8AFDB32B875B5970C0465BC05A8C7F94AA1DE061E4688A45C
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvw"
Digest: DC92B92580A8EB8452B6CFA693D0424580BA3CEB631C8ADD390495ACF6AF4AF5E7F7FD7215B7FD1E26C8BB0EABA09A0E9DDE964927EC458B34B89D7E554F890E
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwx"
Digest: A7F21EBDAE7CD6A8905A3A2AC39B86657A74B211FC0A056AA54457654CECBCBB50CB56293C48BA09AAED41BCC9AE3FA1710D17B976BD021C90E3162A125AAD98
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxy"
Digest: C5F0B0A3D2CC1783E4FFB98D88B75D5E0E7292A042C0105FD48F59EB72E8A022671048238292037584E1DBD5EB2CBCEA631829E5B2B0CCEB3D576E2CDCCA6C1C
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz"
Digest: 719CB49641189CE476322171431A61037955FF180057806A4D536CBAC0E4922B1990B8FD22D26894A61298AB6DF59518B872F97752EC83285C1783577EBDADB1
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0"
Digest: 1E9A5678DE8721EA74DFB4CA41CDDB8F2DD8C0DBA308C434B7709CEE6D789F4D43C516250AB85BDA9A1C04939D7B55B2407129CA340DA070CEBD04C5B2C7F869
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz01"
Digest: B3EC90EF034F75DC6494ABA71B2147F5A00DCDAAEECAAEEC382B6B43FD3FE1AAF9DFAD265CCB33F3CCBC9D9F1DC1176BAC14CA4C97B1A9D8426AD3AF19157F31
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz012"
Digest: B66FAAD26B6EB6D67AD84F82D39AFFED49777599501C628D45EFD07075A16922097C4FB4ED3ED60EBA3933F7BB414D63C0907F3A055858B323E59678605C8221
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123"
Digest: 041C69DCCCC228BBEB9D6BD2DA388A3467B80DD5DA41050F68D900065FCDD238A768BB30E2ECBF1DF6CF79F4F67482942F16E66894A7AA21D652F418D91C0AC0
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz01234"
Digest: 023947F7ED12586F20DB3AF3E9EEC296081A578C838AA92C0290012D3F2A23D2910F27A150BA79935315CCD3D2E4F76835741ED0DE88700CEFB3071E6DDE5E55
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz012345"
Digest: C9A15E010026F792408297D959CA7B66BCF209D639BA3890366B561F1FABAD6CF60A109B0322560BB0D3E9C841782FF7708D5B0CAE6D6E3EDADCBD7CEC54C72D
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456"
Digest: AD14E33C9F46ADC33DB5AC711B3566A0B9D68FC0051A938FF5C55AE61BE3CD507726BEDC71A4F9159826F3C4171F8CC25C36CCD887F4D4EA7CA75E0923FD403E
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz01234567"
Digest: 0D2B6DC78385A72681953C17635D10AA7DA55660EEF4F033354CF605D69407DEDCA665FB91A25A5015AF2AD19C6F0B7B47991465365C57D7D4ACB505CBC38E6D
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz012345678"
Digest: 37EB568A932947E9D8B908134F6D36D5E8A07D3C29FD7EAEB68D922ACE110B4EBDFA8BC7698D966CDDFC15262A21FD97F7871F35E52E1ED6E4D4C26A9423EFE1
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789"
Digest: 2729344A595C4CEBCB523568CADEBF7D8743A0B419F216A61F2119A3379DFCCC39BC4652E9CBBD70A1BF499CC909313F12D6C3EADB0DFD8FCE3BED94EBA2B4F8
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789a"
Digest: 3F04ED5D49C17820E66995065FA2C9289DD3F6DA105A188C7DBAC7BBB84D839B3A53E1F50DFA32BD3E3904A28482757FBEBFD192C74E055508047413EB1D637E
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789ab"
Digest: AF436523CDF2205B20D2A07CA9F5BD5BAC76325C8008B2D7B18FB140F56FBB104178534768A75BEE7845E1036ABA5DB2556BB6B8A7933CB98F73E4F167B23DCA
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abc"
Digest: FEF284632004F6C0AB83DCB83F98D573BF61F04349F3C5CCEA4A8B52923CF308CA404BEEB0F0847D1CF4F62AF01EECD6648E2FDEDCD6C927250CED1394F5EE99
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcd"
Digest: 1111417618B661B97630D55333AE65AFB6B5DEADF13FE357D313D2D9AFC92BD0F8183C14DDAA262959613F85A57A379A76093B617ECB72A3842BF8D17FDB691C
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcde"
Digest: 97CB1FFEB0D3336427EEF440B2494FB2D0A92CE1B86E86D721C0B96B865E3D7832DCE3328223907ED0675475E135D087D2E494234BA679E71C2F2A74CBC5A2F7
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdef"
Digest: 4EE9CC4B52C1AD8B7E190C5ACE1A5975B3A8F6C9661519DC9B3029BDBA6EA4294A6E71174273811688C9A4F3647DA83742D4FCBF041820184473CEFE51E94CE1
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefg"
Digest: D5B08BF6F0AC497BCD9CA4F8B638352B9431F79AD4A26E85587D286CD5BB4D915B3287F81F025905540D584A868D199F7DB1F1CA75B6BC3D475BDF042E611CF6
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefgh"
Digest: 81A6475811D2E17A1C2F2500D0D1EFB3481C5FFEF635568D4B0D7F538DB48B3BBD976BD21646A5DA3A4AFC2508EA7A46A73F64DBAF7472FC80094673DA89FA5B
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghi"
Digest: 92FFA9D0DD341A1A29535BF3B775EFDFFFF36B31CC14E5DE74A93AA12F2C89ACE38E0DC8516E0F7245E410BC8B8C903B0109F57AF5FA01D941354ADC7E0CC2B1
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghij"
Digest: 2F9A94362D7E83E81C84AB2311F43D0ECCD46D8805EF5ADB2D639A1EF68268B39069D5FB174F5978E5416F0A183BA9F5E0C431890CC689D6F9CFB1B2B6DF535D
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijk"
Digest: E4F10AEE15613631FBE2A10C812A7D1AF3D0988A555BF7AF282F0E6A1AB9E1EC98C594D600E54430898A5E625A9265B92D67B7B515F58585546E3C33A87EAFBD
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijkl"
Digest: F185EE402517BE76540B735618B5F02E0ACC4A484E2CA785442B3DBC228711A8ABF1A18C1216B32928A0D0384012D22BDA09EE62EA4B4BF9233D6271E043ACEF
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklm"
Digest: EDBB843A233F6FA3D591137FCCD44E92043FF03A82D26C9C0431CB2B63DD27AA2D6A7826C42F58B4D2DBF1EA2243B8357187DF72C9ABEF0F5A154AE4D64EEC86
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmn"
Digest: C6165A33D4D0C32FCC01F7004BA28EB084EA9B99DF22B44DE26F9EE9AA07D2A37DC5295AC0B4257BBEEE67D3DD42009A52ABF0DEABC4C807658A64B817299047
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmno"
Digest: 3D342D9E50D81170573804F5635298082AD0734CC58BCA2D12723DE5A41EC057D69B0D44F8C2346CA5B56C10E4A5D0C68C3BD7D1A9A1C4C3F99CC37562AD4DA0
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnop"
Digest: 787FD5E609BAB1E86B4AFD86A66C10DE238E066D19E56C7F759E134F14F8A9143F472D9A9EC91378B3654334A703292F8E2C55B41963D408EFA9DC876D0C64EC
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopq"
Digest: D438DA0C3BC39CE1A331029EF6EF1C30B8CD31BF18359F89E5E0D2217CBA202C2F51C911B96B7AF400B3CD34FBAD40C0EA325F8DE5ADC699C4A46D2BABC0551D
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqr"
Digest: 1304AB08A91B92A5E059B6531D21F67F8395EB6573D18EDD6D5A083AB8575319219900E22999D0B8631C2416A9311A9A509C80D43C20ED8982F92B0AC7550007
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrs"
Digest: 5D343971F3A9EE13E36269C02227938C9CAC9224456F97F931D53AA174B9740980E056F8FAA06E7F236814CC6FB8B6611D95576CB37E2C82C81740DC763053A8
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrst"
Digest: 5DCFC07EE8E414EC397C5042284CB8C43F03DCF538E1C9528E91E1DCD5E4ADB131003A8340A20E41DBB02E549C594B2DCAE44DD7F6B6C541EF5EF1011E7A6826
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstu"
Digest: A006A585C5338C926AE7739C5CE71BEA8F3ABF79B845C3049C9F5970E83017CB71948632B357B9DE26B56D1B1B4441B9FA7F248C48C2DBDD3FD19F3F9F958B72
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuv"
Digest: FAB0AB0D082C627BF1759138B8DA4B1D7B0979C7FDC7287F6E197804AA47DC4C8B67E6CCBBBE3CD6D2E9ED4093C1A78008FFB922A383ECF7F1157194856C54A7
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvw"
Digest: 23925BF38898621E46C53A98B0896F7BF81F203B45EA1A5420C916D9FB0CE916BD43AF2369C1FEF0D90B211318E0A4C33D58FC7A93DD0B99C0333324A99B482A
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwx"
Digest: 6554E96DE27376C7C26BED61BF88F49D062ECF099D56F60626434F71F044232001B878A7EDFE286BC656640CDD845B8CB9AB48CB111D1BB8343192B1350498DC
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxy"
Digest: 4F6FBFE42D2A472356DE34621C2182A455BAE3C0D1F518439CE8882E193ECB829CB7BD3E49C7D248F6AFE8B92E4E61A6AC70F24E43EEB6B128290532C87B99B2
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz"
Digest: 486E93B4FDFEB93209469CB39FFFC8BBC71CC0024BDF54C61660BCACE500D52D5EDA1766424551AE64299638DB8981C654FD296188176023CADBD4B886CBBE45
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0"
Digest: 85E359B3E52A18D7FC3C2CB7B4CB22577CB25360C4F49F70FB26F321EE23A9F5DDEFBA305B15AF8F9A0B9C24E5E27AE22CEF216DE09F5B54D85B9711B898456A
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz01"
Digest: 875C4BE266D800847A5A014F2842B70FB816DA7B8CE77D2438D0F4B8767FFF1853432161DC19C20F7B553461F1BFDB20B272F37137B5633C79E5662BE101D474
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz012"
Digest: 4645876AEBB575C56B601D1C6C986AF7EA7362536BFC676F360FB7DAA1B336B1309D87FB0446B2CA925EE40D66AB6EF15389FA2EA844983B8FA0B3B7B8BF5F6A
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123"
Digest: AC9A9B49FAF6B4C2063ADDD05B5661EECE2345B33C2FFEEF3EDBDA60CE9675FE1C36410625EB0B64863C0D87D1E27670D0FE0C9708D7B0693A14CE75EF3DD9D6
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz01234"
Digest: 7CCF6B53555E615303CE92DF668E501C69B922E680BFF26896087883A6E58E016734F0581968215AA13F19806AD3359254EBBCCAD21A93EA0B75871A4035EBE8
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz012345"
Digest: D323DC3CD03C1F229C69B67E5FC87125525D8A815089E8F455C17AD8417173167D69D25B840D877255599469704DDD2B2F34DD1D888C9F85AEC2A69C7EF63A5B
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456"
Digest: 7246CF8442726FC1A2B0ED8EB9DAE1CBDF8413F08B559C04FD176C1B63A70F31ACF91574AACF48C07CFCE7BE8799CD6DBA0238EB09373802251D26AFD49B80A8
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz01234567"
Digest: ABCAF5BDDA52EE677A995298E3E723D909F9C0EDBB977E71160DF2EA6EE2A49D438BF8A9EB8EAEAEA6483D5CAE35BEDB987CE83DDBFEE225BF60867510A0D9A7
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz012345678"
Digest: 46A0BA436534FFF482791732C21334262C238F5268FB16E93D266735463A435294AE08561F8637167945181095647BE73A545C9A53A4DF840202C1CAEC2E2982
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789"
Digest: 8AEE4B3C7A179BDC818083479F5D24DD3B8FEE8954569A5DDC75FFD2ACC16EF1EE82CE99A03EC0761332183674E02928FD9534E2D5EAAA5704732BEB5883328F
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789a"
Digest: 6A4666B9B672CAA3E5C18E7DC5394F39836946C46F3CD2703B826E93E4C93257D7756BDEB574A46AF37339F6E641D5AD6B629D69D4DCF7FC2FB0DDADD1687462
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789ab"
Digest: C6EA4D9CA7F7A837F1909ED2E57833559E0AAABA45343089B127363521CFBBB87BFEC5C1FEB6E0A89961C2B87D0D215AF9C462D272F3C29B9803484E15C17FB2
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abc"
Digest: 05C1C2B330F46120C30252742D44FB987669D16E9960FFBC401CDC83B17C888C8FEE52C63BC8A5E9BAB74FA79AC2002C149D6423604171805527112780F8D72F
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcd"
Digest: 58A19F64D5064E0B6C652E7958BE1341F5A1329BA0893AB874EF7DAD12547E2BB6BE5D4CA88CD09331CE1A5DC26264651DA17E72804D84C2EC554E9AB0C2740F
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcde"
Digest: CE22689FFE93D2D915BD2649AF7B86B021E28C400703DDC64B5E6328E61D3092D76AA6650145CEABF690C8A9FE06F548B87C805DD27CE008774D729B2EB3642E
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdef"
Digest: 9A4DCE0DA5D980C240CA656B7BC56BB9FDB1F129301F651BB1CDC8DF52D796A262E895E5F7AD94F0F0FD669037B905A548EB455259890793BEB9257376FDE721
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefg"
Digest: 14A9584DC68604492B2CB36BC64E8EC979DAD79C2984A79671650A56E94CEBB1E62E011F156C1C8E3227A4112F60835481AC9FDD3DA1FF2BCCE44DF0BA9077AD
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefgh"
Digest: 5E2E899E96F5F7C6552962814F8CCBF3212BBE26D53460EB8F45070057E2591DC423B06ED1E310050B87AA67CFE6F08C1467A5B6DE0C657FF192BD2C42F7F693
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghi"
Digest: 71D7D9EC215E8CF315586A09C27C74C4F9F181C463C85D6322C81B94DD3BD99DD4B56DBF704E06A18DCD10F746DE11026561C62AD78B06DD75B2FC133E05434F
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghij"
Digest: D48D8D027EBAF467F1699436E499C8BFFB7A4CC226BDB32B160E7805EC0CC7C40679082724CB415CDFE1E69476447AF713C7A76D27F84CAE883FF013F30BB662
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijk"
Digest: 3C173D59129EA8D95E2B2B930A7BEA1C6FF70485670DBDC96C1C3CB3C80F30012A7445BA50500AE19D33B1FED36AB6B09DD51BE0E49D7C24CE33617936F29FB6
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijkl"
Digest: E3F25835007FF59A7E00062437C0D8AE8E552ED7F0AB997CB3B408DE2DB07F2C4B45FE90B809BAFADF83EF238E4660D552E0B2D75388A5ED6AF66779FEE8A565
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklm"
Digest: C2DB6F8A9C5EA27BFAD7E83B8AC8F9BA64EB483C2D77557CAC3D33768B6E94CEEDC6B2827B9A7ABA97103053B5F06BA6785E0E47C4FD6BC158C3A3ECF1A3DADF
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmn"
Digest: 64514B485B3E350CA33DF1F790E98C7484A89DF3C15D2B8E4811C266066172953545A03E4C26B091D9D79F2183F0973FACF006B04C8613A3DE272931E643F3AA
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmno"
Digest: 57736713856887FD4575CD20D960B204E36B59163CC9EC896590A1D6A12BE406F1312A7489C21E4E42EBE1B035F192B740583E651803390C1540BC4012F3FF11
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnop"
Digest: 2FFFB2751A94EB2B2B2B488EED9C12658B92FA679B72304C08B81C96A815D2A0A0258CE7D027CFDD8A2DFD58B15184F4F5EFC7090139E785AE63BB7F583DA02C
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopq"
Digest: 7161516AD571229F966AD78CFEF7A134495CADC77DC2112836D8A0CE6408DF5338E92923F30418473537125BE78211E36F4078F5493463F12285FB5FC0ECB3AE
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqr"
Digest: E430F674D54D07665BF0EF2B1B4D65500C5E289785801D4F23247ADA7EA8836956B287A691BB76838E3CADC286CF04D7F56E4049623589DB84C5ED9C85A2978E
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrs"
Digest: E22319E5E2C94D7D837FC59F175586ED11628AEEDF2F1B66F26AB7CCCE6382CC7706EAF8147D502286FC3E9E178883DD5A84123F8885AF65D628311DC25255C9
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrst"
Digest: 72CDE85B5599CE143069E14C30B2DBA31394747331AB4226B012E09431073DB953794DF50E26F43E4AB4B6BF351AC37BCEFA8CAAE142CAAFAC1EA516D2C4D7AC
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstu"
Digest: C4B9BD6D28B107484C8F90B14497B2D906512747785525D7C3433345E263B913784FFA5C53C9E97174400296077AC8E22AC51B4921E1F0DD2C14A96F0BF41568
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuv"
Digest: 7C1C18EA68298994E67E9AD3F57FCB56B1BBB47CE95D4EA7D52D3B54E5B0754A97A0C482FA61AC979E34F130C29C46431BEF479B8D1B07714A4BEAC63D3E9BDF
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvw"
Digest: 99E78C57E98E8253683F4883A4E3837E89DF87DE5FFC45BAB612F51DBFA311E8CABEF43E546227B65F50B5E36CFB9C02611776EE4C6FC67CEB12817DFB166B8D
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwx"
Digest: 16546C58150F45302E1F8DA602A4DD08DE5DA8B92141F21236A8182BBE4FE0CE44A701589CD9F9830010C74C49E32C954C6E09FE5B8830E240D511E1B7FF7406
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxy"
Digest: EDB0D348F2BE67BA09BC69D947B03A5B370550200A303801D88946E9DF2B31E874EF96E4926B7A13BF67148F78B8030575997999EBAA1F506382613A4FDD6E39
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz"
Digest: 29180A1CA2537C9BC4CC0D35968184D1E3404F73D309972D44CDC01F99BC394998479FDD134FD894D675599F8B676AC4F3AC54710537ECE351D1A18E59DB9377
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0"
Digest: 20C8A452A9C03D942E063C7C9AFD13992D8272BA505F67FAEEF38526B9FAB07FD1D5BCDDAE29F284C5E7FD8FF0442DE70DF1B9381C2C7E2DD080D6163B4C51F9
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz01"
Digest: 45854F7D639522DBE213FA85A270DD4F222F3CFD86DC9FD856ED5BBD9FE4DE6A8F7039CE10196098532BA94D11DD2A8B9A637DD4F6C87F26F95F2204EDA232C3
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz012"
Digest: FC5675E464D2306720D2AACB7C6E303DB3BD9FBCCAC340F28E16F319DD716040EAA56C063AEFF60A5E22AD08ACE5CD9B1564716701E54EE6E8508EA68BE1B7D3
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123"
Digest: 06BB967C6EB7C906D47AC24696ADF4010929B6E81D867FF16AD15470DDF5C94E230B62E7DC2F9CCA0C9D24662488EBEC8E1224FB4C6B2AF776790F26CADCCBBD
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz01234"
Digest: 8FC8E13C60129A89FB2671EAF34CE7118AB1C4FE6B143F9EA7C9322C8F25DE82AE8B8C366CBFFC6F7E65F41984DB2195E4FBD2D26AD4D4E764DFE3D10342BDC8
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz012345"
Digest: 3B731F6A35A9893CDEACF4B566F7F3754D8121C6FBCEC3265DA5F05BDA996B9BF926ABC5C82B975EEA0E6214BC6F6524F2AD957F0BB6A22E57E9FC34626B714B
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456"
Digest: A8A3A00854DF5FE036D27354042649F9D5ED4B01FBD7E77B37A4FFB7CCB0297555E01B109FE2E52ABA557523AC3D6821D8212C84DB987DA60A44EFFF6BD575C4
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz01234567"
Digest: 77E04F3DCE600C16C3EF85C6674DBCB32F4DD340AD7705384E2AD909899BE2649106661769265750B5556CCF685C2C9E257189C7477E70D0E94157129E0E1C9B
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz012345678"
Digest: 9068DA2BA75655FC6818E2CB565B9E3688FFC6C22DD83FDEDA60012FD78C899B0063A57C8D948F3D5EA442441EF92AE5D3A0E7B71B04C6B0683C758ABBA5C514
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789"
Digest: FFD4A61F80D55FFA83BA8D2BD62DCFC33148ADE507A8F7F85A5AF2C619E126FF11E9284F12BF3EE6A2B5CBC711FA84C37DA343AB7D29BCDF722DF0171E41297A
Test: Verify

223
TestVectors/blake2s.txt Normal file
View File

@ -0,0 +1,223 @@
AlgorithmType: MessageDigest
Name: BLAKE2s
Source: blake2s-ref.c reference implementation
Message: ""
Digest: 69217A3079908094E11121D042354A7C1F55B6482CA1A51E1B250DFD1ED0EEF9
Test: Verify
Message: "a"
Digest: 4A0D129873403037C2CD9B9048203687F6233FB6738956E0349BD4320FEC3E90
Test: Verify
Message: "ab"
Digest: 19C3EBEED2EE90063CB5A8A4DD700ED7E5852DFC6108C84FAC85888682A18F0E
Test: Verify
Message: "abc"
Digest: 508C5E8C327C14E2E1A72BA34EEB452F37458B209ED63A294D999B4C86675982
Test: Verify
Message: "abcd"
Digest: 716748CCE97A0ABC942E1D491BC25102F5B6FF71EE62A86ABD605A6C40120169
Test: Verify
Message: "abcde"
Digest: 4BD7246C13721CC5B96F045BE71D49D5C82535332C6903771AFE9EF7B772136F
Test: Verify
Message: "abcdef"
Digest: 267E4443FC1A38879FEB1090AF1E788956DFD93204CDDCBA818D6E32EE57F335
Test: Verify
Message: "abcdefg"
Digest: 4468A2B5329224C54C243D4FAE24CDF050A27A563480F4AF5FEDD4446D8C4A04
Test: Verify
Message: "abcdefgh"
Digest: DA651C965D6B93CA7611C9E996FB8C15A250B35206D13763FF3D53851EEF55F9
Test: Verify
Message: "abcdefghi"
Digest: 7EA377E88982E90724AA8E2CB5C9B086713C89161D5CF6178F31E43AF4EB3504
Test: Verify
Message: "abcdefghij"
Digest: CF49AE6DAC01A20AC87F5044F9EB26D760DFC1670454F6A52FF9E46DF691D556
Test: Verify
Message: "abcdefghijk"
Digest: E03E2542DEDF659C147D7507E9FA77F1ACBB1A17AF7476608648DE2152AE26F8
Test: Verify
Message: "abcdefghijkl"
Digest: 401251AD137811C941DB66BA4B3D2EC1A16D21D9B861D111CFD133CB3DFB0048
Test: Verify
Message: "abcdefghijklm"
Digest: B709A02DD0FFEE06078F1D6D10EC626CE913C6508FEE29D91B4CB52F9AE44DB9
Test: Verify
Message: "abcdefghijklmn"
Digest: 81EFCCF8F3A0633144BDBE1127E871ED6057B91F6670AEF7A1D4F5C00AF3D6E3
Test: Verify
Message: "abcdefghijklmno"
Digest: F987BDE38FD64779F7E9C38C98AFD4E256B158DC7B183C638C13E2B3D196F6A5
Test: Verify
Message: "abcdefghijklmnop"
Digest: B6775FD68A7B03F177426A0EF1ACEF97AC070AE0D330BB462EBB529316A61CF7
Test: Verify
Message: "abcdefghijklmnopq"
Digest: 132CB571FBADF705507F019C2031EE66E7C312F2378F08932A3F24C247A49DC5
Test: Verify
Message: "abcdefghijklmnopqr"
Digest: 020293AEC430765B1F204AB38DC88B287516C8A9E6E20AB62BC7E51DF933C623
Test: Verify
Message: "abcdefghijklmnopqrs"
Digest: BD045D76AFC2B1687B0BCA64EA18F76BEB8085CB89CA27D06DF17A9A49FE18BC
Test: Verify
Message: "abcdefghijklmnopqrst"
Digest: 6396FC1AF8C37D41109C77829808DE8561E46CB3EF5A3056CADCA05E668BDDE6
Test: Verify
Message: "abcdefghijklmnopqrstu"
Digest: 25B954495BD753DA179901E4BFD8138CA986891457F58FF16D1F7DA7DD394D86
Test: Verify
Message: "abcdefghijklmnopqrstuv"
Digest: CBC0CA9D4062C10C403CC0611D2FA868095C7EFE022C84475CBF8B3F6B98D68D
Test: Verify
Message: "abcdefghijklmnopqrstuvw"
Digest: 5A51B79FF266AFE916A75D8737FCE58F602C9DD7099F5A8BB6121B3A49EE2DC6
Test: Verify
Message: "abcdefghijklmnopqrstuvwx"
Digest: 9C04324FD5D4B09887B0FE711CC5AD85A7EDC712F7DA09011A970A11352C04CA
Test: Verify
Message: "abcdefghijklmnopqrstuvwxy"
Digest: A516D0912FDB3E4A1E76B503D4F0B9B86208FDFC31C1FCA800BDFF4EF0E995A2
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz"
Digest: BDF88EB1F86A0CDF0E840BA88FA118508369DF186C7355B4B16CF79FA2710A12
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0"
Digest: D9FCBA8D138E331B17B9E19FABF9E6F7DAB867E95801C7E55E33289A527E0A5E
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz01"
Digest: 3C2103028D1641AC7C590304B077E6DFA437C9A351DEDA25E1481C9975CE56F8
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz012"
Digest: 7E9DA933B32D3ADB54CD280AED0E1A5ECF6CD6322B13EFCFCF66CDD5A0493768
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123"
Digest: 868F75CE0A86F5D0786E4459D1285DACE0EF6D7B1E48568585C0598DAAFE3796
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz01234"
Digest: 75B7A1494A29C6A4439EA7B495CAD63E7BDA7BC708C0A40D5382F660CD701268
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz012345"
Digest: C0B82A4981AD7BCCAD873635400A257C7473A80526F3ABA9E131EE4872343C70
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456"
Digest: 8A5A17993027DFD9BB52D77E99780327E30BFB5658E60AB7273EDE0E97703020
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz01234567"
Digest: 2D447F3656CB42C9580808902EEC3A428F9D5EB2C9E66D604FAA3A19D1ABE901
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz012345678"
Digest: 075EEE56AD752714525BBC273A5E859AC592AFDAE4F68048412943CAB1724788
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789"
Digest: 8A77ACF4D3ACBF623D106A3220B137497CAA95E4CD3E58D53C51CDBF8C874059
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789a"
Digest: 452D83737FB3DC327D6198E2B45AA0E99F95140AAB94ED94E554F384C52E4BF2
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789ab"
Digest: E6D1C45FC95895F8169E71EA4457A637BE89E9F8C05160696DA7474205C7A4A6
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abc"
Digest: 170D8823EDBD0CABD93E7FD109A694FFC196674741B539C2909F34284557B658
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcd"
Digest: 69C2255B75432B458C73B3F08D357E7A816D0D5FF2E341DF6F49E488DD544D5C
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcde"
Digest: 7C5C8D25E7C6DB899239F985131E7D72CCBD4F6687151F2F1BD9D7E056E68D4D
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdef"
Digest: AF5C76CF3768283D407B5980473D93F7E2F43960CD8A50181267A6380019E087
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefg"
Digest: F75B7F994A3394538D2E08F54E7AD097242B7333EE8448413813010AC8066111
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefgh"
Digest: FE1EB837B35D144ABDFDE8DF3C3C96AF6E1827DEEF8156077F1C3190F29C36C5
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghi"
Digest: 058AE502EAF6E8D38665D849197BB7E653A4C6C7842D77385FF9AEA5CA02C4DA
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghij"
Digest: 0DBA2CD05F9A5DBEA5F93C8B3A899F7E91E1530AD2CB57B3914309EAC5F8701F
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijk"
Digest: 4565481196B3B1FD39CF2C1A7D74AE1DA7F7D3BBE9252BF0454B5C98C912FF22
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijkl"
Digest: 57CFAD8CD1C48C2E4C5559AB5EDECCF6FEC0BD7197AF6424B923296F4031D5BE
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklm"
Digest: 2A6125E4032218AF7B5CB424DC8C7CD3D1896DCD3469CD9EEC66A314B4D08D2C
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmn"
Digest: 53602BF85609888BB9ACA687749EA867EAC99056FFC38F757645AE7C4DB9E86C
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmno"
Digest: 80ADF98092759DE4943EAF28292D895E447D539AC7540FC67932AA23F5E1FA4F
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnop"
Digest: 44ECBEF584B20453776BDC9C7F416945BC63B89227BFEA06B8777B659F1B49A0
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopq"
Digest: 97BD1043A184D0D5BE699D3D0A896FBB6F7684574FF3DE148BE1BCFF10F787F0
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqr"
Digest: 7D5096C5AA9623883548776A08D8DC92A84A6F62B06D824A57E72B90ADB80397
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrs"
Digest: 190509A4B4723A767E1F13839035991239F8240187BA08B7E995BB1E4525385C
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrst"
Digest: AF01C1821681377BF4DFB4A4FB65A94FD7374B9DB491CB943F937B34C7F4E6A0
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstu"
Digest: B803E3FD5409527AB57384D73B92077DA338547CBFA7D0833269A03D7D6D637E
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuv"
Digest: 82957A282BCF5A098E2707B5C1A6292DFB9A4A215C195FD874B74E99BE18F432
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvw"
Digest: A8DF28F6C9F90D86ABC76E343C1FBB50F376569EB31419230E4FAD2DD5CE9172
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwx"
Digest: D06D0B49C49BAF6E95EF6A88E22CD6963FE4A1A0694DE77B340AA85356BBC4C7
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxy"
Digest: 71EF3312C64058ECB59919E27D68CA525973698ACA2A5316AC8B3DBC0C2E8273
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz"
Digest: 4710F86DA62B70813FE3C2DFFAB8EF81E097C7B10FD674B362F0C90EA2CED4ED
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0"
Digest: 59FFCE58B7CC67EC4BA651860A758847272E4B77B8D5A17553F0EECAF71CCC5F
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz01"
Digest: 727615786E11B42CEF150BD72C6F07080AA67FBE16FD6716B84AD355E82E73F5
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz012"
Digest: E820C057653AAD4CC63E3F86B197B008731AF0FB79BCB687DD53D25C8BD93212
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123"
Digest: D4B25D15AA53087A4597BCDC5553D653BB6DF80CC46E176BB3CA965E0D36F9D1
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz01234"
Digest: 8F192D38F7CB9052157FAECA289FAEA7E3EF027A61507CF76945DC7CF7C54A50
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz012345"
Digest: C5360F6744C7D9235B3E58E7E8C5F7E567ED145AD25B8D26B9E84C14443C2CBB
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456"
Digest: 999EF1410CF942250B5837A4EF0A5961D873C60C899BEDAACE45728E347B52F0
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz01234567"
Digest: CEB19A9C697C122E4DEFAD4ABC34092B3E8248E5A638AACC84B9529B47F03E73
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz012345678"
Digest: F82A15491EA937D60D74A0CEA7F9D10535B0B850871CC77D97948C607662BD43
Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789"
Digest: 44DDDB39BDB2AF80C147894C1D756ADA3D1C2AC2B100541E04FE87B4A59E1243
Test: Verify

549
blake2.cpp Normal file
View File

@ -0,0 +1,549 @@
// blake2.cpp - written and placed in the public domain by Jeffrey Walton and Zooko Wilcox-O'Hearn
// Based on Aumasson, Neves, Wilcox-OHearn and Winnerlein's reference BLAKE2
// implementation at http://github.com/BLAKE2/BLAKE2.
#include "pch.h"
#include "config.h"
#include "cryptlib.h"
#include "blake2.h"
#include "cpu.h"
NAMESPACE_BEGIN(CryptoPP)
// TODO
#undef CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE
#undef CRYPTOPP_BOOL_SSE4_INTRINSICS_AVAILABLE
// C/C++ implementation
static inline void BLAKE2_CXX_Compress32(const byte* input, BLAKE2_State<word32, false>& state);
static inline void BLAKE2_CXX_Compress64(const byte* input, BLAKE2_State<word64, true>& state);
#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE
static inline void BLAKE2_SSE2_Compress32(const byte* input, BLAKE2_State<word32, false>& state);
static inline void BLAKE2_SSE2_Compress64(const byte* input, BLAKE2_State<word64, true>& state);
#endif
#if CRYPTOPP_BOOL_SSE4_INTRINSICS_AVAILABLE
static inline void BLAKE2_SSE4_Compress32(const byte* input, BLAKE2_State<word32, false>& state);
static inline void BLAKE2_SSE4_Compress64(const byte* input, BLAKE2_State<word64, true>& state);
#endif
#ifndef CRYPTOPP_DOXYGEN_PROCESSING
//! \class BLAKE2_IV
//! \brief BLAKE2 initialization vector
//! \tparam T_64bit flag indicating 64-bit
//! \details IV and Sigma are a better fit as part of BLAKE2_Base, but that
//! places the constants out of reach for the SSE2 and SSE4 implementations.
template<bool T_64bit>
struct CRYPTOPP_NO_VTABLE BLAKE2_IV {};
//! \brief BLAKE2s initialization vector specialization
template<>
struct CRYPTOPP_NO_VTABLE BLAKE2_IV<false>
{
CRYPTOPP_CONSTANT(IVSIZE = 8);
static const word32 iv[8];
};
const word32 BLAKE2_IV<false>::iv[8] = {
0x6A09E667UL, 0xBB67AE85UL, 0x3C6EF372UL, 0xA54FF53AUL,
0x510E527FUL, 0x9B05688CUL, 0x1F83D9ABUL, 0x5BE0CD19UL
};
//! \brief BLAKE2b initialization vector specialization
template<>
struct CRYPTOPP_NO_VTABLE BLAKE2_IV<true>
{
CRYPTOPP_CONSTANT(IVSIZE = 8);
static const word64 iv[8];
};
const word64 BLAKE2_IV<true>::iv[8] = {
0x6a09e667f3bcc908ULL, 0xbb67ae8584caa73bULL,
0x3c6ef372fe94f82bULL, 0xa54ff53a5f1d36f1ULL,
0x510e527fade682d1ULL, 0x9b05688c2b3e6c1fULL,
0x1f83d9abfb41bd6bULL, 0x5be0cd19137e2179ULL
};
//! \class BLAKE2_Sigma
//! \brief BLAKE2 sigma table
//! \tparam T_64bit flag indicating 64-bit
//! \details IV and Sigma are a better fit as part of BLAKE2_Base, but that
//! places the constants out of reach for the SSE2 and SSE4 implementations.
template<bool T_64bit>
struct CRYPTOPP_NO_VTABLE BLAKE2_Sigma {};
//! \brief BLAKE2s sigma table specialization
template<>
struct CRYPTOPP_NO_VTABLE BLAKE2_Sigma<false>
{
CRYPTOPP_CONSTANT(ROW = 10);
CRYPTOPP_CONSTANT(COL = 16);
static const byte sigma[10][16];
};
const byte BLAKE2_Sigma<false>::sigma[10][16] = {
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
{ 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 },
{ 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 },
{ 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 },
{ 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13 },
{ 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9 },
{ 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11 },
{ 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10 },
{ 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5 },
{ 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13 , 0 },
};
//! \brief BLAKE2b sigma table specialization
template<>
struct CRYPTOPP_NO_VTABLE BLAKE2_Sigma<true>
{
CRYPTOPP_CONSTANT(ROW = 12);
CRYPTOPP_CONSTANT(COL = 16);
static const byte sigma[12][16];
};
const byte BLAKE2_Sigma<true>::sigma[12][16] = {
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
{ 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 },
{ 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 },
{ 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 },
{ 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13 },
{ 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9 },
{ 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11 },
{ 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10 },
{ 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5 },
{ 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13 , 0 },
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
{ 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 }
};
// i-th word, not byte
template<class W, bool T_64bit>
inline W ReadWord(const BLAKE2_ParameterBlock<T_64bit>& block, size_t i)
{
assert(sizeof(block) > ((i+1)*sizeof(W)) - 1);
const byte* p = reinterpret_cast<const byte*>(&block) + i*sizeof(W);
return GetWord<W>(true, LITTLE_ENDIAN_ORDER, p);
}
// i-th word, not byte
template<class W, bool T_64bit>
inline W ReadWord(const byte* block, size_t i)
{
const byte* p = block + i*sizeof(W);
return GetWord<W>(true, LITTLE_ENDIAN_ORDER, p);
}
// i-th word, not byte
template<class W, bool T_64bit>
inline void WriteWord(W value, byte* block, size_t i)
{
byte* p = block + i*sizeof(W);
PutWord<W>(true, LITTLE_ENDIAN_ORDER, p, value, NULL);
}
template<bool T_64bit>
inline void ThrowIfInvalidSalt(size_t size)
{
if (size > BLAKE2_Info<T_64bit>::SALTSIZE)
throw InvalidSaltLength(T_64bit ? "Blake2b" : "Blake2s", size);
}
template<bool T_64bit>
inline void ThrowIfInvalidPersonalization(size_t size)
{
if (size > BLAKE2_Info<T_64bit>::PERSONALIZATIONSIZE)
throw InvalidPersonalizationLength(T_64bit ? "Blake2b" : "Blake2s", size);
}
#endif // CRYPTOPP_DOXYGEN_PROCESSING
BLAKE2_ParameterBlock<false>::BLAKE2_ParameterBlock(size_t digestLen, size_t keyLen,
const byte* salt, size_t saltLen,
const byte* personalization, size_t personalizationLen)
{
ThrowIfInvalidSalt<false>(saltLen);
ThrowIfInvalidPersonalization<false>(personalizationLen);
memset(this, 0x00, sizeof(*this));
this->digestLength = digestLen;
this->keyLength = keyLen;
fanout = depth = 1;
if (salt && saltLen)
memcpy_s(this->salt, sizeof(this->salt), salt, saltLen);
if (personalization && personalizationLen)
memcpy_s(this->personalization, sizeof(this->personalization), personalization, personalizationLen);
}
BLAKE2_ParameterBlock<true>::BLAKE2_ParameterBlock(size_t digestLen, size_t keyLen,
const byte* salt, size_t saltLen,
const byte* personalization, size_t personalizationLen)
{
ThrowIfInvalidSalt<true>(saltLen);
ThrowIfInvalidPersonalization<true>(personalizationLen);
memset(this, 0x00, sizeof(*this));
this->digestLength = (byte)digestLen;
this->keyLength = (byte)keyLen;
fanout = depth = 1;
if (salt && saltLen)
memcpy_s(this->salt, sizeof(this->salt), salt, saltLen);
if (personalization && personalizationLen)
memcpy_s(this->personalization, sizeof(this->personalization), personalization, personalizationLen);
}
template <class W, bool T_64bit>
void BLAKE2_Base<W, T_64bit>::UncheckedSetKey(const byte *key, unsigned int length, const CryptoPP::NameValuePairs&)
{
CRYPTOPP_CONSTANT(KEYBLOCKSIZE = BLAKE2_Info<T_64bit>::BLOCKSIZE);
if (key && length)
{
AlignedSecByteBlock k(KEYBLOCKSIZE);
memcpy_s(k, KEYBLOCKSIZE, key, length);
memset(k+length, 0x00, KEYBLOCKSIZE-length);
m_key.swap(k);
}
else
{
m_key.resize(0);
}
}
template <class W, bool T_64bit>
BLAKE2_Base<W, T_64bit>::BLAKE2_Base() : m_digestSize(DIGESTSIZE), m_treeMode(false)
{
UncheckedSetKey(NULL, 0, g_nullNameValuePairs);
Restart();
}
template <class W, bool T_64bit>
BLAKE2_Base<W, T_64bit>::BLAKE2_Base(bool treeMode, unsigned int digestSize) : m_digestSize(digestSize), m_treeMode(treeMode)
{
this->ThrowIfInvalidTruncatedSize(digestSize);
UncheckedSetKey(NULL, 0, g_nullNameValuePairs);
Restart();
}
template <class W, bool T_64bit>
BLAKE2_Base<W, T_64bit>::BLAKE2_Base(const byte *key, size_t keyLength, const byte* salt, size_t saltLength,
const byte* personalization, size_t personalizationLength, bool treeMode, unsigned int digestSize)
: m_block(ParameterBlock(digestSize, keyLength, salt, saltLength,
personalization, personalizationLength)), m_digestSize(digestSize), m_treeMode(false)
{
this->ThrowIfInvalidKeyLength(keyLength);
this->ThrowIfInvalidTruncatedSize(digestSize);
UncheckedSetKey(key, keyLength, g_nullNameValuePairs);
Restart();
}
template <class W, bool T_64bit>
void BLAKE2_Base<W, T_64bit>::Restart()
{
static const W zero[2] = {0,0};
Restart(m_block, zero);
}
template <class W, bool T_64bit>
void BLAKE2_Base<W, T_64bit>::Restart(const BLAKE2_ParameterBlock<T_64bit>& block, const W counter[2])
{
m_state.t[0] = m_state.t[1] = 0, m_state.f[0] = m_state.f[1] = 0, m_state.length = 0;
for(unsigned int i = 0; i < BLAKE2_IV<T_64bit>::IVSIZE; ++i)
m_state.h[i] = BLAKE2_IV<T_64bit>::iv[i];
if (&block != &m_block)
{
m_block = block;
m_block.digestLength = (byte)m_digestSize;
m_block.keyLength = (byte)m_key.size();
}
if (counter != NULL)
{
m_state.t[0] = counter[0];
m_state.t[1] = counter[1];
}
// When BLAKE2 is keyed, the input stream is simply {key||message}. Key it
// during Restart to avoid FirstPut and friends. Key size == 0 means no key.
if (m_key.size())
{
// Key is properly sized and padded
Update(m_key, m_key.size());
}
for(unsigned int i = 0; i < BLAKE2_IV<T_64bit>::IVSIZE; ++i)
m_state.h[i] ^= ReadWord<W, T_64bit>(m_block, i);
}
template <class W, bool T_64bit>
void BLAKE2_Base<W, T_64bit>::Update(const byte *input, size_t length)
{
if (m_state.length + length > BLOCKSIZE)
{
/* Complete current block */
size_t left = m_state.length;
size_t fill = BLOCKSIZE - left;
memcpy(&m_state.buffer[left], input, fill);
IncrementCounter();
Compress(m_state.buffer);
m_state.length = 0;
length -= fill;
input += fill;
/* Avoid buffer copies when possible */
while (length > BLOCKSIZE) {
IncrementCounter();
Compress(input);
length -= BLOCKSIZE;
input += BLOCKSIZE;
}
}
memcpy(&m_state.buffer[m_state.length], input, length);
m_state.length += static_cast<unsigned int>(length);
}
template <class W, bool T_64bit>
void BLAKE2_Base<W, T_64bit>::TruncatedFinal(byte *hash, size_t size)
{
// Set last block unconditionally
m_state.f[0] = static_cast<W>(-1);
// Set last node if tree mode
if (m_treeMode)
m_state.f[1] = static_cast<W>(-1);
// Increment counter for tail bytes only
IncrementCounter(m_state.length);
memset(m_state.buffer + m_state.length, 0x00, BLOCKSIZE - m_state.length);
Compress(m_state.buffer);
if (size < DIGESTSIZE)
{
SecByteBlock buffer(DIGESTSIZE);
for(unsigned int i = 0; i < 8; ++i)
WriteWord<W, T_64bit>(m_state.h[i], buffer, i);
memcpy_s(hash, DIGESTSIZE, buffer, size);
}
else
{
// Write directly to the caller buffer
for(unsigned int i = 0; i < 8; ++i)
WriteWord<W, T_64bit>(m_state.h[i], hash, i);
}
Restart();
}
template <class W, bool T_64bit>
void BLAKE2_Base<W, T_64bit>::IncrementCounter(size_t count)
{
m_state.t[0] += count;
m_state.t[1] += !!(m_state.t[0] < count);
}
template <>
void BLAKE2_Base<word64, true>::Compress(const byte *input)
{
#if CRYPTOPP_BOOL_SSE4_INTRINSICS_AVAILABLE
if (HasSSE4())
BLAKE2_SSE4_Compress64(m_state);
else
#endif
#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE
if (HasSSE2())
BLAKE2_SSE2_Compress64(input, m_state);
else
#endif
BLAKE2_CXX_Compress64(input, m_state);
}
template <>
void BLAKE2_Base<word32, false>::Compress(const byte *input)
{
#if CRYPTOPP_BOOL_SSE4_INTRINSICS_AVAILABLE
if (HasSSE4())
BLAKE2_SSE4_Compress32(input, m_state);
else
#endif
#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE
if (HasSSE2())
BLAKE2_SSE2_Compress32(input, m_state);
else
#endif
BLAKE2_CXX_Compress32(input, m_state);
}
void BLAKE2_CXX_Compress64(const byte* input, BLAKE2_State<word64, true>& state)
{
#undef BLAKE2_G
#undef BLAKE2_ROUND
#define BLAKE2_G(r,i,a,b,c,d) \
do { \
a = a + b + m[BLAKE2_Sigma<true>::sigma[r][2*i+0]]; \
d = rotrVariable<word64>(d ^ a, 32); \
c = c + d; \
b = rotrVariable<word64>(b ^ c, 24); \
a = a + b + m[BLAKE2_Sigma<true>::sigma[r][2*i+1]]; \
d = rotrVariable<word64>(d ^ a, 16); \
c = c + d; \
b = rotrVariable<word64>(b ^ c, 63); \
} while(0)
#define BLAKE2_ROUND(r) \
do { \
BLAKE2_G(r,0,v[ 0],v[ 4],v[ 8],v[12]); \
BLAKE2_G(r,1,v[ 1],v[ 5],v[ 9],v[13]); \
BLAKE2_G(r,2,v[ 2],v[ 6],v[10],v[14]); \
BLAKE2_G(r,3,v[ 3],v[ 7],v[11],v[15]); \
BLAKE2_G(r,4,v[ 0],v[ 5],v[10],v[15]); \
BLAKE2_G(r,5,v[ 1],v[ 6],v[11],v[12]); \
BLAKE2_G(r,6,v[ 2],v[ 7],v[ 8],v[13]); \
BLAKE2_G(r,7,v[ 3],v[ 4],v[ 9],v[14]); \
} while(0)
word64 m[16], v[16];
unsigned int i;
for(i = 0; i < 16; ++i)
m[i] = ReadWord<word64, true>(input, i);
for(i = 0; i < 8; ++i)
v[i] = state.h[i];
v[ 8] = BLAKE2_IV<true>::iv[0];
v[ 9] = BLAKE2_IV<true>::iv[1];
v[10] = BLAKE2_IV<true>::iv[2];
v[11] = BLAKE2_IV<true>::iv[3];
v[12] = state.t[0] ^ BLAKE2_IV<true>::iv[4];
v[13] = state.t[1] ^ BLAKE2_IV<true>::iv[5];
v[14] = state.f[0] ^ BLAKE2_IV<true>::iv[6];
v[15] = state.f[1] ^ BLAKE2_IV<true>::iv[7];
BLAKE2_ROUND( 0 );
BLAKE2_ROUND( 1 );
BLAKE2_ROUND( 2 );
BLAKE2_ROUND( 3 );
BLAKE2_ROUND( 4 );
BLAKE2_ROUND( 5 );
BLAKE2_ROUND( 6 );
BLAKE2_ROUND( 7 );
BLAKE2_ROUND( 8 );
BLAKE2_ROUND( 9 );
BLAKE2_ROUND( 10 );
BLAKE2_ROUND( 11 );
for(i = 0; i < 8; ++i)
state.h[i] = state.h[i] ^ v[i] ^ v[i + 8];
}
void BLAKE2_CXX_Compress32(const byte* input, BLAKE2_State<word32, false>& state)
{
#undef BLAKE2_G
#undef BLAKE2_ROUND
#define BLAKE2_G(r,i,a,b,c,d) \
do { \
a = a + b + m[BLAKE2_Sigma<false>::sigma[r][2*i+0]]; \
d = rotrVariable<word32>(d ^ a, 16); \
c = c + d; \
b = rotrVariable<word32>(b ^ c, 12); \
a = a + b + m[BLAKE2_Sigma<false>::sigma[r][2*i+1]]; \
d = rotrVariable<word32>(d ^ a, 8); \
c = c + d; \
b = rotrVariable<word32>(b ^ c, 7); \
} while(0)
#define BLAKE2_ROUND(r) \
do { \
BLAKE2_G(r,0,v[ 0],v[ 4],v[ 8],v[12]); \
BLAKE2_G(r,1,v[ 1],v[ 5],v[ 9],v[13]); \
BLAKE2_G(r,2,v[ 2],v[ 6],v[10],v[14]); \
BLAKE2_G(r,3,v[ 3],v[ 7],v[11],v[15]); \
BLAKE2_G(r,4,v[ 0],v[ 5],v[10],v[15]); \
BLAKE2_G(r,5,v[ 1],v[ 6],v[11],v[12]); \
BLAKE2_G(r,6,v[ 2],v[ 7],v[ 8],v[13]); \
BLAKE2_G(r,7,v[ 3],v[ 4],v[ 9],v[14]); \
} while(0)
word32 m[16], v[16];
unsigned int i;
for(i = 0; i < 16; ++i)
m[i] = ReadWord<word32, false>(input, i);
for(i = 0; i < 8; ++i)
v[i] = state.h[i];
v[ 8] = BLAKE2_IV<false>::iv[0];
v[ 9] = BLAKE2_IV<false>::iv[1];
v[10] = BLAKE2_IV<false>::iv[2];
v[11] = BLAKE2_IV<false>::iv[3];
v[12] = state.t[0] ^ BLAKE2_IV<false>::iv[4];
v[13] = state.t[1] ^ BLAKE2_IV<false>::iv[5];
v[14] = state.f[0] ^ BLAKE2_IV<false>::iv[6];
v[15] = state.f[1] ^ BLAKE2_IV<false>::iv[7];
BLAKE2_ROUND( 0 );
BLAKE2_ROUND( 1 );
BLAKE2_ROUND( 2 );
BLAKE2_ROUND( 3 );
BLAKE2_ROUND( 4 );
BLAKE2_ROUND( 5 );
BLAKE2_ROUND( 6 );
BLAKE2_ROUND( 7 );
BLAKE2_ROUND( 8 );
BLAKE2_ROUND( 9 );
for(i = 0; i < 8; ++i)
state.h[i] = state.h[i] ^ v[i] ^ v[i + 8];
}
#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE
static inline void BLAKE2_SSE2_Compress32(const byte* input, BLAKE2_State<word32, false>& state)
{
// TODO... fall back to C++
BLAKE2_CXX_Compress32(input, state);
}
static inline void BLAKE2_SSE2_Compress64(const byte* input, BLAKE2_State<word64, true>& state)
{
// TODO... fall back to C++
BLAKE2_CXX_Compress64(input, state);
}
#endif // CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE
#if CRYPTOPP_BOOL_SSE4_INTRINSICS_AVAILABLE
static inline void BLAKE2_SSE4_Compress32(const byte* input, BLAKE2_State<word32, false>& state)
{
// TODO... fall back to C++
BLAKE2_CXX_Compress32(input, state);
}
static inline void BLAKE2_SSE4_Compress64(const byte* input, BLAKE2_State<word64, true>& state)
{
// TODO... fall back to C++
BLAKE2_CXX_Compress64(input, state);
}
#endif // CRYPTOPP_BOOL_SSE4_INTRINSICS_AVAILABLE
template class BLAKE2_Base<word32, false>;
template class BLAKE2_Base<word64, true>;
NAMESPACE_END

319
blake2.h Normal file
View File

@ -0,0 +1,319 @@
// blake2.cpp - written and placed in the public domain by Jeffrey Walton and Zooko Wilcox-O'Hearn
// Based on Aumasson, Neves, Wilcox-OHearn and Winnerlein's reference BLAKE2
// implementation at http://github.com/BLAKE2/BLAKE2.
//! \file blake2.h
//! \brief Classes for BLAKE2b and BLAKE2s message digests and keyed message digests
//! \details This implmentation follows Aumasson, Neves, Wilcox-OHearn and Winnerlein's
//! <A HREF="http://blake2.net/blake2.pdf">BLAKE2: simpler, smaller, fast as MD5</A> (2013.01.29).
//! Static algorithm names return either "BLAKE2b" or "BLAKE2s". An object algorithm name follows
//! the naming described in <A HREF="http://tools.ietf.org/html/rfc7693#section-4">RFC 7693, The
//! BLAKE2 Cryptographic Hash and Message Authentication Code (MAC)</A>.
#ifndef CRYPTOPP_BLAKE2_H
#define CRYPTOPP_BLAKE2_H
#include "cryptlib.h"
#include "secblock.h"
#include "seckey.h"
NAMESPACE_BEGIN(CryptoPP)
// Can't use GetAlignmentOf<W>() because its not a constant expression. GCC has
// some bugs spanning 4.0 through 4.9, so we can't use CRYPTOPP_CONSTANT, either.
// Also see http://stackoverflow.com/q/36642315. We may need to increase alignment
// to 32 bytes due to SSE4 alignment requirements.
#if CRYPTOPP_BOOL_ALIGN16
# define BLAKE2_DALIGN 16
#elif defined(_M_X64) || defined(__LP64__) || defined(__x86_64__) || defined(__amd64__)
# define BLAKE2_DALIGN 8
#else
# define BLAKE2_DALIGN 4
#endif
//! \class BLAKE2_Info
//! \brief BLAKE2 hash information
//! \tparam T_64bit flag indicating 64-bit
template <bool T_64bit>
struct CRYPTOPP_NO_VTABLE BLAKE2_Info : public VariableKeyLength<0,0,(T_64bit ? 64 : 32),1,SimpleKeyingInterface::NOT_RESYNCHRONIZABLE>
{
CRYPTOPP_CONSTANT(BLOCKSIZE = (T_64bit ? 128 : 64))
CRYPTOPP_CONSTANT(DIGESTSIZE = (T_64bit ? 64 : 32))
CRYPTOPP_CONSTANT(SALTSIZE = (T_64bit ? 16 : 8))
CRYPTOPP_CONSTANT(PERSONALIZATIONSIZE = (T_64bit ? 16 : 8))
CRYPTOPP_CONSTANT(ALIGNSIZE = BLAKE2_DALIGN);
static const char *StaticAlgorithmName() {return (T_64bit ? "BLAKE2b" : "BLAKE2s");}
};
//! \class BLAKE2_ParameterBlock
//! \brief BLAKE2 parameter block
//! \tparam T_64bit flag indicating 64-bit
//! \details BLAKE2b uses BLAKE2_ParameterBlock<true>, while BLAKE2s
//! uses BLAKE2_ParameterBlock<false>.
template <bool T_64bit>
struct CRYPTOPP_NO_VTABLE BLAKE2_ParameterBlock
{
};
//! \brief BLAKE2b parameter block specialization
template<>
struct CRYPTOPP_NO_VTABLE BLAKE2_ParameterBlock<true>
{
CRYPTOPP_CONSTANT(SALTSIZE = BLAKE2_Info<true>::SALTSIZE);
CRYPTOPP_CONSTANT(DIGESTSIZE = BLAKE2_Info<true>::DIGESTSIZE);
CRYPTOPP_CONSTANT(PERSONALIZATIONSIZE = BLAKE2_Info<true>::PERSONALIZATIONSIZE);
~BLAKE2_ParameterBlock()
{
// Easier than SecBlock<ParameterBlock> or using an AlignedAllocatorWithCleanup
SecureWipeBuffer(reinterpret_cast<byte*>(this), sizeof(*this));
};
BLAKE2_ParameterBlock()
{
memset(this, 0x00, sizeof(*this));
digestLength = DIGESTSIZE;
fanout = depth = 1;
}
BLAKE2_ParameterBlock(size_t digestSize)
{
assert(digestSize <= DIGESTSIZE);
memset(this, 0x00, sizeof(*this));
digestLength = (byte)digestSize;
fanout = depth = 1;
}
BLAKE2_ParameterBlock(size_t digestSize, size_t keyLength, const byte* salt, size_t saltLength,
const byte* personalization, size_t personalizationLength);
byte digestLength, keyLength, fanout, depth;
byte leafLength[4];
byte nodeOffset[8];
byte nodeDepth, innerLength, rfu[14];
byte salt[SALTSIZE];
byte personalization[PERSONALIZATIONSIZE];
};
//! \brief BLAKE2s parameter block specialization
template<>
struct CRYPTOPP_NO_VTABLE BLAKE2_ParameterBlock<false>
{
CRYPTOPP_CONSTANT(SALTSIZE = BLAKE2_Info<false>::SALTSIZE);
CRYPTOPP_CONSTANT(DIGESTSIZE = BLAKE2_Info<false>::DIGESTSIZE);
CRYPTOPP_CONSTANT(PERSONALIZATIONSIZE = BLAKE2_Info<false>::PERSONALIZATIONSIZE);
~BLAKE2_ParameterBlock()
{
// Easier than SecBlock<ParameterBlock> or using an AlignedAllocatorWithCleanup
SecureWipeBuffer(reinterpret_cast<byte*>(this), sizeof(*this));
};
BLAKE2_ParameterBlock()
{
memset(this, 0x00, sizeof(*this));
digestLength = DIGESTSIZE;
fanout = depth = 1;
}
BLAKE2_ParameterBlock(size_t digestSize)
{
assert(digestSize <= BLAKE2_Info<false>::DIGESTSIZE);
memset(this, 0x00, sizeof(*this));
digestLength = (byte)digestSize;
fanout = depth = 1;
}
BLAKE2_ParameterBlock(size_t digestSize, size_t keyLength, const byte* salt, size_t saltLength,
const byte* personalization, size_t personalizationLength);
byte digestLength, keyLength, fanout, depth;
byte leafLength[4];
byte nodeOffset[6];
byte nodeDepth, innerLength;
byte salt[SALTSIZE];
byte personalization[PERSONALIZATIONSIZE];
};
//! \class BLAKE2_State
//! \brief BLAKE2 state information
//! \tparam W word type
//! \tparam T_64bit flag indicating 64-bit
//! \details BLAKE2b uses BLAKE2_State<word64, true>, while BLAKE2s
//! uses BLAKE2_State<word32, false>.
template <class W, bool T_64bit>
struct CRYPTOPP_NO_VTABLE BLAKE2_State
{
// CRYPTOPP_CONSTANT(ALIGNSIZE = BLAKE2_Info<T_64bit>::ALIGNSIZE);
CRYPTOPP_CONSTANT(BLOCKSIZE = BLAKE2_Info<T_64bit>::BLOCKSIZE);
~BLAKE2_State()
{
// Easier than SecBlock<State> or using an AlignedAllocatorWithCleanup
SecureWipeBuffer(reinterpret_cast<byte*>(this), sizeof(*this));
};
BLAKE2_State()
{
// Set all members excpet scratch buf[]
memset(this, 0x00, sizeof(*this)-sizeof(buffer));
}
W t[2], h[8], f[2];
size_t length;
byte buffer[BLOCKSIZE];
};
//! \class BLAKE2_Base
//! \brief BLAKE2 hash implementation
//! \tparam W word type
//! \tparam T_64bit flag indicating 64-bit
//! \details BLAKE2b uses BLAKE2_Base<word64, true>, while BLAKE2s
//! uses BLAKE2_Base<word32, false>.
template <class W, bool T_64bit>
class CRYPTOPP_NO_VTABLE BLAKE2_Base : public SimpleKeyingInterfaceImpl<MessageAuthenticationCode, BLAKE2_Info<T_64bit> >
{
public:
CRYPTOPP_CONSTANT(DIGESTSIZE = BLAKE2_Info<T_64bit>::DIGESTSIZE);
CRYPTOPP_CONSTANT(BLOCKSIZE = BLAKE2_Info<T_64bit>::BLOCKSIZE);
CRYPTOPP_CONSTANT(ALIGNSIZE = BLAKE2_Info<T_64bit>::ALIGNSIZE);
typedef BLAKE2_ParameterBlock<T_64bit> ParameterBlock;
typedef BLAKE2_State<W, T_64bit> State;
virtual ~BLAKE2_Base() {}
//! \brief Retrieve the static algorithm name
//! \returns the algorithm name (BLAKE2s or BLAKE2b)
static const char *StaticAlgorithmName() {return BLAKE2_Info<T_64bit>::StaticAlgorithmName();}
//! \brief Retrieve the object's name
//! \returns the object's algorithm name following RFC 7693
//! \details Object algorithm name follows the naming described in
//! <A HREF="http://tools.ietf.org/html/rfc7693#section-4">RFC 7693, The BLAKE2 Cryptographic Hash and
//! Message Authentication Code (MAC)</A>. For example, "BLAKE2b-512" and "BLAKE2s-256".
std::string AlgorithmName() const {return std::string(StaticAlgorithmName()) + "-" + IntToString(this->DigestSize()*8);}
unsigned int DigestSize() const {return m_digestSize;}
unsigned int OptimalDataAlignment() const {return ALIGNSIZE;}
void Update(const byte *input, size_t length);
void Restart();
//! \brief Restart a hash with parameter block and counter
//! \param block paramter block
//! \param counter counter array
//! \details Parameter block is persisted across calls to Restart().
void Restart(const BLAKE2_ParameterBlock<T_64bit>& block, const W counter[2]);
//! \brief Set tree mode
//! \param mode the new tree mode
//! \details BLAKE2 has two finalization flags, called State::f[0] and State::f[1].
//! If <tt>treeMode=false</tt> (default), then State::f[1] is never set. If
//! <tt>treeMode=true</tt>, then State::f[1] is set when State::f[0] is set.
//! Tree mode is persisted across calls to Restart().
void SetTreeMode(bool mode) {m_treeMode=mode;}
//! \brief Get tree mode
//! \returns the current tree mode
//! \details Tree mode is persisted across calls to Restart().
bool GetTreeMode() const {return m_treeMode;}
void TruncatedFinal(byte *hash, size_t size);
protected:
BLAKE2_Base();
BLAKE2_Base(bool treeMode, unsigned int digestSize);
BLAKE2_Base(const byte *key, size_t keyLength, const byte* salt, size_t saltLength,
const byte* personalization, size_t personalizationLength,
bool treeMode, unsigned int digestSize);
// Operates on state buffer and/or input. Must be BLOCKSIZE, final block will pad with 0's.
void Compress(const byte *input);
inline void IncrementCounter(size_t count=BLOCKSIZE);
void UncheckedSetKey(const byte* key, unsigned int length, const CryptoPP::NameValuePairs& params);
private:
CRYPTOPP_ALIGN_DATA(BLAKE2_DALIGN) State m_state;
CRYPTOPP_ALIGN_DATA(BLAKE2_DALIGN) ParameterBlock m_block;
AlignedSecByteBlock m_key;
word32 m_digestSize;
bool m_treeMode;
};
//! \brief The BLAKE2b cryptographic hash function
//! \details BLAKE2b can function as both a hash and keyed hash. If you want only the hash,
//! then use the BLAKE2b constructor that accepts no parameters or digest size. If you
//! want a keyed hash, then use the constuctor that accpts the key as a parameter.
//! Once a key and digest size are selected, its effectively immutable. The Restart()
//! method that accepts a ParameterBlock does not allow you to change it.
//! \sa Aumasson, Neves, Wilcox-OHearn and Winnerlein's
//! <A HREF="http://blake2.net/blake2.pdf">BLAKE2: simpler, smaller, fast as MD5</A> (2013.01.29).
class BLAKE2b : public BLAKE2_Base<word64, true>
{
public:
CRYPTOPP_CONSTANT(DIGESTSIZE = BLAKE2_Info<true>::DIGESTSIZE);
typedef BLAKE2_Base<word64, true> BaseClass; // Early Visual Studio workaround
typedef BLAKE2_ParameterBlock<true> ParameterBlock;
CRYPTOPP_COMPILE_ASSERT(sizeof(ParameterBlock) == 64);
//! \brief Construct a BLAKE2b hash
//! \param digestSize the digest size, in bytes
BLAKE2b(bool treeMode=false, unsigned int digestSize = DIGESTSIZE) : BaseClass(treeMode, digestSize) {}
//! \brief Construct a BLAKE2b hash
//! \param key a byte array used to key the cipher
//! \param keyLength the size of the byte array
//! \param salt a byte array used as salt
//! \param saltLength the size of the byte array
//! \param personalization a byte array used as prsonalization string
//! \param personalizationLength the size of the byte array
//! \param treeMode flag indicating tree mode
//! \param digestSize the digest size, in bytes
BLAKE2b(const byte *key, size_t keyLength, const byte* salt = NULL, size_t saltLength = 0,
const byte* personalization = NULL, size_t personalizationLength = 0,
bool treeMode=false, unsigned int digestSize = DIGESTSIZE)
: BaseClass(key, keyLength, salt, saltLength, personalization, personalizationLength, treeMode, digestSize) {}
};
//! \brief The BLAKE2s cryptographic hash function
//! \details BLAKE2s can function as both a hash and keyed hash. If you want only the hash,
//! then use the BLAKE2s constructor that accepts no parameters or digest size. If you
//! want a keyed hash, then use the constuctor that accpts the key as a parameter.
//! Once a key and digest size are selected, its effectively immutable. The Restart()
//! method that accepts a ParameterBlock does not allow you to change it.
//! \sa Aumasson, Neves, Wilcox-OHearn and Winnerlein's
//! <A HREF="http://blake2.net/blake2.pdf">BLAKE2: simpler, smaller, fast as MD5</A> (2013.01.29).
class BLAKE2s : public BLAKE2_Base<word32, false>
{
public:
CRYPTOPP_CONSTANT(DIGESTSIZE = BLAKE2_Info<false>::DIGESTSIZE);
typedef BLAKE2_Base<word32, false> BaseClass; // Early Visual Studio workaround
typedef BLAKE2_ParameterBlock<false> ParameterBlock;
CRYPTOPP_COMPILE_ASSERT(sizeof(ParameterBlock) == 32);
//! \brief Construct a BLAKE2b hash
//! \param digestSize the digest size, in bytes
BLAKE2s(bool treeMode=false, unsigned int digestSize = DIGESTSIZE) : BaseClass(treeMode, digestSize) {}
//! \brief Construct a BLAKE2b hash
//! \param key a byte array used to key the cipher
//! \param keyLength the size of the byte array
//! \param salt a byte array used as salt
//! \param saltLength the size of the byte array
//! \param personalization a byte array used as prsonalization string
//! \param personalizationLength the size of the byte array
//! \param treeMode flag indicating tree mode
//! \param digestSize the digest size, in bytes
BLAKE2s(const byte *key, size_t keyLength, const byte* salt = NULL, size_t saltLength = 0,
const byte* personalization = NULL, size_t personalizationLength = 0,
bool treeMode=false, unsigned int digestSize = DIGESTSIZE)
: BaseClass(key, keyLength, salt, saltLength, personalization, personalizationLength, treeMode, digestSize) {}
};
NAMESPACE_END
#endif

View File

@ -50,6 +50,7 @@
#include "crc.h"
#include "adler32.h"
#include "sha3.h"
#include "blake2.h"
#include "hkdf.h"
// Aggressive stack checking with VS2005 SP1 and above.
@ -157,6 +158,10 @@ void RegisterFactories()
RegisterSymmetricCipherDefaultFactories<CTR_Mode<Blowfish> >();
RegisterSymmetricCipherDefaultFactories<ECB_Mode<SEED> >();
RegisterSymmetricCipherDefaultFactories<CTR_Mode<SEED> >();
RegisterDefaultFactoryFor<HashTransformation, BLAKE2s>();
RegisterDefaultFactoryFor<MessageAuthenticationCode, BLAKE2s>();
RegisterDefaultFactoryFor<HashTransformation, BLAKE2b>();
RegisterDefaultFactoryFor<MessageAuthenticationCode, BLAKE2b>();
RegisterDefaultFactoryFor<KeyDerivationFunction, HKDF<SHA1> >();
RegisterDefaultFactoryFor<KeyDerivationFunction, HKDF<SHA256> >();
RegisterDefaultFactoryFor<KeyDerivationFunction, HKDF<SHA512> >();

View File

@ -58,6 +58,22 @@ public:
explicit InvalidRounds(const std::string &algorithm, unsigned int rounds) : InvalidArgument(algorithm + ": " + IntToString(rounds) + " is not a valid number of rounds") {}
};
//! \class InvalidPersonalizationLength
//! \brief Exception thrown when an invalid personalization string length is encountered
class CRYPTOPP_DLL InvalidPersonalizationLength : public InvalidArgument
{
public:
explicit InvalidPersonalizationLength(const std::string &algorithm, size_t length) : InvalidArgument(algorithm + ": " + IntToString(length) + " is not a valid salt length") {}
};
//! \class InvalidSaltLength
//! \brief Exception thrown when an invalid salt length is encountered
class CRYPTOPP_DLL InvalidSaltLength : public InvalidArgument
{
public:
explicit InvalidSaltLength(const std::string &algorithm, size_t length) : InvalidArgument(algorithm + ": " + IntToString(length) + " is not a valid salt length") {}
};
// *****************************
//! \class Bufferless