summaryrefslogtreecommitdiff
path: root/cryptlib.cpp
diff options
context:
space:
mode:
authorweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2003-03-26 21:50:44 +0000
committerweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2003-03-26 21:50:44 +0000
commit0a0244dacface689335de6e0edf978b29ddb66e1 (patch)
treeef84fa621368e7bce53a7708b5188ae8df1d9ed3 /cryptlib.cpp
parent79694912becd37f5f0077464350f3db55dd2ca7c (diff)
downloadcryptopp-0a0244dacface689335de6e0edf978b29ddb66e1.tar.gz
fix bugs in SEAL and Panama
git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@54 57ff6487-cd31-0410-9ec3-f628ee90f5f0
Diffstat (limited to 'cryptlib.cpp')
-rw-r--r--cryptlib.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/cryptlib.cpp b/cryptlib.cpp
index e3fe2d5..07dd87c 100644
--- a/cryptlib.cpp
+++ b/cryptlib.cpp
@@ -57,6 +57,28 @@ void SimpleKeyingInterface::ThrowIfInvalidKeyLength(const Algorithm &algorithm,
throw InvalidKeyLength(algorithm.AlgorithmName(), length);
}
+void SimpleKeyingInterface::ThrowIfResynchronizable()
+{
+ if (IsResynchronizable())
+ throw InvalidArgument("SimpleKeyingInterface: 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");
+}
+
+const byte * SimpleKeyingInterface::GetIVAndThrowIfInvalid(const NameValuePairs &params)
+{
+ const byte *iv;
+ if (params.GetValue(Name::IV(), iv))
+ ThrowIfInvalidIV(iv);
+ else
+ ThrowIfResynchronizable();
+ return iv;
+}
+
void BlockTransformation::ProcessAndXorMultipleBlocks(const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, unsigned int numberOfBlocks) const
{
unsigned int blockSize = BlockSize();