00001 //---------------------------------------------------------------------------- 00004 // 00005 // (C) 2003-2006 Celartem Technology Inc. All rights reserved. 00006 //---------------------------------------------------------------------------- 00007 00008 #ifndef _cel_crypt_h_ 00009 #define _cel_crypt_h_ 00010 00011 #include "cel_types.h" 00012 #include "cel_referable.h" 00013 #include "cel_storage.h" 00014 00015 namespace Celartem 00016 { 00020 class BlockCipher : public Referable 00021 { 00022 public: 00023 virtual ~BlockCipher() {} 00024 00030 virtual const char *getName() const = 0; 00031 00037 virtual size_t getMinimumKeyByteLength() const = 0; 00038 00044 virtual size_t getMaximumKeyByteLength() const = 0; 00045 00058 virtual void init( 00059 const void *inKey, size_t inKeyByteLength) = 0; 00060 00066 virtual size_t getBlockLength() const = 0; 00067 00081 virtual void encrypt( 00082 void* CEL_RESTRICT outResult, 00083 const void* CEL_RESTRICT inData) const = 0; 00084 00098 virtual void decrypt( 00099 void* CEL_RESTRICT outResult, 00100 const void* CEL_RESTRICT inData) const = 0; 00101 00107 virtual AutoPtr<BlockCipher> duplicate() const = 0; 00108 00121 static AutoPtr<BlockCipher> create(const String& inCipherName); 00122 }; 00123 00127 class CipherStream : public Stream 00128 { 00129 public: 00138 static AutoPtr<CipherStream> create( 00139 Storage* inStorage, 00140 const BlockCipher* inCipher, 00141 u32 inSalt); 00142 00149 static AutoPtr<CipherStream> create( 00150 Stream* inStream, 00151 const BlockCipher* inCipher); 00152 }; 00153 } 00154 00155 #endif // _cel_crypt_h_