From cbea7bc041e5c14670042e3e52f0786f9561af05 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Sun, 9 Oct 2016 21:43:38 +0200 Subject: Better error handling (exceptions) --- envelope/envelope | Bin 0 -> 121056 bytes envelope/main.cpp | 23 ++++++++++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) create mode 100755 envelope/envelope (limited to 'envelope') diff --git a/envelope/envelope b/envelope/envelope new file mode 100755 index 0000000..599c263 Binary files /dev/null and b/envelope/envelope differ diff --git a/envelope/main.cpp b/envelope/main.cpp index f0e544e..3889c2a 100644 --- a/envelope/main.cpp +++ b/envelope/main.cpp @@ -52,7 +52,13 @@ void mode_keygen(int keylength){ } void mode_encrypt(const string &pubkeyrepr){ - RSA::Key key(RSA::importKey(pubkeyrepr)); + RSA::Key key; + try { + key=RSA::importKey(pubkeyrepr); + } catch(invalid_argument){ + cerr<<"The given public key is not a valid key!"<