summaryrefslogtreecommitdiff
path: root/cryptlib.h
diff options
context:
space:
mode:
authorweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2006-12-10 02:12:23 +0000
committerweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2006-12-10 02:12:23 +0000
commitc3bad1afc1564f3bfac8434d45d6694811139333 (patch)
treeebfbbcf4dffdf4914b9ce879d3d2c93d3615f7ab /cryptlib.h
parente553818e00684e8905ede16e53aa490c153b7e7a (diff)
downloadcryptopp-c3bad1afc1564f3bfac8434d45d6694811139333.tar.gz
port to GCC 4, reorganize implementations of SetKey
git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@248 57ff6487-cd31-0410-9ec3-f628ee90f5f0
Diffstat (limited to 'cryptlib.h')
-rw-r--r--cryptlib.h19
1 files changed, 10 insertions, 9 deletions
diff --git a/cryptlib.h b/cryptlib.h
index 5851d95..aaa8a31 100644
--- a/cryptlib.h
+++ b/cryptlib.h
@@ -367,7 +367,7 @@ public:
//! set or reset the key of this object
/*! \param params is used to specify Rounds, BlockSize, etc */
- virtual void SetKey(const byte *key, size_t length, const NameValuePairs &params = g_nullNameValuePairs) =0;
+ virtual void SetKey(const byte *key, size_t length, const NameValuePairs &params = g_nullNameValuePairs);
//! calls SetKey() with an NameValuePairs object that just specifies "Rounds"
void SetKeyWithRounds(const byte *key, size_t length, int rounds);
@@ -400,15 +400,15 @@ public:
virtual void GetNextIV(byte *IV) {throw NotImplemented("SimpleKeyingInterface: this object doesn't support GetNextIV()");}
protected:
- void ThrowIfInvalidKeyLength(const Algorithm &algorithm, size_t length);
+ virtual const Algorithm & GetAlgorithm() const =0;
+ virtual void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs &params) =0;
+
+ void ThrowIfInvalidKeyLength(size_t length);
void ThrowIfResynchronizable(); // to be called when no IV is passed
void ThrowIfInvalidIV(const byte *iv); // check for NULL IV if it can't be used
const byte * GetIVAndThrowIfInvalid(const NameValuePairs &params);
-
inline void AssertValidKeyLength(size_t length) const
- {
- assert(IsValidKeyLength(length));
- }
+ {assert(IsValidKeyLength(length));}
};
//! interface for the data processing part of block ciphers
@@ -451,6 +451,8 @@ public:
//! encrypt or decrypt multiple blocks, for bit-slicing implementations
virtual void ProcessAndXorMultipleBlocks(const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t numberOfBlocks) const;
+
+ inline CipherDir GetCipherDirection() const {return IsForwardTransformation() ? ENCRYPTION : DECRYPTION;}
};
//! interface for the data processing part of stream ciphers
@@ -590,9 +592,8 @@ typedef HashTransformation HashFunction;
template <class T>
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE SimpleKeyedTransformation : public T, public SimpleKeyingInterface
{
-public:
- void ThrowIfInvalidKeyLength(size_t length)
- {SimpleKeyingInterface::ThrowIfInvalidKeyLength(*this, length);}
+protected:
+ const Algorithm & GetAlgorithm() const {return *this;}
};
#ifdef CRYPTOPP_DOXYGEN_PROCESSING