From c3bad1afc1564f3bfac8434d45d6694811139333 Mon Sep 17 00:00:00 2001 From: weidai Date: Sun, 10 Dec 2006 02:12:23 +0000 Subject: 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 --- cryptlib.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'cryptlib.cpp') diff --git a/cryptlib.cpp b/cryptlib.cpp index fe0d764..642d5f2 100644 --- a/cryptlib.cpp +++ b/cryptlib.cpp @@ -47,6 +47,12 @@ Algorithm::Algorithm(bool checkSelfTestStatus) } } +void SimpleKeyingInterface::SetKey(const byte *key, size_t length, const NameValuePairs ¶ms) +{ + this->ThrowIfInvalidKeyLength(length); + this->UncheckedSetKey(key, (unsigned int)length, params); +} + void SimpleKeyingInterface::SetKeyWithRounds(const byte *key, size_t length, int rounds) { SetKey(key, length, MakeParameters(Name::Rounds(), rounds)); @@ -57,22 +63,22 @@ void SimpleKeyingInterface::SetKeyWithIV(const byte *key, size_t length, const b SetKey(key, length, MakeParameters(Name::IV(), iv)); } -void SimpleKeyingInterface::ThrowIfInvalidKeyLength(const Algorithm &algorithm, size_t length) +void SimpleKeyingInterface::ThrowIfInvalidKeyLength(size_t length) { if (!IsValidKeyLength(length)) - throw InvalidKeyLength(algorithm.AlgorithmName(), length); + throw InvalidKeyLength(GetAlgorithm().AlgorithmName(), length); } void SimpleKeyingInterface::ThrowIfResynchronizable() { if (IsResynchronizable()) - throw InvalidArgument("SimpleKeyingInterface: this object requires an IV"); + throw InvalidArgument(GetAlgorithm().AlgorithmName() + ": this object requires an IV"); } void SimpleKeyingInterface::ThrowIfInvalidIV(const byte *iv) { if (!iv && !(IVRequirement() == INTERNALLY_GENERATED_IV || IVRequirement() == STRUCTURED_IV || !IsResynchronizable())) - throw InvalidArgument("SimpleKeyingInterface: this object cannot use a null IV"); + throw InvalidArgument(GetAlgorithm().AlgorithmName() + ": this object cannot use a null IV"); } const byte * SimpleKeyingInterface::GetIVAndThrowIfInvalid(const NameValuePairs ¶ms) -- cgit v1.2.1