diff options
author | Francis Dupont <fdupont@isc.org> | 2017-01-12 23:35:08 +0100 |
---|---|---|
committer | Francis Dupont <fdupont@isc.org> | 2017-01-12 23:35:08 +0100 |
commit | fa68968aeb3df94b8e229b54d288032c7d9d6134 (patch) | |
tree | cafb730e9f27ef9c3a039dd7b3853cf360504fca | |
parent | [4633] Addressed some comments (diff) | |
download | kea-fa68968aeb3df94b8e229b54d288032c7d9d6134.tar.xz kea-fa68968aeb3df94b8e229b54d288032c7d9d6134.zip |
[4633] Decorated library errors
-rw-r--r-- | src/lib/cryptolink/botan_hash.cc | 17 | ||||
-rw-r--r-- | src/lib/cryptolink/botan_hmac.cc | 16 | ||||
-rw-r--r-- | src/lib/cryptolink/botan_link.cc | 4 | ||||
-rw-r--r-- | src/lib/cryptolink/openssl_hash.cc | 5 | ||||
-rw-r--r-- | src/lib/cryptolink/openssl_hmac.cc | 22 |
5 files changed, 35 insertions, 29 deletions
diff --git a/src/lib/cryptolink/botan_hash.cc b/src/lib/cryptolink/botan_hash.cc index 8e87786c42..0ed47e50b8 100644 --- a/src/lib/cryptolink/botan_hash.cc +++ b/src/lib/cryptolink/botan_hash.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2016 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2014-2017 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -74,7 +74,8 @@ public: "Unknown hash algorithm: " << static_cast<int>(hash_algorithm)); } catch (const Botan::Exception& exc) { - isc_throw(isc::cryptolink::LibraryError, exc.what()); + isc_throw(isc::cryptolink::LibraryError, + "Botan error: " << exc.what()); } hash_.reset(hash); @@ -110,7 +111,8 @@ public: try { hash_->update(static_cast<const Botan::byte*>(data), len); } catch (const Botan::Exception& exc) { - isc_throw(isc::cryptolink::LibraryError, exc.what()); + isc_throw(isc::cryptolink::LibraryError, + "Botan error: " << exc.what()); } } @@ -126,7 +128,8 @@ public: } result.writeData(&b_result[0], len); } catch (const Botan::Exception& exc) { - isc_throw(isc::cryptolink::LibraryError, exc.what()); + isc_throw(isc::cryptolink::LibraryError, + "Botan error: " << exc.what()); } } @@ -142,7 +145,8 @@ public: } std::memcpy(result, &b_result[0], output_size); } catch (const Botan::Exception& exc) { - isc_throw(isc::cryptolink::LibraryError, exc.what()); + isc_throw(isc::cryptolink::LibraryError, + "Botan error: " << exc.what()); } } @@ -157,7 +161,8 @@ public: } return (std::vector<uint8_t>(&b_result[0], &b_result[len])); } catch (const Botan::Exception& exc) { - isc_throw(isc::cryptolink::LibraryError, exc.what()); + isc_throw(isc::cryptolink::LibraryError, + "Botan error: " << exc.what()); } } diff --git a/src/lib/cryptolink/botan_hmac.cc b/src/lib/cryptolink/botan_hmac.cc index 713dad1bb0..0471e2b24e 100644 --- a/src/lib/cryptolink/botan_hmac.cc +++ b/src/lib/cryptolink/botan_hmac.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2011-2016 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2011-2017 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -58,7 +58,7 @@ public: "Unknown hash algorithm: " << static_cast<int>(hash_algorithm)); } catch (const Botan::Exception& exc) { - isc_throw(LibraryError, exc.what()); + isc_throw(LibraryError, "Botan error: " << exc.what()); } hmac_.reset(new Botan::HMAC(hash)); @@ -94,7 +94,7 @@ public: } catch (const Botan::Invalid_Key_Length& ikl) { isc_throw(BadKey, ikl.what()); } catch (const Botan::Exception& exc) { - isc_throw(LibraryError, exc.what()); + isc_throw(LibraryError, "Botan error: " << exc.what()); } } @@ -129,7 +129,7 @@ public: try { hmac_->update(static_cast<const Botan::byte*>(data), len); } catch (const Botan::Exception& exc) { - isc_throw(LibraryError, exc.what()); + isc_throw(LibraryError, "Botan error: " << exc.what()); } } @@ -145,7 +145,7 @@ public: } result.writeData(&b_result[0], len); } catch (const Botan::Exception& exc) { - isc_throw(LibraryError, exc.what()); + isc_throw(LibraryError, "Botan error: " << exc.what()); } } @@ -161,7 +161,7 @@ public: } std::memcpy(result, &b_result[0], output_size); } catch (const Botan::Exception& exc) { - isc_throw(LibraryError, exc.what()); + isc_throw(LibraryError, "Botan error: " << exc.what()); } } @@ -176,7 +176,7 @@ public: } return (std::vector<uint8_t>(&b_result[0], &b_result[len])); } catch (const Botan::Exception& exc) { - isc_throw(LibraryError, exc.what()); + isc_throw(LibraryError, "Botan error: " << exc.what()); } } @@ -203,7 +203,7 @@ public: static_cast<const unsigned char*>(sig), len)); } catch (const Botan::Exception& exc) { - isc_throw(LibraryError, exc.what()); + isc_throw(LibraryError, "Botan error: " << exc.what()); } } diff --git a/src/lib/cryptolink/botan_link.cc b/src/lib/cryptolink/botan_link.cc index 965d1256e9..b05e51d5d8 100644 --- a/src/lib/cryptolink/botan_link.cc +++ b/src/lib/cryptolink/botan_link.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2011-2015 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2011-2015,2017 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -31,7 +31,7 @@ CryptoLink::initialize() { try { c.impl_ = new CryptoLinkImpl(); } catch (const Botan::Exception& ex) { - isc_throw(InitializationError, ex.what()); + isc_throw(InitializationError, "Botan error: " << ex.what()); } } } diff --git a/src/lib/cryptolink/openssl_hash.cc b/src/lib/cryptolink/openssl_hash.cc index 6b19c6fcbe..4d68a32033 100644 --- a/src/lib/cryptolink/openssl_hash.cc +++ b/src/lib/cryptolink/openssl_hash.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2016 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2014-2017 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -67,7 +67,8 @@ public: md_ = EVP_MD_CTX_new(); if (md_ == 0) { - isc_throw(isc::cryptolink::LibraryError, "EVP_MD_CTX_new"); + isc_throw(isc::cryptolink::LibraryError, + "OpenSSL EVP_MD_CTX_new() failed"); } EVP_DigestInit_ex(md_, algo, NULL); diff --git a/src/lib/cryptolink/openssl_hmac.cc b/src/lib/cryptolink/openssl_hmac.cc index 0da7278f11..5529858371 100644 --- a/src/lib/cryptolink/openssl_hmac.cc +++ b/src/lib/cryptolink/openssl_hmac.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2016 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2014-2017 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -46,13 +46,13 @@ public: md_ = HMAC_CTX_new(); if (md_ == 0) { - isc_throw(LibraryError, "HMAC_CTX_new"); + isc_throw(LibraryError, "OpenSSL HMAC_CTX_new() failed"); } if (!HMAC_Init_ex(md_, secret, static_cast<int>(secret_len), algo, NULL)) { - isc_throw(LibraryError, "HMAC_Init_ex"); + isc_throw(LibraryError, "OpenSSL HMAC_Init_ex() failed"); } } @@ -75,7 +75,7 @@ public: size_t getOutputLength() const { int size = HMAC_size(md_); if (size < 0) { - isc_throw(LibraryError, "HMAC_size"); + isc_throw(LibraryError, "OpenSSL HMAC_size() failed"); } return (static_cast<size_t>(size)); } @@ -87,7 +87,7 @@ public: if (!HMAC_Update(md_, static_cast<const unsigned char*>(data), len)) { - isc_throw(LibraryError, "HMAC_Update"); + isc_throw(LibraryError, "OpenSSLHMAC_Update() failed"); } } @@ -98,7 +98,7 @@ public: size_t size = getOutputLength(); ossl::SecBuf<unsigned char> digest(size); if (!HMAC_Final(md_, &digest[0], NULL)) { - isc_throw(LibraryError, "HMAC_Final"); + isc_throw(LibraryError, "OpenSSL HMAC_Final() failed"); } if (len > size) { len = size; @@ -113,7 +113,7 @@ public: size_t size = getOutputLength(); ossl::SecBuf<unsigned char> digest(size); if (!HMAC_Final(md_, &digest[0], NULL)) { - isc_throw(LibraryError, "HMAC_Final"); + isc_throw(LibraryError, "OpenSSL HMAC_Final() failed"); } if (len > size) { len = size; @@ -128,7 +128,7 @@ public: size_t size = getOutputLength(); ossl::SecBuf<unsigned char> digest(size); if (!HMAC_Final(md_, &digest[0], NULL)) { - isc_throw(LibraryError, "HMAC_Final"); + isc_throw(LibraryError, "OpenSSL HMAC_Final() failed"); } if (len < size) { digest.resize(len); @@ -148,16 +148,16 @@ public: // Get the digest from a copy of the context HMAC_CTX* tmp = HMAC_CTX_new(); if (tmp == 0) { - isc_throw(LibraryError, "HMAC_CTX_new"); + isc_throw(LibraryError, "OpenSSL HMAC_CTX_new() failed"); } if (!HMAC_CTX_copy(tmp, md_)) { HMAC_CTX_free(tmp); - isc_throw(LibraryError, "HMAC_CTX_copy"); + isc_throw(LibraryError, "OpenSSL HMAC_CTX_copy() failed"); } ossl::SecBuf<unsigned char> digest(size); if (!HMAC_Final(tmp, &digest[0], NULL)) { HMAC_CTX_free(tmp); - isc_throw(LibraryError, "HMAC_Final"); + isc_throw(LibraryError, "OpenSSL HMAC_Final() failed"); } HMAC_CTX_free(tmp); if (len > size) { |