From 0cb6bcfedef6ffa797801acd7cb945feb2d05d50 Mon Sep 17 00:00:00 2001 From: lloyd Date: Thu, 14 Oct 2010 18:04:35 +0000 Subject: In all cases where the block size of the cipher is fixed, the key parameters are as well. So make them template paramters. The sole exception was AES, because you could either initialize AES with a fixed key length, in which case it would only be that specific key length, or not, in which case it would support any valid AES key size. This is removed in this checkin; you have to specifically ask for AES-128, AES-192, or AES-256, depending on which one you want. This is probably actually a good thing, because every implementation other than the base one (SSSE3, AES-NI, OpenSSL) did not support "AES", only the versions with specific fixed key sizes. So forcing the user to ask for the one they want ensures they get the ones that are faster and/or safer. --- checks/validate.dat | 294 ++++++++++++---------------------------------------- 1 file changed, 68 insertions(+), 226 deletions(-) (limited to 'checks') diff --git a/checks/validate.dat b/checks/validate.dat index 3da482cf9..9e0aba063 100644 --- a/checks/validate.dat +++ b/checks/validate.dat @@ -8,119 +8,10 @@ # Block cipher format is plaintext:ciphertext:key -[AES] -# From FIPS 197 +[AES-128] 00112233445566778899AABBCCDDEEFF:69C4E0D86A7B0430D8CDB78070B4C55A:\ 000102030405060708090A0B0C0D0E0F -00112233445566778899AABBCCDDEEFF:DDA97CA4864CDFE06EAF70A0EC0D7191:\ -000102030405060708090A0B0C0D0E0F1011121314151617 -00112233445566778899AABBCCDDEEFF:8EA2B7CA516745BFEAFC49904B496089:\ -000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F - -506812A45F08C889B97F5980038B8359:D8F532538289EF7D06B506A4FD5BE9C9:\ -00010203050607080A0B0C0D0F101112 -5C6D71CA30DE8B8B00549984D2EC7D4B:59AB30F4D4EE6E4FF9907EF65B1FB68C:\ -14151617191A1B1C1E1F202123242526 -53F3F4C64F8616E4E7C56199F48F21F6:BF1ED2FCB2AF3FD41443B56D85025CB1:\ -28292A2B2D2E2F30323334353738393A -A1EB65A3487165FB0F1C27FF9959F703:7316632D5C32233EDCB0780560EAE8B2:\ -3C3D3E3F41424344464748494B4C4D4E -3553ECF0B1739558B08E350A98A39BFA:408C073E3E2538072B72625E68B8364B:\ -50515253555657585A5B5C5D5F606162 -67429969490B9711AE2B01DC497AFDE8:E1F94DFA776597BEACA262F2F6366FEA:\ -64656667696A6B6C6E6F707173747576 -93385C1F2AEC8BED192F5A8E161DD508:F29E986C6A1C27D7B29FFD7EE92B75F1:\ -78797A7B7D7E7F80828384858788898A -3E23B3BC065BCC152407E23896D77783:1959338344E945670678A5D432C90B93:\ -54555657595A5B5C5E5F606163646566 -79F0FBA002BE1744670E7E99290D8F52:E49BDDD2369B83EE66E6C75A1161B394:\ -68696A6B6D6E6F70727374757778797A -DA23FE9D5BD63E1D72E3DAFBE21A6C2A:D3388F19057FF704B70784164A74867D:\ -7C7D7E7F81828384868788898B8C8D8E -E3F5698BA90B6A022EFD7DB2C7E6C823:23AA03E2D5E4CD24F3217E596480D1E1:\ -A4A5A6A7A9AAABACAEAFB0B1B3B4B5B6 -BDC2691D4F1B73D2700679C3BCBF9C6E:C84113D68B666AB2A50A8BDB222E91B9:\ -E0E1E2E3E5E6E7E8EAEBECEDEFF0F1F2 -BA74E02093217EE1BA1B42BD5624349A:AC02403981CD4340B507963DB65CB7B6:\ -08090A0B0D0E0F10121314151718191A -B5C593B5851C57FBF8B3F57715E8F680:8D1299236223359474011F6BF5088414:\ -6C6D6E6F71727374767778797B7C7D7E - -FEC1C04F529BBD17D8CECFCC4718B17F:62564C738F3EFE186E1A127A0C4D3C61:\ -4A4B4C4D4F50515254555657595A5B5C5E5F606163646566 -32DF99B431ED5DC5ACF8CAF6DC6CE475:07805AA043986EB23693E23BEF8F3438:\ -68696A6B6D6E6F70727374757778797A7C7D7E7F81828384 -7FDC2B746F3F665296943B83710D1F82:DF0B4931038BADE848DEE3B4B85AA44B:\ -868788898B8C8D8E90919293959697989A9B9C9D9FA0A1A2 -8FBA1510A3C5B87E2EAA3F7A91455CA2:592D5FDED76582E4143C65099309477C:\ -A4A5A6A7A9AAABACAEAFB0B1B3B4B5B6B8B9BABBBDBEBFC0 -2C9B468B1C2EED92578D41B0716B223B:C9B8D6545580D3DFBCDD09B954ED4E92:\ -C2C3C4C5C7C8C9CACCCDCECFD1D2D3D4D6D7D8D9DBDCDDDE -0A2BBF0EFC6BC0034F8A03433FCA1B1A:5DCCD5D6EB7C1B42ACB008201DF707A0:\ -E0E1E2E3E5E6E7E8EAEBECEDEFF0F1F2F4F5F6F7F9FAFBFC -25260E1F31F4104D387222E70632504B:A2A91682FFEB6ED1D34340946829E6F9:\ -FEFE01010304050608090A0B0D0E0F10121314151718191A -C527D25A49F08A5228D338642AE65137:E45D185B797000348D9267960A68435D:\ -1C1D1E1F21222324262728292B2C2D2E3031323335363738 -3B49FC081432F5890D0E3D87E884A69E:45E060DAE5901CDA8089E10D4F4C246B:\ -3A3B3C3D3F40414244454647494A4B4C4E4F505153545556 -D173F9ED1E57597E166931DF2754A083:F6951AFACC0079A369C71FDCFF45DF50:\ -58595A5B5D5E5F60626364656768696A6C6D6E6F71727374 -8C2B7CAFA5AFE7F13562DAEAE1ADEDE0:9E95E00F351D5B3AC3D0E22E626DDAD6:\ -767778797B7C7D7E80818283858687888A8B8C8D8F909192 -AAF4EC8C1A815AEB826CAB741339532C:9CB566FF26D92DAD083B51FDC18C173C:\ -94959697999A9B9C9E9FA0A1A3A4A5A6A8A9AAABADAEAFB0 -40BE8C5D9108E663F38F1A2395279ECF:C9C82766176A9B228EB9A974A010B4FB:\ -D0D1D2D3D5D6D7D8DADBDCDDDFE0E1E2E4E5E6E7E9EAEBEC -0C8AD9BC32D43E04716753AA4CFBE351:D8E26AA02945881D5137F1C1E1386E88:\ -2A2B2C2D2F30313234353637393A3B3C3E3F404143444546 -1407B1D5F87D63357C8DC7EBBAEBBFEE:C0E024CCD68FF5FFA4D139C355A77C55:\ -48494A4B4D4E4F50525354555758595A5C5D5E5F61626364 -E51AA0B135DBA566939C3B6359A980C5:8CD9423DFC459E547155C5D1D522E540:\ -E0E1E2E3E5E6E7E8EAEBECEDEFF0F1F2F4F5F6F7F9FAFBFCFEFE010103040506 -069A007FC76A459F98BAF917FEDF9521:080E9517EB1677719ACF728086040AE3:\ -08090A0B0D0E0F10121314151718191A1C1D1E1F21222324262728292B2C2D2E -726165C1723FBCF6C026D7D00B091027:7C1700211A3991FC0ECDED0AB3E576B0:\ -30313233353637383A3B3C3D3F40414244454647494A4B4C4E4F505153545556 -D7C544DE91D55CFCDE1F84CA382200CE:DABCBCC855839251DB51E224FBE87435:\ -58595A5B5D5E5F60626364656768696A6C6D6E6F71727374767778797B7C7D7E -FED3C9A161B9B5B2BD611B41DC9DA357:68D56FAD0406947A4DD27A7448C10F1D:\ -80818283858687888A8B8C8D8F90919294959697999A9B9C9E9FA0A1A3A4A5A6 -4F634CDC6551043409F30B635832CF82:DA9A11479844D1FFEE24BBF3719A9925:\ -A8A9AAABADAEAFB0B2B3B4B5B7B8B9BABCBDBEBFC1C2C3C4C6C7C8C9CBCCCDCE -109CE98DB0DFB36734D9F3394711B4E6:5E4BA572F8D23E738DA9B05BA24B8D81:\ -D0D1D2D3D5D6D7D8DADBDCDDDFE0E1E2E4E5E6E7E9EAEBECEEEFF0F1F3F4F5F6 -4EA6DFABA2D8A02FFDFFA89835987242:A115A2065D667E3F0B883837A6E903F8:\ -70717273757677787A7B7C7D7F80818284858687898A8B8C8E8F909193949596 -5AE094F54AF58E6E3CDBF976DAC6D9EF:3E9E90DC33EAC2437D86AD30B137E66E:\ -98999A9B9D9E9FA0A2A3A4A5A7A8A9AAACADAEAFB1B2B3B4B6B7B8B9BBBCBDBE -764D8E8E0F29926DBE5122E66354FDBE:01CE82D8FBCDAE824CB3C48E495C3692:\ -C0C1C2C3C5C6C7C8CACBCCCDCFD0D1D2D4D5D6D7D9DADBDCDEDFE0E1E3E4E5E6 -3F0418F888CDF29A982BF6B75410D6A9:0C9CFF163CE936FAAF083CFD3DEA3117:\ -E8E9EAEBEDEEEFF0F2F3F4F5F7F8F9FAFCFDFEFF01020304060708090B0C0D0E -E4A3E7CB12CDD56AA4A75197A9530220:5131BA9BD48F2BBA85560680DF504B52:\ -10111213151617181A1B1C1D1F20212224252627292A2B2C2E2F303133343536 -211677684AAC1EC1A160F44C4EBF3F26:9DC503BBF09823AEC8A977A5AD26CCB2:\ -38393A3B3D3E3F40424344454748494A4C4D4E4F51525354565758595B5C5D5E -D21E439FF749AC8F18D6D4B105E03895:9A6DB0C0862E506A9E397225884041D7:\ -60616263656667686A6B6C6D6F70717274757677797A7B7C7E7F808183848586 -D9F6FF44646C4725BD4C0103FF5552A7:430BF9570804185E1AB6365FC6A6860C:\ -88898A8B8D8E8F90929394959798999A9C9D9E9FA1A2A3A4A6A7A8A9ABACADAE -0B1256C2A00B976250CFC5B0C37ED382:3525EBC02F4886E6A5A3762813E8CE8A:\ -B0B1B2B3B5B6B7B8BABBBCBDBFC0C1C2C4C5C6C7C9CACBCCCECFD0D1D3D4D5D6 -B056447FFC6DC4523A36CC2E972A3A79:07FA265C763779CCE224C7BAD671027B:\ -D8D9DADBDDDEDFE0E2E3E4E5E7E8E9EAECEDEEEFF1F2F3F4F6F7F8F9FBFCFDFE -5E25CA78F0DE55802524D38DA3FE4456:E8B72B4E8BE243438C9FFF1F0E205872:\ -00010203050607080A0B0C0D0F10111214151617191A1B1C1E1F202123242526 -A5BCF4728FA5EAAD8567C0DC24675F83:109D4F999A0E11ACE1F05E6B22CBCB50:\ -28292A2B2D2E2F30323334353738393A3C3D3E3F41424344464748494B4C4D4E -814E59F97ED84646B78B2CA022E9CA43:45A5E8D4C3ED58403FF08D68A0CC4029:\ -50515253555657585A5B5C5D5F60616264656667696A6B6C6E6F707173747576 -15478BEEC58F4775C7A7F5D4395514D7:196865964DB3D417B6BD4D586BCB7634:\ -78797A7B7D7E7F80828384858788898A8C8D8E8F91929394969798999B9C9D9E - -[AES-128] 506812A45F08C889B97F5980038B8359:D8F532538289EF7D06B506A4FD5BE9C9:\ 00010203050607080A0B0C0D0F101112 @@ -1274,6 +1165,9 @@ A0A1A2A3A5A6A7A8AAABACADAFB0B1B2 00000000000000000000000000000000 [AES-192] +00112233445566778899AABBCCDDEEFF:DDA97CA4864CDFE06EAF70A0EC0D7191:\ +000102030405060708090A0B0C0D0E0F1011121314151617 + 2D33EEF2C0430A8A9EBF45E809C40BB6:DFF4945E0336DF4C1C56BC700EFF837F:\ 00010203050607080A0B0C0D0F10111214151617191A1B1C @@ -2619,6 +2513,9 @@ D3D2DDDCAAADACAF9C9D9E9FE8EBEAE5:9ADB3D4CCA559BB98C3E2ED73DBF1154:\ 000000000000000000000000000000000000000000000000 [AES-256] +00112233445566778899AABBCCDDEEFF:8EA2B7CA516745BFEAFC49904B496089:\ +000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F + 834EADFCCAC7E1B30664B1ABA44815AB:1946DABF6A03A2A2C3D0B05080AED6FC:\ 00010203050607080A0B0C0D0F10111214151617191A1B1C1E1F202123242526 @@ -25233,13 +25130,14 @@ F58C4C04D6E5F1BA779EABFB5F7BFBD69CFC4E967EDB808D679F777BC6702C7D\ 603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:\ 000102030405060708090A0B0C0D0E0F -[AES/CFB] +[AES-128/CFB] 6BC1BEE22E409F96E93D7E117393172AAE2D8A571E03AC9C9EB76FAC45AF8E51\ 30C81C46A35CE411E5FBC1191A0A52EFF69F2445DF4F9B17AD2B417BE66C3710:\ 3B3FD92EB72DAD20333449F8E83CFB4AC8A64537A0B3A93FCDE3CDAD9F1CE58B\ 26751F67A3CBB140B1808CF187A4F4DFC04B05357C5D1C0EEAC4C66F9FF7F2E6:\ 2B7E151628AED2A6ABF7158809CF4F3C:000102030405060708090A0B0C0D0E0F +[AES-192/CFB] 6BC1BEE22E409F96E93D7E117393172AAE2D8A571E03AC9C9EB76FAC45AF8E51\ 30C81C46A35CE411E5FBC1191A0A52EFF69F2445DF4F9B17AD2B417BE66C3710:\ CDC80D6FDDF18CAB34C25909C99A417467CE7F7F81173621961A2B70171D3D7A\ @@ -25247,6 +25145,7 @@ CDC80D6FDDF18CAB34C25909C99A417467CE7F7F81173621961A2B70171D3D7A\ 8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:\ 000102030405060708090A0B0C0D0E0F +[AES-256/CFB] 6BC1BEE22E409F96E93D7E117393172AAE2D8A571E03AC9C9EB76FAC45AF8E51\ 30C81C46A35CE411E5FBC1191A0A52EFF69F2445DF4F9B17AD2B417BE66C3710:\ DC7E84BFDA79164B7ECD8486985D386039FFED143B28B1C832113C6331E5407B\ @@ -25254,13 +25153,14 @@ DF10132415E54B92A13ED0A8267AE2F975A385741AB9CEF82031623D55B1E471:\ 603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:\ 000102030405060708090A0B0C0D0E0F -[AES/OFB] +[AES-128/OFB] 6BC1BEE22E409F96E93D7E117393172AAE2D8A571E03AC9C9EB76FAC45AF8E51\ 30C81C46A35CE411E5FBC1191A0A52EFF69F2445DF4F9B17AD2B417BE66C3710:\ 3B3FD92EB72DAD20333449F8E83CFB4A7789508D16918F03F53C52DAC54ED825\ 9740051E9C5FECF64344F7A82260EDCC304C6528F659C77866A510D9C1D6AE5E:\ 2B7E151628AED2A6ABF7158809CF4F3C:000102030405060708090A0B0C0D0E0F +[AES-192/OFB] 6BC1BEE22E409F96E93D7E117393172AAE2D8A571E03AC9C9EB76FAC45AF8E51\ 30C81C46A35CE411E5FBC1191A0A52EFF69F2445DF4F9B17AD2B417BE66C3710:\ CDC80D6FDDF18CAB34C25909C99A4174FCC28B8D4C63837C09E81700C1100401\ @@ -25268,6 +25168,7 @@ CDC80D6FDDF18CAB34C25909C99A4174FCC28B8D4C63837C09E81700C1100401\ 8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:\ 000102030405060708090A0B0C0D0E0F +[AES-256/OFB] 6BC1BEE22E409F96E93D7E117393172AAE2D8A571E03AC9C9EB76FAC45AF8E51\ 30C81C46A35CE411E5FBC1191A0A52EFF69F2445DF4F9B17AD2B417BE66C3710:\ DC7E84BFDA79164B7ECD8486985D38604FEBDC6740D20B3AC88F6AD82A4FB08D\ @@ -59660,10 +59561,11 @@ D1FADD67122FF916A6DE358A5D4BE30645761273D97CF9A3AA:\ 4761EF4FF7D28587CC62F4FBC8BF75129035D173686AD394A5DC:\ BF0557B787C01A589BBD6EBB83F3A330:69ECFA9B0A41FDF990F4CC167B987870 -[CMAC(AES)] -# First twelve vectors come from a paper, they were generated by Eisuke Kuroda -# and Yuki Ohira at Ibaraki University. The rest were generated by me for the -# EAX specification. +# First 4 vectors for each key size come from a paper, they were +# generated by Eisuke Kuroda and Yuki Ohira at Ibaraki University. The +# rest were generated by me for the EAX specification. + +[CMAC(AES-128)] :BB1D6929E95937287FA37D129B756746:2B7E151628AED2A6ABF7158809CF4F3C 6BC1BEE22E409F96E93D7E117393172A:070A16B46B4D4144F79BDD9DD04A287C:\ @@ -59677,99 +59579,7 @@ DFA66747DE9AE63030CA32611497C827:2B7E151628AED2A6ABF7158809CF4F3C 30C81C46A35CE411E5FBC1191A0A52EFF69F2445DF4F9B17AD2B417BE66C3710:\ 51F0BEBF7E3B9D92FC49741779363CFE:2B7E151628AED2A6ABF7158809CF4F3C -:D17DDF46ADAACDE531CAC483DE7A9367:\ -8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B - -6BC1BEE22E409F96E93D7E117393172A:9E99A7BF31E710900662F65E617C5184:\ -8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B - -6BC1BEE22E409F96E93D7E117393172AAE2D8A571E03AC9C9EB76FAC45AF8E51\ -30C81C46A35CE411:8A1DE5BE2EB31AAD089A82E6EE908B0E:\ -8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B - -6BC1BEE22E409F96E93D7E117393172AAE2D8A571E03AC9C9EB76FAC45AF8E51\ -30C81C46A35CE411E5FBC1191A0A52EFF69F2445DF4F9B17AD2B417BE66C3710:\ -A1D5DF0EED790F794D77589659F39A11:\ -8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B - -:028962F61B7BF89EFC6B551F4667D983:\ -603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4 - -6BC1BEE22E409F96E93D7E117393172A:28A7023F452E8F82BD4BF28D8C37C35C:\ -603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4 - -6BC1BEE22E409F96E93D7E117393172AAE2D8A571E03AC9C9EB76FAC45AF8E51\ -30C81C46A35CE411:AAF3D8F1DE5640C232F5B169B9C911E6:\ -603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4 - -6BC1BEE22E409F96E93D7E117393172AAE2D8A571E03AC9C9EB76FAC45AF8E51\ -30C81C46A35CE411E5FBC1191A0A52EFF69F2445DF4F9B17AD2B417BE66C3710:\ -E1992190549F6ED5696A2C056C315410:\ -603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4 - # The rest were generated by me and are non-official -:146843CEFEF83BB230862DEE5288012C:FBFC57D01402E2527D11C008C041D51F - -4C:3FD7EC49061ABD552D6FA2685FF77388:556813A5E6DC9A926FB235991CA1A014 - -258B:80BC1B9501710D77C01451732517F272:6195FB30EABDBEEF1C5CE5E2CD533893 - -D1EF53:B708B2BDDEAB33BF33AAE5B47C8ED59B:7BB3D07953D5D76252B2C73642F1C829 - -84878883:D8E24AF6410BE6D26FE65E05DB95C1A0:18D366221A8BDAD5DD6483A388163EF5 - -721CFD4147:8F8ECB42EFE42F708D0EF849B4180627:2E0C3C02080D6B4C6A01FABC78FCC2D2 - -991225136F00:2B73C3006233572AD1AF399539723018:A157A82608FD6228D0F08D785B1AAB24 - -350183544EB437:D25C063089641481A482D02BAE21DEB0:\ -DA042063FE9E16CBA7EA06345E479DB5 - -424ADA19952F4588:2625B8C34C00C1F1BB066BBCCBFF9BCA:\ -8DC221212A006704B5DB69FDFE17FCF9 - -8596E11E94EA19CC3A:86A9ACE5C41B661924C8D4CB02335E0F:\ -B7F6065E06187815BCEA2B8260C4968A - -7C82BF2335D8A2E21C7A:836A7DC8C531AB6CFA8022132D88B4FD:\ -43929194A29B904776D80925BCDDA258 - -70202B9787517E4E1135C3:2C05A0B0ED6D8425347C07AC28CCE816:\ -F587DAD7CEB57FD9D205B1FBA1C7CD48 - -AFB34746EDC8281368ADB521:01454B9D291553F7B2832A88F0D4F4A9:\ -19B140930E41923A1381B76133A28067 - -C35C54CA3855817DC78E9E3187:A0FA07F0E142234072A12F0512197ECD:\ -C9D0F494B96DE372B33D8507EA2AA2B3 - -A601BF53B49B3CBED0CFC259C96D:0BA5CC599A16EC3965A5E2FC53AE2016:\ -2767C4F69FF145F1226863771AC86B90 - -3581A17D977891E5EBA90C547397A1:6A8EB76EFA42243E15A7CE5913298331:\ -4D1F72F544CE74099E135956FAF88FF8 - -1E28DBAA317AFA919A0F97FE25B3C8A1:1DB868DE86D1E6ED593060147B78E08E:\ -C97C0A1C1E2F7327331FBF3337846251 - -01702E80410F607CE8A85041E0419FE88A:666315D7F0A1D25BD69E7C11E0220258:\ -5E0848CEB6E1469C33B9C397C6212608 - -DFC8914D867E651B30F5910397E6DEB9F140:137C3A9C80A9FBAE82B1B53586EED7DC:\ -DB210A614E72085F8681A82936893EE6 - -1C8EF80E2D646CE28406C4312000F18E95D82A:B964FEC670CD39AAF35D2DC10D3071EE:\ -BF6E95E79CFF45B78B60B523682A67F8 - -3DC82D1710367C124696CAA6760F1C01B626E065:7F6E14CF8020207D74CB786FCE9F10C0:\ -768AA70ADFAF6738DC8FF2A85C34B6AE - -91D45A498BB9A093F6F678C495A7EF12C881A782E0:0BCFCBF5C1011EED7453CAEBEFEDDFC3:\ -2B7D219195BA5F620E18C9628F3611EC - -91B47BA5E78F1D059BE584C388D76CB7F55079BAC1EC:36790C9BA09C76E402F22D4FE9127C9C:\ -A92F1EE4C1C4717339FA7A4305851B5D - 3B2E8F8C7838FDE9610CE6FCC10F854AEAAE3A2184832A:\ 6B642B7D118A78A160B7EA0E11789A99:8989DA29F037D54809D39E0F21BAD66B @@ -59821,9 +59631,59 @@ A517CF03FBC41E32CE9A4385A141074CC3EECDFE930E607DA8B1C0C07464B61A\ 43AD:DE5E5B64B403E3772CCB13E175C734FE:\ EDCBA48465D6B8BDBF274658EF587F72 +85380139C424704AC24497634E9CBFCEE21E0F99CF3AC8F9C6AE2D6FDD091363\ +41149C05380C4FFA50E65D9E831D6C653B7BFE0BB5C6047C7431EB513AFEB47B\ +1250804B5DD045ADB6A34C39C0B89EFB349C06E9620A65D63C5028764EDCF261\ +2D72AC8A42F137F9948332543CD150706D5659D061BFA69D0FCE135EAB05BFD8\ +786B62BA5C99B3F11DE64559B795C924EC22F44DE19BEAF169FD4F14030EEC7B\ +794E35D5E8E9C6:\ +3015A6D16CDDF7E1E8C28521F4064A28:FB565C5DB38C2237869ED34CA10A055C + +7B326530160FE8CFFB68704022DE43BBB54FCD83BF4C554774BAC625441C1DBF\ +4F82F06591D8348C40A4CD6282101D3860EBBB1F371166ABCB2DD00F49EDCF98\ +6FBFFD0197328DD7D65A39596B5791CB424CEA795D5024287DF438C7E1075F50\ +C65D515D8FDF3465396DBEA4C44F6F069C597FF9AAA32227:\ +39F2933F156616549749CCAEBF682322:\ +0398D70C12CE6F7ED28828647FB18A56 + +[CMAC(AES-192)] +:D17DDF46ADAACDE531CAC483DE7A9367:\ +8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B + +6BC1BEE22E409F96E93D7E117393172A:9E99A7BF31E710900662F65E617C5184:\ +8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B + +6BC1BEE22E409F96E93D7E117393172AAE2D8A571E03AC9C9EB76FAC45AF8E51\ +30C81C46A35CE411:8A1DE5BE2EB31AAD089A82E6EE908B0E:\ +8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B + +6BC1BEE22E409F96E93D7E117393172AAE2D8A571E03AC9C9EB76FAC45AF8E51\ +30C81C46A35CE411E5FBC1191A0A52EFF69F2445DF4F9B17AD2B417BE66C3710:\ +A1D5DF0EED790F794D77589659F39A11:\ +8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B + F4FF3C7E2F56F4:E1D41EC244EBC98373457A95685D0EFB:\ 76BF48A88F0F5531C4D1A14846742CE39B8D8827F863ABDA +E2C0FFB463EF4B6EC114322FAFB8:D25D89E8CE9685D975C645FB2A19E50D:\ +970BD2C9C46E9B85E13949E13D39B466A8070F40570D1070 + +[CMAC(AES-256)] +:028962F61B7BF89EFC6B551F4667D983:\ +603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4 + +6BC1BEE22E409F96E93D7E117393172A:28A7023F452E8F82BD4BF28D8C37C35C:\ +603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4 + +6BC1BEE22E409F96E93D7E117393172AAE2D8A571E03AC9C9EB76FAC45AF8E51\ +30C81C46A35CE411:AAF3D8F1DE5640C232F5B169B9C911E6:\ +603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4 + +6BC1BEE22E409F96E93D7E117393172AAE2D8A571E03AC9C9EB76FAC45AF8E51\ +30C81C46A35CE411E5FBC1191A0A52EFF69F2445DF4F9B17AD2B417BE66C3710:\ +E1992190549F6ED5696A2C056C315410:\ +603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4 + B664B2C219D625DC472EC765605E6D5822681C5E9FFD10645B:\ 3FC310BAF6F1A39FA25AE7DEA104EDA9:\ 19449A56180CB52462C37109EA1D329708F7C4FBC43B37E1B2C55E38F5551C0E @@ -59837,24 +59697,6 @@ F0D16D00B5CF601F1A5BE91422A5562C252C5C1DEBDF05B5BC328BF8505DF740 CB1C20084C5DACB3270F118633DB4F33:\ 420D2C372E496D403A9F520158FCCDA6D6BCE14E6EAD2B90918B919E5E8621A0 -E2C0FFB463EF4B6EC114322FAFB8:D25D89E8CE9685D975C645FB2A19E50D:\ -970BD2C9C46E9B85E13949E13D39B466A8070F40570D1070 - -85380139C424704AC24497634E9CBFCEE21E0F99CF3AC8F9C6AE2D6FDD091363\ -41149C05380C4FFA50E65D9E831D6C653B7BFE0BB5C6047C7431EB513AFEB47B\ -1250804B5DD045ADB6A34C39C0B89EFB349C06E9620A65D63C5028764EDCF261\ -2D72AC8A42F137F9948332543CD150706D5659D061BFA69D0FCE135EAB05BFD8\ -786B62BA5C99B3F11DE64559B795C924EC22F44DE19BEAF169FD4F14030EEC7B\ -794E35D5E8E9C6:\ -3015A6D16CDDF7E1E8C28521F4064A28:FB565C5DB38C2237869ED34CA10A055C - -7B326530160FE8CFFB68704022DE43BBB54FCD83BF4C554774BAC625441C1DBF\ -4F82F06591D8348C40A4CD6282101D3860EBBB1F371166ABCB2DD00F49EDCF98\ -6FBFFD0197328DD7D65A39596B5791CB424CEA795D5024287DF438C7E1075F50\ -C65D515D8FDF3465396DBEA4C44F6F069C597FF9AAA32227:\ -39F2933F156616549749CCAEBF682322:\ -0398D70C12CE6F7ED28828647FB18A56 - # SSL3-MAC vectors were posted by Thomas Pornin to sci.crypt [SSL3-MAC(MD5)] 00:A856430AF077AE2C328D9FFE4E56813A:0123456789ABCDEF0123456789ABCDEF -- cgit v1.2.3 From 576c5c901375d1ba5bfdfc5873562c63228abab5 Mon Sep 17 00:00:00 2001 From: lloyd Date: Thu, 28 Oct 2010 19:34:18 +0000 Subject: Simple standalone base64 encoder --- checks/validate.dat | 4 ++ src/codec/base64/base64.cpp | 103 ++++++++++++++++++++++++++++++++++++++++++++ src/codec/base64/base64.h | 55 +++++++++++++++++++++++ src/codec/base64/info.txt | 1 + 4 files changed, 163 insertions(+) create mode 100644 src/codec/base64/base64.cpp create mode 100644 src/codec/base64/base64.h create mode 100644 src/codec/base64/info.txt (limited to 'checks') diff --git a/checks/validate.dat b/checks/validate.dat index 9e0aba063..8745fab46 100644 --- a/checks/validate.dat +++ b/checks/validate.dat @@ -60560,6 +60560,10 @@ A39B76C6EEC8374A11493AD08C246A3E40DFAE5064F4EE3489C273646178:64:1000 4142634452313236:51554A6A524649784D6A593D 241BB300A3989A620659:4A42757A414B4F596D6D494757513D3D +6C6561737572652E:62475668633356795A53343D +6561737572652E:5A57467A64584A6C4C673D3D +61737572652E:59584E31636D5575 + 31323537374343666671333435337836:\ 4D5449314E7A644451325A6D63544D304E544E344E673D3D diff --git a/src/codec/base64/base64.cpp b/src/codec/base64/base64.cpp new file mode 100644 index 000000000..96a686e38 --- /dev/null +++ b/src/codec/base64/base64.cpp @@ -0,0 +1,103 @@ +/* +* Base64 Encoding and Decoding +* (C) 2010 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#include +#include +#include +#include + +#include +#include + +namespace Botan { + +namespace { + +static const byte BIN_TO_BASE64[64] = { + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', + 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', + 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', + 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/' +}; + +void do_base64_encode(char out[4], const byte in[3]) + { + out[0] = BIN_TO_BASE64[((in[0] & 0xFC) >> 2)]; + out[1] = BIN_TO_BASE64[((in[0] & 0x03) << 4) | (in[1] >> 4)]; + out[2] = BIN_TO_BASE64[((in[1] & 0x0F) << 2) | (in[2] >> 6)]; + out[3] = BIN_TO_BASE64[((in[2] & 0x3F) )]; + } + +} + +size_t base64_encode(char out[], + const byte in[], + size_t input_length, + size_t& input_consumed, + bool final_inputs) + { + input_consumed = 0; + + size_t input_remaining = input_length; + size_t output_produced = 0; + + while(input_remaining >= 3) + { + do_base64_encode(out + output_produced, in + input_consumed); + + input_consumed += 3; + output_produced += 4; + input_remaining -= 3; + } + + if(final_inputs && input_remaining) + { + byte remainder[3] = { 0 }; + for(size_t i = 0; i != input_remaining; ++i) + remainder[i] = in[input_consumed + i]; + + do_base64_encode(out + output_produced, remainder); + + size_t empty_bits = 8 * (3 - input_remaining); + size_t index = output_produced + 4 - 1; + while(empty_bits >= 8) + { + out[index--] = '='; + empty_bits -= 6; + } + + input_consumed += input_remaining; + output_produced += 4; + } + + return output_produced; + } + +std::string base64_encode(const byte input[], + size_t input_length) + { + std::string output((round_up(input_length, 3) / 3) * 4, 0); + + size_t consumed = 0; + size_t produced = base64_encode(&output[0], + input, input_length, + consumed, true); + + assert(consumed == input_length); + assert(produced == output.size()); + + return output; + } + +std::string base64_encode(const MemoryRegion& input) + { + return base64_encode(&input[0], input.size()); + } + + +} diff --git a/src/codec/base64/base64.h b/src/codec/base64/base64.h new file mode 100644 index 000000000..551f3daf8 --- /dev/null +++ b/src/codec/base64/base64.h @@ -0,0 +1,55 @@ +/* +* Base64 Encoding and Decoding +* (C) 2010 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_BASE64_CODEC_H__ +#define BOTAN_BASE64_CODEC_H__ + +#include +#include + +namespace Botan { + +/** +* Perform base64 encoding +* @param output an array of at least input_length*4/3 bytes +* @param input is some binary data +* @param input_length length of input in bytes +* @param input_consumed is an output parameter which says how many +* bytes of input were actually consumed. If less than +* input_length, then the range input[consumed:length] +* should be passed in later along with more input. +* @param final_inputs true iff this is the last input, in which case + padding chars will be applied if needed +* @return number of bytes written to output +*/ +size_t BOTAN_DLL base64_encode(char output[], + const byte input[], + size_t input_length, + size_t& input_consumed, + bool final_inputs); + +/** +* Perform base64 encoding +* @param input some input +* @param input_length length of input in bytes +* @param uppercase should output be upper or lower case? +* @return base64adecimal representation of input +*/ +std::string BOTAN_DLL base64_encode(const byte input[], + size_t input_length); + +/** +* Perform base64 encoding +* @param input some input +* @param uppercase should output be upper or lower case? +* @return base64adecimal representation of input +*/ +std::string BOTAN_DLL base64_encode(const MemoryRegion& input); + +} + +#endif diff --git a/src/codec/base64/info.txt b/src/codec/base64/info.txt new file mode 100644 index 000000000..aed5db3b6 --- /dev/null +++ b/src/codec/base64/info.txt @@ -0,0 +1 @@ +define BASE64_CODEC -- cgit v1.2.3