aboutsummaryrefslogtreecommitdiff
path: root/aes.cpp
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2016-10-09 21:43:38 +0200
committertomsmeding <tom.smeding@gmail.com>2016-10-09 21:43:38 +0200
commitcbea7bc041e5c14670042e3e52f0786f9561af05 (patch)
tree4d646978f1ed984099828a65c92bcee0a72b47dc /aes.cpp
parentd6dd94c63252ace898d9a60a539c7ab14d69f0ea (diff)
Better error handling (exceptions)
Diffstat (limited to 'aes.cpp')
-rw-r--r--aes.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/aes.cpp b/aes.cpp
index 29fc7fc..7430717 100644
--- a/aes.cpp
+++ b/aes.cpp
@@ -248,7 +248,9 @@ namespace AES{
case AES_256_CBC: increment=2; break;
default: assert(false);
}
- assert((int)key.size()==4*(4+2*increment));
+ if((int)key.size()!=4*(4+2*increment)){
+ throw invalid_argument("Invalid AES key length");
+ }
return decryptCBC(data,key,10+2*increment);
}