diff options
author | Jack Lloyd <[email protected]> | 2016-07-17 11:42:53 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2016-09-02 05:28:10 -0400 |
commit | 1c0bc3cc6bcbd6318d8ae33d0442ffd24302a044 (patch) | |
tree | da27a2597938f5b5edd1bd43f4d3d0e3c978e8be /src/lib/block | |
parent | cd9f852b46f62087dcf7940303a0fe52a009e6c7 (diff) |
Remove deprecated ciphers MARS, RC2, RC5, RC6, SAFER-SK and TEA
XTEA was also deprecated but has been spared, it does seem to be somewhat
common (eg, included in the Go x/crypto library)
Diffstat (limited to 'src/lib/block')
-rw-r--r-- | src/lib/block/block_cipher.cpp | 60 | ||||
-rw-r--r-- | src/lib/block/mars/info.txt | 1 | ||||
-rw-r--r-- | src/lib/block/mars/mars.cpp | 392 | ||||
-rw-r--r-- | src/lib/block/mars/mars.h | 35 | ||||
-rw-r--r-- | src/lib/block/rc2/info.txt | 1 | ||||
-rw-r--r-- | src/lib/block/rc2/rc2.cpp | 181 | ||||
-rw-r--r-- | src/lib/block/rc2/rc2.h | 42 | ||||
-rw-r--r-- | src/lib/block/rc5/info.txt | 1 | ||||
-rw-r--r-- | src/lib/block/rc5/rc5.cpp | 133 | ||||
-rw-r--r-- | src/lib/block/rc5/rc5.h | 42 | ||||
-rw-r--r-- | src/lib/block/rc6/info.txt | 1 | ||||
-rw-r--r-- | src/lib/block/rc6/rc6.cpp | 143 | ||||
-rw-r--r-- | src/lib/block/rc6/rc6.h | 35 | ||||
-rw-r--r-- | src/lib/block/safer/info.txt | 1 | ||||
-rw-r--r-- | src/lib/block/safer/safer_sk.cpp | 255 | ||||
-rw-r--r-- | src/lib/block/safer/safer_sk.h | 42 | ||||
-rw-r--r-- | src/lib/block/tea/info.txt | 1 | ||||
-rw-r--r-- | src/lib/block/tea/tea.cpp | 78 | ||||
-rw-r--r-- | src/lib/block/tea/tea.h | 34 |
19 files changed, 0 insertions, 1478 deletions
diff --git a/src/lib/block/block_cipher.cpp b/src/lib/block/block_cipher.cpp index c70ba229d..230d9e3a0 100644 --- a/src/lib/block/block_cipher.cpp +++ b/src/lib/block/block_cipher.cpp @@ -63,14 +63,6 @@ #include <botan/lion.h> #endif -#if defined(BOTAN_HAS_LUBY_RACKOFF) - #include <botan/lubyrack.h> -#endif - -#if defined(BOTAN_HAS_MARS) - #include <botan/mars.h> -#endif - #if defined(BOTAN_HAS_MISTY1) #include <botan/misty1.h> #endif @@ -83,22 +75,6 @@ #include <botan/noekeon_simd.h> #endif -#if defined(BOTAN_HAS_RC2) - #include <botan/rc2.h> -#endif - -#if defined(BOTAN_HAS_RC5) - #include <botan/rc5.h> -#endif - -#if defined(BOTAN_HAS_RC6) - #include <botan/rc6.h> -#endif - -#if defined(BOTAN_HAS_SAFER) - #include <botan/safer_sk.h> -#endif - #if defined(BOTAN_HAS_SEED) #include <botan/seed.h> #endif @@ -111,18 +87,6 @@ #include <botan/serp_simd.h> #endif -#if defined(BOTAN_HAS_SKIPJACK) - #include <botan/skipjack.h> -#endif - -#if defined(BOTAN_HAS_SQUARE) - #include <botan/square.h> -#endif - -#if defined(BOTAN_HAS_TEA) - #include <botan/tea.h> -#endif - #if defined(BOTAN_HAS_TWOFISH) #include <botan/twofish.h> #endif @@ -232,10 +196,6 @@ BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(CPUID::has_sse2(), IDEA_SSE2, "IDEA", BOTAN_REGISTER_BLOCK_CIPHER_NOARGS(KASUMI); #endif -#if defined(BOTAN_HAS_MARS) -BOTAN_REGISTER_BLOCK_CIPHER_NOARGS(MARS); -#endif - #if defined(BOTAN_HAS_MISTY1) BOTAN_REGISTER_BLOCK_CIPHER_NOARGS(MISTY1); #endif @@ -249,22 +209,6 @@ BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(CPUID::has_simd_32(), Noekeon_SIMD, "Noeke "simd32", BOTAN_SIMD_ALGORITHM_PRIO); #endif -#if defined(BOTAN_HAS_RC2) -BOTAN_REGISTER_BLOCK_CIPHER_NOARGS(RC2); -#endif - -#if defined(BOTAN_HAS_RC5) -BOTAN_REGISTER_BLOCK_CIPHER_1LEN(RC5, 12); -#endif - -#if defined(BOTAN_HAS_RC6) -BOTAN_REGISTER_BLOCK_CIPHER_NOARGS(RC6); -#endif - -#if defined(BOTAN_HAS_SAFER) -BOTAN_REGISTER_BLOCK_CIPHER_NAMED_1LEN(SAFER_SK, "SAFER-SK", 10); -#endif - #if defined(BOTAN_HAS_SEED) BOTAN_REGISTER_BLOCK_CIPHER_NOARGS(SEED); #endif @@ -278,10 +222,6 @@ BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(CPUID::has_simd_32(), Serpent_SIMD, "Serpe "simd32", BOTAN_SIMD_ALGORITHM_PRIO); #endif -#if defined(BOTAN_HAS_TEA) -BOTAN_REGISTER_BLOCK_CIPHER_NOARGS(TEA); -#endif - #if defined(BOTAN_HAS_TWOFISH) BOTAN_REGISTER_BLOCK_CIPHER_NOARGS(Twofish); #endif diff --git a/src/lib/block/mars/info.txt b/src/lib/block/mars/info.txt deleted file mode 100644 index 0af3d7955..000000000 --- a/src/lib/block/mars/info.txt +++ /dev/null @@ -1 +0,0 @@ -define MARS 20131128 diff --git a/src/lib/block/mars/mars.cpp b/src/lib/block/mars/mars.cpp deleted file mode 100644 index 4605be415..000000000 --- a/src/lib/block/mars/mars.cpp +++ /dev/null @@ -1,392 +0,0 @@ -/* -* MARS -* (C) 1999-2009 Jack Lloyd -* -* Botan is released under the Simplified BSD License (see license.txt) -*/ - -#include <botan/mars.h> -#include <botan/loadstor.h> - -namespace Botan { - -namespace { - -/** -* The MARS sbox -*/ -const u32bit SBOX[512] = { - 0x09D0C479, 0x28C8FFE0, 0x84AA6C39, 0x9DAD7287, 0x7DFF9BE3, 0xD4268361, - 0xC96DA1D4, 0x7974CC93, 0x85D0582E, 0x2A4B5705, 0x1CA16A62, 0xC3BD279D, - 0x0F1F25E5, 0x5160372F, 0xC695C1FB, 0x4D7FF1E4, 0xAE5F6BF4, 0x0D72EE46, - 0xFF23DE8A, 0xB1CF8E83, 0xF14902E2, 0x3E981E42, 0x8BF53EB6, 0x7F4BF8AC, - 0x83631F83, 0x25970205, 0x76AFE784, 0x3A7931D4, 0x4F846450, 0x5C64C3F6, - 0x210A5F18, 0xC6986A26, 0x28F4E826, 0x3A60A81C, 0xD340A664, 0x7EA820C4, - 0x526687C5, 0x7EDDD12B, 0x32A11D1D, 0x9C9EF086, 0x80F6E831, 0xAB6F04AD, - 0x56FB9B53, 0x8B2E095C, 0xB68556AE, 0xD2250B0D, 0x294A7721, 0xE21FB253, - 0xAE136749, 0xE82AAE86, 0x93365104, 0x99404A66, 0x78A784DC, 0xB69BA84B, - 0x04046793, 0x23DB5C1E, 0x46CAE1D6, 0x2FE28134, 0x5A223942, 0x1863CD5B, - 0xC190C6E3, 0x07DFB846, 0x6EB88816, 0x2D0DCC4A, 0xA4CCAE59, 0x3798670D, - 0xCBFA9493, 0x4F481D45, 0xEAFC8CA8, 0xDB1129D6, 0xB0449E20, 0x0F5407FB, - 0x6167D9A8, 0xD1F45763, 0x4DAA96C3, 0x3BEC5958, 0xABABA014, 0xB6CCD201, - 0x38D6279F, 0x02682215, 0x8F376CD5, 0x092C237E, 0xBFC56593, 0x32889D2C, - 0x854B3E95, 0x05BB9B43, 0x7DCD5DCD, 0xA02E926C, 0xFAE527E5, 0x36A1C330, - 0x3412E1AE, 0xF257F462, 0x3C4F1D71, 0x30A2E809, 0x68E5F551, 0x9C61BA44, - 0x5DED0AB8, 0x75CE09C8, 0x9654F93E, 0x698C0CCA, 0x243CB3E4, 0x2B062B97, - 0x0F3B8D9E, 0x00E050DF, 0xFC5D6166, 0xE35F9288, 0xC079550D, 0x0591AEE8, - 0x8E531E74, 0x75FE3578, 0x2F6D829A, 0xF60B21AE, 0x95E8EB8D, 0x6699486B, - 0x901D7D9B, 0xFD6D6E31, 0x1090ACEF, 0xE0670DD8, 0xDAB2E692, 0xCD6D4365, - 0xE5393514, 0x3AF345F0, 0x6241FC4D, 0x460DA3A3, 0x7BCF3729, 0x8BF1D1E0, - 0x14AAC070, 0x1587ED55, 0x3AFD7D3E, 0xD2F29E01, 0x29A9D1F6, 0xEFB10C53, - 0xCF3B870F, 0xB414935C, 0x664465ED, 0x024ACAC7, 0x59A744C1, 0x1D2936A7, - 0xDC580AA6, 0xCF574CA8, 0x040A7A10, 0x6CD81807, 0x8A98BE4C, 0xACCEA063, - 0xC33E92B5, 0xD1E0E03D, 0xB322517E, 0x2092BD13, 0x386B2C4A, 0x52E8DD58, - 0x58656DFB, 0x50820371, 0x41811896, 0xE337EF7E, 0xD39FB119, 0xC97F0DF6, - 0x68FEA01B, 0xA150A6E5, 0x55258962, 0xEB6FF41B, 0xD7C9CD7A, 0xA619CD9E, - 0xBCF09576, 0x2672C073, 0xF003FB3C, 0x4AB7A50B, 0x1484126A, 0x487BA9B1, - 0xA64FC9C6, 0xF6957D49, 0x38B06A75, 0xDD805FCD, 0x63D094CF, 0xF51C999E, - 0x1AA4D343, 0xB8495294, 0xCE9F8E99, 0xBFFCD770, 0xC7C275CC, 0x378453A7, - 0x7B21BE33, 0x397F41BD, 0x4E94D131, 0x92CC1F98, 0x5915EA51, 0x99F861B7, - 0xC9980A88, 0x1D74FD5F, 0xB0A495F8, 0x614DEED0, 0xB5778EEA, 0x5941792D, - 0xFA90C1F8, 0x33F824B4, 0xC4965372, 0x3FF6D550, 0x4CA5FEC0, 0x8630E964, - 0x5B3FBBD6, 0x7DA26A48, 0xB203231A, 0x04297514, 0x2D639306, 0x2EB13149, - 0x16A45272, 0x532459A0, 0x8E5F4872, 0xF966C7D9, 0x07128DC0, 0x0D44DB62, - 0xAFC8D52D, 0x06316131, 0xD838E7CE, 0x1BC41D00, 0x3A2E8C0F, 0xEA83837E, - 0xB984737D, 0x13BA4891, 0xC4F8B949, 0xA6D6ACB3, 0xA215CDCE, 0x8359838B, - 0x6BD1AA31, 0xF579DD52, 0x21B93F93, 0xF5176781, 0x187DFDDE, 0xE94AEB76, - 0x2B38FD54, 0x431DE1DA, 0xAB394825, 0x9AD3048F, 0xDFEA32AA, 0x659473E3, - 0x623F7863, 0xF3346C59, 0xAB3AB685, 0x3346A90B, 0x6B56443E, 0xC6DE01F8, - 0x8D421FC0, 0x9B0ED10C, 0x88F1A1E9, 0x54C1F029, 0x7DEAD57B, 0x8D7BA426, - 0x4CF5178A, 0x551A7CCA, 0x1A9A5F08, 0xFCD651B9, 0x25605182, 0xE11FC6C3, - 0xB6FD9676, 0x337B3027, 0xB7C8EB14, 0x9E5FD030, 0x6B57E354, 0xAD913CF7, - 0x7E16688D, 0x58872A69, 0x2C2FC7DF, 0xE389CCC6, 0x30738DF1, 0x0824A734, - 0xE1797A8B, 0xA4A8D57B, 0x5B5D193B, 0xC8A8309B, 0x73F9A978, 0x73398D32, - 0x0F59573E, 0xE9DF2B03, 0xE8A5B6C8, 0x848D0704, 0x98DF93C2, 0x720A1DC3, - 0x684F259A, 0x943BA848, 0xA6370152, 0x863B5EA3, 0xD17B978B, 0x6D9B58EF, - 0x0A700DD4, 0xA73D36BF, 0x8E6A0829, 0x8695BC14, 0xE35B3447, 0x933AC568, - 0x8894B022, 0x2F511C27, 0xDDFBCC3C, 0x006662B6, 0x117C83FE, 0x4E12B414, - 0xC2BCA766, 0x3A2FEC10, 0xF4562420, 0x55792E2A, 0x46F5D857, 0xCEDA25CE, - 0xC3601D3B, 0x6C00AB46, 0xEFAC9C28, 0xB3C35047, 0x611DFEE3, 0x257C3207, - 0xFDD58482, 0x3B14D84F, 0x23BECB64, 0xA075F3A3, 0x088F8EAD, 0x07ADF158, - 0x7796943C, 0xFACABF3D, 0xC09730CD, 0xF7679969, 0xDA44E9ED, 0x2C854C12, - 0x35935FA3, 0x2F057D9F, 0x690624F8, 0x1CB0BAFD, 0x7B0DBDC6, 0x810F23BB, - 0xFA929A1A, 0x6D969A17, 0x6742979B, 0x74AC7D05, 0x010E65C4, 0x86A3D963, - 0xF907B5A0, 0xD0042BD3, 0x158D7D03, 0x287A8255, 0xBBA8366F, 0x096EDC33, - 0x21916A7B, 0x77B56B86, 0x951622F9, 0xA6C5E650, 0x8CEA17D1, 0xCD8C62BC, - 0xA3D63433, 0x358A68FD, 0x0F9B9D3C, 0xD6AA295B, 0xFE33384A, 0xC000738E, - 0xCD67EB2F, 0xE2EB6DC2, 0x97338B02, 0x06C9F246, 0x419CF1AD, 0x2B83C045, - 0x3723F18A, 0xCB5B3089, 0x160BEAD7, 0x5D494656, 0x35F8A74B, 0x1E4E6C9E, - 0x000399BD, 0x67466880, 0xB4174831, 0xACF423B2, 0xCA815AB3, 0x5A6395E7, - 0x302A67C5, 0x8BDB446B, 0x108F8FA4, 0x10223EDA, 0x92B8B48B, 0x7F38D0EE, - 0xAB2701D4, 0x0262D415, 0xAF224A30, 0xB3D88ABA, 0xF8B2C3AF, 0xDAF7EF70, - 0xCC97D3B7, 0xE9614B6C, 0x2BAEBFF4, 0x70F687CF, 0x386C9156, 0xCE092EE5, - 0x01E87DA6, 0x6CE91E6A, 0xBB7BCC84, 0xC7922C20, 0x9D3B71FD, 0x060E41C6, - 0xD7590F15, 0x4E03BB47, 0x183C198E, 0x63EEB240, 0x2DDBF49A, 0x6D5CBA54, - 0x923750AF, 0xF9E14236, 0x7838162B, 0x59726C72, 0x81B66760, 0xBB2926C1, - 0x48A0CE0D, 0xA6C0496D, 0xAD43507B, 0x718D496A, 0x9DF057AF, 0x44B1BDE6, - 0x054356DC, 0xDE7CED35, 0xD51A138B, 0x62088CC9, 0x35830311, 0xC96EFCA2, - 0x686F86EC, 0x8E77CB68, 0x63E1D6B8, 0xC80F9778, 0x79C491FD, 0x1B4C67F2, - 0x72698D7D, 0x5E368C31, 0xF7D95E2E, 0xA1D3493F, 0xDCD9433E, 0x896F1552, - 0x4BC4CA7A, 0xA6D1BAF4, 0xA5A96DCC, 0x0BEF8B46, 0xA169FDA7, 0x74DF40B7, - 0x4E208804, 0x9A756607, 0x038E87C8, 0x20211E44, 0x8B7AD4BF, 0xC6403F35, - 0x1848E36D, 0x80BDB038, 0x1E62891C, 0x643D2107, 0xBF04D6F8, 0x21092C8C, - 0xF644F389, 0x0778404E, 0x7B78ADB8, 0xA2C52D53, 0x42157ABE, 0xA2253E2E, - 0x7BF3F4AE, 0x80F594F9, 0x953194E7, 0x77EB92ED, 0xB3816930, 0xDA8D9336, - 0xBF447469, 0xF26D9483, 0xEE6FAED5, 0x71371235, 0xDE425F73, 0xB4E59F43, - 0x7DBE2D4E, 0x2D37B185, 0x49DC9A63, 0x98C39D98, 0x1301C9A2, 0x389B1BBF, - 0x0C18588D, 0xA421C1BA, 0x7AA3865C, 0x71E08558, 0x3C5CFCAA, 0x7D239CA4, - 0x0297D9DD, 0xD7DC2830, 0x4B37802B, 0x7428AB54, 0xAEEE0347, 0x4B3FBB85, - 0x692F2F08, 0x134E578E, 0x36D9E0BF, 0xAE8B5FCF, 0xEDB93ECF, 0x2B27248E, - 0x170EB1EF, 0x7DC57FD6, 0x1E760F16, 0xB1136601, 0x864E1B9B, 0xD7EA7319, - 0x3AB871BD, 0xCFA4D76F, 0xE31BD782, 0x0DBEB469, 0xABB96061, 0x5370F85D, - 0xFFB07E37, 0xDA30D0FB, 0xEBC977B6, 0x0B98B40F, 0x3A4D0FE6, 0xDF4FC26B, - 0x159CF22A, 0xC298D6E2, 0x2B78EF6A, 0x61A94AC0, 0xAB561187, 0x14EEA0F0, - 0xDF0D4164, 0x19AF70EE }; - -/* -* MARS Encryption Round -*/ -inline void encrypt_round(u32bit& A, u32bit& B, u32bit& C, u32bit& D, - u32bit EK1, u32bit EK2) - { - const u32bit X = A + EK1; - A = rotate_left(A, 13); - u32bit Y = A * EK2; - u32bit Z = SBOX[X % 512]; - - Y = rotate_left(Y, 5); - Z ^= Y; - C += rotate_left(X, Y % 32); - Y = rotate_left(Y, 5); - Z ^= Y; - D ^= Y; - B += rotate_left(Z, Y % 32); - } - -/* -* MARS Decryption Round -*/ -inline void decrypt_round(u32bit& A, u32bit& B, u32bit& C, u32bit& D, - u32bit EK1, u32bit EK2) - { - u32bit Y = A * EK1; - A = rotate_right(A, 13); - const u32bit X = A + EK2; - u32bit Z = SBOX[X % 512]; - - Y = rotate_left(Y, 5); - Z ^= Y; - C -= rotate_left(X, Y % 32); - Y = rotate_left(Y, 5); - Z ^= Y; - D ^= Y; - B -= rotate_left(Z, Y % 32); - } - -/* -* MARS Forward Mixing Operation -*/ -void forward_mix(u32bit& A, u32bit& B, u32bit& C, u32bit& D) - { - for(size_t j = 0; j != 2; ++j) - { - B ^= SBOX[get_byte(3, A)]; B += SBOX[get_byte(2, A) + 256]; - C += SBOX[get_byte(1, A)]; D ^= SBOX[get_byte(0, A) + 256]; - A = rotate_right(A, 24) + D; - - C ^= SBOX[get_byte(3, B)]; C += SBOX[get_byte(2, B) + 256]; - D += SBOX[get_byte(1, B)]; A ^= SBOX[get_byte(0, B) + 256]; - B = rotate_right(B, 24) + C; - - D ^= SBOX[get_byte(3, C)]; D += SBOX[get_byte(2, C) + 256]; - A += SBOX[get_byte(1, C)]; B ^= SBOX[get_byte(0, C) + 256]; - C = rotate_right(C, 24); - - A ^= SBOX[get_byte(3, D)]; A += SBOX[get_byte(2, D) + 256]; - B += SBOX[get_byte(1, D)]; C ^= SBOX[get_byte(0, D) + 256]; - D = rotate_right(D, 24); - } - } - -/* -* MARS Reverse Mixing Operation -*/ -void reverse_mix(u32bit& A, u32bit& B, u32bit& C, u32bit& D) - { - for(size_t j = 0; j != 2; ++j) - { - B ^= SBOX[get_byte(3, A) + 256]; C -= SBOX[get_byte(0, A)]; - D -= SBOX[get_byte(1, A) + 256]; D ^= SBOX[get_byte(2, A)]; - A = rotate_left(A, 24); - - C ^= SBOX[get_byte(3, B) + 256]; D -= SBOX[get_byte(0, B)]; - A -= SBOX[get_byte(1, B) + 256]; A ^= SBOX[get_byte(2, B)]; - C -= (B = rotate_left(B, 24)); - - D ^= SBOX[get_byte(3, C) + 256]; A -= SBOX[get_byte(0, C)]; - B -= SBOX[get_byte(1, C) + 256]; B ^= SBOX[get_byte(2, C)]; - C = rotate_left(C, 24); - D -= A; - - A ^= SBOX[get_byte(3, D) + 256]; B -= SBOX[get_byte(0, D)]; - C -= SBOX[get_byte(1, D) + 256]; C ^= SBOX[get_byte(2, D)]; - D = rotate_left(D, 24); - } - } - -/* -* Generate a mask for runs of bits -*/ -u32bit gen_mask(u32bit input) - { - u32bit mask = 0; - - for(u32bit j = 2; j != 31; ++j) - { - const u32bit region = (input >> (j-1)) & 0x07; - - if(region == 0x00 || region == 0x07) - { - const u32bit low = (j < 9) ? 0 : (j - 9); - const u32bit high = (j < 23) ? j : 23; - - for(u32bit k = low; k != high; ++k) - { - const u32bit value = (input >> k) & 0x3FF; - - if(value == 0 || value == 0x3FF) - { - mask |= static_cast<u32bit>(1) << j; - break; - } - } - } - } - - return mask; - } - -} - -/* -* MARS Encryption -*/ -void MARS::encrypt_n(const byte in[], byte out[], size_t blocks) const - { - for(size_t i = 0; i != blocks; ++i) - { - u32bit A = load_le<u32bit>(in, 0) + m_EK[0]; - u32bit B = load_le<u32bit>(in, 1) + m_EK[1]; - u32bit C = load_le<u32bit>(in, 2) + m_EK[2]; - u32bit D = load_le<u32bit>(in, 3) + m_EK[3]; - - forward_mix(A, B, C, D); - - encrypt_round(A, B, C, D, m_EK[ 4], m_EK[ 5]); - encrypt_round(B, C, D, A, m_EK[ 6], m_EK[ 7]); - encrypt_round(C, D, A, B, m_EK[ 8], m_EK[ 9]); - encrypt_round(D, A, B, C, m_EK[10], m_EK[11]); - encrypt_round(A, B, C, D, m_EK[12], m_EK[13]); - encrypt_round(B, C, D, A, m_EK[14], m_EK[15]); - encrypt_round(C, D, A, B, m_EK[16], m_EK[17]); - encrypt_round(D, A, B, C, m_EK[18], m_EK[19]); - - encrypt_round(A, D, C, B, m_EK[20], m_EK[21]); - encrypt_round(B, A, D, C, m_EK[22], m_EK[23]); - encrypt_round(C, B, A, D, m_EK[24], m_EK[25]); - encrypt_round(D, C, B, A, m_EK[26], m_EK[27]); - encrypt_round(A, D, C, B, m_EK[28], m_EK[29]); - encrypt_round(B, A, D, C, m_EK[30], m_EK[31]); - encrypt_round(C, B, A, D, m_EK[32], m_EK[33]); - encrypt_round(D, C, B, A, m_EK[34], m_EK[35]); - - reverse_mix(A, B, C, D); - - A -= m_EK[36]; B -= m_EK[37]; C -= m_EK[38]; D -= m_EK[39]; - - store_le(out, A, B, C, D); - - in += BLOCK_SIZE; - out += BLOCK_SIZE; - } - } - -/* -* MARS Decryption -*/ -void MARS::decrypt_n(const byte in[], byte out[], size_t blocks) const - { - for(size_t i = 0; i != blocks; ++i) - { - u32bit A = load_le<u32bit>(in, 3) + m_EK[39]; - u32bit B = load_le<u32bit>(in, 2) + m_EK[38]; - u32bit C = load_le<u32bit>(in, 1) + m_EK[37]; - u32bit D = load_le<u32bit>(in, 0) + m_EK[36]; - - forward_mix(A, B, C, D); - - decrypt_round(A, B, C, D, m_EK[35], m_EK[34]); - decrypt_round(B, C, D, A, m_EK[33], m_EK[32]); - decrypt_round(C, D, A, B, m_EK[31], m_EK[30]); - decrypt_round(D, A, B, C, m_EK[29], m_EK[28]); - decrypt_round(A, B, C, D, m_EK[27], m_EK[26]); - decrypt_round(B, C, D, A, m_EK[25], m_EK[24]); - decrypt_round(C, D, A, B, m_EK[23], m_EK[22]); - decrypt_round(D, A, B, C, m_EK[21], m_EK[20]); - - decrypt_round(A, D, C, B, m_EK[19], m_EK[18]); - decrypt_round(B, A, D, C, m_EK[17], m_EK[16]); - decrypt_round(C, B, A, D, m_EK[15], m_EK[14]); - decrypt_round(D, C, B, A, m_EK[13], m_EK[12]); - decrypt_round(A, D, C, B, m_EK[11], m_EK[10]); - decrypt_round(B, A, D, C, m_EK[ 9], m_EK[ 8]); - decrypt_round(C, B, A, D, m_EK[ 7], m_EK[ 6]); - decrypt_round(D, C, B, A, m_EK[ 5], m_EK[ 4]); - - reverse_mix(A, B, C, D); - - A -= m_EK[3]; B -= m_EK[2]; C -= m_EK[1]; D -= m_EK[0]; - - store_le(out, D, C, B, A); - - in += BLOCK_SIZE; - out += BLOCK_SIZE; - } - } - -/* -* MARS Key Schedule -*/ -void MARS::key_schedule(const byte key[], size_t length) - { - secure_vector<u32bit> T(15); - for(size_t i = 0; i != length / 4; ++i) - T[i] = load_le<u32bit>(key, i); - - T[length / 4] = static_cast<u32bit>(length) / 4; - - m_EK.resize(40); - - for(u32bit i = 0; i != 4; ++i) - { - T[ 0] ^= rotate_left(T[ 8] ^ T[13], 3) ^ (i ); - T[ 1] ^= rotate_left(T[ 9] ^ T[14], 3) ^ (i + 4); - T[ 2] ^= rotate_left(T[10] ^ T[ 0], 3) ^ (i + 8); - T[ 3] ^= rotate_left(T[11] ^ T[ 1], 3) ^ (i + 12); - T[ 4] ^= rotate_left(T[12] ^ T[ 2], 3) ^ (i + 16); - T[ 5] ^= rotate_left(T[13] ^ T[ 3], 3) ^ (i + 20); - T[ 6] ^= rotate_left(T[14] ^ T[ 4], 3) ^ (i + 24); - T[ 7] ^= rotate_left(T[ 0] ^ T[ 5], 3) ^ (i + 28); - T[ 8] ^= rotate_left(T[ 1] ^ T[ 6], 3) ^ (i + 32); - T[ 9] ^= rotate_left(T[ 2] ^ T[ 7], 3) ^ (i + 36); - T[10] ^= rotate_left(T[ 3] ^ T[ 8], 3) ^ (i + 40); - T[11] ^= rotate_left(T[ 4] ^ T[ 9], 3) ^ (i + 44); - T[12] ^= rotate_left(T[ 5] ^ T[10], 3) ^ (i + 48); - T[13] ^= rotate_left(T[ 6] ^ T[11], 3) ^ (i + 52); - T[14] ^= rotate_left(T[ 7] ^ T[12], 3) ^ (i + 56); - - for(size_t j = 0; j != 4; ++j) - { - T[ 0] = rotate_left(T[ 0] + SBOX[T[14] % 512], 9); - T[ 1] = rotate_left(T[ 1] + SBOX[T[ 0] % 512], 9); - T[ 2] = rotate_left(T[ 2] + SBOX[T[ 1] % 512], 9); - T[ 3] = rotate_left(T[ 3] + SBOX[T[ 2] % 512], 9); - T[ 4] = rotate_left(T[ 4] + SBOX[T[ 3] % 512], 9); - T[ 5] = rotate_left(T[ 5] + SBOX[T[ 4] % 512], 9); - T[ 6] = rotate_left(T[ 6] + SBOX[T[ 5] % 512], 9); - T[ 7] = rotate_left(T[ 7] + SBOX[T[ 6] % 512], 9); - T[ 8] = rotate_left(T[ 8] + SBOX[T[ 7] % 512], 9); - T[ 9] = rotate_left(T[ 9] + SBOX[T[ 8] % 512], 9); - T[10] = rotate_left(T[10] + SBOX[T[ 9] % 512], 9); - T[11] = rotate_left(T[11] + SBOX[T[10] % 512], 9); - T[12] = rotate_left(T[12] + SBOX[T[11] % 512], 9); - T[13] = rotate_left(T[13] + SBOX[T[12] % 512], 9); - T[14] = rotate_left(T[14] + SBOX[T[13] % 512], 9); - } - - m_EK[10*i + 0] = T[ 0]; - m_EK[10*i + 1] = T[ 4]; - m_EK[10*i + 2] = T[ 8]; - m_EK[10*i + 3] = T[12]; - m_EK[10*i + 4] = T[ 1]; - m_EK[10*i + 5] = T[ 5]; - m_EK[10*i + 6] = T[ 9]; - m_EK[10*i + 7] = T[13]; - m_EK[10*i + 8] = T[ 2]; - m_EK[10*i + 9] = T[ 6]; - } - - for(size_t i = 5; i != 37; i += 2) - { - const u32bit key3 = m_EK[i] & 3; - m_EK[i] |= 3; - m_EK[i] ^= rotate_left(SBOX[265 + key3], m_EK[i-1] % 32) & gen_mask(m_EK[i]); - } - } - -void MARS::clear() - { - zap(m_EK); - } - -} diff --git a/src/lib/block/mars/mars.h b/src/lib/block/mars/mars.h deleted file mode 100644 index a4d7a07d6..000000000 --- a/src/lib/block/mars/mars.h +++ /dev/null @@ -1,35 +0,0 @@ -/* -* MARS -* (C) 1999-2007 Jack Lloyd -* -* Botan is released under the Simplified BSD License (see license.txt) -*/ - -#ifndef BOTAN_MARS_H__ -#define BOTAN_MARS_H__ - -#include <botan/block_cipher.h> - -namespace Botan { - -/** -* MARS, IBM's candidate for AES -*/ -class BOTAN_DLL MARS final : public Block_Cipher_Fixed_Params<16, 16, 32, 4> - { - public: - void encrypt_n(const byte in[], byte out[], size_t blocks) const override; - void decrypt_n(const byte in[], byte out[], size_t blocks) const override; - - void clear() override; - std::string name() const override { return "MARS"; } - BlockCipher* clone() const override { return new MARS; } - private: - void key_schedule(const byte[], size_t) override; - - secure_vector<u32bit> m_EK; - }; - -} - -#endif diff --git a/src/lib/block/rc2/info.txt b/src/lib/block/rc2/info.txt deleted file mode 100644 index fae09cf23..000000000 --- a/src/lib/block/rc2/info.txt +++ /dev/null @@ -1 +0,0 @@ -define RC2 20131128 diff --git a/src/lib/block/rc2/rc2.cpp b/src/lib/block/rc2/rc2.cpp deleted file mode 100644 index 112c6561d..000000000 --- a/src/lib/block/rc2/rc2.cpp +++ /dev/null @@ -1,181 +0,0 @@ -/* -* RC2 -* (C) 1999-2007 Jack Lloyd -* -* Botan is released under the Simplified BSD License (see license.txt) -*/ - -#include <botan/rc2.h> -#include <botan/loadstor.h> - -namespace Botan { - -/* -* RC2 Encryption -*/ -void RC2::encrypt_n(const byte in[], byte out[], size_t blocks) const - { - for(size_t i = 0; i != blocks; ++i) - { - u16bit R0 = load_le<u16bit>(in, 0); - u16bit R1 = load_le<u16bit>(in, 1); - u16bit R2 = load_le<u16bit>(in, 2); - u16bit R3 = load_le<u16bit>(in, 3); - - for(size_t j = 0; j != 16; ++j) - { - R0 += (R1 & ~R3) + (R2 & R3) + m_K[4*j]; - R0 = rotate_left(R0, 1); - - R1 += (R2 & ~R0) + (R3 & R0) + m_K[4*j + 1]; - R1 = rotate_left(R1, 2); - - R2 += (R3 & ~R1) + (R0 & R1) + m_K[4*j + 2]; - R2 = rotate_left(R2, 3); - - R3 += (R0 & ~R2) + (R1 & R2) + m_K[4*j + 3]; - R3 = rotate_left(R3, 5); - - if(j == 4 || j == 10) - { - R0 += m_K[R3 % 64]; - R1 += m_K[R0 % 64]; - R2 += m_K[R1 % 64]; - R3 += m_K[R2 % 64]; - } - } - - store_le(out, R0, R1, R2, R3); - - in += BLOCK_SIZE; - out += BLOCK_SIZE; - } - } - -/* -* RC2 Decryption -*/ -void RC2::decrypt_n(const byte in[], byte out[], size_t blocks) const - { - for(size_t i = 0; i != blocks; ++i) - { - u16bit R0 = load_le<u16bit>(in, 0); - u16bit R1 = load_le<u16bit>(in, 1); - u16bit R2 = load_le<u16bit>(in, 2); - u16bit R3 = load_le<u16bit>(in, 3); - - for(size_t j = 0; j != 16; ++j) - { - R3 = rotate_right(R3, 5); - R3 -= (R0 & ~R2) + (R1 & R2) + m_K[63 - (4*j + 0)]; - - R2 = rotate_right(R2, 3); - R2 -= (R3 & ~R1) + (R0 & R1) + m_K[63 - (4*j + 1)]; - - R1 = rotate_right(R1, 2); - R1 -= (R2 & ~R0) + (R3 & R0) + m_K[63 - (4*j + 2)]; - - R0 = rotate_right(R0, 1); - R0 -= (R1 & ~R3) + (R2 & R3) + m_K[63 - (4*j + 3)]; - - if(j == 4 || j == 10) - { - R3 -= m_K[R2 % 64]; - R2 -= m_K[R1 % 64]; - R1 -= m_K[R0 % 64]; - R0 -= m_K[R3 % 64]; - } - } - - store_le(out, R0, R1, R2, R3); - - in += BLOCK_SIZE; - out += BLOCK_SIZE; - } - } - -/* -* RC2 Key Schedule -*/ -void RC2::key_schedule(const byte key[], size_t length) - { - static const byte TABLE[256] = { - 0xD9, 0x78, 0xF9, 0xC4, 0x19, 0xDD, 0xB5, 0xED, 0x28, 0xE9, 0xFD, 0x79, - 0x4A, 0xA0, 0xD8, 0x9D, 0xC6, 0x7E, 0x37, 0x83, 0x2B, 0x76, 0x53, 0x8E, - 0x62, 0x4C, 0x64, 0x88, 0x44, 0x8B, 0xFB, 0xA2, 0x17, 0x9A, 0x59, 0xF5, - 0x87, 0xB3, 0x4F, 0x13, 0x61, 0x45, 0x6D, 0x8D, 0x09, 0x81, 0x7D, 0x32, - 0xBD, 0x8F, 0x40, 0xEB, 0x86, 0xB7, 0x7B, 0x0B, 0xF0, 0x95, 0x21, 0x22, - 0x5C, 0x6B, 0x4E, 0x82, 0x54, 0xD6, 0x65, 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C, 0x77, 0x0A, 0xA6, 0x20, 0x68, - 0xFE, 0x7F, 0xC1, 0xAD }; - - secure_vector<byte> L(128); - copy_mem(L.data(), key, length); - - for(size_t i = length; i != 128; ++i) - L[i] = TABLE[(L[i-1] + L[i-length]) % 256]; - - L[128-length] = TABLE[L[128-length]]; - - for(s32bit i = 127-length; i >= 0; --i) - L[i] = TABLE[L[i+1] ^ L[i+length]]; - - m_K.resize(64); - load_le<u16bit>(m_K.data(), L.data(), 64); - } - -void RC2::clear() - { - zap(m_K); - } - -/* -* Return the code of the effective key bits -*/ -byte RC2::EKB_code(size_t ekb) - { - const byte EKB[256] = { - 0xBD, 0x56, 0xEA, 0xF2, 0xA2, 0xF1, 0xAC, 0x2A, 0xB0, 0x93, 0xD1, 0x9C, - 0x1B, 0x33, 0xFD, 0xD0, 0x30, 0x04, 0xB6, 0xDC, 0x7D, 0xDF, 0x32, 0x4B, - 0xF7, 0xCB, 0x45, 0x9B, 0x31, 0xBB, 0x21, 0x5A, 0x41, 0x9F, 0xE1, 0xD9, - 0x4A, 0x4D, 0x9E, 0xDA, 0xA0, 0x68, 0x2C, 0xC3, 0x27, 0x5F, 0x80, 0x36, - 0x3E, 0xEE, 0xFB, 0x95, 0x1A, 0xFE, 0xCE, 0xA8, 0x34, 0xA9, 0x13, 0xF0, - 0xA6, 0x3F, 0xD8, 0x0C, 0x78, 0x24, 0xAF, 0x23, 0x52, 0xC1, 0x67, 0x17, - 0xF5, 0x66, 0x90, 0xE7, 0xE8, 0x07, 0xB8, 0x60, 0x48, 0xE6, 0x1E, 0x53, - 0xF3, 0x92, 0xA4, 0x72, 0x8C, 0x08, 0x15, 0x6E, 0x86, 0x00, 0x84, 0xFA, - 0xF4, 0x7F, 0x8A, 0x42, 0x19, 0xF6, 0xDB, 0xCD, 0x14, 0x8D, 0x50, 0x12, - 0xBA, 0x3C, 0x06, 0x4E, 0xEC, 0xB3, 0x35, 0x11, 0xA1, 0x88, 0x8E, 0x2B, - 0x94, 0x99, 0xB7, 0x71, 0x74, 0xD3, 0xE4, 0xBF, 0x3A, 0xDE, 0x96, 0x0E, - 0xBC, 0x0A, 0xED, 0x77, 0xFC, 0x37, 0x6B, 0x03, 0x79, 0x89, 0x62, 0xC6, - 0xD7, 0xC0, 0xD2, 0x7C, 0x6A, 0x8B, 0x22, 0xA3, 0x5B, 0x05, 0x5D, 0x02, - 0x75, 0xD5, 0x61, 0xE3, 0x18, 0x8F, 0x55, 0x51, 0xAD, 0x1F, 0x0B, 0x5E, - 0x85, 0xE5, 0xC2, 0x57, 0x63, 0xCA, 0x3D, 0x6C, 0xB4, 0xC5, 0xCC, 0x70, - 0xB2, 0x91, 0x59, 0x0D, 0x47, 0x20, 0xC8, 0x4F, 0x58, 0xE0, 0x01, 0xE2, - 0x16, 0x38, 0xC4, 0x6F, 0x3B, 0x0F, 0x65, 0x46, 0xBE, 0x7E, 0x2D, 0x7B, - 0x82, 0xF9, 0x40, 0xB5, 0x1D, 0x73, 0xF8, 0xEB, 0x26, 0xC7, 0x87, 0x97, - 0x25, 0x54, 0xB1, 0x28, 0xAA, 0x98, 0x9D, 0xA5, 0x64, 0x6D, 0x7A, 0xD4, - 0x10, 0x81, 0x44, 0xEF, 0x49, 0xD6, 0xAE, 0x2E, 0xDD, 0x76, 0x5C, 0x2F, - 0xA7, 0x1C, 0xC9, 0x09, 0x69, 0x9A, 0x83, 0xCF, 0x29, 0x39, 0xB9, 0xE9, - 0x4C, 0xFF, 0x43, 0xAB }; - - if(ekb < 256) - return EKB[ekb]; - else - throw Encoding_Error("RC2::EKB_code: EKB is too large"); - } - -} diff --git a/src/lib/block/rc2/rc2.h b/src/lib/block/rc2/rc2.h deleted file mode 100644 index 9ec9b9557..000000000 --- a/src/lib/block/rc2/rc2.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -* RC2 -* (C) 1999-2007 Jack Lloyd -* -* Botan is released under the Simplified BSD License (see license.txt) -*/ - -#ifndef BOTAN_RC2_H__ -#define BOTAN_RC2_H__ - -#include <botan/block_cipher.h> - -namespace Botan { - -/** -* RC2 -*/ -class BOTAN_DLL RC2 final : public Block_Cipher_Fixed_Params<8, 1, 32> - { - public: - void encrypt_n(const byte in[], byte out[], size_t blocks) const override; - void decrypt_n(const byte in[], byte out[], size_t blocks) const override; - - /** - * Return the code of the effective key bits - * @param bits key length - * @return EKB code - */ - static byte EKB_code(size_t bits); - - void clear() override; - std::string name() const override { return "RC2"; } - BlockCipher* clone() const override { return new RC2; } - private: - void key_schedule(const byte[], size_t) override; - - secure_vector<u16bit> m_K; - }; - -} - -#endif diff --git a/src/lib/block/rc5/info.txt b/src/lib/block/rc5/info.txt deleted file mode 100644 index 2c2c613ba..000000000 --- a/src/lib/block/rc5/info.txt +++ /dev/null @@ -1 +0,0 @@ -define RC5 20131128 diff --git a/src/lib/block/rc5/rc5.cpp b/src/lib/block/rc5/rc5.cpp deleted file mode 100644 index a02a45e9f..000000000 --- a/src/lib/block/rc5/rc5.cpp +++ /dev/null @@ -1,133 +0,0 @@ -/* -* RC5 -* (C) 1999-2007 Jack Lloyd -* -* Botan is released under the Simplified BSD License (see license.txt) -*/ - -#include <botan/rc5.h> -#include <botan/loadstor.h> -#include <botan/parsing.h> - -namespace Botan { - -/* -* RC5 Encryption -*/ -void RC5::encrypt_n(const byte in[], byte out[], size_t blocks) const - { - for(size_t i = 0; i != blocks; ++i) - { - u32bit A = load_le<u32bit>(in, 0); - u32bit B = load_le<u32bit>(in, 1); - - A += m_S[0]; B += m_S[1]; - for(size_t j = 0; j != m_rounds; j += 4) - { - A = rotate_left(A ^ B, B % 32) + m_S[2*j+2]; - B = rotate_left(B ^ A, A % 32) + m_S[2*j+3]; - - A = rotate_left(A ^ B, B % 32) + m_S[2*j+4]; - B = rotate_left(B ^ A, A % 32) + m_S[2*j+5]; - - A = rotate_left(A ^ B, B % 32) + m_S[2*j+6]; - B = rotate_left(B ^ A, A % 32) + m_S[2*j+7]; - - A = rotate_left(A ^ B, B % 32) + m_S[2*j+8]; - B = rotate_left(B ^ A, A % 32) + m_S[2*j+9]; - } - - store_le(out, A, B); - - in += BLOCK_SIZE; - out += BLOCK_SIZE; - } - } - -/* -* RC5 Decryption -*/ -void RC5::decrypt_n(const byte in[], byte out[], size_t blocks) const - { - for(size_t i = 0; i != blocks; ++i) - { - u32bit A = load_le<u32bit>(in, 0); - u32bit B = load_le<u32bit>(in, 1); - - for(size_t j = m_rounds; j != 0; j -= 4) - { - B = rotate_right(B - m_S[2*j+1], A % 32) ^ A; - A = rotate_right(A - m_S[2*j ], B % 32) ^ B; - - B = rotate_right(B - m_S[2*j-1], A % 32) ^ A; - A = rotate_right(A - m_S[2*j-2], B % 32) ^ B; - - B = rotate_right(B - m_S[2*j-3], A % 32) ^ A; - A = rotate_right(A - m_S[2*j-4], B % 32) ^ B; - - B = rotate_right(B - m_S[2*j-5], A % 32) ^ A; - A = rotate_right(A - m_S[2*j-6], B % 32) ^ B; - } - B -= m_S[1]; A -= m_S[0]; - - store_le(out, A, B); - - in += BLOCK_SIZE; - out += BLOCK_SIZE; - } - } - -/* -* RC5 Key Schedule -*/ -void RC5::key_schedule(const byte key[], size_t length) - { - m_S.resize(2*m_rounds + 2); - - const size_t WORD_KEYLENGTH = (((length - 1) / 4) + 1); - const size_t MIX_ROUNDS = 3 * std::max(WORD_KEYLENGTH, m_S.size()); - - m_S[0] = 0xB7E15163; - for(size_t i = 1; i != m_S.size(); ++i) - m_S[i] = m_S[i-1] + 0x9E3779B9; - - secure_vector<u32bit> K(8); - - for(s32bit i = length-1; i >= 0; --i) - K[i/4] = (K[i/4] << 8) + key[i]; - - u32bit A = 0, B = 0; - - for(size_t i = 0; i != MIX_ROUNDS; ++i) - { - A = rotate_left(m_S[i % m_S.size()] + A + B, 3); - B = rotate_left(K[i % WORD_KEYLENGTH] + A + B, (A + B) % 32); - m_S[i % m_S.size()] = A; - K[i % WORD_KEYLENGTH] = B; - } - } - -void RC5::clear() - { - zap(m_S); - } - -/* -* Return the name of this type -*/ -std::string RC5::name() const - { - return "RC5(" + std::to_string(m_rounds) + ")"; - } - -/* -* RC5 Constructor -*/ -RC5::RC5(size_t r) : m_rounds(r) - { - if(m_rounds < 8 || m_rounds > 32 || (m_rounds % 4 != 0)) - throw Invalid_Argument("RC5: Invalid number of rounds " + - std::to_string(m_rounds)); - } - -} diff --git a/src/lib/block/rc5/rc5.h b/src/lib/block/rc5/rc5.h deleted file mode 100644 index 4d9232326..000000000 --- a/src/lib/block/rc5/rc5.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -* RC5 -* (C) 1999-2007 Jack Lloyd -* -* Botan is released under the Simplified BSD License (see license.txt) -*/ - -#ifndef BOTAN_RC5_H__ -#define BOTAN_RC5_H__ - -#include <botan/block_cipher.h> - -namespace Botan { - -/** -* RC5 -*/ -class BOTAN_DLL RC5 final : public Block_Cipher_Fixed_Params<8, 1, 32> - { - public: - void encrypt_n(const byte in[], byte out[], size_t blocks) const override; - void decrypt_n(const byte in[], byte out[], size_t blocks) const override; - - void clear() override; - std::string name() const override; - BlockCipher* clone() const override { return new RC5(m_rounds); } - - /** - * @param rounds the number of RC5 rounds to run. Must be between - * 8 and 32 and a multiple of 4. - */ - explicit RC5(size_t rounds); - private: - void key_schedule(const byte[], size_t) override; - - size_t m_rounds; - secure_vector<u32bit> m_S; - }; - -} - -#endif diff --git a/src/lib/block/rc6/info.txt b/src/lib/block/rc6/info.txt deleted file mode 100644 index e54379f65..000000000 --- a/src/lib/block/rc6/info.txt +++ /dev/null @@ -1 +0,0 @@ -define RC6 20131128 diff --git a/src/lib/block/rc6/rc6.cpp b/src/lib/block/rc6/rc6.cpp deleted file mode 100644 index 426b86ebd..000000000 --- a/src/lib/block/rc6/rc6.cpp +++ /dev/null @@ -1,143 +0,0 @@ -/* -* RC6 -* (C) 1999-2007 Jack Lloyd -* -* Botan is released under the Simplified BSD License (see license.txt) -*/ - -#include <botan/rc6.h> -#include <botan/loadstor.h> - -namespace Botan { - -/* -* RC6 Encryption -*/ -void RC6::encrypt_n(const byte in[], byte out[], size_t blocks) const - { - for(size_t i = 0; i != blocks; ++i) - { - u32bit A = load_le<u32bit>(in, 0); - u32bit B = load_le<u32bit>(in, 1); - u32bit C = load_le<u32bit>(in, 2); - u32bit D = load_le<u32bit>(in, 3); - - B += m_S[0]; D += m_S[1]; - - for(size_t j = 0; j != 20; j += 4) - { - u32bit T1, T2; - - T1 = rotate_left(B*(2*B+1), 5); - T2 = rotate_left(D*(2*D+1), 5); - A = rotate_left(A ^ T1, T2 % 32) + m_S[2*j+2]; - C = rotate_left(C ^ T2, T1 % 32) + m_S[2*j+3]; - - T1 = rotate_left(C*(2*C+1), 5); - T2 = rotate_left(A*(2*A+1), 5); - B = rotate_left(B ^ T1, T2 % 32) + m_S[2*j+4]; - D = rotate_left(D ^ T2, T1 % 32) + m_S[2*j+5]; - - T1 = rotate_left(D*(2*D+1), 5); - T2 = rotate_left(B*(2*B+1), 5); - C = rotate_left(C ^ T1, T2 % 32) + m_S[2*j+6]; - A = rotate_left(A ^ T2, T1 % 32) + m_S[2*j+7]; - - T1 = rotate_left(A*(2*A+1), 5); - T2 = rotate_left(C*(2*C+1), 5); - D = rotate_left(D ^ T1, T2 % 32) + m_S[2*j+8]; - B = rotate_left(B ^ T2, T1 % 32) + m_S[2*j+9]; - } - - A += m_S[42]; C += m_S[43]; - - store_le(out, A, B, C, D); - - in += BLOCK_SIZE; - out += BLOCK_SIZE; - } - } - -/* -* RC6 Decryption -*/ -void RC6::decrypt_n(const byte in[], byte out[], size_t blocks) const - { - for(size_t i = 0; i != blocks; ++i) - { - u32bit A = load_le<u32bit>(in, 0); - u32bit B = load_le<u32bit>(in, 1); - u32bit C = load_le<u32bit>(in, 2); - u32bit D = load_le<u32bit>(in, 3); - - C -= m_S[43]; A -= m_S[42]; - - for(size_t j = 0; j != 20; j += 4) - { - u32bit T1, T2; - - T1 = rotate_left(A*(2*A+1), 5); - T2 = rotate_left(C*(2*C+1), 5); - B = rotate_right(B - m_S[41 - 2*j], T1 % 32) ^ T2; - D = rotate_right(D - m_S[40 - 2*j], T2 % 32) ^ T1; - - T1 = rotate_left(D*(2*D+1), 5); - T2 = rotate_left(B*(2*B+1), 5); - A = rotate_right(A - m_S[39 - 2*j], T1 % 32) ^ T2; - C = rotate_right(C - m_S[38 - 2*j], T2 % 32) ^ T1; - - T1 = rotate_left(C*(2*C+1), 5); - T2 = rotate_left(A*(2*A+1), 5); - D = rotate_right(D - m_S[37 - 2*j], T1 % 32) ^ T2; - B = rotate_right(B - m_S[36 - 2*j], T2 % 32) ^ T1; - - T1 = rotate_left(B*(2*B+1), 5); - T2 = rotate_left(D*(2*D+1), 5); - C = rotate_right(C - m_S[35 - 2*j], T1 % 32) ^ T2; - A = rotate_right(A - m_S[34 - 2*j], T2 % 32) ^ T1; - } - - D -= m_S[1]; B -= m_S[0]; - - store_le(out, A, B, C, D); - - in += BLOCK_SIZE; - out += BLOCK_SIZE; - } - } - -/* -* RC6 Key Schedule -*/ -void RC6::key_schedule(const byte key[], size_t length) - { - m_S.resize(44); - - const size_t WORD_KEYLENGTH = (((length - 1) / 4) + 1); - const size_t MIX_ROUNDS = 3 * std::max(WORD_KEYLENGTH, m_S.size()); - - m_S[0] = 0xB7E15163; - for(size_t i = 1; i != m_S.size(); ++i) - m_S[i] = m_S[i-1] + 0x9E3779B9; - - secure_vector<u32bit> K(8); - - for(s32bit i = length-1; i >= 0; --i) - K[i/4] = (K[i/4] << 8) + key[i]; - - u32bit A = 0, B = 0; - for(size_t i = 0; i != MIX_ROUNDS; ++i) - { - A = rotate_left(m_S[i % m_S.size()] + A + B, 3); - B = rotate_left(K[i % WORD_KEYLENGTH] + A + B, (A + B) % 32); - m_S[i % m_S.size()] = A; - K[i % WORD_KEYLENGTH] = B; - } - } - -void RC6::clear() - { - zap(m_S); - } - -} diff --git a/src/lib/block/rc6/rc6.h b/src/lib/block/rc6/rc6.h deleted file mode 100644 index 3f9bb0af1..000000000 --- a/src/lib/block/rc6/rc6.h +++ /dev/null @@ -1,35 +0,0 @@ -/* -* RC6 -* (C) 1999-2007 Jack Lloyd -* -* Botan is released under the Simplified BSD License (see license.txt) -*/ - -#ifndef BOTAN_RC6_H__ -#define BOTAN_RC6_H__ - -#include <botan/block_cipher.h> - -namespace Botan { - -/** -* RC6, Ron Rivest's AES candidate -*/ -class BOTAN_DLL RC6 final : public Block_Cipher_Fixed_Params<16, 1, 32> - { - public: - void encrypt_n(const byte in[], byte out[], size_t blocks) const override; - void decrypt_n(const byte in[], byte out[], size_t blocks) const override; - - void clear() override; - std::string name() const override { return "RC6"; } - BlockCipher* clone() const override { return new RC6; } - private: - void key_schedule(const byte[], size_t) override; - - secure_vector<u32bit> m_S; - }; - -} - -#endif diff --git a/src/lib/block/safer/info.txt b/src/lib/block/safer/info.txt deleted file mode 100644 index ad7841dab..000000000 --- a/src/lib/block/safer/info.txt +++ /dev/null @@ -1 +0,0 @@ -define SAFER 20131128 diff --git a/src/lib/block/safer/safer_sk.cpp b/src/lib/block/safer/safer_sk.cpp deleted file mode 100644 index 8dec0b897..000000000 --- a/src/lib/block/safer/safer_sk.cpp +++ /dev/null @@ -1,255 +0,0 @@ -/* -* SAFER-SK -* (C) 1999-2009 Jack Lloyd -* -* Botan is released under the Simplified BSD License (see license.txt) -*/ - -#include <botan/safer_sk.h> -#include <botan/rotate.h> -#include <botan/parsing.h> - -namespace Botan { - -namespace { - -const byte EXP[256] = { - 0x01, 0x2D, 0xE2, 0x93, 0xBE, 0x45, 0x15, 0xAE, 0x78, 0x03, 0x87, 0xA4, - 0xB8, 0x38, 0xCF, 0x3F, 0x08, 0x67, 0x09, 0x94, 0xEB, 0x26, 0xA8, 0x6B, - 0xBD, 0x18, 0x34, 0x1B, 0xBB, 0xBF, 0x72, 0xF7, 0x40, 0x35, 0x48, 0x9C, - 0x51, 0x2F, 0x3B, 0x55, 0xE3, 0xC0, 0x9F, 0xD8, 0xD3, 0xF3, 0x8D, 0xB1, - 0xFF, 0xA7, 0x3E, 0xDC, 0x86, 0x77, 0xD7, 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 0xE7, 0x73, 0x23, 0x21, 0xC8, 0x05, - 0xE1, 0x66, 0xDD, 0xB3, 0x58, 0x69, 0x63, 0x56, 0x0F, 0xA1, 0x31, 0x95, - 0x17, 0x07, 0x3A, 0x28 }; - -const byte LOG[512] = { - 0x80, 0x00, 0xB0, 0x09, 0x60, 0xEF, 0xB9, 0xFD, 0x10, 0x12, 0x9F, 0xE4, - 0x69, 0xBA, 0xAD, 0xF8, 0xC0, 0x38, 0xC2, 0x65, 0x4F, 0x06, 0x94, 0xFC, - 0x19, 0xDE, 0x6A, 0x1B, 0x5D, 0x4E, 0xA8, 0x82, 0x70, 0xED, 0xE8, 0xEC, - 0x72, 0xB3, 0x15, 0xC3, 0xFF, 0xAB, 0xB6, 0x47, 0x44, 0x01, 0xAC, 0x25, - 0xC9, 0xFA, 0x8E, 0x41, 0x1A, 0x21, 0xCB, 0xD3, 0x0D, 0x6E, 0xFE, 0x26, - 0x58, 0xDA, 0x32, 0x0F, 0x20, 0xA9, 0x9D, 0x84, 0x98, 0x05, 0x9C, 0xBB, - 0x22, 0x8C, 0x63, 0xE7, 0xC5, 0xE1, 0x73, 0xC6, 0xAF, 0x24, 0x5B, 0x87, - 0x66, 0x27, 0xF7, 0x57, 0xF4, 0x96, 0xB1, 0xB7, 0x5C, 0x8B, 0xD5, 0x54, - 0x79, 0xDF, 0xAA, 0xF6, 0x3E, 0xA3, 0xF1, 0x11, 0xCA, 0xF5, 0xD1, 0x17, - 0x7B, 0x93, 0x83, 0xBC, 0xBD, 0x52, 0x1E, 0xEB, 0xAE, 0xCC, 0xD6, 0x35, - 0x08, 0xC8, 0x8A, 0xB4, 0xE2, 0xCD, 0xBF, 0xD9, 0xD0, 0x50, 0x59, 0x3F, - 0x4D, 0x62, 0x34, 0x0A, 0x48, 0x88, 0xB5, 0x56, 0x4C, 0x2E, 0x6B, 0x9E, - 0xD2, 0x3D, 0x3C, 0x03, 0x13, 0xFB, 0x97, 0x51, 0x75, 0x4A, 0x91, 0x71, - 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/ -void SAFER_SK::encrypt_n(const byte in[], byte out[], size_t blocks) const - { - for(size_t i = 0; i != blocks; ++i) - { - byte A = in[0], B = in[1], C = in[2], D = in[3], - E = in[4], F = in[5], G = in[6], H = in[7], X, Y; - - for(size_t j = 0; j != 16*m_rounds; j += 16) - { - A = EXP[A ^ m_EK[j ]]; B = LOG[B + m_EK[j+1]]; - C = LOG[C + m_EK[j+2]]; D = EXP[D ^ m_EK[j+3]]; - E = EXP[E ^ m_EK[j+4]]; F = LOG[F + m_EK[j+5]]; - G = LOG[G + m_EK[j+6]]; H = EXP[H ^ m_EK[j+7]]; - - A += m_EK[j+ 8]; B ^= m_EK[j+ 9]; C ^= m_EK[j+10]; D += m_EK[j+11]; - E += m_EK[j+12]; F ^= m_EK[j+13]; G ^= m_EK[j+14]; H += m_EK[j+15]; - - B += A; D += C; F += E; H += G; A += B; C += D; E += F; G += H; - C += A; G += E; D += B; H += F; A += C; E += G; B += D; F += H; - H += D; Y = D + H; D = B + F; X = B + D; B = A + E; - A += B; F = C + G; E = C + F; C = X; G = Y; - } - - out[0] = A ^ m_EK[16*m_rounds+0]; out[1] = B + m_EK[16*m_rounds+1]; - out[2] = C + m_EK[16*m_rounds+2]; out[3] = D ^ m_EK[16*m_rounds+3]; - out[4] = E ^ m_EK[16*m_rounds+4]; out[5] = F + m_EK[16*m_rounds+5]; - out[6] = G + m_EK[16*m_rounds+6]; out[7] = H ^ m_EK[16*m_rounds+7]; - - in += BLOCK_SIZE; - out += BLOCK_SIZE; - } - } - -/* -* SAFER-SK Decryption -*/ -void SAFER_SK::decrypt_n(const byte in[], byte out[], size_t blocks) const - { - for(size_t i = 0; i != blocks; ++i) - { - byte A = in[0], B = in[1], C = in[2], D = in[3], - E = in[4], F = in[5], G = in[6], H = in[7]; - - A ^= m_EK[16*m_rounds+0]; B -= m_EK[16*m_rounds+1]; C -= m_EK[16*m_rounds+2]; - D ^= m_EK[16*m_rounds+3]; E ^= m_EK[16*m_rounds+4]; F -= m_EK[16*m_rounds+5]; - G -= m_EK[16*m_rounds+6]; H ^= m_EK[16*m_rounds+7]; - - for(s32bit j = 16*(m_rounds-1); j >= 0; j -= 16) - { - byte T = E; E = B; B = C; C = T; T = F; F = D; D = G; G = T; - A -= E; B -= F; C -= G; D -= H; E -= A; F -= B; G -= C; H -= D; - A -= C; E -= G; B -= D; F -= H; C -= A; G -= E; D -= B; H -= F; - A -= B; C -= D; E -= F; G -= H; B -= A; D -= C; F -= E; H -= G; - - A = LOG[A - m_EK[j+8 ] + 256]; B = EXP[B ^ m_EK[j+9 ]]; - C = EXP[C ^ m_EK[j+10]]; D = LOG[D - m_EK[j+11] + 256]; - E = LOG[E - m_EK[j+12] + 256]; F = EXP[F ^ m_EK[j+13]]; - G = EXP[G ^ m_EK[j+14]]; H = LOG[H - m_EK[j+15] + 256]; - - A ^= m_EK[j+0]; B -= m_EK[j+1]; C -= m_EK[j+2]; D ^= m_EK[j+3]; - E ^= m_EK[j+4]; F -= m_EK[j+5]; G -= m_EK[j+6]; H ^= m_EK[j+7]; - } - - out[0] = A; out[1] = B; out[2] = C; out[3] = D; - out[4] = E; out[5] = F; out[6] = G; out[7] = H; - - in += BLOCK_SIZE; - out += BLOCK_SIZE; - } - } - -/* -* SAFER-SK Key Schedule -*/ -void SAFER_SK::key_schedule(const byte key[], size_t) - { - const byte BIAS[208] = { - 0x16, 0x73, 0x3B, 0x1E, 0x8E, 0x70, 0xBD, 0x86, 0x47, 0x7E, 0x24, 0x56, - 0xF1, 0x77, 0x88, 0x46, 0xB1, 0xBA, 0xA3, 0xB7, 0x10, 0x0A, 0xC5, 0x37, - 0xC9, 0x5A, 0x28, 0xAC, 0x64, 0xA5, 0xEC, 0xAB, 0xC6, 0x67, 0x95, 0x58, - 0x0D, 0xF8, 0x9A, 0xF6, 0x66, 0xDC, 0x05, 0x3D, 0xD3, 0x8A, 0xC3, 0xD8, - 0x6A, 0xE9, 0x36, 0x49, 0x43, 0xBF, 0xEB, 0xD4, 0x9B, 0x68, 0xA0, 0x65, - 0x5D, 0x57, 0x92, 0x1F, 0x71, 0x5C, 0xBB, 0x22, 0xC1, 0xBE, 0x7B, 0xBC, - 0x63, 0x94, 0x5F, 0x2A, 0x61, 0xB8, 0x34, 0x32, 0xFD, 0xFB, 0x17, 0x40, - 0xE6, 0x51, 0x1D, 0x41, 0x8F, 0x29, 0xDD, 0x04, 0x80, 0xDE, 0xE7, 0x31, - 0x7F, 0x01, 0xA2, 0xF7, 0x39, 0xDA, 0x6F, 0x23, 0xFE, 0x3A, 0xD0, 0x1C, - 0xD1, 0x30, 0x3E, 0x12, 0xCD, 0x0F, 0xE0, 0xA8, 0xAF, 0x82, 0x59, 0x2C, - 0x7D, 0xAD, 0xB2, 0xEF, 0xC2, 0x87, 0xCE, 0x75, 0x13, 0x02, 0x90, 0x4F, - 0x2E, 0x72, 0x33, 0x85, 0x8D, 0xCF, 0xA9, 0x81, 0xE2, 0xC4, 0x27, 0x2F, - 0x7A, 0x9F, 0x52, 0xE1, 0x15, 0x38, 0x2B, 0xFC, 0x42, 0xC7, 0x08, 0xE4, - 0x09, 0x55, 0x5E, 0x8C, 0x76, 0x60, 0xFF, 0xDF, 0xD7, 0x98, 0xFA, 0x0B, - 0x00, 0x1A, 0xF9, 0xA6, 0xB9, 0xE8, 0x9E, 0x62, 0xD9, 0x91, 0x50, 0xD2, - 0xEE, 0x18, 0xB4, 0x07, 0xEA, 0x5B, 0xA4, 0xC8, 0x0E, 0xCB, 0x48, 0x69, - 0x4E, 0x9C, 0x35, 0x79, 0x45, 0x4D, 0x54, 0xE5, 0x3C, 0x0C, 0x4A, 0x8B, - 0x3F, 0xCC, 0xA7, 0xDB }; - - const byte KEY_INDEX[208] = { - 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x0B, 0x0C, 0x0D, 0x0E, - 0x0F, 0x10, 0x11, 0x09, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x00, 0x01, - 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x09, 0x0A, 0x0B, 0x05, 0x06, 0x07, 0x08, - 0x00, 0x01, 0x02, 0x03, 0x0F, 0x10, 0x11, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, - 0x07, 0x08, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x11, 0x09, 0x0A, 0x0B, - 0x0C, 0x0D, 0x0E, 0x0F, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x02, 0x03, 0x04, 0x05, - 0x06, 0x07, 0x08, 0x00, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x09, 0x0A, - 0x04, 0x05, 0x06, 0x07, 0x08, 0x00, 0x01, 0x02, 0x0E, 0x0F, 0x10, 0x11, - 0x09, 0x0A, 0x0B, 0x0C, 0x06, 0x07, 0x08, 0x00, 0x01, 0x02, 0x03, 0x04, - 0x10, 0x11, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x08, 0x00, 0x01, 0x02, - 0x03, 0x04, 0x05, 0x06, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, - 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x0B, 0x0C, 0x0D, 0x0E, - 0x0F, 0x10, 0x11, 0x09, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x00, 0x01, - 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x09, 0x0A, 0x0B, 0x05, 0x06, 0x07, 0x08, - 0x00, 0x01, 0x02, 0x03, 0x0F, 0x10, 0x11, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, - 0x07, 0x08, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x11, 0x09, 0x0A, 0x0B, - 0x0C, 0x0D, 0x0E, 0x0F }; - - m_EK.resize(16 * m_rounds + 8); - - secure_vector<byte> KB(18); - - for(size_t i = 0; i != 8; ++i) - { - KB[ 8] ^= KB[i] = rotate_left(key[i], 5); - KB[17] ^= KB[i+9] = m_EK[i] = key[i+8]; - } - - for(size_t i = 0; i != m_rounds; ++i) - { - for(size_t j = 0; j != 18; ++j) - KB[j] = rotate_left(KB[j], 6); - for(size_t j = 0; j != 16; ++j) - m_EK[16*i+j+8] = KB[KEY_INDEX[16*i+j]] + BIAS[16*i+j]; - } - } - -void SAFER_SK::clear() - { - zap(m_EK); - } - -/* -* Return the name of this type -*/ -std::string SAFER_SK::name() const - { - return "SAFER-SK(" + std::to_string(m_rounds) + ")"; - } - -/* -* Return a clone of this object -*/ -BlockCipher* SAFER_SK::clone() const - { - return new SAFER_SK(m_rounds); - } - -/* -* SAFER-SK Constructor -*/ -SAFER_SK::SAFER_SK(size_t r) : m_rounds(r) - { - if(m_rounds > 13 || m_rounds == 0) - throw Invalid_Argument(name() + ": Invalid number of rounds"); - } - -} diff --git a/src/lib/block/safer/safer_sk.h b/src/lib/block/safer/safer_sk.h deleted file mode 100644 index af944b36c..000000000 --- a/src/lib/block/safer/safer_sk.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -* SAFER-SK -* (C) 1999-2007 Jack Lloyd -* -* Botan is released under the Simplified BSD License (see license.txt) -*/ - -#ifndef BOTAN_SAFER_SK_H__ -#define BOTAN_SAFER_SK_H__ - -#include <botan/block_cipher.h> - -namespace Botan { - -/** -* SAFER-SK -*/ -class BOTAN_DLL SAFER_SK final : public Block_Cipher_Fixed_Params<8, 16> - { - public: - void encrypt_n(const byte in[], byte out[], size_t blocks) const override; - void decrypt_n(const byte in[], byte out[], size_t blocks) const override; - - void clear() override; - std::string name() const override; - BlockCipher* clone() const override; - - /** - * @param rounds the number of rounds to use - must be between 1 - * and 13 - */ - explicit SAFER_SK(size_t rounds); - private: - void key_schedule(const byte[], size_t) override; - - size_t m_rounds; - secure_vector<byte> m_EK; - }; - -} - -#endif diff --git a/src/lib/block/tea/info.txt b/src/lib/block/tea/info.txt deleted file mode 100644 index 14edfdb03..000000000 --- a/src/lib/block/tea/info.txt +++ /dev/null @@ -1 +0,0 @@ -define TEA 20131128 diff --git a/src/lib/block/tea/tea.cpp b/src/lib/block/tea/tea.cpp deleted file mode 100644 index 457171e1d..000000000 --- a/src/lib/block/tea/tea.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* -* TEA -* (C) 1999-2007 Jack Lloyd -* -* Botan is released under the Simplified BSD License (see license.txt) -*/ - -#include <botan/tea.h> -#include <botan/loadstor.h> - -namespace Botan { - -/* -* TEA Encryption -*/ -void TEA::encrypt_n(const byte in[], byte out[], size_t blocks) const - { - for(size_t i = 0; i != blocks; ++i) - { - u32bit L = load_be<u32bit>(in, 0); - u32bit R = load_be<u32bit>(in, 1); - - u32bit S = 0; - for(size_t j = 0; j != 32; ++j) - { - S += 0x9E3779B9; - L += ((R << 4) + m_K[0]) ^ (R + S) ^ ((R >> 5) + m_K[1]); - R += ((L << 4) + m_K[2]) ^ (L + S) ^ ((L >> 5) + m_K[3]); - } - - store_be(out, L, R); - - in += BLOCK_SIZE; - out += BLOCK_SIZE; - } - } - -/* -* TEA Decryption -*/ -void TEA::decrypt_n(const byte in[], byte out[], size_t blocks) const - { - for(size_t i = 0; i != blocks; ++i) - { - u32bit L = load_be<u32bit>(in, 0); - u32bit R = load_be<u32bit>(in, 1); - - u32bit S = 0xC6EF3720; - for(size_t j = 0; j != 32; ++j) - { - R -= ((L << 4) + m_K[2]) ^ (L + S) ^ ((L >> 5) + m_K[3]); - L -= ((R << 4) + m_K[0]) ^ (R + S) ^ ((R >> 5) + m_K[1]); - S -= 0x9E3779B9; - } - - store_be(out, L, R); - - in += BLOCK_SIZE; - out += BLOCK_SIZE; - } - } - -/* -* TEA Key Schedule -*/ -void TEA::key_schedule(const byte key[], size_t) - { - m_K.resize(4); - for(size_t i = 0; i != 4; ++i) - m_K[i] = load_be<u32bit>(key, i); - } - -void TEA::clear() - { - zap(m_K); - } - -} diff --git a/src/lib/block/tea/tea.h b/src/lib/block/tea/tea.h deleted file mode 100644 index 6b6308381..000000000 --- a/src/lib/block/tea/tea.h +++ /dev/null @@ -1,34 +0,0 @@ -/* -* TEA -* (C) 1999-2007 Jack Lloyd -* -* Botan is released under the Simplified BSD License (see license.txt) -*/ - -#ifndef BOTAN_TEA_H__ -#define BOTAN_TEA_H__ - -#include <botan/block_cipher.h> - -namespace Botan { - -/** -* TEA -*/ -class BOTAN_DLL TEA final : public Block_Cipher_Fixed_Params<8, 16> - { - public: - void encrypt_n(const byte in[], byte out[], size_t blocks) const override; - void decrypt_n(const byte in[], byte out[], size_t blocks) const override; - - void clear() override; - std::string name() const override { return "TEA"; } - BlockCipher* clone() const override { return new TEA; } - private: - void key_schedule(const byte[], size_t) override; - secure_vector<u32bit> m_K; - }; - -} - -#endif |