summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaciej J. Karpiuk <m.karpiuk2@samsung.com>2014-09-17 13:34:14 +0200
committerMaciej J. Karpiuk <m.karpiuk2@samsung.com>2014-09-17 13:34:14 +0200
commit2ad243af50ef1d9a1304c6f96130d481489cc827 (patch)
treeb636d3c25587983a5df1012e163924cecf088bf0
parent2725c0eb40312ec5fb0d7f1922812202e4650562 (diff)
downloadkey-manager-2ad243af50ef1d9a1304c6f96130d481489cc827.tar.gz
key-manager-2ad243af50ef1d9a1304c6f96130d481489cc827.tar.bz2
key-manager-2ad243af50ef1d9a1304c6f96130d481489cc827.zip
Class naming scheme re-factoring: move towards better consistency.submit/tizen/20140925.122603accepted/tizen/common/20140925.172038
Change-Id: I8ad4d19991c92f5268ef1f0a411258c848c83c64
-rw-r--r--src/CMakeLists.txt4
-rw-r--r--src/manager/CMakeLists.txt2
-rw-r--r--src/manager/client/client-manager-impl.cpp4
-rw-r--r--src/manager/common/certificate-impl.cpp16
-rw-r--r--src/manager/common/certificate-impl.h6
-rw-r--r--src/manager/common/key-impl.cpp (renamed from src/manager/common/generic-key.cpp)30
-rw-r--r--src/manager/common/key-impl.h (renamed from src/manager/common/generic-key.h)14
-rw-r--r--src/manager/common/pkcs12-impl.cpp8
-rw-r--r--src/manager/service/CryptoService.cpp26
-rw-r--r--src/manager/service/CryptoService.h16
-rw-r--r--src/manager/service/ckm-logic.cpp14
-rw-r--r--src/manager/service/ckm-logic.h2
12 files changed, 71 insertions, 71 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index bb2d60aa..fdcc3aa4 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -89,7 +89,7 @@ SET(KEY_MANAGER_CLIENT_SOURCES
${KEY_MANAGER_PATH}/common/smack-check.cpp
${KEY_MANAGER_PATH}/common/certificate-impl.cpp
${KEY_MANAGER_PATH}/common/certificate-store.cpp
- ${KEY_MANAGER_PATH}/common/generic-key.cpp
+ ${KEY_MANAGER_PATH}/common/key-impl.cpp
${KEY_MANAGER_PATH}/common/pkcs12-impl.cpp
${KEY_MANAGER_PATH}/dpl/log/src/abstract_log_provider.cpp
${KEY_MANAGER_PATH}/dpl/log/src/dlog_log_provider.cpp
@@ -148,7 +148,7 @@ SET(KEY_MANAGER_CONTROL_CLIENT_SOURCES
${KEY_MANAGER_PATH}/common/smack-check.cpp
${KEY_MANAGER_PATH}/common/certificate-impl.cpp
${KEY_MANAGER_PATH}/common/certificate-store.cpp
- ${KEY_MANAGER_PATH}/common/generic-key.cpp
+ ${KEY_MANAGER_PATH}/common/key-impl.cpp
${KEY_MANAGER_PATH}/dpl/log/src/abstract_log_provider.cpp
${KEY_MANAGER_PATH}/dpl/log/src/dlog_log_provider.cpp
${KEY_MANAGER_PATH}/dpl/log/src/log.cpp
diff --git a/src/manager/CMakeLists.txt b/src/manager/CMakeLists.txt
index f5e23304..5dfbc78f 100644
--- a/src/manager/CMakeLists.txt
+++ b/src/manager/CMakeLists.txt
@@ -20,7 +20,7 @@ SET(COMMON_SOURCES
${COMMON_PATH}/common/smack-check.cpp
${COMMON_PATH}/common/certificate-impl.cpp
${COMMON_PATH}/common/certificate-store.cpp
- ${COMMON_PATH}/common/generic-key.cpp
+ ${COMMON_PATH}/common/key-impl.cpp
${COMMON_PATH}/dpl/log/src/abstract_log_provider.cpp
${COMMON_PATH}/dpl/log/src/dlog_log_provider.cpp
${COMMON_PATH}/dpl/log/src/log.cpp
diff --git a/src/manager/client/client-manager-impl.cpp b/src/manager/client/client-manager-impl.cpp
index a838b8a0..6e82722c 100644
--- a/src/manager/client/client-manager-impl.cpp
+++ b/src/manager/client/client-manager-impl.cpp
@@ -27,7 +27,7 @@
#include <client-common.h>
#include <message-buffer.h>
#include <protocols.h>
-#include <generic-key.h>
+#include <key-impl.h>
#include <certificate-impl.h>
namespace {
@@ -231,7 +231,7 @@ int ManagerImpl::getKey(const Alias &alias, const Password &password, KeyShPtr &
if (retCode != CKM_API_SUCCESS)
return retCode;
- KeyShPtr keyParsed(new GenericKey(rawData));
+ KeyShPtr keyParsed(new KeyImpl(rawData));
if (keyParsed->empty()) {
LogDebug("Key empty - failed to parse!");
diff --git a/src/manager/common/certificate-impl.cpp b/src/manager/common/certificate-impl.cpp
index f8adbf36..51af4377 100644
--- a/src/manager/common/certificate-impl.cpp
+++ b/src/manager/common/certificate-impl.cpp
@@ -24,7 +24,7 @@
#include <dpl/log/log.h>
-#include <generic-key.h>
+#include <key-impl.h>
#include <certificate-impl.h>
#include <base64.h>
@@ -129,18 +129,18 @@ bool CertificateImpl::empty() const {
return m_x509 == NULL;
}
-GenericKey::EvpShPtr CertificateImpl::getEvpShPtr() const {
- return GenericKey::EvpShPtr(X509_get_pubkey(m_x509), EVP_PKEY_free);
+KeyImpl::EvpShPtr CertificateImpl::getEvpShPtr() const {
+ return KeyImpl::EvpShPtr(X509_get_pubkey(m_x509), EVP_PKEY_free);
}
-GenericKey CertificateImpl::getGenericKey() const {
- GenericKey::EvpShPtr evp(X509_get_pubkey(m_x509), EVP_PKEY_free);
+KeyImpl CertificateImpl::getKeyImpl() const {
+ KeyImpl::EvpShPtr evp(X509_get_pubkey(m_x509), EVP_PKEY_free);
if (EVP_PKEY_type(evp->type) == EVP_PKEY_RSA)
- return GenericKey(evp, KeyType::KEY_RSA_PUBLIC);
+ return KeyImpl(evp, KeyType::KEY_RSA_PUBLIC);
if (EVP_PKEY_type(evp->type) == EVP_PKEY_EC)
- return GenericKey(evp, KeyType::KEY_ECDSA_PUBLIC);
+ return KeyImpl(evp, KeyType::KEY_ECDSA_PUBLIC);
LogError("Unsupported key type in certificate.");
- return GenericKey();
+ return KeyImpl();
}
X509_NAME *getX509Name(X509 *x509, CertificateFieldId type) {
diff --git a/src/manager/common/certificate-impl.h b/src/manager/common/certificate-impl.h
index 62ebfbb2..679de866 100644
--- a/src/manager/common/certificate-impl.h
+++ b/src/manager/common/certificate-impl.h
@@ -26,7 +26,7 @@
#include <ckm/ckm-type.h>
#include <ckm/ckm-certificate.h>
-#include <generic-key.h>
+#include <key-impl.h>
namespace CKM {
@@ -44,8 +44,8 @@ public:
virtual bool empty() const;
virtual X509* getX509() const;
- GenericKey::EvpShPtr getEvpShPtr() const;
- GenericKey getGenericKey() const;
+ KeyImpl::EvpShPtr getEvpShPtr() const;
+ KeyImpl getKeyImpl() const;
std::string getOneLine(CertificateFieldId type) const;
std::string getField(CertificateFieldId type, int fieldNid) const;
diff --git a/src/manager/common/generic-key.cpp b/src/manager/common/key-impl.cpp
index 6835b8e4..ceb6ef0f 100644
--- a/src/manager/common/generic-key.cpp
+++ b/src/manager/common/key-impl.cpp
@@ -13,7 +13,7 @@
* limitations under the License
*
*
- * @file generic-key.cpp
+ * @file key-impl.cpp
* @author Bartlomiej Grzelewski (b.grzelewski@samsung.com)
* @version 1.0
* @brief Key implementation.
@@ -33,7 +33,7 @@
#include <dpl/log/log.h>
#include <ckm/ckm-type.h>
-#include <generic-key.h>
+#include <key-impl.h>
namespace CKM {
namespace {
@@ -88,17 +88,17 @@ CKM::RawBuffer i2d(I2D_CONV fun, EVP_PKEY* pkey) {
} // anonymous namespace
-GenericKey::GenericKey()
+KeyImpl::KeyImpl()
: m_pkey(NULL, EVP_PKEY_free)
, m_type(KeyType::KEY_NONE)
{}
-GenericKey::GenericKey(const GenericKey &second) {
+KeyImpl::KeyImpl(const KeyImpl &second) {
m_pkey = second.m_pkey;
m_type = second.m_type;
}
-GenericKey::GenericKey(const RawBuffer &buf, const Password &password)
+KeyImpl::KeyImpl(const RawBuffer &buf, const Password &password)
: m_pkey(NULL, EVP_PKEY_free)
, m_type(KeyType::KEY_NONE)
{
@@ -159,7 +159,7 @@ GenericKey::GenericKey(const RawBuffer &buf, const Password &password)
LogDebug("KeyType is: " << (int)m_type << " isPrivate: " << isPrivate);
}
-GenericKey::GenericKey(EvpShPtr pkey, KeyType type)
+KeyImpl::KeyImpl(EvpShPtr pkey, KeyType type)
: m_pkey(pkey)
, m_type(type)
{
@@ -175,27 +175,27 @@ GenericKey::GenericKey(EvpShPtr pkey, KeyType type)
}
}
-bool GenericKey::empty() const {
+bool KeyImpl::empty() const {
return m_pkey.get() == NULL;
}
-GenericKey::EvpShPtr GenericKey::getEvpShPtr() const {
+KeyImpl::EvpShPtr KeyImpl::getEvpShPtr() const {
return m_pkey;
}
-KeyType GenericKey::getType() const {
+KeyType KeyImpl::getType() const {
return m_type;
}
-RawBuffer GenericKey::getDERPRV() const {
+RawBuffer KeyImpl::getDERPRV() const {
return i2d(i2d_PrivateKey_bio, m_pkey.get());
}
-RawBuffer GenericKey::getDERPUB() const {
+RawBuffer KeyImpl::getDERPUB() const {
return i2d(i2d_PUBKEY_bio, m_pkey.get());
}
-RawBuffer GenericKey::getDER() const {
+RawBuffer KeyImpl::getDER() const {
if (m_type == KeyType::KEY_ECDSA_PRIVATE || m_type == KeyType::KEY_RSA_PRIVATE) {
return getDERPRV();
} else if (m_type == KeyType::KEY_RSA_PUBLIC || m_type == KeyType::KEY_ECDSA_PUBLIC) {
@@ -206,14 +206,14 @@ RawBuffer GenericKey::getDER() const {
KeyShPtr Key::create(const RawBuffer &raw, const Password &password) {
try {
- KeyShPtr output = std::make_shared<GenericKey>(raw, password);
+ KeyShPtr output = std::make_shared<KeyImpl>(raw, password);
if (output->empty())
output.reset();
return output;
} catch (const std::bad_alloc &) {
- LogDebug("Bad alloc was catch during GenericKey creation");
+ LogDebug("Bad alloc was catch during KeyImpl creation");
} catch (...) {
- LogError("Critical error: Unknown exception was caught during GenericKey creation");
+ LogError("Critical error: Unknown exception was caught during KeyImpl creation");
}
return KeyShPtr();
}
diff --git a/src/manager/common/generic-key.h b/src/manager/common/key-impl.h
index ac1918cc..9d7831a4 100644
--- a/src/manager/common/generic-key.h
+++ b/src/manager/common/key-impl.h
@@ -13,7 +13,7 @@
* limitations under the License
*
*
- * @file generic-key.h
+ * @file key-impl.h
* @author Bartlomiej Grzelewski (b.grzelewski@samsung.com)
* @version 1.0
* @brief Key implementation.
@@ -28,14 +28,14 @@
namespace CKM {
-class GenericKey : public Key {
+class KeyImpl : public Key {
public:
typedef std::shared_ptr<EVP_PKEY> EvpShPtr;
- GenericKey();
- GenericKey(const GenericKey &second);
- GenericKey(const RawBuffer& buffer, const Password &password = Password());
- GenericKey(EvpShPtr pkey, KeyType type);
+ KeyImpl();
+ KeyImpl(const KeyImpl &second);
+ KeyImpl(const RawBuffer& buffer, const Password &password = Password());
+ KeyImpl(EvpShPtr pkey, KeyType type);
virtual KeyType getType() const;
virtual RawBuffer getDER() const;
@@ -52,7 +52,7 @@ public:
}
virtual bool empty() const;
- virtual ~GenericKey(){}
+ virtual ~KeyImpl(){}
protected:
EvpShPtr m_pkey;
KeyType m_type;
diff --git a/src/manager/common/pkcs12-impl.cpp b/src/manager/common/pkcs12-impl.cpp
index 255a752a..394b6490 100644
--- a/src/manager/common/pkcs12-impl.cpp
+++ b/src/manager/common/pkcs12-impl.cpp
@@ -28,7 +28,7 @@
#include <pkcs12-impl.h>
#include <certificate-impl.h>
-#include <generic-key.h>
+#include <key-impl.h>
namespace CKM {
namespace {
@@ -71,11 +71,11 @@ PKCS12Impl::PKCS12Impl(const RawBuffer &buffer, const Password &password)
}
if (pkey) {
- GenericKey::EvpShPtr ptr(pkey, EVP_PKEY_free);
+ KeyImpl::EvpShPtr ptr(pkey, EVP_PKEY_free);
if (EVP_PKEY_type(pkey->type) == EVP_PKEY_RSA) {
- m_pkey = std::make_shared<GenericKey>(ptr, KeyType::KEY_RSA_PRIVATE);
+ m_pkey = std::make_shared<KeyImpl>(ptr, KeyType::KEY_RSA_PRIVATE);
} else if (EVP_PKEY_type(pkey->type) == EVP_PKEY_EC) {
- m_pkey = std::make_shared<GenericKey>(ptr, KeyType::KEY_ECDSA_PRIVATE);
+ m_pkey = std::make_shared<KeyImpl>(ptr, KeyType::KEY_ECDSA_PRIVATE);
} else {
LogError("Unsupported private key type.");
EVP_PKEY_free(pkey);
diff --git a/src/manager/service/CryptoService.cpp b/src/manager/service/CryptoService.cpp
index 39908a34..b705a93e 100644
--- a/src/manager/service/CryptoService.cpp
+++ b/src/manager/service/CryptoService.cpp
@@ -20,7 +20,7 @@
#include <openssl/obj_mac.h>
#include <ckm/ckm-error.h>
#include <ckm/ckm-type.h>
-#include <generic-key.h>
+#include <key-impl.h>
#include <CryptoService.h>
#include <key-manager-util.h>
#include <assert.h>
@@ -80,8 +80,8 @@ int CryptoService::initialize() {
int CryptoService::createKeyPairRSA(const int size, // size in bits [1024, 2048, 4096]
- GenericKey &createdPrivateKey, // returned value
- GenericKey &createdPublicKey) // returned value
+ KeyImpl &createdPrivateKey, // returned value
+ KeyImpl &createdPublicKey) // returned value
{
EVP_PKEY_CTX *ctx = NULL;
EVP_PKEY *pkey = NULL;
@@ -141,10 +141,10 @@ int CryptoService::createKeyPairRSA(const int size, // size in bits [1024, 2048,
ReThrowMsg(CryptoService::Exception::opensslError,"Error in opensslError function !!");
}
- GenericKey::EvpShPtr ptr(pkey, EVP_PKEY_free); // shared ptr will free pkey
+ KeyImpl::EvpShPtr ptr(pkey, EVP_PKEY_free); // shared ptr will free pkey
- createdPrivateKey = GenericKey(ptr, KeyType::KEY_RSA_PRIVATE);
- createdPublicKey = GenericKey(ptr, KeyType::KEY_RSA_PUBLIC);
+ createdPrivateKey = KeyImpl(ptr, KeyType::KEY_RSA_PRIVATE);
+ createdPublicKey = KeyImpl(ptr, KeyType::KEY_RSA_PUBLIC);
if(pparam) {
EVP_PKEY_free(pparam);
@@ -158,8 +158,8 @@ int CryptoService::createKeyPairRSA(const int size, // size in bits [1024, 2048,
}
int CryptoService::createKeyPairECDSA(ElipticCurve type,
- GenericKey &createdPrivateKey, // returned value
- GenericKey &createdPublicKey) // returned value
+ KeyImpl &createdPrivateKey, // returned value
+ KeyImpl &createdPublicKey) // returned value
{
int ecCurve = NOT_DEFINED;
EVP_PKEY_CTX *pctx = NULL;
@@ -253,10 +253,10 @@ int CryptoService::createKeyPairECDSA(ElipticCurve type,
ReThrowMsg(CryptoService::Exception::opensslError,"Error in openssl function !!");
}
- GenericKey::EvpShPtr ptr(pkey, EVP_PKEY_free); // shared ptr will free pkey
+ KeyImpl::EvpShPtr ptr(pkey, EVP_PKEY_free); // shared ptr will free pkey
- createdPrivateKey = GenericKey(ptr, KeyType::KEY_ECDSA_PRIVATE);
- createdPublicKey = GenericKey(ptr, KeyType::KEY_ECDSA_PUBLIC);
+ createdPrivateKey = KeyImpl(ptr, KeyType::KEY_ECDSA_PRIVATE);
+ createdPublicKey = KeyImpl(ptr, KeyType::KEY_ECDSA_PUBLIC);
if(pparam) {
EVP_PKEY_free(pparam);
@@ -273,7 +273,7 @@ int CryptoService::createKeyPairECDSA(ElipticCurve type,
return CKM_CRYPTO_CREATEKEY_SUCCESS;
}
-int CryptoService::createSignature(const GenericKey &privateKey,
+int CryptoService::createSignature(const KeyImpl &privateKey,
const RawBuffer &message,
const HashAlgorithm hashAlgo,
const RSAPaddingAlgorithm padAlgo,
@@ -402,7 +402,7 @@ int CryptoService::createSignature(const GenericKey &privateKey,
return CKM_CREATE_SIGNATURE_SUCCESS;
}
-int CryptoService::verifySignature(const GenericKey &publicKey,
+int CryptoService::verifySignature(const KeyImpl &publicKey,
const RawBuffer &message,
const RawBuffer &signature,
const HashAlgorithm hashAlgo,
diff --git a/src/manager/service/CryptoService.h b/src/manager/service/CryptoService.h
index 22e92fe5..44eff2fb 100644
--- a/src/manager/service/CryptoService.h
+++ b/src/manager/service/CryptoService.h
@@ -1,7 +1,7 @@
#pragma once
#include <iostream>
-#include <generic-key.h>
+#include <key-impl.h>
#include <certificate-impl.h>
#include <ckm/ckm-type.h>
#include <vector>
@@ -53,20 +53,20 @@ class CryptoService {
static int initialize();
static int createKeyPairRSA(const int size, // size in bits [1024, 2048, 4096]
- GenericKey &createdPrivateKey, // returned value ==> Key &createdPrivateKey,
- GenericKey &createdPublicKey); // returned value ==> Key &createdPublicKey
+ KeyImpl &createdPrivateKey, // returned value ==> Key &createdPrivateKey,
+ KeyImpl &createdPublicKey); // returned value ==> Key &createdPublicKey
static int createKeyPairECDSA(ElipticCurve type1,
- GenericKey &createdPrivateKey, // returned value
- GenericKey &createdPublicKey); // returned value
+ KeyImpl &createdPrivateKey, // returned value
+ KeyImpl &createdPublicKey); // returned value
- int createSignature(const GenericKey &privateKey,
+ int createSignature(const KeyImpl &privateKey,
const RawBuffer &message,
const HashAlgorithm hashAlgo,
const RSAPaddingAlgorithm padAlgo,
RawBuffer &signature);
- int verifySignature(const GenericKey &publicKey,
+ int verifySignature(const KeyImpl &publicKey,
const RawBuffer &message,
const RawBuffer &signature,
const HashAlgorithm hashAlgo,
@@ -75,7 +75,7 @@ class CryptoService {
int verifyCertificateChain(const CertificateImpl &certificate,
const CertificateImplVector &untrustedCertificates,
const CertificateImplVector &userTrustedCertificates,
- CertificateImplVector &certificateChainVector);
+ CertificateImplVector &certificateChainVector);
private:
std::vector<X509 *> verifyCertChain(X509 *cert,
diff --git a/src/manager/service/ckm-logic.cpp b/src/manager/service/ckm-logic.cpp
index 587d9bb4..f74ea05a 100644
--- a/src/manager/service/ckm-logic.cpp
+++ b/src/manager/service/ckm-logic.cpp
@@ -27,7 +27,7 @@
#include <file-system.h>
#include <CryptoService.h>
#include <ckm-logic.h>
-#include <generic-key.h>
+#include <key-impl.h>
namespace {
const char * const CERT_SYSTEM_DIR = "/etc/ssl/certs";
@@ -446,7 +446,7 @@ int CKMLogic::createKeyPairRSAHelper(
return CKM_API_ERROR_DB_LOCKED;
auto &handler = m_userDataMap[cred.uid];
- GenericKey prv, pub;
+ KeyImpl prv, pub;
int retCode;
if (CKM_CRYPTO_CREATEKEY_SUCCESS !=
@@ -534,7 +534,7 @@ int CKMLogic::createKeyPairECDSAHelper(
return CKM_API_ERROR_DB_LOCKED;
auto &handler = m_userDataMap[cred.uid];
- GenericKey prv, pub;
+ KeyImpl prv, pub;
int retCode;
if (CKM_CRYPTO_CREATEKEY_SUCCESS !=
@@ -721,7 +721,7 @@ RawBuffer CKMLogic::createSignature(
break;
}
- GenericKey keyParsed(row.data, Password());
+ KeyImpl keyParsed(row.data, Password());
if (keyParsed.empty())
retCode = CKM_API_ERROR_SERVER_ERROR;
else
@@ -765,18 +765,18 @@ RawBuffer CKMLogic::verifySignature(
do {
CryptoService cs;
DBRow row;
- GenericKey key;
+ KeyImpl key;
retCode = getDataHelper(cred, DBDataType::DB_KEY_FIRST, publicKeyOrCertAlias, password, row);
if (retCode == CKM_API_SUCCESS) {
- key = GenericKey(row.data);
+ key = KeyImpl(row.data);
} else if (retCode == CKM_API_ERROR_DB_ALIAS_UNKNOWN) {
retCode = getDataHelper(cred, DBDataType::CERTIFICATE, publicKeyOrCertAlias, password, row);
if (retCode != CKM_API_SUCCESS)
break;
CertificateImpl cert(row.data, DataFormat::FORM_DER);
- key = cert.getGenericKey();
+ key = cert.getKeyImpl();
} else {
break;
}
diff --git a/src/manager/service/ckm-logic.h b/src/manager/service/ckm-logic.h
index 9ed10c13..1a6971fe 100644
--- a/src/manager/service/ckm-logic.h
+++ b/src/manager/service/ckm-logic.h
@@ -178,7 +178,7 @@ private:
Credentials &cred,
const Alias &publicKeyOrCertAlias,
const Password &password, // password for public_key (optional)
- const GenericKey &genericKey);
+ const KeyImpl &genericKey);
std::map<uid_t, UserData> m_userDataMap;
CertificateStore m_certStore;