From e8722fcff88a3d34b7efb6f10ae9caa89dd94fff Mon Sep 17 00:00:00 2001 From: brain Date: Sat, 18 Nov 2006 17:31:01 +0000 Subject: Change from dos to unix line endings (how did these get in here?) git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5765 e03df62e-2008-0410-955e-edbf42e46eb7 --- include/aes.h | 418 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 209 insertions(+), 209 deletions(-) (limited to 'include/aes.h') diff --git a/include/aes.h b/include/aes.h index b14338e7a..05f947084 100644 --- a/include/aes.h +++ b/include/aes.h @@ -1,209 +1,209 @@ -#ifndef __AES_H__ -#define __AES_H__ - -#include -#include "inspircd_config.h" -#include "base.h" - -using namespace std; - -/** The AES class is a utility class for use in modules and the core for encryption of data. - */ -class AES : public classbase -{ -public: - enum { ECB=0, CBC=1, CFB=2 }; - -private: - enum { DEFAULT_BLOCK_SIZE=16 }; - enum { MAX_BLOCK_SIZE=32, MAX_ROUNDS=14, MAX_KC=8, MAX_BC=8 }; - - static int Mul(int a, int b) - { - return (a != 0 && b != 0) ? sm_alog[(sm_log[a & 0xFF] + sm_log[b & 0xFF]) % 255] : 0; - } - - /** Convenience method used in generating Transposition Boxes - */ - static int Mul4(int a, char b[]) - { - if(a == 0) - return 0; - a = sm_log[a & 0xFF]; - int a0 = (b[0] != 0) ? sm_alog[(a + sm_log[b[0] & 0xFF]) % 255] & 0xFF : 0; - int a1 = (b[1] != 0) ? sm_alog[(a + sm_log[b[1] & 0xFF]) % 255] & 0xFF : 0; - int a2 = (b[2] != 0) ? sm_alog[(a + sm_log[b[2] & 0xFF]) % 255] & 0xFF : 0; - int a3 = (b[3] != 0) ? sm_alog[(a + sm_log[b[3] & 0xFF]) % 255] & 0xFF : 0; - return a0 << 24 | a1 << 16 | a2 << 8 | a3; - } - -public: - AES(); - - virtual ~AES(); - - /** Expand a user-supplied key material into a session key. - * - * @param key The 128/192/256-bit user-key to use. - * @param chain Initial chain block for CBC and CFB modes. - * @param keylength 16, 24 or 32 bytes - * @param blockSize The block size in bytes of this Rijndael (16, 24 or 32 bytes). - */ - void MakeKey(char const* key, char const* chain, int keylength=DEFAULT_BLOCK_SIZE, int blockSize=DEFAULT_BLOCK_SIZE); - -private: - /** Auxiliary Function - */ - void Xor(char* buff, char const* chain) - { - if(false==m_bKeyInit) - return; - for(int i=0; i +#include "inspircd_config.h" +#include "base.h" + +using namespace std; + +/** The AES class is a utility class for use in modules and the core for encryption of data. + */ +class AES : public classbase +{ +public: + enum { ECB=0, CBC=1, CFB=2 }; + +private: + enum { DEFAULT_BLOCK_SIZE=16 }; + enum { MAX_BLOCK_SIZE=32, MAX_ROUNDS=14, MAX_KC=8, MAX_BC=8 }; + + static int Mul(int a, int b) + { + return (a != 0 && b != 0) ? sm_alog[(sm_log[a & 0xFF] + sm_log[b & 0xFF]) % 255] : 0; + } + + /** Convenience method used in generating Transposition Boxes + */ + static int Mul4(int a, char b[]) + { + if(a == 0) + return 0; + a = sm_log[a & 0xFF]; + int a0 = (b[0] != 0) ? sm_alog[(a + sm_log[b[0] & 0xFF]) % 255] & 0xFF : 0; + int a1 = (b[1] != 0) ? sm_alog[(a + sm_log[b[1] & 0xFF]) % 255] & 0xFF : 0; + int a2 = (b[2] != 0) ? sm_alog[(a + sm_log[b[2] & 0xFF]) % 255] & 0xFF : 0; + int a3 = (b[3] != 0) ? sm_alog[(a + sm_log[b[3] & 0xFF]) % 255] & 0xFF : 0; + return a0 << 24 | a1 << 16 | a2 << 8 | a3; + } + +public: + AES(); + + virtual ~AES(); + + /** Expand a user-supplied key material into a session key. + * + * @param key The 128/192/256-bit user-key to use. + * @param chain Initial chain block for CBC and CFB modes. + * @param keylength 16, 24 or 32 bytes + * @param blockSize The block size in bytes of this Rijndael (16, 24 or 32 bytes). + */ + void MakeKey(char const* key, char const* chain, int keylength=DEFAULT_BLOCK_SIZE, int blockSize=DEFAULT_BLOCK_SIZE); + +private: + /** Auxiliary Function + */ + void Xor(char* buff, char const* chain) + { + if(false==m_bKeyInit) + return; + for(int i=0; i