aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--checks/algos.cpp1
-rw-r--r--checks/validate.dat280
-rw-r--r--doc/log.txt1
-rw-r--r--include/salsa20.h39
-rw-r--r--src/def_alg.cpp2
-rw-r--r--src/salsa20.cpp180
6 files changed, 503 insertions, 0 deletions
diff --git a/checks/algos.cpp b/checks/algos.cpp
index 1a95773aa..4ce6ea3b6 100644
--- a/checks/algos.cpp
+++ b/checks/algos.cpp
@@ -56,6 +56,7 @@ std::vector<algorithm> get_algos()
algos.push_back(algorithm("Cipher Mode", "AES-128/EAX", 16, 16));
algos.push_back(algorithm("Stream Cipher", "ARC4", 16));
+ algos.push_back(algorithm("Stream Cipher", "Salsa20", 32));
algos.push_back(algorithm("Stream Cipher", "Turing", 32));
algos.push_back(algorithm("Stream Cipher", "WiderWake4+1",
"WiderWake4+1-BE", 16, 8));
diff --git a/checks/validate.dat b/checks/validate.dat
index 98b207552..6f5b9d006 100644
--- a/checks/validate.dat
+++ b/checks/validate.dat
@@ -26769,6 +26769,286 @@ A2F81CF25695060C04A2ED2E6F92339A
80206B94450FA80D81D44D3E751C8541E15B9DCFBCC05DC6007425E52851DF51B8166A9EF2:\
BD348966C075CE6B78BA2918258538ED
+[Salsa20]
+
+# From linux-2.6.25.9's crypto/tcrypt.h (all zero IVs)
+0000000000000000000000000000000000000000\
+00000000000000000000000000000000000000:\
+2DD5C3F7BA2B20F76802410C688688895AD8C1BD4\
+EA6C9B140FB9B90E21049BF583F527970EBC1:\
+000102030405060708090A0B0C0D0E0F
+
+0000000000000000000000000000000000000000000000000000000000000000\
+0000000000000000000000000000000000000000000000000000000000000000\
+0000000000000000000000000000000000000000000000000000000000000000\
+000000000000000000000000000000:\
+AE39508EAC9AECE7BF97BB20B9DEE41F87D947F828913598DB72CC232948565E\
+837E0BF37D5D387B2D7102B43BB5D823B04ADF3CECB6D93B9BA752BEC5D45059\
+1514B40E40E653D1839C5BA092296B5E965B1E2FD3ACC192B1413F192FC43BC6\
+95464554E975030844AFE58A811209:\
+1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A
+
+# From Crypto++ via Linux kernel
+000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F\
+202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F\
+404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F\
+606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F\
+808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9F\
+A0A1A2A3A4A5A6A7A8A9AAABACADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBF\
+C0C1C2C3C4C5C6C7C8C9CACBCCCDCECFD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDF\
+E0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF\
+000306090C0F1215181B1E2124272A2D303336393C3F4245484B4E5154575A5D\
+606366696C6F7275787B7E8184878A8D909396999C9FA2A5A8ABAEB1B4B7BABD\
+C0C3C6C9CCCFD2D5D8DBDEE1E4E7EAEDF0F3F6F9FCFF0205080B0E1114171A1D\
+202326292C2F3235383B3E4144474A4D505356595C5F6265686B6E7174777A7D\
+808386898C8F9295989B9EA1A4A7AAADB0B3B6B9BCBFC2C5C8CBCED1D4D7DADD\
+E0E3E6E9ECEFF2F5F8FBFE0104070A0D101316191C1F2225282B2E3134373A3D\
+404346494C4F5255585B5E6164676A6D707376797C7F8285888B8E9194979A9D\
+A0A3A6A9ACAFB2B5B8BBBEC1C4C7CACDD0D3D6D9DCDFE2E5E8EBEEF1F4F7FAFD\
+00050A0F14191E23282D32373C41464B50555A5F64696E73787D82878C91969B\
+A0A5AAAFB4B9BEC3C8CDD2D7DCE1E6EBF0F5FAFF04090E13181D22272C31363B\
+40454A4F54595E63686D72777C81868B90959A9FA4A9AEB3B8BDC2C7CCD1D6DB\
+E0E5EAEFF4F9FE03080D12171C21262B30353A3F44494E53585D62676C71767B\
+80858A8F94999EA3A8ADB2B7BCC1C6CBD0D5DADFE4E9EEF3F8FD02070C11161B\
+20252A2F34393E43484D52575C61666B70757A7F84898E93989DA2A7ACB1B6BB\
+C0C5CACFD4D9DEE3E8EDF2F7FC01060B10151A1F24292E33383D42474C51565B\
+60656A6F74797E83888D92979CA1A6ABB0B5BABFC4C9CED3D8DDE2E7ECF1F6FB\
+00070E151C232A31383F464D545B626970777E858C939AA1A8AFB6BDC4CBD2D9\
+E0E7EEF5FC030A11181F262D343B424950575E656C737A81888F969DA4ABB2B9\
+C0C7CED5DCE3EAF1F8FF060D141B222930373E454C535A61686F767D848B9299\
+A0A7AEB5BCC3CAD1D8DFE6EDF4FB020910171E252C333A41484F565D646B7279\
+80878E959CA3AAB1B8BFC6CDD4DBE2E9F0F7FE050C131A21282F363D444B5259\
+60676E757C838A91989FA6ADB4BBC2C9D0D7DEE5ECF3FA01080F161D242B3239\
+40474E555C636A71787F868D949BA2A9B0B7BEC5CCD3DAE1E8EFF6FD040B1219\
+20272E353C434A51585F666D747B828990979EA5ACB3BAC1C8CFD6DDE4EBF2F9\
+0009121B242D363F48515A636C757E879099A2ABB4BDC6CFD8E1EAF3FC050E17\
+2029323B444D565F68717A838C959EA7B0B9C2CBD4DDE6EFF8010A131C252E37\
+4049525B646D767F88919AA3ACB5BEC7D0D9E2EBF4FD060F18212A333C454E57\
+6069727B848D969FA8B1BAC3CCD5DEE7F0F9020B141D262F38414A535C656E77\
+8089929BA4ADB6BFC8D1DAE3ECF5FE071019222B343D464F58616A737C858E97\
+A0A9B2BBC4CDD6DFE8F1FA030C151E273039424B545D666F78818A939CA5AEB7\
+C0C9D2DBE4EDF6FF08111A232C353E475059626B747D868F98A1AAB3BCC5CED7\
+E0E9F2FB040D161F28313A434C555E677079828B949DA6AFB8C1CAD3DCE5EEF7\
+000B16212C37424D58636E79848F9AA5B0BBC6D1DCE7F2FD08131E29343F4A55\
+606B76818C97A2ADB8C3CED9E4EFFA05101B26313C47525D68737E89949FAAB5\
+C0CBD6E1ECF7020D18232E39444F5A65707B86919CA7B2BDC8D3DEE9F4FF0A15\
+202B36414C57626D78838E99A4AFBAC5D0DBE6F1FC07121D28333E49545F6A75\
+808B96A1ACB7C2CDD8E3EEF9040F1A25303B46515C67727D88939EA9B4BFCAD5\
+E0EBF6010C17222D38434E59646F7A85909BA6B1BCC7D2DDE8F3FE09141F2A35\
+404B56616C77828D98A3AEB9C4CFDAE5F0FB06111C27323D48535E69747F8A95\
+A0ABB6C1CCD7E2EDF8030E19242F3A45505B66717C87929DA8B3BEC9D4DFEAF5\
+000D1A2734414E5B6875828F9CA9B6C3D0DDEAF704111E2B3845525F6C798693\
+A0ADBAC7D4E1EEFB0815222F3C495663707D8A97A4B1BECBD8E5F2FF0C192633\
+404D5A6774818E9BA8B5C2CFDCE9F603101D2A3744515E6B7885929FACB9C6D3\
+E0EDFA0714212E3B4855626F7C8996A3B0BDCAD7E4F1FE0B1825323F4C596673\
+808D9AA7B4C1CEDBE8F5020F1C293643505D6A7784919EABB8C5D2DFECF90613\
+202D3A4754616E7B8895A2AFBCC9D6E3F0FD0A1724313E4B5865727F8C99A6B3\
+C0CDDAE7F4010E1B2835424F5C697683909DAAB7C4D1DEEBF805121F2C394653\
+606D7A8794A1AEBBC8D5E2EFFC091623303D4A5764717E8B98A5B2BFCCD9E6F3\
+000F1E2D3C4B5A69788796A5B4C3D2E1F0FF0E1D2C3B4A5968778695A4B3C2D1\
+E0EFFE0D1C2B3A495867768594A3B2C1D0DFEEFD0C1B2A39485766758493A2B1\
+C0CFDEEDFC0B1A2938475665748392A1B0BFCEDDECFB0A192837465564738291\
+A0AFBECDDCEBFA091827364554637281909FAEBDCCDBEAF90817263544536271\
+808F9EADBCCBDAE9F807162534435261707F8E9DACBBCAD9E8F7061524334251\
+606F7E8D9CABBAC9D8E7F60514233241505F6E7D8C9BAAB9C8D7E6F504132231\
+404F5E6D7C8B9AA9B8C7D6E5F4031221303F4E5D6C7B8A99A8B7C6D5E4F30211\
+202F3E4D5C6B7A8998A7B6C5D4E3F201101F2E3D4C5B6A798897A6B5C4D3E2F1\
+00112233445566778899AABBCCDDEEFF102132435465768798A9BACBDCEDFE0F\
+2031425364758697A8B9CADBECFD0E1F30415263748596A7B8C9DAEBFC0D1E2F\
+405162738495A6B7C8D9EAFB0C1D2E3F5061728394A5B6C7D8E9FA0B1C2D3E4F\
+60718293A4B5C6D7E8F90A1B2C3D4E5F708192A3B4C5D6E7F8091A2B3C4D5E6F\
+8091A2B3C4D5E6F708192A3B4C5D6E7F90A1B2C3D4E5F60718293A4B5C6D7E8F\
+A0B1C2D3E4F5061728394A5B6C7D8E9FB0C1D2E3F405162738495A6B7C8D9EAF\
+C0D1E2F30415263748596A7B8C9DAEBFD0E1F2031425364758697A8B9CADBECF\
+E0F102132435465768798A9BACBDCEDFF00112233445566778899AABBCCDDEEF\
+001326394C5F728598ABBED1E4F70A1D304356697C8FA2B5C8DBEE0114273A4D\
+60738699ACBFD2E5F80B1E3144576A7D90A3B6C9DCEF0215283B4E6174879AAD\
+C0D3E6F90C1F3245586B7E91A4B7CADDF00316293C4F6275889BAEC1D4E7FA0D\
+203346596C7F92A5B8CBDEF104172A3D506376899CAFC2D5E8FB0E2134475A6D\
+8093A6B9CCDFF205182B3E5164778A9DB0C3D6E9FC0F2235485B6E8194A7BACD\
+E0F306192C3F5265788B9EB1C4D7EAFD102336495C6F8295A8BBCEE1F4071A2D\
+405366798C9FB2C5D8EBFE1124374A5D708396A9BCCFE2F5081B2E4154677A8D\
+A0B3C6D9ECFF1225384B5E718497AABDD0E3F6091C2F4255687B8EA1B4C7DAED\
+00152A3F54697E93A8BDD2E7FC11263B50657A8FA4B9CEE3F80D22374C61768B\
+A0B5CADFF4091E33485D72879CB1C6DBF0051A2F44596E8398ADC2D7EC01162B\
+40556A7F94A9BED3E8FD12273C51667B90A5BACFE4F90E23384D62778CA1B6CB\
+E0F50A1F34495E73889DB2C7DCF1061B30455A6F8499AEC3D8ED02172C41566B\
+8095AABFD4E9FE13283D52677C91A6BBD0E5FA0F24394E63788DA2B7CCE1F60B\
+20354A5F74899EB3C8DDF2071C31465B70859AAFC4D9EE03182D42576C8196AB\
+C0D5EAFF14293E53687D92A7BCD1E6FB10253A4F64798EA3B8CDE2F70C21364B\
+60758A9FB4C9DEF3081D32475C71869BB0C5DAEF04192E43586D8297ACC1D6EB\
+00172E455C738AA1B8CFE6FD142B425970879EB5CCE3FA11283F566D849BB2C9\
+E0F70E253C536A8198AFC6DDF40B223950677E95ACC3DAF1081F364D647B92A9\
+C0D7EE051C334A61788FA6BDD4EB021930475E758CA3BAD1E8FF162D445B7289\
+A0B7CEE5FC132A41586F869DB4CBE2F910273E556C839AB1C8DFF60D243B5269\
+8097AEC5DCF30A21384F667D94ABC2D9F0071E354C637A91A8BFD6ED041B3249\
+60778EA5BCD3EA01182F465D748BA2B9D0E7FE152C435A71889FB6CDE4FB1229\
+40576E859CB3CAE1F80F263D546B8299B0C7DEF50C233A51687F96ADC4DBF209\
+20374E657C93AAC1D8EF061D344B627990A7BED5EC031A31485F768DA4BBD2E9\
+0019324B647D96AFC8E1FA132C455E7790A9C2DBF40D263F58718AA3BCD5EE07\
+2039526B849DB6CFE8011A334C657E97B0C9E2FB142D465F7891AAC3DCF50E27\
+4059728BA4BDD6EF08213A536C859EB7D0E9021B344D667F98B1CAE3FC152E47\
+607992ABC4DDF60F28415A738CA5BED7F009223B546D869FB8D1EA031C354E67\
+8099B2CBE4FD162F48617A93ACC5DEF71029425B748DA6BFD8F10A233C556E87\
+A0B9D2EB041D364F68819AB3CCE5FE173049627B94ADC6DFF8112A435C758EA7\
+C0D9F20B243D566F88A1BAD3EC051E375069829BB4CDE6FF18314A637C95AEC7\
+E0F9122B445D768FA8C1DAF30C253E577089A2BBD4ED061F38516A839CB5CEE7\
+001B36516C87A2BDD8F30E29445F7A95B0CBE6011C37526D88A3BED9F40F2A45\
+607B96B1CCE7021D38536E89A4BFDAF5102B46617C97B2CDE8031E39546F8AA5\
+C0DBF6112C47627D98B3CEE9041F3A55708BA6C1DCF7122D48637E99B4CFEA05\
+203B56718CA7C2DDF8132E49647F9AB5D0EB06213C57728DA8C3DEF9142F4A65\
+809BB6D1EC07223D58738EA9C4DFFA15304B66819CB7D2ED08233E59748FAAC5\
+E0FB16314C67829DB8D3EE09243F5A7590ABC6E1FC17324D68839EB9D4EF0A25\
+405B7691ACC7E2FD18334E69849FBAD5F00B26415C7792ADC8E3FE19344F6A85\
+A0BBD6F10C27425D7893AEC9E4FF1A35506B86A1BCD7F20D28435E7994AFCAE5\
+001D3A577491AECBE805223F5C7996B3D0ED0A2744617E9BB8D5F20F2C496683\
+A0BDDAF714314E6B88A5C2DFFC193653708DAAC7E4011E3B587592AFCCE90623\
+405D7A97B4D1EE0B2845627F9CB9D6F3102D4A6784A1BEDBF815324F6C89A6C3\
+E0FD1A3754718EABC8E5021F3C597693B0CDEA0724415E7B98B5D2EF0C294663\
+809DBAD7F4112E4B6885A2BFDCF91633506D8AA7C4E1FE1B3855728FACC9E603\
+203D5A7794B1CEEB0825425F7C99B6D3F00D2A4764819EBBD8F5122F4C6986A3\
+C0DDFA1734516E8BA8C5E2FF1C39567390ADCAE704213E5B7895B2CFEC092643\
+607D9AB7D4F10E2B4865829FBCD9F613304D6A87A4C1DEFB1835526F8CA9C6E3\
+001F3E5D7C9BBAD9F81736557493B2D1F00F2E4D6C8BAAC9E80726456483A2C1\
+E0FF1E3D5C7B9AB9D8F71635547392B1D0EF0E2D4C6B8AA9C8E70625446382A1\
+C0DFFE1D3C5B7A99B8D7F61534537291B0CFEE0D2C4B6A89A8C7E60524436281\
+A0BFDEFD1C3B5A7998B7D6F51433527190AFCEED0C2B4A6988A7C6E504234261\
+809FBEDDFC1B3A597897B6D5F4133251708FAECDEC0B2A496887A6C5E4032241\
+607F9EBDDCFB1A39587796B5D4F31231506F8EADCCEB0A29486786A5C4E30221\
+405F7E9DBCDBFA1938577695B4D3F211304F6E8DACCBEA0928476685A4C3E201\
+203F5E7D9CBBDAF91837567594B3D2F1102F4E6D8CABCAE90827466584A3C2E1\
+00214263:\
+B581F5641873E3F04C13F2771860655E2901CE985553F90C2A08D509B3575556\
+C5E95690CB6AA3C0FFC479B4D2975DC443D1FE947B88065AB29E2CFC4403B790\
+A0C1BA6A33B8C7B29DE1124FC064D401FE8C7A66F7E65A91BBDE5686AB652130\
+00846524A57D85B4E317ED3AB76FB40B0BAF15AE5A8FF20C2F27F409D8D296B7\
+71F2C5994D7E7F757789308B59DBA2B2A0F319392BC57E3F4FD9D356289744DC\
+C08B7724D952E7C5AFF67D59B244051DB1B011A50FEC33E16D1B4E1FFF5791B4\
+5B9A96C553BCAE203CBB14E2E82233C15E769E4699F62A15C69702A06643D1A6\
+31A69FFBF4D369E5CD7695B87A827F2145FF3FCE55F6951008771043C6F309E5\
+68E73CAD0052450DFE2DC6C2948C121DE625AE98128E199C8168B111F669DAE3\
+6208187A254928ACBA71120BE4A2E5C75D8EEC494021BF5A98F3026855037F8A\
+E5940C325C078263AF6F9140848E5225D0B0295305E2507A34EBC94620A83DDE\
+7F165F36C52EDCD11547C750406D91C5E793951AD357BC5233EE1419225289A7\
+4A2556774BCACF0AE1F53585307E594ABD145BDFE346CBAC1F6C960EF481D199\
+CA88633D02586BA9E59FB300B254C6741CBF46AB97CCF85404070852E6C0DA93\
+747D93995D7868A62E6BD36A69CC126BD4C7A5C6E7F603045DCD615E1740DCD1\
+5CF508DF5C9085A4AFF678BB0DF1F4A45426729E61FA86CFE89EA1E0C74823AE\
+5A90AE750A74188905B192B27FD01BA662072501C7C24FF9E8FE63958007B426\
+CCD126B6C43F9ECB8E3B2E4416D3109A9508EBC8CBEBBF6F0BCD1FC8CA86AAEC\
+33E669F44525863A22944F00236A44C2499733AB36140A7024C3BE043B79A0F9\
+B8E776292283D7F294F44149BA5F7B07B5FBDB031A9FB64CC22E374049C33816\
+E24F7782B0684C711D57619CD94E5499471328733CBB0090F34DC90EFDE7B171\
+D31579BFCC262FBDAD6C50696C3E6D809AEA78AF19B20D4DAD0407AE22904A93\
+320E369B1B46BA3BB4ACC6D1A231533B2A3D45FE036110851769A678CC6C8749\
+53F98010DE80A2416AC33202AD6D3C5600715106A7BDFBEF3CB59FFC487D537C\
+66B04923C447100EE56C7413E6C53FAADEFF0744DD561BAD0977FB5B12B80D38\
+1737357B9BBCFED47E8BDA7E5B04A722A731A12086C71B99DBD189F494A35369\
+8DE7E874118D74D60737919FFD67503AC9E1F436D5A047D1F9E539A331AC0736\
+23F866181428340FB8D0E729B3044B550141B2758DCB96853AFBAB2B9EFA5820\
+441FC014227561E8AA19CFF18256F4D7787B3D5FB39E0B8A5750DB1741654DA3\
+02C99C9C53FB39399B1D7224DAB739BE133BFA29DA9E54646EBAD8A1CBB336FA\
+CB4785E96138BCBEC500382A54F7C4B9B3D37BA0A0F8727F8C8E820EC61C759D\
+CA8E6187DEAD80D2F5F980EF1575AFF580FBFF6D1E25B740616A395A6AB531AB\
+978A19894440C0A6B44E30327B13E767A98B5704C201A6F42899AD2C76A378C2\
+4AE6CA5C506AC1B0624B108E7C1743B317661C3E8D69F05A71F597DCD145DD28\
+F35DDF537B11E5BC4CDB1B516BE9FB3DC1C32CB971F5B6B21336798053E8D3A6\
+0AAFFD5697F7408E45CEF8B09E5C3382B04456FC0509E92AAC2680141DC83A35\
+4C8297FD76B7A90A3558798E0F66EAAF516C09A96E9BCB9A3147A02F7C71B44A\
+11AA8C66C564E63A54DA246AC441654682A00A0F5FFB25D02C91A7EEC4810786\
+755E336997E42CA89D9F0B6ABEAD98DA6D9441DA2C1E89C4C2AF1E00050B8360\
+BD43EA15237FB9ACEE4F2CAF2AF3DFD0F31931BB4A74841752322C7D61E4CBEB\
+80381552CB6FEAE5739CD92469C6953221C811E4DC36D7933866FBB27F3AB9AF\
+31DD9375788A2C94871A58EC9E7D4DBAE1E54DFCBCA42A14EFCCA7ECAB430918\
+D3AB68D107994447D683853B30EAA96B63EAC407FB432FA4AAB0AB0389CE3F8C\
+027C8654BC88AF75D2DC6317D326F696A93CF1618C1118CCD6EA5BE2CDF0F1B2\
+E535901F854C765B66CE44A4329FE67B716E9F5815677287648E3A4445D476FA\
+C2F6EF8505187A9BBA4154ACF0FC59123FDFA0E58A65FD3A628D832C03BE0576\
+2E5349979433AE408115DB6EADAAF54BE39870DFE07CCDDB02D47D2FC1E6B4F3\
+D70D7AD9239E872DCE87ADCC72050029DC737F64C1150EC2DFA75FEB41A1CDEF\
+5C50792A5656718CACC0795069CA593265F254E4523876D15EDE269EFB752E11\
+B510F41773F589C74F435C8E7CB90552244099FE9B850B6C223E8BAE86A1D279\
+05686BABE34149ED15A18D402D61DF1A59C9268BEF304C884B10F88DA6929F4B\
+F3C4530B895D2892CF78B2C05DED7EFCC012235F5A7886436E27F75AA76AED19\
+04F0B312D1BD0E896EBC96A8D849399F7E67F02E3E01A9BAEC8B628ECB4A7043\
+C7C2C4CA820373E911DFCF54EAC9B09551C0133D9205FAF4A934C8CE6C3D54CC\
+C4AFF1DC114426A2AFF185757D0361684E78C6927D867D77DC7172DBC6AEA1CB\
+709A0B19BE4A6C2AE2BA6C649A1328DF8575E643F68708686EBA6E799F04BC23\
+50F6335C1F2425BE3347804556A3A7D77AB1340B903C9CAD445F9E0E9DD4BD93\
+5EFA3CE0B0D9EDF3D62EFF24D8716CEDAF55EB22AC936832055B47DDC64ACBC7\
+10E13C921AF323782BA1D280F412B1208FFF2635DDFBC74E78F12D501277A860\
+7C0FF5162F63702AC096804E0AB493355D1D3F56F72FBB9011168FA2EC47BEAC\
+56012656B18CB210F91ACAF5D1B7392063F169204F13121F5B65FC98F7C47ABE\
+F7264D2B847B42ADD87A0AB4D874BFC1F06EB429A3BBCA4667706A2DCE0EA28A\
+A987BF05C4C104A3ABD445438CB602B041C8FC443D59AA2E44212A8D889D57F4\
+A00277B8A6A0E6755C82653E035C298F3855AB3326EF9F4352FD68AF36B4BB9A\
+5809091BC36546461DA7941823502CCA2C551997019D933B6386F2036745D272\
+28526CF4E31CB51113F1EB21C7D956822B8239BD6954ED62C3E2DE73D46A12AE\
+13217F4B5BFCBFE82BBE56BA688B9AB16EFABF7E5A4BF1AC986585D19353D37B\
+09DD4B106D84B01365BDCF5209C485E284741565B7F751AF55ADA4D122547094\
+A01C9041FD99D75A31EFAA25D07F4FEA1D5542E549B0D046623643B282157550\
+A472EB54271F8AE47DE966C5F153A4D10CEBB8F8BCD4E2E7E1F84BCBA9A1AF15\
+83CB72D03379002D9FD7F12E1E10E445C0753A39EA68F75D1B738FE98E0F7247\
+AE350A317A144D4A6F47F77E916E748B2647F9C3F9DE70F561ABA9279F82E49C\
+89913F2E6AFDB549E9FD59143649406D32D88542F3A5DF0CA827D754E2632FF2\
+7E8B8BE7F19A953543DC3AE4B6F4D0DF9CCB94F321A07750E2C6C4C65F09645B\
+9290D8E1D1ED4B42D737AF653D1139B6248A60AED61EBF0E0DD7DC960E65754E\
+29069DA4513A10638F1707D58E3CF428005A5B0519D8C06CE515E49C9D719D5E\
+94291AA780FA0E3303DDB73E9AA9261837A964084D945A88CA35CE8102E31F1B\
+891A7785E3416D324219237DC873EE25850DF83125791B6F7925D2D8D423FDF7\
+82366A0C462215E9FF724191917D3AB7DD659970F68D84F867152011D6B2557B\
+DB87EEEF55892A592B078F438A593C018B6554A166D538BDC630A9CC49B6A81B\
+B8C00EE34528E2FF419F7E7CD1AE9E253F4C7C7CF4A8264D5CFD4B2718F96176\
+48BA0C6BA94DFCF53B357E2F4AA9C29AAEAB860989C9C240392C81B3B81767C2\
+0D324A3A6781D71A3452C5DB0AF56339EA1FE17CA19EC135E3B1184567F92238\
+95D9343486C6419415F95B41A6878BF8D5E11BE25BF38610FFE6AE6976BC0DB4\
+09900CA2650CAD74F5D7FFDAC1CE85BE00A7FF4D2F65D38C862D05E8ED3E6B8B\
+0F3D838CF11D5B962EB19CC298E170B9BA5C8A43D634A72DC992AEF2A57B0549\
+A7333486CAE49623765BF2C6F15128427BCC768FFAA2AD31D4D67A6D252554E4\
+3F5059E15C05B72748BF07EC1B13BE2BA1572BD5ABD7D04C1ECB719BC59085D3\
+DE59EC71EB89BBD00950E1163FFD1C34C31CA110775398EFF2FDA50159C29B26\
+C742D949DA582B6E9F5319767ED9C90E68C87F512242EF49A455B636AC09C731\
+88154B2E8F3A08F7D8F7A8C5A933A645E4C49476F30D8F7EC8F6BC230AB64CD3\
+6ACD36C2905C5C3C657BC2D6CCE60D87732E7179160663280915D88938383DB5\
+421C0824F72AD29DC8CAEFF927D80786F7430B55153F9F83EFDC499D2AC15462\
+BD9B66559FB712F31B4D9D2A5CED87758726EC612CB40F89B0FB2E685D15C78D\
+2EC0D9ECAF4FD22529E8D2262B67E9FC2BA86796121F5B96C61453AF44EAD6E2\
+9498E412934C92E018A58D2DE4713C474CF7E6479EC068DFD4F55A74B12B2903\
+1907AF90625C6898481611029DEEB49BE5427F08FD16320BD0B3FA2BB799F929\
+CD20459FB31A5DA2AF4DE0BD420DBC74999C8E531AB43EBDA29A2DF7F8390F67\
+63FC6BC0AFB34B4F55C4CFA7C804113E1432BB1B3877D67F544CDF75F3072D33\
+9BA820E17B12B5F3EF2FCE72E52460C130E2ABA18E1109A8213344FE7F353293\
+39A7AD8B7906B2CB4EA95FC7BA7429EC93A04E5493C0BC5564F048E55799EE75\
+D6790F66B7C65776F7B7F39CC560E87F8376D60EAAE690391DA6326A34E355F8\
+58A0587D33E02239446487865A2FA77E0F38EAB030CC61A56A32AE1EF7E9D0A9\
+0C324BB54928AB852F8E01363852D0BAD60278F80E3E9C8B6B45993F5CFE58F1\
+5C9404E1F5186D51B25D1820B6C29A421DB3AB3CB63A1303B246824FFC64BC4F\
+CAFA9CC0D5A7BD11B7E45AF66F4D4D54EAA49866D4223BD38F3447D97CF4723B\
+4D0277F6D6DD080A81E186893E56103CBAD7818C08BC8BE253ECA789EEC856B5\
+362CB203BA99DD7C48A0B0BC9133E9A8CBCDCF595F1F15E256F54E0135274577\
+47C8BCCB7E39C19728D384FC2C3EC8AD9CF88A619C28AAC5992043859DA5E28B\
+B8AEEBD0320D527809563FC7D87E26FC37FB6F04FCFA9210ACF83E21DC8C2116\
+7D676EF6CDDAB69823AB233CB210A0535A569FC5D0FFBBE4983C691EDB388F7E\
+0FD29888818B4567EA33F1EBE997552ED9AAEB5AECDAE168A89D3C847C053D62\
+878F032128950C8925224AB093A950A22F576E184219540C5567C61149F45CD2\
+E93DDD8B48712100C39A6C857428834A1B3105E10692E7DA85737845207FAE13\
+7C330622F483F9353F6C71A84E48BE9BCE8ABADABE2808F7E2148C71EA72F933\
+F2883FD7BB696C2919DC84CE1F124FC8AFA504BA5AABB0D9141F6C689839897A\
+D9D82FDFA8474A25E2FB33F45978E16885CFFE5920D4051D8099AEBCCAAE0F2F\
+6543348E7EACD3932FAC6D143D0207709DA4F31B5C36FC017334850C6CD6F1BD\
+3FDFEEF5D9BA56EFF49B6BEE9F5A786D3219F4F7F84C690B4BBCBBB7F285AF70\
+75246C54A70E4D1D01BF08ACCF7F2CE314895E705A9992CD0184C8D2ABE54F58\
+E70F2F0EFF68EAFD15B317E6B0E785D8232E05C7C9C4461FE19E492023244D7E\
+2965FFF4B6FD1A85C416ECFCEA7BD62C43F8B7BF79C085CDEFE198D3A5F7908C\
+E97F806BD2AC4C30A7C6616CD2F92CFF30BC22817D9312E40ACDAFDDE8AB0A1E\
+13A427C35FF74BBB37094B916F924FAF52EEDFEF096FF75C6E1217726357C7BA\
+3B6B3832731B9C80C17AC6CFCD35C06B311A6BE9D82C293F96FBB6CD13913BC2\
+D2A3318DA4CD57CD133D64FD06CEE6DC0C2443314057F17217E33A636D35CF5D\
+974059DDF73C02F71C7E05BBA90D01B18EC030A95324C989846DAAD0CD91C24D\
+91B089E2BF8344AA287223A0C2ADAD1CFC3F097A0BDCC51B8713C65B598DF2C8\
+AFDF1195:\
+000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F
+
[Turing]
0000000000000000000000000000000000000000:\
696626BBDC6E09F6DA9ABAB5B56C14878246DF18:\
diff --git a/doc/log.txt b/doc/log.txt
index 0a6a9a24a..8030f68bc 100644
--- a/doc/log.txt
+++ b/doc/log.txt
@@ -1,5 +1,6 @@
* 1.7.11, 2008-??-??
+ - Added the Salsa20 stream cipher
- Optimized Montgomery reduction, Karatsuba squaring
- Inline several BigInt functions
- Add useful information to the generated build.h
diff --git a/include/salsa20.h b/include/salsa20.h
new file mode 100644
index 000000000..e107d8569
--- /dev/null
+++ b/include/salsa20.h
@@ -0,0 +1,39 @@
+/*************************************************
+* Salsa20 Header File *
+* (C) 1999-2008 Jack Lloyd *
+*************************************************/
+
+#ifndef BOTAN_SALSA20_H__
+#define BOTAN_SALSA20_H__
+
+#include <botan/base.h>
+
+namespace Botan {
+
+/*************************************************
+* Salsa20 *
+*************************************************/
+class BOTAN_DLL Salsa20 : public StreamCipher
+ {
+ public:
+ void clear() throw();
+ std::string name() const;
+ StreamCipher* clone() const { return new Salsa20; }
+
+ void resync(const byte[], u32bit);
+
+ Salsa20();
+ ~Salsa20() { clear(); }
+ private:
+ void cipher(const byte[], byte[], u32bit);
+ void key(const byte[], u32bit);
+
+ SecureBuffer<u32bit, 16> state;
+
+ SecureBuffer<byte, 64> buffer;
+ u32bit position;
+ };
+
+}
+
+#endif
diff --git a/src/def_alg.cpp b/src/def_alg.cpp
index 77f4b188d..10c8e49d9 100644
--- a/src/def_alg.cpp
+++ b/src/def_alg.cpp
@@ -33,6 +33,7 @@
#include <botan/xtea.h>
#include <botan/arc4.h>
+#include <botan/salsa20.h>
#include <botan/turing.h>
#include <botan/wid_wake.h>
@@ -167,6 +168,7 @@ Default_Engine::find_stream_cipher(const std::string& algo_spec) const
HANDLE_TYPE_ONE_U32BIT("ARC4", ARC4, 0);
HANDLE_TYPE_ONE_U32BIT("RC4_drop", ARC4, 768);
+ HANDLE_TYPE_NO_ARGS("Salsa20", Salsa20);
HANDLE_TYPE_NO_ARGS("Turing", Turing);
HANDLE_TYPE_NO_ARGS("WiderWake4+1-BE", WiderWake_41_BE);
diff --git a/src/salsa20.cpp b/src/salsa20.cpp
new file mode 100644
index 000000000..710e043f7
--- /dev/null
+++ b/src/salsa20.cpp
@@ -0,0 +1,180 @@
+/*************************************************
+* Salsa20 Source File *
+* (C) 1999-2008 Jack Lloyd *
+*************************************************/
+
+#include <botan/salsa20.h>
+#include <botan/mem_ops.h>
+#include <botan/xor_buf.h>
+#include <botan/loadstor.h>
+#include <botan/parsing.h>
+
+namespace Botan {
+
+namespace {
+
+/*************************************************
+* Generate Salsa20 cipher stream *
+*************************************************/
+void salsa20(byte output[64], u32bit input[16])
+ {
+ u32bit x[16];
+
+ copy_mem(x, input, 16);
+
+ for(u32bit i = 0; i != 10; ++i)
+ {
+ x[ 4] ^= rotate_left(x[ 0] + x[12], 7);
+ x[ 8] ^= rotate_left(x[ 4] + x[ 0], 9);
+ x[12] ^= rotate_left(x[ 8] + x[ 4], 13);
+ x[ 0] ^= rotate_left(x[12] + x[ 8], 18);
+ x[ 9] ^= rotate_left(x[ 5] + x[ 1], 7);
+ x[13] ^= rotate_left(x[ 9] + x[ 5], 9);
+ x[ 1] ^= rotate_left(x[13] + x[ 9], 13);
+ x[ 5] ^= rotate_left(x[ 1] + x[13], 18);
+ x[14] ^= rotate_left(x[10] + x[ 6], 7);
+ x[ 2] ^= rotate_left(x[14] + x[10], 9);
+ x[ 6] ^= rotate_left(x[ 2] + x[14], 13);
+ x[10] ^= rotate_left(x[ 6] + x[ 2], 18);
+ x[ 3] ^= rotate_left(x[15] + x[11], 7);
+ x[ 7] ^= rotate_left(x[ 3] + x[15], 9);
+ x[11] ^= rotate_left(x[ 7] + x[ 3], 13);
+ x[15] ^= rotate_left(x[11] + x[ 7], 18);
+ x[ 1] ^= rotate_left(x[ 0] + x[ 3], 7);
+ x[ 2] ^= rotate_left(x[ 1] + x[ 0], 9);
+ x[ 3] ^= rotate_left(x[ 2] + x[ 1], 13);
+ x[ 0] ^= rotate_left(x[ 3] + x[ 2], 18);
+ x[ 6] ^= rotate_left(x[ 5] + x[ 4], 7);
+ x[ 7] ^= rotate_left(x[ 6] + x[ 5], 9);
+ x[ 4] ^= rotate_left(x[ 7] + x[ 6], 13);
+ x[ 5] ^= rotate_left(x[ 4] + x[ 7], 18);
+ x[11] ^= rotate_left(x[10] + x[ 9], 7);
+ x[ 8] ^= rotate_left(x[11] + x[10], 9);
+ x[ 9] ^= rotate_left(x[ 8] + x[11], 13);
+ x[10] ^= rotate_left(x[ 9] + x[ 8], 18);
+ x[12] ^= rotate_left(x[15] + x[14], 7);
+ x[13] ^= rotate_left(x[12] + x[15], 9);
+ x[14] ^= rotate_left(x[13] + x[12], 13);
+ x[15] ^= rotate_left(x[14] + x[13], 18);
+ }
+
+ for(u32bit i = 0; i != 16; ++i)
+ store_le(x[i] + input[i], output + 4 * i);
+
+ ++input[8];
+ if(!input[8])
+ ++input[9];
+ }
+
+}
+
+/*************************************************
+* Combine cipher stream with message *
+*************************************************/
+void Salsa20::cipher(const byte in[], byte out[], u32bit length)
+ {
+ while(length >= buffer.size() - position)
+ {
+ xor_buf(out, in, buffer.begin() + position, buffer.size() - position);
+ length -= (buffer.size() - position);
+ in += (buffer.size() - position);
+ out += (buffer.size() - position);
+ salsa20(buffer.begin(), state);
+ position = 0;
+ }
+
+ xor_buf(out, in, buffer.begin() + position, length);
+
+ position += length;
+ }
+
+/*************************************************
+* Salsa20 Key Schedule *
+*************************************************/
+void Salsa20::key(const byte key[], u32bit length)
+ {
+ clear();
+
+ if(length == 16)
+ {
+ const u32bit TAU[] = { 0x61707865, 0x3120646e, 0x79622d36, 0x6b206574 };
+
+ state[0] = TAU[0];
+ state[1] = load_le<u32bit>(key, 0);
+ state[2] = load_le<u32bit>(key, 1);
+ state[3] = load_le<u32bit>(key, 2);
+ state[4] = load_le<u32bit>(key, 3);
+ state[5] = TAU[1];
+ state[10] = TAU[2];
+ state[11] = load_le<u32bit>(key, 0);
+ state[12] = load_le<u32bit>(key, 1);
+ state[13] = load_le<u32bit>(key, 2);
+ state[14] = load_le<u32bit>(key, 3);
+ state[15] = TAU[3];
+ }
+ else if(length == 32)
+ {
+ const u32bit SIGMA[] = { 0x61707865, 0x3320646e, 0x79622d32, 0x6b206574 };
+
+ state[0] = SIGMA[0];
+ state[1] = load_le<u32bit>(key, 0);
+ state[2] = load_le<u32bit>(key, 1);
+ state[3] = load_le<u32bit>(key, 2);
+ state[4] = load_le<u32bit>(key, 3);
+ state[5] = SIGMA[1];
+ state[10] = SIGMA[2];
+ state[11] = load_le<u32bit>(key, 4);
+ state[12] = load_le<u32bit>(key, 5);
+ state[13] = load_le<u32bit>(key, 6);
+ state[14] = load_le<u32bit>(key, 7);
+ state[15] = SIGMA[3];
+ }
+
+ const byte ZERO[8] = { 0 };
+ resync(ZERO, sizeof(ZERO));
+ }
+
+/*************************************************
+* Return the name of this type *
+*************************************************/
+void Salsa20::resync(const byte iv[], u32bit length)
+ {
+ if(length != IV_LENGTH)
+ throw Invalid_IV_Length(name(), length);
+
+ state[6] = load_le<u32bit>(iv, 0);
+ state[7] = load_le<u32bit>(iv, 1);
+ state[8] = 0;
+ state[9] = 0;
+
+ salsa20(buffer.begin(), state);
+ position = 0;
+ }
+
+/*************************************************
+* Return the name of this type *
+*************************************************/
+std::string Salsa20::name() const
+ {
+ return "Salsa20";
+ }
+
+/*************************************************
+* Clear memory of sensitive data *
+*************************************************/
+void Salsa20::clear() throw()
+ {
+ state.clear();
+ buffer.clear();
+ position = 0;
+ }
+
+/*************************************************
+* Salsa20 Constructor *
+*************************************************/
+Salsa20::Salsa20() : StreamCipher(16, 32, 16, 8)
+ {
+ clear();
+ }
+
+}