From 50759ee25cd172d7abd2180095c355e2ebea67bd Mon Sep 17 00:00:00 2001 From: Krzysztof Jackiewicz Date: Tue, 7 Apr 2015 10:36:24 +0200 Subject: AES key creation API [Issue#] N/A [Feature] API allowing creation of AES key in key-manager database [Problem] N/A [Cause] N/A [Solution] N/A [Verification] Successfull compilation. Run tests. Change-Id: I3ec358ce4a58afb657afaf110ca81bacea7dcd10 --- src/include/ckm/ckm-manager-async.h | 5 ++++ src/include/ckm/ckm-manager.h | 5 ++++ src/include/ckmc/ckmc-manager.h | 36 +++++++++++++++++++++++ src/manager/client-async/client-manager-async.cpp | 7 +++++ src/manager/client-capi/ckmc-manager.cpp | 8 +++++ src/manager/client/client-manager-impl.cpp | 9 ++++++ src/manager/client/client-manager-impl.h | 5 ++++ 7 files changed, 75 insertions(+) diff --git a/src/include/ckm/ckm-manager-async.h b/src/include/ckm/ckm-manager-async.h index 21f8b648..9a743f5a 100644 --- a/src/include/ckm/ckm-manager-async.h +++ b/src/include/ckm/ckm-manager-async.h @@ -142,6 +142,11 @@ public: const Alias& publicKeyAlias, const Policy& policyPrivateKey = Policy(), const Policy& policyPublicKey = Policy()); + void createKeyAES( + const ObserverPtr& observer, + int size, + const Alias &keyAlias, + const Policy &policyKey = Policy()); void getCertificateChain( const ObserverPtr& observer, diff --git a/src/include/ckm/ckm-manager.h b/src/include/ckm/ckm-manager.h index 6cb7ec3a..920953b8 100644 --- a/src/include/ckm/ckm-manager.h +++ b/src/include/ckm/ckm-manager.h @@ -95,6 +95,11 @@ public: const Policy &policyPrivateKey = Policy(), const Policy &policyPublicKey = Policy()) = 0; + virtual int createKeyAES( + const int size, // size in bits [128, 192, 256] + const Alias &keyAlias, + const Policy &policyKey = Policy()) = 0; + virtual int getCertificateChain( const CertificateShPtr &certificate, const CertificateShPtrVector &untrustedCertificates, diff --git a/src/include/ckmc/ckmc-manager.h b/src/include/ckmc/ckmc-manager.h index 7210026c..9d3cae00 100644 --- a/src/include/ckmc/ckmc-manager.h +++ b/src/include/ckmc/ckmc-manager.h @@ -704,6 +704,42 @@ int ckmc_create_key_pair_ecdsa(const ckmc_ec_type_e type, const ckmc_policy_s policy_private_key, const ckmc_policy_s policy_public_key); +/** + * @brief Creates AES key and stores it inside key manager based on the policy. + * + * @since_tizen 3.0 + * @privlevel public + * @privilege %http://tizen.org/privilege/keymanager + * + * @remarks If password in policy is provided, the key is additionally encrypted with the password + * in policy. + * + * @param[in] size The size of key strength to be created. \n + * @c 128, @c 192 and @c 256 are supported. + * @param[in] key_alias The name of key to be stored + * @param[in] key_policy The policy about how to store the key securely + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval #CKMC_ERROR_NONE Successful + * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid + * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged + * in) + * @retval #CKMC_ERROR_DB_ALIAS_EXISTS Alias already exists + * @retval #CKMC_ERROR_DB_ERROR Failed due to other DB transaction unexpectedly + * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager + * + * @pre User is already logged in and the user key is already loaded into memory in plain text form. + * + * @see ckmc_create_key_pair_rsa() + * @see ckmc_create_key_pair_dsa() + * @see ckmc_create_key_pair_ecdsa() + */ +int ckmc_create_key_aes(const size_t size, + const char *key_alias, + const ckmc_policy_s key_policy); + /** * @brief Creates a signature on a given message using a private key and returns the signature. * diff --git a/src/manager/client-async/client-manager-async.cpp b/src/manager/client-async/client-manager-async.cpp index 6bbabfb0..8d507237 100644 --- a/src/manager/client-async/client-manager-async.cpp +++ b/src/manager/client-async/client-manager-async.cpp @@ -184,6 +184,13 @@ void ManagerAsync::createKeyPairECDSA(const ObserverPtr& observer, policyPublicKey); } +void ManagerAsync::createKeyAES(const ObserverPtr& /*observer*/, + int /*size*/, + const Alias &/*keyAlias*/, + const Policy &/*policyKey*/) +{ +} + void ManagerAsync::getCertificateChain(const ObserverPtr& observer, const CertificateShPtr& certificate, const CertificateShPtrVector& untrustedCertificates, diff --git a/src/manager/client-capi/ckmc-manager.cpp b/src/manager/client-capi/ckmc-manager.cpp index d9ab8d1a..6f6078de 100644 --- a/src/manager/client-capi/ckmc-manager.cpp +++ b/src/manager/client-capi/ckmc-manager.cpp @@ -601,6 +601,14 @@ int ckmc_create_key_pair_ecdsa(const ckmc_ec_type_e type, return to_ckmc_error(ret); } +KEY_MANAGER_CAPI +int ckmc_create_key_aes(const size_t /*size*/, + const char */*key_alias*/, + const ckmc_policy_s /*key_policy*/) +{ + return 0; +} + KEY_MANAGER_CAPI int ckmc_create_signature(const char *private_key_alias, const char *password, diff --git a/src/manager/client/client-manager-impl.cpp b/src/manager/client/client-manager-impl.cpp index 91bb2633..41383bf4 100644 --- a/src/manager/client/client-manager-impl.cpp +++ b/src/manager/client/client-manager-impl.cpp @@ -456,6 +456,15 @@ int ManagerImpl::createKeyPairECDSA( return this->createKeyPair(CKM::KeyType::KEY_ECDSA_PUBLIC, static_cast(type), privateKeyAlias, publicKeyAlias, policyPrivateKey, policyPublicKey); } +int ManagerImpl::createKeyAES( + const int /*size*/, + const Alias &/*keyAlias*/, + const Policy &/*policyKey*/) +{ + return 0; +} + + int ManagerImpl::createKeyPair( const KeyType key_type, const int additional_param, diff --git a/src/manager/client/client-manager-impl.h b/src/manager/client/client-manager-impl.h index e93b89c8..fce5992e 100644 --- a/src/manager/client/client-manager-impl.h +++ b/src/manager/client/client-manager-impl.h @@ -76,6 +76,11 @@ public: const Policy &policyPrivateKey = Policy(), const Policy &policyPublicKey = Policy()); + int createKeyAES( + const int size, // size in bits [128, 192, 256] + const Alias &keyAlias, + const Policy &policyKey = Policy()); + int getCertificateChain( const CertificateShPtr &certificate, const CertificateShPtrVector &untrustedCertificates, -- cgit v1.2.3