Replace old exception with new ones. 76/61776/6
authorBartlomiej Grzelewski <b.grzelewski@samsung.com>
Wed, 9 Mar 2016 17:22:48 +0000 (18:22 +0100)
committerkyungwook tak <k.tak@samsung.com>
Fri, 15 Jul 2016 04:34:44 +0000 (21:34 -0700)
Change-Id: I3390d6ff8a7d8e1594847fd87625144e11ec0f69

12 files changed:
src/manager/client-async/client-manager-async-impl.cpp
src/manager/client/client-common.cpp
src/manager/client/client-manager-impl.cpp
src/manager/common/base64.cpp
src/manager/common/base64.h
src/manager/common/data-type.cpp
src/manager/common/data-type.h
src/manager/crypto/sw-backend/internals.cpp
src/manager/service/ckm-service.cpp
src/manager/service/crypto-logic.cpp
tests/test_base64.cpp
tests/test_data-type.cpp

index 5b9fbf3..96454cb 100644 (file)
@@ -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());
        }
 }
 
index c50a71a..d0c7a2f 100644 (file)
@@ -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);
index 78c1076..f1b68bb 100644 (file)
@@ -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(
index 1e37998..091ddfd 100644 (file)
@@ -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;
index 228285e..f73266e 100644 (file)
@@ -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);
 
index ba1a6b2..9049d1b 100644 (file)
@@ -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;
 }
index a322534..ba3c4fd 100644 (file)
@@ -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.
 #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,
index b6f725c..91a61fe 100644 (file)
@@ -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)};
index 0e97004..c7e8f74 100644 (file)
@@ -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) {
index aed2e89..32022cd 100644 (file)
@@ -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)
index df1a241..cc6ce45 100644 (file)
@@ -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());
index e2ba333..3598273 100644 (file)
@@ -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()