summaryrefslogtreecommitdiff
path: root/src/manager/crypto/sw-backend/store.cpp
diff options
context:
space:
mode:
authorBartlomiej Grzelewski <b.grzelewski@samsung.com>2015-06-09 15:09:59 +0200
committerBartlomiej Grzelewski <b.grzelewski@samsung.com>2015-06-12 13:24:09 +0200
commite8c312dd9465c28b900444121a9617fad64dbc40 (patch)
treeb5e363a2d45f6abe6f0a9fc7fa75f9bb285d4094 /src/manager/crypto/sw-backend/store.cpp
parentd6d9b820e45563d1d2df255c7c11c08e3eac4a32 (diff)
downloadkey-manager-e8c312dd9465c28b900444121a9617fad64dbc40.tar.gz
key-manager-e8c312dd9465c28b900444121a9617fad64dbc40.tar.bz2
key-manager-e8c312dd9465c28b900444121a9617fad64dbc40.zip
Introduce new (much simpler) Exception type.
This commit changes the exception class hierarhy. Exceptions class won't be hidden inside classes. From now exceptions will be defined globally per project. It does not mean that you cannot create hidden exception inside class. Change-Id: If10bc10154684de91ea1f82332860ef53bdd2d3a
Diffstat (limited to 'src/manager/crypto/sw-backend/store.cpp')
-rw-r--r--src/manager/crypto/sw-backend/store.cpp23
1 files changed, 7 insertions, 16 deletions
diff --git a/src/manager/crypto/sw-backend/store.cpp b/src/manager/crypto/sw-backend/store.cpp
index a3fd0021..9f18575e 100644
--- a/src/manager/crypto/sw-backend/store.cpp
+++ b/src/manager/crypto/sw-backend/store.cpp
@@ -20,8 +20,6 @@
*/
#include <memory>
-#include <dpl/log/log.h>
-
#include <generic-backend/exception.h>
#include <sw-backend/key.h>
#include <sw-backend/store.h>
@@ -40,8 +38,7 @@ Store::Store(CryptoBackend backendId)
GKeyShPtr Store::getKey(const Token &token) {
if (token.backendId != m_backendId) {
- LogError("Decider choose wrong backend!");
- ThrowMsg(Exception::WrongBackend, "Decider choose wrong backend!");
+ ThrowErr(Exc::Crypto::WrongBackend, "Decider choose wrong backend!");
}
if (token.dataType.isKeyPrivate() || token.dataType.isKeyPublic()) {
@@ -56,10 +53,8 @@ GKeyShPtr Store::getKey(const Token &token) {
return std::make_shared<Cert>(token.data, token.dataType);
}
- LogDebug(
- "This type of data is not supported by openssl backend: " << (int)token.dataType);
- ThrowMsg(Exception::KeyNotSupported,
- "This type of data is not supported by openssl backend: " << (int)token.dataType);
+ ThrowErr(Exc::Crypto::KeyNotSupported,
+ "This type of data is not supported by openssl backend: ", (int)token.dataType);
}
TokenPair Store::generateAKey(const CryptoAlgorithm &algorithm)
@@ -71,7 +66,7 @@ TokenPair Store::generateAKey(const CryptoAlgorithm &algorithm)
{
int keyLength = 0;
if(!algorithm.getParam(ParamName::GEN_KEY_LEN, keyLength))
- ThrowMsg(Crypto::Exception::InputParam, "Error, parameter GEN_KEY_LEN not found.");
+ ThrowErr(Exc::Crypto::InputParam, "Error, parameter GEN_KEY_LEN not found.");
if(keyType == AlgoType::RSA_GEN)
return Internals::createKeyPairRSA(m_backendId, keyLength);
@@ -82,18 +77,18 @@ TokenPair Store::generateAKey(const CryptoAlgorithm &algorithm)
{
int ecType = 0;
if(!algorithm.getParam(ParamName::GEN_EC, ecType))
- ThrowMsg(Crypto::Exception::InputParam, "Error, parameter GEN_EC not found.");
+ ThrowErr(Exc::Crypto::InputParam, "Error, parameter GEN_EC not found.");
return Internals::createKeyPairECDSA(m_backendId, static_cast<ElipticCurve>(ecType));
}
- ThrowMsg(Crypto::Exception::InputParam, "wrong key type");
+ ThrowErr(Exc::Crypto::InputParam, "wrong key type");
}
Token Store::generateSKey(const CryptoAlgorithm &algorithm)
{
int keyLength = 0;
if(!algorithm.getParam(ParamName::GEN_KEY_LEN, keyLength))
- ThrowMsg(Crypto::Exception::InputParam, "Error, parameter GEN_KEY_LEN not found.");
+ ThrowErr(Exc::Crypto::InputParam, "Error, parameter GEN_KEY_LEN not found.");
return Internals::createKeyAES(m_backendId, keyLength);
}
@@ -102,10 +97,6 @@ Token Store::import(DataType dataType, const RawBuffer &buffer) {
return Token(m_backendId, dataType, buffer);
}
-
-
-
-
} // namespace SW
} // namespace Crypto
} // namespace CKM