${KEY_MANAGER_PATH}/dpl/db/src/sql_connection.cpp
${KEY_MANAGER_PATH}/dpl/db/src/naive_synchronization_object.cpp
${KEY_MANAGER_PATH}/sqlcipher/sqlcipher.c
- ${KEY_MANAGER_PATH}/crypto/sw-backend/key.cpp
+ ${KEY_MANAGER_PATH}/crypto/sw-backend/obj.cpp
${KEY_MANAGER_PATH}/crypto/sw-backend/internals.cpp
${KEY_MANAGER_PATH}/crypto/sw-backend/store.cpp
${KEY_MANAGER_PATH}/crypto/platform/decider.cpp
- ${KEY_MANAGER_PATH}/crypto/tz-backend/key.cpp
+ ${KEY_MANAGER_PATH}/crypto/tz-backend/obj.cpp
${KEY_MANAGER_PATH}/crypto/tz-backend/store.cpp
${SECURITY_MANAGER_WRAPPER_PATH}
${CYNARA_WRAPPER_PATH}
typedef CKM::Exc::InputParam InputParam;
typedef CKM::Exc::InternalError InternalError;
-typedef CKM::Exc::InternalError KeyNotSupported;
+typedef CKM::Exc::InternalError DataTypeNotSupported;
typedef CKM::Exc::InternalError OperationNotSupported;
typedef CKM::Exc::InternalError WrongBackend;
* limitations under the License
*/
/*
- * @file gkey.h
+ * @file gobj.h
* @author Bartłomiej Grzelewski (b.grzelewski@samsung.com)
* @version 1.0
*/
namespace CKM {
namespace Crypto {
-class GKey {
+class GObj {
protected:
- GKey(){}
+ GObj(){}
public:
virtual RawBuffer getBinary() const {
ThrowErr(Exc::Crypto::OperationNotSupported);
ThrowErr(Exc::Crypto::OperationNotSupported);
}
- virtual ~GKey () {}
+ virtual ~GObj () {}
};
-typedef std::unique_ptr<GKey> GKeyUPtr;
-typedef std::shared_ptr<GKey> GKeyShPtr;
+typedef std::unique_ptr<GObj> GObjUPtr;
+typedef std::shared_ptr<GObj> GObjShPtr;
} // namespace Crypto
} // namespace CKM
#include <memory>
#include <generic-backend/exception.h>
-#include <generic-backend/gkey.h>
+#include <generic-backend/gobj.h>
#include <ckm/ckm-type.h>
#include <crypto-backend.h>
#include <token.h>
class GStore {
public:
- virtual GKeyUPtr getKey(const Token &) { ThrowErr(Exc::Crypto::OperationNotSupported); }
+ virtual GObjUPtr getObject(const Token &) { ThrowErr(Exc::Crypto::OperationNotSupported); }
virtual TokenPair generateAKey(const CryptoAlgorithm &) { ThrowErr(Exc::Crypto::OperationNotSupported); }
virtual Token generateSKey(const CryptoAlgorithm &) { ThrowErr(Exc::Crypto::OperationNotSupported); }
virtual Token import(DataType, const RawBuffer &) { ThrowErr(Exc::Crypto::OperationNotSupported); }
#include <ckm/ckm-type.h>
#include <openssl/evp.h>
#include <token.h>
-#include <sw-backend/key.h>
+#include <sw-backend/obj.h>
#define EVP_SUCCESS 1 // DO NOTCHANGE THIS VALUE
#define EVP_FAIL 0 // DO NOTCHANGE THIS VALUE
* limitations under the License
*/
/*
- * @file key.cpp
+ * @file obj.cpp
* @author Bartłomiej Grzelewski (b.grzelewski@samsung.com)
* @version 1.0
*/
#include <dpl/log/log.h>
#include <generic-backend/exception.h>
-#include <sw-backend/key.h>
+#include <sw-backend/obj.h>
#include <sw-backend/internals.h>
#define EVP_SUCCESS 1 // DO NOTCHANGE THIS VALUE
typedef std::unique_ptr<BIO, std::function<void(BIO*)>> BioUniquePtr;
-RawBuffer SKey::getBinary() const {
- return m_key;
+RawBuffer BData::getBinary() const {
+ return m_raw;
}
RawBuffer SKey::encrypt(const CryptoAlgorithm &alg, const RawBuffer &data)
return Internals::sign(getEvpShPtr().get(), algWithType, message);
}
-RawBuffer AKey::getBinary() const {
- return m_key;
-}
-
int AKey::verify(const CryptoAlgorithm &alg, const RawBuffer &message, const RawBuffer &sign) {
CryptoAlgorithm algWithType(alg);
EVP_PKEY* evp = getEvpShPtr().get();
if (!pkey) {
(void)BIO_reset(bio.get());
- BIO_write(bio.get(), m_key.data(), m_key.size());
+ BIO_write(bio.get(), m_raw.data(), m_raw.size());
pkey = d2i_PrivateKey_bio(bio.get(), NULL);
LogDebug("Trying d2i_PrivateKey_bio Status: " << (void*)pkey);
}
if (!pkey) {
(void)BIO_reset(bio.get());
- BIO_write(bio.get(), m_key.data(), m_key.size());
+ BIO_write(bio.get(), m_raw.data(), m_raw.size());
pkey = d2i_PUBKEY_bio(bio.get(), NULL);
LogDebug("Trying d2i_PUBKEY_bio Status: " << (void*)pkey);
}
if (m_evp)
return m_evp;
- int size = static_cast<int>(m_key.size());
- const unsigned char *ptr = reinterpret_cast<const unsigned char *>(m_key.data());
+ int size = static_cast<int>(m_raw.size());
+ const unsigned char *ptr = reinterpret_cast<const unsigned char *>(m_raw.data());
X509 *x509 = d2i_X509(NULL, &ptr, size);
* limitations under the License
*/
/*
- * @file key.h
+ * @file obj.h
* @author Bartłomiej Grzelewski (b.grzelewski@samsung.com)
* @version 1.0
*/
#include <openssl/evp.h>
-#include <generic-backend/gkey.h>
+#include <generic-backend/gobj.h>
#include <data-type.h>
namespace CKM {
typedef std::unique_ptr<EVP_PKEY_CTX,std::function<void(EVP_PKEY_CTX*)>> ContextUPtr;
typedef std::shared_ptr<EVP_PKEY> EvpShPtr;
-class SKey : public GKey {
+class BData : public GObj {
public:
- SKey(RawBuffer buffer, DataType keyType)
- : m_key(std::move(buffer))
+ BData(RawBuffer buffer, DataType keyType)
+ : m_raw(std::move(buffer))
, m_type(keyType)
{}
virtual RawBuffer getBinary() const;
- virtual RawBuffer encrypt(const CryptoAlgorithm &, const RawBuffer &);
- virtual RawBuffer decrypt(const CryptoAlgorithm &, const RawBuffer &);
protected:
- RawBuffer m_key;
+ RawBuffer m_raw;
DataType m_type;
};
-class AKey : public GKey {
+class SKey : public BData {
public:
- AKey(RawBuffer buffer, DataType dataType)
- : m_key(std::move(buffer))
- , m_type(dataType)
+ SKey(RawBuffer buffer, DataType keyType) : BData(std::move(buffer), keyType)
+ {}
+
+ virtual RawBuffer encrypt(const CryptoAlgorithm &, const RawBuffer &);
+ virtual RawBuffer decrypt(const CryptoAlgorithm &, const RawBuffer &);
+};
+
+class AKey : public BData {
+public:
+ AKey(RawBuffer buffer, DataType dataType) : BData(std::move(buffer), dataType)
{}
virtual RawBuffer sign(const CryptoAlgorithm &alg, const RawBuffer &message);
virtual int verify(const CryptoAlgorithm &alg, const RawBuffer &message, const RawBuffer &sign);
virtual RawBuffer encrypt(const CryptoAlgorithm &, const RawBuffer &);
virtual RawBuffer decrypt(const CryptoAlgorithm &, const RawBuffer &);
- virtual RawBuffer getBinary() const;
virtual ~AKey(){}
protected:
virtual EvpShPtr getEvpShPtr();
EvpShPtr m_evp;
- RawBuffer m_key;
- DataType m_type;
};
class Cert : public AKey {
#include <memory>
#include <generic-backend/exception.h>
-#include <sw-backend/key.h>
+#include <sw-backend/obj.h>
#include <sw-backend/store.h>
#include <sw-backend/internals.h>
{
}
-GKeyUPtr Store::getKey(const Token &token) {
+GObjUPtr Store::getObject(const Token &token) {
if (token.backendId != m_backendId) {
ThrowErr(Exc::Crypto::WrongBackend, "Decider choose wrong backend!");
}
return make_unique<Cert>(token.data, token.dataType);
}
- ThrowErr(Exc::Crypto::KeyNotSupported,
+ if (token.dataType.isBinaryData()) {
+ return make_unique<BData>(token.data, token.dataType);
+ }
+
+ ThrowErr(Exc::Crypto::DataTypeNotSupported,
"This type of data is not supported by openssl backend: ", (int)token.dataType);
}
*/
#pragma once
-#include <generic-backend/gkey.h>
+#include <generic-backend/gobj.h>
#include <generic-backend/gstore.h>
namespace CKM {
public:
explicit Store(CryptoBackend backendId);
- virtual GKeyUPtr getKey(const Token &token);
+ virtual GObjUPtr getObject(const Token &token);
virtual TokenPair generateAKey(const CryptoAlgorithm &);
virtual Token generateSKey(const CryptoAlgorithm &);
virtual Token import(DataType dataType, const RawBuffer &buffer);
* limitations under the License
*/
/*
- * @file key.cpp
+ * @file obj.cpp
* @author Bartłomiej Grzelewski (b.grzelewski@samsung.com)
* @version 1.0
*/
* limitations under the License
*/
/*
- * @file key.h
+ * @file obj.h
* @author Bartłomiej Grzelewski (b.grzelewski@samsung.com)
* @version 1.0
*/
#pragma once
-#include <generic-backend/gkey.h>
+#include <generic-backend/gobj.h>
namespace CKM {
namespace Crypto {
namespace TZ {
-class SKey : public GKey {
+class SKey : public GObj {
public:
SKey(){}
virtual ~SKey(){}
protected:
};
-class AKey : public GKey {
+class AKey : public GObj {
public:
AKey(){}
virtual ~AKey(){}
* @version 1.0
*/
#include <generic-backend/exception.h>
-#include <tz-backend/key.h>
+#include <tz-backend/obj.h>
#include <tz-backend/store.h>
namespace CKM {
: GStore(backendId)
{}
-GKeyUPtr Store::getKey(const Token &) {
+GObjUPtr Store::getObject(const Token &) {
ThrowErr(Exc::Crypto::OperationNotSupported, "Trust zone backend is not implemented!");
}
*/
#pragma once
-#include <generic-backend/gkey.h>
+#include <generic-backend/gobj.h>
#include <generic-backend/gstore.h>
namespace CKM {
public:
explicit Store(CryptoBackend backendId);
- virtual GKeyUPtr getKey(const Token &token);
+ virtual GObjUPtr getObject(const Token &token);
virtual TokenPair generateAKey(const CryptoAlgorithm &);
virtual Token import(DataType dataType, const RawBuffer &buffer);
virtual void destroy(const Token &){}
#include <protocols.h>
#include <ckm/ckm-error.h>
#include <communication-manager.h>
-#include <generic-backend/gkey.h>
+#include <generic-backend/gobj.h>
namespace CKM {
// key response
struct MsgKeyResponse : public MsgBase
{
- MsgKeyResponse(int id, const Crypto::GKeyShPtr& key, int errorCode = CKM_API_SUCCESS) :
+ MsgKeyResponse(int id, const Crypto::GObjShPtr& key, int errorCode = CKM_API_SUCCESS) :
MsgBase(id),
key(key),
error(errorCode)
{}
- Crypto::GKeyShPtr key;
+ Crypto::GObjShPtr key;
int error;
};
const Name &name,
const Label &label,
const Password &pass,
- Crypto::GKeyShPtr &key)
+ Crypto::GObjShPtr &key)
{
DB::Row row;
try {
// Key is for internal service use. It won't be exported to the client
int retCode = readDataHelper(false, cred, DataType::DB_KEY_FIRST, name, label, pass, row);
if (retCode == CKM_API_SUCCESS)
- key = m_decider.getStore(row).getKey(row);
+ key = m_decider.getStore(row).getObject(row);
return retCode;
} catch (const DB::Crypto::Exception::Base &e) {
LogError("DB::Crypto failed with message: " << e.GetMessage());
try {
retCode = readDataHelper(false, cred, DataType::DB_KEY_FIRST, privateKeyName, ownerLabel, password, row);
if(retCode == CKM_API_SUCCESS) {
- signature = m_decider.getStore(row).getKey(row)->sign(cryptoAlg, message);
+ signature = m_decider.getStore(row).getObject(row)->sign(cryptoAlg, message);
}
} catch (const DB::Crypto::Exception::Base &e) {
LogError("DB::Crypto failed with message: " << e.GetMessage());
}
if (retCode == CKM_API_SUCCESS) {
- retCode = m_decider.getStore(row).getKey(row)->verify(params, message, signature);
+ retCode = m_decider.getStore(row).getObject(row)->verify(params, message, signature);
}
} catch (const Exc::Exception &e) {
retCode = e.error();
#include <access-control.h>
#include <certificate-impl.h>
#include <sys/types.h>
-#include <generic-backend/gkey.h>
+#include <generic-backend/gobj.h>
#include <platform/decider.h>
const Name &name,
const Label &label,
const Password& pass,
- Crypto::GKeyShPtr& key);
+ Crypto::GObjShPtr& key);
protected:
int unlockSystemDB();
void CKMService::ProcessMessage(MsgKeyRequest msg)
{
- Crypto::GKeyShPtr key;
+ Crypto::GObjShPtr key;
int ret = m_logic->getKeyForService(msg.cred,
msg.name,
msg.label,
#include <generic-socket-manager.h>
#include <ckm/ckm-type.h>
-#include <generic-backend/gkey.h>
+#include <generic-backend/gobj.h>
#include <protocols.h>
#include <crypto-request.h>
${KEY_MANAGER_PATH}/dpl/db/src/sql_connection.cpp
${KEY_MANAGER_PATH}/dpl/db/src/naive_synchronization_object.cpp
${KEY_MANAGER_PATH}/sqlcipher/sqlcipher.c
- ${KEY_MANAGER_PATH}/crypto/sw-backend/key.cpp
+ ${KEY_MANAGER_PATH}/crypto/sw-backend/obj.cpp
${KEY_MANAGER_PATH}/crypto/sw-backend/internals.cpp
${KEY_MANAGER_PATH}/crypto/sw-backend/store.cpp
${KEY_MANAGER_PATH}/crypto/platform/decider.cpp