diff options
author | Jack Lloyd <[email protected]> | 2017-10-26 20:31:30 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2017-10-26 22:26:15 -0400 |
commit | e6d45052efedfe49e99adb6318aaf56e0a9e8d7b (patch) | |
tree | c6c3ccd3cff3d04285940bf1d518c809e0653947 /src/lib/base | |
parent | 315b002ecf00f6b6bb0f0d5200d1f39a83527e8f (diff) |
Add checks that keyed algorithms are actually keyed before use
Previously calling update or encrypt without calling set_key first
would result in invalid outputs or else crashing.
Diffstat (limited to 'src/lib/base')
-rw-r--r-- | src/lib/base/sym_algo.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/lib/base/sym_algo.h b/src/lib/base/sym_algo.h index a596f5932..a0ebac626 100644 --- a/src/lib/base/sym_algo.h +++ b/src/lib/base/sym_algo.h @@ -91,6 +91,13 @@ class BOTAN_PUBLIC_API(2,0) SymmetricAlgorithm */ virtual std::string name() const = 0; + protected: + void verify_key_set(bool cond) const + { + if(cond == false) + throw Key_Not_Set(name()); + } + private: /** * Run the key schedule |