00001 /* 00002 * lib/crypto/bcipherbase.h 00003 * 00004 * Include header for a cryptographic block cipher base class. 00005 * 00006 * Copyright (c) 2001--2004 by Wolfgang Wieser ] wwieser (a) gmx <*> de [ 00007 * 00008 * This file may be distributed and/or modified under the terms of the 00009 * GNU General Public License version 2 as published by the Free Software 00010 * Foundation. (See COPYING.GPL for details.) 00011 * 00012 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00013 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00014 * 00015 */ 00016 00017 #ifndef _LIB_CRYPTO_BlockCipherBase_H_ 00018 #define _LIB_CRYPTO_BlockCipherBase_H_ 1 00019 00026 #include <lib/sconfig.h> /* MUST be first */ 00027 00028 00042 class BlockCipherBase 00043 { 00044 public: 00046 struct Parameters 00047 { 00048 size_t block_size; 00049 int n_key_lengths; 00050 00051 00052 const size_t *key_length; 00053 int cipher_ID; 00054 const char *name; 00055 }; 00056 00057 public: 00060 static const Parameters par; 00061 00062 private: 00064 BlockCipherBase(const BlockCipherBase &); 00065 void operator=(const BlockCipherBase &); 00066 public: 00068 BlockCipherBase() { } 00070 virtual ~BlockCipherBase() { } 00071 00081 virtual const Parameters *GetPar() const 00082 { return(&BlockCipherBase::par); } 00083 00086 virtual int SetKey(char *key,size_t len); 00087 00098 virtual int CheckWeakKey(); 00099 00110 00111 virtual void EncryptBlock(char *ibuf,char *obuf); 00112 virtual void DecryptBlock(char *ibuf,char *obuf); 00114 00124 virtual int CopyFrom(BlockCipherBase *bcb); 00125 }; 00126 00127 #endif /* _LIB_CRYPTO_BlockCipherBase_H_ */