diff options
author | Bartlomiej Grzelewski <b.grzelewski@samsung.com> | 2016-03-09 18:22:48 +0100 |
---|---|---|
committer | kyungwook tak <k.tak@samsung.com> | 2016-07-14 21:34:44 -0700 |
commit | a3740cdb1f6f2a2cf161453637a178237adc0ed3 (patch) | |
tree | cbf8c992544d4087ef6202dfc5fffb0e8b0279fd | |
parent | b4d6ae17bf61f9ee85d96634ebc544324adb21a2 (diff) | |
download | key-manager-a3740cdb1f6f2a2cf161453637a178237adc0ed3.tar.gz key-manager-a3740cdb1f6f2a2cf161453637a178237adc0ed3.tar.bz2 key-manager-a3740cdb1f6f2a2cf161453637a178237adc0ed3.zip |
Replace old exception with new ones.
Change-Id: I3390d6ff8a7d8e1594847fd87625144e11ec0f69
-rw-r--r-- | src/manager/client-async/client-manager-async-impl.cpp | 5 | ||||
-rw-r--r-- | src/manager/client/client-common.cpp | 8 | ||||
-rw-r--r-- | src/manager/client/client-manager-impl.cpp | 8 | ||||
-rw-r--r-- | src/manager/common/base64.cpp | 38 | ||||
-rw-r--r-- | src/manager/common/base64.h | 15 | ||||
-rw-r--r-- | src/manager/common/data-type.cpp | 24 | ||||
-rw-r--r-- | src/manager/common/data-type.h | 10 | ||||
-rw-r--r-- | src/manager/crypto/sw-backend/internals.cpp | 6 | ||||
-rw-r--r-- | src/manager/service/ckm-service.cpp | 2 | ||||
-rw-r--r-- | src/manager/service/crypto-logic.cpp | 117 | ||||
-rw-r--r-- | tests/test_base64.cpp | 13 | ||||
-rw-r--r-- | tests/test_data-type.cpp | 9 |
12 files changed, 105 insertions, 150 deletions
diff --git a/src/manager/client-async/client-manager-async-impl.cpp b/src/manager/client-async/client-manager-async-impl.cpp index 5b9fbf36..96454cbd 100644 --- a/src/manager/client-async/client-manager-async-impl.cpp +++ b/src/manager/client-async/client-manager-async-impl.cpp @@ -24,6 +24,7 @@ #include <ckm/ckm-error.h> #include <message-buffer.h> #include <client-common.h> +#include <exception.h> #include <client-manager-async-impl.h> @@ -49,8 +50,8 @@ void ManagerAsync::Impl::saveKey(const ObserverPtr &observer, try { saveBinaryData(observer, alias, DataType(key->getType()), key->getDER(), policy); - } catch (const DataType::Exception::Base &) { - observer->ReceivedError(CKM_API_ERROR_INPUT_PARAM); + } catch (const Exc::Exception &e) { + observer->ReceivedError(e.error()); } } diff --git a/src/manager/client/client-common.cpp b/src/manager/client/client-common.cpp index c50a71aa..d0c7a2f5 100644 --- a/src/manager/client/client-common.cpp +++ b/src/manager/client/client-common.cpp @@ -328,8 +328,6 @@ int try_catch(const std::function<int()> &func) return func(); } catch (const MessageBuffer::Exception::Base &e) { LogError("CKM::MessageBuffer::Exception " << e.DumpToString()); - } catch (const DataType::Exception::Base &e) { - LogError("CKM::DBDataType::Exception " << e.DumpToString()); } catch (const std::exception &e) { LogError("STD exception " << e.what()); } catch (...) { @@ -363,9 +361,9 @@ void try_catch_async(const std::function<void()> &func, } catch (const MessageBuffer::Exception::Base &e) { LogError("CKM::MessageBuffer::Exception " << e.DumpToString()); error(CKM_API_ERROR_BAD_REQUEST); - } catch (const DataType::Exception::Base &e) { - LogError("CKM::DBDataType conversion failed:" << e.DumpToString()); - error(CKM_API_ERROR_UNKNOWN); + } catch (const Exc::Exception &e) { + LogError("Exception: " << e.what()); + error(e.error()); } catch (const std::exception &e) { LogError("STD exception " << e.what()); error(CKM_API_ERROR_UNKNOWN); diff --git a/src/manager/client/client-manager-impl.cpp b/src/manager/client/client-manager-impl.cpp index 78c10768..f1b68bb1 100644 --- a/src/manager/client/client-manager-impl.cpp +++ b/src/manager/client/client-manager-impl.cpp @@ -26,6 +26,7 @@ #include <crypto-init.h> #include <client-manager-impl.h> #include <client-common.h> +#include <exception.h> #include <message-buffer.h> #include <protocols.h> #include <key-impl.h> @@ -147,11 +148,10 @@ int Manager::Impl::saveKey(const Alias &alias, const KeyShPtr &key, try { return saveBinaryData(alias, DataType(key->getType()), key->getDER(), policy); - } catch (const DataType::Exception::Base &) { - LogError("Error in key conversion. Could not convert KeyType::NONE to DBDataType!"); + } catch (const Exc::Exception &e) { + LogError("Exception: " << e.what()); + return e.error(); } - - return CKM_API_ERROR_INPUT_PARAM; } int Manager::Impl::saveCertificate( diff --git a/src/manager/common/base64.cpp b/src/manager/common/base64.cpp index 1e37998d..091ddfdd 100644 --- a/src/manager/common/base64.cpp +++ b/src/manager/common/base64.cpp @@ -23,6 +23,7 @@ #include <dpl/log/log.h> +#include <exception.h> #include <base64.h> namespace CKM { @@ -37,8 +38,7 @@ Base64Encoder::Base64Encoder() : void Base64Encoder::append(const RawBuffer &data) { if (m_finalized) { - LogWarning("Already finalized."); - ThrowMsg(Exception::AlreadyFinalized, "Already finalized"); + ThrowErr(Exc::InternalError, "Already finalized"); } if (!m_b64) @@ -50,8 +50,7 @@ void Base64Encoder::append(const RawBuffer &data) void Base64Encoder::finalize() { if (m_finalized) { - LogWarning("Already finalized."); - ThrowMsg(Exception::AlreadyFinalized, "Already finalized."); + ThrowErr(Exc::InternalError, "Already finalized."); } m_finalized = true; @@ -61,16 +60,14 @@ void Base64Encoder::finalize() RawBuffer Base64Encoder::get() { if (!m_finalized) { - LogWarning("Not finalized"); - ThrowMsg(Exception::NotFinalized, "Not finalized"); + ThrowErr(Exc::InternalError, "Not finalized"); } BUF_MEM *bptr = nullptr; BIO_get_mem_ptr(m_b64, &bptr); if (!bptr) { - LogError("Bio internal error"); - ThrowMsg(Exception::InternalError, "Bio internal error"); + ThrowErr(Exc::InternalError, "Bio internal error"); } if (bptr->length > 0) @@ -87,9 +84,7 @@ void Base64Encoder::reset() m_bmem = BIO_new(BIO_s_mem()); if (!m_b64 || !m_bmem) { - LogError("Error during allocation memory in BIO"); - ThrowMsg(Exception::InternalError, - "Error during allocation memory in BIO"); + ThrowErr(Exc::InternalError, "Error during allocation memory in BIO"); } BIO_set_flags(m_b64, BIO_FLAGS_BASE64_NO_NL); @@ -109,8 +104,7 @@ Base64Decoder::Base64Decoder() : void Base64Decoder::append(const RawBuffer &data) { if (m_finalized) { - LogWarning("Already finalized."); - ThrowMsg(Exception::AlreadyFinalized, "Already finalized."); + ThrowErr(Exc::InternalError, "Already finalized."); } std::copy(data.begin(), data.end(), std::back_inserter(m_input)); @@ -124,8 +118,7 @@ static bool whiteCharacter(char a) bool Base64Decoder::finalize() { if (m_finalized) { - LogWarning("Already finalized."); - ThrowMsg(Exception::AlreadyFinalized, "Already finalized."); + ThrowErr(Exc::InternalError, "Already finalized."); } m_finalized = true; @@ -152,16 +145,14 @@ bool Base64Decoder::finalize() RawBuffer buffer(len); if (!buffer.data()) { - LogError("Error in malloc."); - ThrowMsg(Exception::InternalError, "Error in malloc."); + ThrowErr(Exc::InternalError, "Error in malloc."); } memset(buffer.data(), 0, buffer.size()); b64 = BIO_new(BIO_f_base64()); if (!b64) { - LogError("Couldn't create BIO object."); - ThrowMsg(Exception::InternalError, "Couldn't create BIO object."); + ThrowErr(Exc::InternalError, "Couldn't create BIO object."); } BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL); @@ -172,16 +163,14 @@ bool Base64Decoder::finalize() if (!bmem) { BIO_free(b64); - LogError("Internal error in BIO"); - ThrowMsg(Exception::InternalError, "Internal error in BIO"); + ThrowErr(Exc::InternalError, "Internal error in BIO"); } bmem = BIO_push(b64, bmem); if (!bmem) { BIO_free(b64); - LogError("Internal error in BIO"); - ThrowMsg(Exception::InternalError, "Internal error in BIO"); + ThrowErr(Exc::InternalError, "Internal error in BIO"); } int readlen = BIO_read(bmem, buffer.data(), buffer.size()); @@ -203,8 +192,7 @@ bool Base64Decoder::finalize() RawBuffer Base64Decoder::get() const { if (!m_finalized) { - LogWarning("Not finalized."); - ThrowMsg(Exception::NotFinalized, "Not finalized"); + ThrowErr(Exc::InternalError, "Not finalized"); } return m_output; diff --git a/src/manager/common/base64.h b/src/manager/common/base64.h index 228285ec..f73266e9 100644 --- a/src/manager/common/base64.h +++ b/src/manager/common/base64.h @@ -17,7 +17,6 @@ #define _BASE64_H_ #include <string> -#include <dpl/exception.h> #include <ckm/ckm-type.h> #include <noncopyable.h> @@ -32,13 +31,6 @@ class COMMON_API Base64Encoder { public: NONCOPYABLE(Base64Encoder) - class Exception { - public: - DECLARE_EXCEPTION_TYPE(CKM::Exception, Base) - DECLARE_EXCEPTION_TYPE(Base, InternalError) - DECLARE_EXCEPTION_TYPE(Base, NotFinalized) - DECLARE_EXCEPTION_TYPE(Base, AlreadyFinalized) - }; Base64Encoder(); void append(const RawBuffer &data); void finalize(); @@ -56,13 +48,6 @@ class COMMON_API Base64Decoder { public: NONCOPYABLE(Base64Decoder) - class Exception { - public: - DECLARE_EXCEPTION_TYPE(CKM::Exception, Base) - DECLARE_EXCEPTION_TYPE(Base, InternalError) - DECLARE_EXCEPTION_TYPE(Base, NotFinalized) - DECLARE_EXCEPTION_TYPE(Base, AlreadyFinalized) - }; Base64Decoder(); void append(const RawBuffer &data); diff --git a/src/manager/common/data-type.cpp b/src/manager/common/data-type.cpp index ba1a6b2a..9049d1be 100644 --- a/src/manager/common/data-type.cpp +++ b/src/manager/common/data-type.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ */ #include <data-type.h> +#include <exception.h> namespace CKM { @@ -32,8 +33,8 @@ DataType::DataType(Type data) : m_dataType(data) { if (!isInRange(data)) - ThrowMsg(Exception::OutOfRange, - "Invalid conversion from DataType=" << static_cast<int>(data) << + ThrowErr(Exc::InputParam, + "Invalid conversion from DataType=", static_cast<int>(data), " to DBDataType"); } @@ -69,8 +70,8 @@ DataType::DataType(KeyType key) break; default: - ThrowMsg(Exception::OutOfRange, - "Invalid conversion from KeyType=" << static_cast<int>(key) << + ThrowErr(Exc::InputParam, + "Invalid conversion from KeyType=", static_cast<int>(key), " to DBDataType"); } } @@ -103,8 +104,8 @@ DataType::DataType(AlgoType algorithmType) break; default: - ThrowMsg(Exception::OutOfRange, - "Invalid conversion from AlgoType=" << static_cast<int>(algorithmType) << + ThrowErr(Exc::InputParam, + "Invalid conversion from AlgoType=", static_cast<int>(algorithmType), " to DBDataType"); } } @@ -113,8 +114,7 @@ DataType::DataType(int data) : m_dataType(static_cast<Type>(data)) { if (!isInRange(data)) - ThrowMsg(Exception::OutOfRange, - "Invalid conversion from int=" << data << " to DBDataType"); + ThrowErr(Exc::InputParam, "Invalid conversion from int=", data, " to DBDataType"); } DataType::operator int () const @@ -147,8 +147,8 @@ DataType::operator KeyType() const return KeyType::KEY_AES; default: - ThrowMsg(Exception::OutOfRange, - "Invalid conversion from DBDataType=" << static_cast<int>(m_dataType) << + ThrowErr(Exc::InputParam, + "Invalid conversion from DBDataType=", static_cast<int>(m_dataType), " to KeyType"); } } @@ -231,7 +231,7 @@ DataType DataType::getChainDatatype(unsigned int index) DataType result(static_cast<int>(index) + DB_CHAIN_FIRST); if (!result.isChainCert()) - ThrowMsg(Exception::OutOfRange, "Certificate number is out of range"); + ThrowErr(Exc::InputParam, "Certificate number is out of range"); return result; } diff --git a/src/manager/common/data-type.h b/src/manager/common/data-type.h index a3225342..ba3c4fd0 100644 --- a/src/manager/common/data-type.h +++ b/src/manager/common/data-type.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,18 +22,13 @@ #pragma once #include <ckm/ckm-type.h> -#include <dpl/exception.h> +#include <exception.h> #include <symbol-visibility.h> namespace CKM { class COMMON_API DataType { public: - class Exception { - public: - DECLARE_EXCEPTION_TYPE(CKM::Exception, Base) - DECLARE_EXCEPTION_TYPE(Base, OutOfRange) - }; enum Type { KEY_RSA_PUBLIC, @@ -45,7 +40,6 @@ public: KEY_AES, CERTIFICATE, BINARY_DATA, - CHAIN_CERT_0, CHAIN_CERT_1, CHAIN_CERT_2, diff --git a/src/manager/crypto/sw-backend/internals.cpp b/src/manager/crypto/sw-backend/internals.cpp index b6f725c2..91a61fe5 100644 --- a/src/manager/crypto/sw-backend/internals.cpp +++ b/src/manager/crypto/sw-backend/internals.cpp @@ -556,16 +556,14 @@ Data createKeyAES(const int sizeBits) { // check the parameters of functions if (sizeBits != 128 && sizeBits != 192 && sizeBits != 256) { - LogError("Error in AES input size"); - ThrowMsg(Exc::Crypto::InputParam, "Error in AES input size"); + ThrowErr(Exc::Crypto::InputParam, "Error in AES input size"); } uint8_t key[32]; int sizeBytes = sizeBits / 8; if (!RAND_bytes(key, sizeBytes)) { - LogError("Error in AES key generation"); - ThrowMsg(Exc::Crypto::InternalError, "Error in AES key generation"); + ThrowErr(Exc::Crypto::InternalError, "Error in AES key generation"); } return { DataType(KeyType::KEY_AES), CKM::RawBuffer(key, key + sizeBytes)}; diff --git a/src/manager/service/ckm-service.cpp b/src/manager/service/ckm-service.cpp index 0e970047..c7e8f746 100644 --- a/src/manager/service/ckm-service.cpp +++ b/src/manager/service/ckm-service.cpp @@ -98,8 +98,6 @@ bool CKMService::ProcessOne( LogError("Broken protocol. Closing socket: " << e.DumpToString()); } catch (const Exception::BrokenProtocol &e) { LogError("Broken protocol. Closing socket: " << e.DumpToString()); - } catch (const DataType::Exception::Base &e) { - LogError("Closing socket. DBDataType::Exception: " << e.DumpToString()); } catch (const std::string &e) { LogError("String exception(" << e << "). Closing socket"); } catch (const std::exception &e) { diff --git a/src/manager/service/crypto-logic.cpp b/src/manager/service/crypto-logic.cpp index aed2e893..32022cd2 100644 --- a/src/manager/service/crypto-logic.cpp +++ b/src/manager/service/crypto-logic.cpp @@ -35,6 +35,7 @@ #include <dpl/log/log.h> +#include <exception.h> #include <base64.h> #include <crypto-logic.h> @@ -144,47 +145,41 @@ RawBuffer CryptoLogic::generateRandIV() const void CryptoLogic::encryptRow(DB::Row &row) { - try { - DB::Row crow = row; - RawBuffer key; - RawBuffer result1; - RawBuffer result2; + DB::Row crow = row; + RawBuffer key; + RawBuffer result1; + RawBuffer result2; - crow.algorithmType = DBCMAlgType::AES_GCM_256; - crow.dataSize = crow.data.size(); + crow.algorithmType = DBCMAlgType::AES_GCM_256; + crow.dataSize = crow.data.size(); - if (crow.dataSize <= 0) - ThrowErr(Exc::InternalError, "Invalid dataSize."); + if (crow.dataSize <= 0) + ThrowErr(Exc::InternalError, "Invalid dataSize."); - if (!haveKey(row.ownerLabel)) - ThrowErr(Exc::InternalError, "Missing application key for ", - row.ownerLabel, " label."); + if (!haveKey(row.ownerLabel)) + ThrowErr(Exc::InternalError, "Missing application key for ", + row.ownerLabel, " label."); - if (crow.iv.empty()) - crow.iv = generateRandIV(); + if (crow.iv.empty()) + crow.iv = generateRandIV(); - key = m_keyMap[row.ownerLabel]; - crow.encryptionScheme = ENCR_APPKEY; + key = m_keyMap[row.ownerLabel]; + crow.encryptionScheme = ENCR_APPKEY; - auto dataPair = Crypto::SW::Internals::encryptDataAesGcm(key, crow.data, - crow.iv, AES_GCM_TAG_SIZE); - crow.data = dataPair.first; + auto dataPair = Crypto::SW::Internals::encryptDataAesGcm(key, crow.data, + crow.iv, AES_GCM_TAG_SIZE); + crow.data = dataPair.first; - crow.tag = dataPair.second; + crow.tag = dataPair.second; - encBase64(crow.data); - crow.encryptionScheme |= ENCR_BASE64; - encBase64(crow.iv); + encBase64(crow.data); + crow.encryptionScheme |= ENCR_BASE64; + encBase64(crow.iv); - crow.encryptionScheme &= ENCR_ORDER_CLEAR; - crow.encryptionScheme |= ENCR_ORDER_V2; + crow.encryptionScheme &= ENCR_ORDER_CLEAR; + crow.encryptionScheme |= ENCR_ORDER_V2; - row = std::move(crow); - } catch (const CKM::Base64Encoder::Exception::Base &e) { - ThrowErr(Exc::InternalError, e.GetMessage()); - } catch (const CKM::Base64Decoder::Exception::Base &e) { - ThrowErr(Exc::InternalError, e.GetMessage()); - } + row = std::move(crow); } int CryptoLogic::getSchemeVersion(int encryptionScheme) @@ -194,33 +189,33 @@ int CryptoLogic::getSchemeVersion(int encryptionScheme) void CryptoLogic::decryptRow(const Password &password, DB::Row &row) { - try { - DB::Row crow = row; - RawBuffer key; - RawBuffer digest, dataDigest; + DB::Row crow = row; + RawBuffer key; + RawBuffer digest, dataDigest; - if (row.algorithmType != DBCMAlgType::AES_GCM_256) - ThrowErr(Exc::AuthenticationFailed, "Invalid algorithm type."); + if (row.algorithmType != DBCMAlgType::AES_GCM_256) + ThrowErr(Exc::AuthenticationFailed, "Invalid algorithm type."); - if ((row.encryptionScheme & ENCR_PASSWORD) && password.empty()) - ThrowErr(Exc::AuthenticationFailed, - "DB row is password protected, but given password is empty."); + if ((row.encryptionScheme & ENCR_PASSWORD) && password.empty()) + ThrowErr(Exc::AuthenticationFailed, + "DB row is password protected, but given password is empty."); - if (!(row.encryptionScheme & ENCR_PASSWORD) && !password.empty()) - ThrowErr(Exc::AuthenticationFailed, - "DB row is not password protected, but given password is not empty."); + if (!(row.encryptionScheme & ENCR_PASSWORD) && !password.empty()) + ThrowErr(Exc::AuthenticationFailed, + "DB row is not password protected, but given password is not empty."); - if ((row.encryptionScheme & ENCR_APPKEY) && !haveKey(row.ownerLabel)) - ThrowErr(Exc::AuthenticationFailed, - "Missing application key for ", - row.ownerLabel, - " label."); + if ((row.encryptionScheme & ENCR_APPKEY) && !haveKey(row.ownerLabel)) + ThrowErr(Exc::AuthenticationFailed, + "Missing application key for ", + row.ownerLabel, + " label."); - decBase64(crow.iv); + decBase64(crow.iv); - if (crow.encryptionScheme & ENCR_BASE64) - decBase64(crow.data); + if (crow.encryptionScheme & ENCR_BASE64) + decBase64(crow.data); + try { if ((crow.encryptionScheme >> ENCR_ORDER_OFFSET) == ENCR_ORDER_V2) { if (crow.encryptionScheme & ENCR_APPKEY) { key = m_keyMap[crow.ownerLabel]; @@ -240,21 +235,17 @@ void CryptoLogic::decryptRow(const Password &password, DB::Row &row) crow.tag); } } - - if (static_cast<int>(crow.data.size()) < crow.dataSize) - ThrowErr(Exc::AuthenticationFailed, "Decrypted row size mismatch"); - - if (static_cast<int>(crow.data.size()) > crow.dataSize) - crow.data.resize(crow.dataSize); - - row = std::move(crow); - } catch (const CKM::Base64Encoder::Exception::Base &e) { - ThrowErr(Exc::InternalError, e.GetMessage()); - } catch (const CKM::Base64Decoder::Exception::Base &e) { - ThrowErr(Exc::InternalError, e.GetMessage()); } catch (const Exc::Exception &e) { ThrowErr(Exc::AuthenticationFailed, e.message()); } + + if (static_cast<int>(crow.data.size()) < crow.dataSize) + ThrowErr(Exc::AuthenticationFailed, "Decrypted row size mismatch"); + + if (static_cast<int>(crow.data.size()) > crow.dataSize) + crow.data.resize(crow.dataSize); + + row = std::move(crow); } void CryptoLogic::encBase64(RawBuffer &data) diff --git a/tests/test_base64.cpp b/tests/test_base64.cpp index df1a2414..cc6ce455 100644 --- a/tests/test_base64.cpp +++ b/tests/test_base64.cpp @@ -25,6 +25,7 @@ #include <boost/test/unit_test.hpp> #include <ckm/ckm-type.h> +#include <exception.h> using CKM::Base64Encoder; using CKM::Base64Decoder; @@ -77,30 +78,30 @@ BOOST_AUTO_TEST_CASE(THROW_SOMETHING) { /* encode data */ Base64Encoder encoder; - BOOST_REQUIRE_THROW(encoder.get(), Base64Encoder::Exception::NotFinalized); + BOOST_REQUIRE_THROW(encoder.get(), CKM::Exc::InternalError); BOOST_REQUIRE_NO_THROW(encoder.append(rawbuf)); BOOST_REQUIRE_NO_THROW(encoder.finalize()); BOOST_REQUIRE_THROW(encoder.append(rawbuf), - Base64Encoder::Exception::AlreadyFinalized); + CKM::Exc::InternalError); BOOST_REQUIRE_THROW(encoder.finalize(), - Base64Encoder::Exception::AlreadyFinalized); + CKM::Exc::InternalError); RawBuffer encdata; BOOST_REQUIRE_NO_THROW(encdata = encoder.get()); /* decode data */ Base64Decoder decoder; - BOOST_REQUIRE_THROW(decoder.get(), Base64Decoder::Exception::NotFinalized); + BOOST_REQUIRE_THROW(decoder.get(), CKM::Exc::InternalError); BOOST_REQUIRE_NO_THROW(decoder.append(encdata)); BOOST_REQUIRE_NO_THROW(decoder.finalize()); BOOST_REQUIRE_THROW(decoder.append(encdata), - Base64Decoder::Exception::AlreadyFinalized); + CKM::Exc::InternalError); BOOST_REQUIRE_THROW(decoder.finalize(), - Base64Decoder::Exception::AlreadyFinalized); + CKM::Exc::InternalError); RawBuffer decdata; BOOST_REQUIRE_NO_THROW(decdata = decoder.get()); diff --git a/tests/test_data-type.cpp b/tests/test_data-type.cpp index e2ba333c..3598273b 100644 --- a/tests/test_data-type.cpp +++ b/tests/test_data-type.cpp @@ -23,6 +23,7 @@ #include <boost/test/unit_test.hpp> #include <ckm/ckm-type.h> +#include <exception.h> using CKM::DataType; using CKM::KeyType; @@ -33,9 +34,9 @@ BOOST_AUTO_TEST_SUITE(DATA_TYPE_TEST) BOOST_AUTO_TEST_CASE(CONSTRUCTOR) { BOOST_REQUIRE_THROW(DataType(static_cast<DataType::Type>(999)), - DataType::Exception::OutOfRange); + CKM::Exc::InputParam); BOOST_REQUIRE_THROW(DataType(static_cast<KeyType>(999)), - DataType::Exception::OutOfRange); + CKM::Exc::InputParam); std::vector<DataType> types; @@ -77,7 +78,7 @@ BOOST_AUTO_TEST_CASE(CONSTRUCTOR) BOOST_REQUIRE_THROW( DataType(static_cast<AlgoType>(-1)), - DataType::Exception::OutOfRange); + CKM::Exc::InputParam); } BOOST_AUTO_TEST_CASE(KEY_TYPE_CASTING) @@ -161,7 +162,7 @@ BOOST_AUTO_TEST_CASE(GET_CHAIN_TYPE) BOOST_REQUIRE(type.getChainDatatype(13) == DataType(DataType::CHAIN_CERT_13)); BOOST_REQUIRE(type.getChainDatatype(15) == DataType(DataType::DB_CHAIN_LAST)); - BOOST_REQUIRE_THROW(type.getChainDatatype(16), DataType::Exception::OutOfRange); + BOOST_REQUIRE_THROW(type.getChainDatatype(16), CKM::Exc::InputParam); } BOOST_AUTO_TEST_SUITE_END() |