diff options
author | Krzysztof Jackiewicz <k.jackiewicz@samsung.com> | 2015-11-16 15:18:01 +0100 |
---|---|---|
committer | Bartlomiej Grzelewski <b.grzelewski@samsung.com> | 2015-11-24 09:39:39 -0800 |
commit | d4f99fea8ba5ee3ffe06b04cc0b61e0d9cba327d (patch) | |
tree | e8107a792942600e7e37d406f8526631a6aaddfe | |
parent | 96a0c8de39f676bdd88c23ac7aef6b82a02d7c3f (diff) | |
download | key-manager-d4f99fea8ba5ee3ffe06b04cc0b61e0d9cba327d.tar.gz key-manager-d4f99fea8ba5ee3ffe06b04cc0b61e0d9cba327d.tar.bz2 key-manager-d4f99fea8ba5ee3ffe06b04cc0b61e0d9cba327d.zip |
Load app key when importing initial values
[Problem] Missing app key.
[Solution] Fixed.
[Verification] Run tests
Change-Id: If1a156094bb81a349af41f077443c6503b9cea04
-rw-r--r-- | src/manager/service/ckm-logic.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/manager/service/ckm-logic.cpp b/src/manager/service/ckm-logic.cpp index 48198574..2a6e9b11 100644 --- a/src/manager/service/ckm-logic.cpp +++ b/src/manager/service/ckm-logic.cpp @@ -1098,12 +1098,16 @@ int CKMLogic::importInitialData( const Crypto::DataEncryption &enc, const Policy &policy) { - if (CKM_API_SUCCESS != unlockSystemDB() ) - ThrowErr(Exc::DatabaseLocked, "can not unlock system database"); - auto &handler = m_userDataMap[SYSTEM_DB_UID]; + // Inital values are always imported with root credentials. Label is not important. + Credentials rootCred(0,""); - if (!isNameValid(name)) - return CKM_API_ERROR_INPUT_PARAM; + auto &handler = selectDatabase(rootCred, OWNER_ID_SYSTEM); + + // check if save is possible + DB::Crypto::Transaction transaction(&handler.database); + int retCode = checkSaveConditions(rootCred, handler, name, OWNER_ID_SYSTEM); + if(retCode != CKM_API_SUCCESS) + return retCode; Crypto::GStore& store = m_decider.getStore(data.type, policy.extractable, !enc.encryptedKey.empty()); @@ -1117,7 +1121,6 @@ int CKMLogic::importInitialData( DB::Row row(std::move(token), name, OWNER_ID_SYSTEM, static_cast<int>(policy.extractable)); handler.crypto.encryptRow(row); - DB::Crypto::Transaction transaction(&handler.database); handler.database.saveRow(row); transaction.commit(); |