2 * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License
18 * @author Bartlomiej Grzelewski (b.grzelewski@samsung.com)
20 * @brief Sample service implementation.
22 #include <dpl/serialization.h>
23 #include <dpl/log/log.h>
24 #include <ckm/ckm-error.h>
25 #include <ckm/ckm-type.h>
26 #include <key-provider.h>
27 #include <file-system.h>
28 #include <CryptoService.h>
29 #include <ckm-logic.h>
33 const char * const CERT_SYSTEM_DIR = "/etc/ssl/certs";
34 } // anonymous namespace
40 int retCode = FileSystem::init();
41 // TODO what can I do when init went wrong? exit(-1) ??
43 LogError("Fatal error in FileSystem::init()");
46 if (CKM_API_SUCCESS != m_certStore.setSystemCertificateDir(CERT_SYSTEM_DIR)) {
47 LogError("Fatal error in CertificateStore::setSystemCertificateDir. Chain creation will not work");
51 CKMLogic::~CKMLogic(){}
53 RawBuffer CKMLogic::unlockUserKey(uid_t user, const Password &password) {
54 // TODO try catch for all errors that should be supported by error code
55 int retCode = CKM_API_SUCCESS;
58 if (0 == m_userDataMap.count(user) || !(m_userDataMap[user].keyProvider.isInitialized())) {
59 auto &handle = m_userDataMap[user];
61 auto wrappedDomainKEK = fs.getDKEK();
63 if (wrappedDomainKEK.empty()) {
64 wrappedDomainKEK = KeyProvider::generateDomainKEK(std::to_string(user), password);
65 fs.saveDKEK(wrappedDomainKEK);
68 handle.keyProvider = KeyProvider(wrappedDomainKEK, password);
70 auto wrappedDatabaseDEK = fs.getDBDEK();
72 if (wrappedDatabaseDEK.empty()) {
73 wrappedDatabaseDEK = handle.keyProvider.generateDEK(std::to_string(user));
74 fs.saveDBDEK(wrappedDatabaseDEK);
77 RawBuffer key = handle.keyProvider.getPureDEK(wrappedDatabaseDEK);
78 handle.database = DBCrypto(fs.getDBPath(), key);
79 handle.crypto = CryptoLogic();
81 // remove data of removed apps during locked state
82 AppLabelVector removedApps = fs.clearRemovedsApps();
83 for(auto& appSmackLabel : removedApps) {
84 handle.database.deleteKey(appSmackLabel);
89 } catch (const KeyProvider::Exception::PassWordError &e) {
90 LogError("Incorrect Password " << e.GetMessage());
91 retCode = CKM_API_ERROR_AUTHENTICATION_FAILED;
92 } catch (const KeyProvider::Exception::Base &e) {
93 LogError("Error in KeyProvider " << e.GetMessage());
94 retCode = CKM_API_ERROR_SERVER_ERROR;
95 } catch (const CryptoLogic::Exception::Base &e) {
96 LogError("CryptoLogic error: " << e.GetMessage());
97 retCode = CKM_API_ERROR_SERVER_ERROR;
98 } catch (const CKM::Exception &e) {
99 LogError("CKM::Exception: " << e.GetMessage());
100 retCode = CKM_API_ERROR_SERVER_ERROR;
103 if(retCode != CKM_API_SUCCESS) {
104 // When not successful, UserData in m_userDataMap should be erased.
105 // Because other operations make decision based on the existence of UserData in m_userDataMap.
106 m_userDataMap.erase(user);
109 MessageBuffer response;
110 Serialization::Serialize(response, retCode);
111 return response.Pop();
114 RawBuffer CKMLogic::lockUserKey(uid_t user) {
115 int retCode = CKM_API_SUCCESS;
116 // TODO try catch for all errors that should be supported by error code
117 m_userDataMap.erase(user);
119 MessageBuffer response;
120 Serialization::Serialize(response, retCode);
121 return response.Pop();
124 RawBuffer CKMLogic::removeUserData(uid_t user) {
125 int retCode = CKM_API_SUCCESS;
126 // TODO try catch for all errors that should be supported by error code
127 m_userDataMap.erase(user);
132 MessageBuffer response;
133 Serialization::Serialize(response, retCode);
134 return response.Pop();
137 RawBuffer CKMLogic::changeUserPassword(
139 const Password &oldPassword,
140 const Password &newPassword)
142 int retCode = CKM_API_SUCCESS;
145 auto wrappedDomainKEK = fs.getDKEK();
146 if (wrappedDomainKEK.empty()) {
147 retCode = CKM_API_ERROR_BAD_REQUEST;
149 wrappedDomainKEK = KeyProvider::reencrypt(wrappedDomainKEK, oldPassword, newPassword);
150 fs.saveDKEK(wrappedDomainKEK);
152 } catch (const KeyProvider::Exception::PassWordError &e) {
153 LogError("Incorrect Password " << e.GetMessage());
154 retCode = CKM_API_ERROR_AUTHENTICATION_FAILED;
155 } catch (const KeyProvider::Exception::Base &e) {
156 LogError("Error in KeyProvider " << e.GetMessage());
157 retCode = CKM_API_ERROR_SERVER_ERROR;
158 } catch (const CKM::Exception &e) {
159 LogError("CKM::Exception: " << e.GetMessage());
160 retCode = CKM_API_ERROR_SERVER_ERROR;
163 MessageBuffer response;
164 Serialization::Serialize(response, retCode);
165 return response.Pop();
168 RawBuffer CKMLogic::resetUserPassword(
170 const Password &newPassword)
172 int retCode = CKM_API_SUCCESS;
174 if (0 == m_userDataMap.count(user)) {
175 retCode = CKM_API_ERROR_BAD_REQUEST;
177 auto &handler = m_userDataMap[user];
179 fs.saveDKEK(handler.keyProvider.getWrappedDomainKEK(newPassword));
182 MessageBuffer response;
183 Serialization::Serialize(response, retCode);
184 return response.Pop();
187 RawBuffer CKMLogic::removeApplicationData(const std::string &smackLabel) {
188 int retCode = CKM_API_SUCCESS;
192 if (smackLabel.empty()) {
193 retCode = CKM_API_ERROR_INPUT_PARAM;
195 UidVector uids = FileSystem::getUIDsFromDBFile();
196 for (auto userId : uids) {
197 if (0 == m_userDataMap.count(userId)) {
198 FileSystem fs(userId);
199 fs.addRemovedApp(smackLabel);
201 auto &handle = m_userDataMap[userId];
202 handle.database.deleteKey(smackLabel);
207 } catch (const DBCrypto::Exception::InternalError &e) {
208 LogError("DBCrypto couldn't remove data: " << e.GetMessage());
209 retCode = CKM_API_ERROR_DB_ERROR;
210 } catch (const DBCrypto::Exception::TransactionError &e) {
211 LogError("DBCrypto transaction failed with message " << e.GetMessage());
212 retCode = CKM_API_ERROR_DB_ERROR;
215 MessageBuffer response;
216 Serialization::Serialize(response, retCode);
217 return response.Pop();
220 int CKMLogic::saveDataHelper(
224 const RawBuffer &key,
225 const PolicySerializable &policy)
227 if (0 == m_userDataMap.count(cred.uid))
228 return CKM_API_ERROR_DB_LOCKED;
230 DBRow row = { alias, cred.smackLabel,
231 policy.extractable, dataType, DBCMAlgType::NONE,
232 0, RawBuffer(), static_cast<int>(key.size()), key, RawBuffer() };
234 auto &handler = m_userDataMap[cred.uid];
235 DBCrypto::Transaction transaction(&handler.database);
236 if (!handler.crypto.haveKey(cred.smackLabel)) {
238 auto key_optional = handler.database.getKey(cred.smackLabel);
240 LogDebug("No Key in database found. Generating new one for label: "
242 key = handler.keyProvider.generateDEK(cred.smackLabel);
243 handler.database.saveKey(cred.smackLabel, key);
245 LogDebug("Key from DB");
249 key = handler.keyProvider.getPureDEK(key);
250 handler.crypto.pushKey(cred.smackLabel, key);
252 handler.crypto.encryptRow(policy.password, row);
253 handler.database.saveDBRow(row);
254 transaction.commit();
255 return CKM_API_SUCCESS;
258 RawBuffer CKMLogic::saveData(
263 const RawBuffer &key,
264 const PolicySerializable &policy)
266 int retCode = CKM_API_SUCCESS;
268 retCode = saveDataHelper(cred, dataType, alias, key, policy);
269 LogDebug("SaveDataHelper returned: " << retCode);
270 } catch (const KeyProvider::Exception::Base &e) {
271 LogError("KeyProvider failed with message: " << e.GetMessage());
272 retCode = CKM_API_ERROR_SERVER_ERROR;
273 } catch (const CryptoLogic::Exception::Base &e) {
274 LogError("CryptoLogic failed with message: " << e.GetMessage());
275 retCode = CKM_API_ERROR_SERVER_ERROR;
276 } catch (const DBCrypto::Exception::InternalError &e) {
277 LogError("DBCrypto failed with message: " << e.GetMessage());
278 retCode = CKM_API_ERROR_DB_ERROR;
279 } catch (const DBCrypto::Exception::AliasExists &e) {
280 LogError("DBCrypto couldn't save duplicate alias");
281 retCode = CKM_API_ERROR_DB_ALIAS_EXISTS;
282 } catch (const DBCrypto::Exception::TransactionError &e) {
283 LogError("DBCrypto transaction failed with message " << e.GetMessage());
284 retCode = CKM_API_ERROR_DB_ERROR;
287 MessageBuffer response;
288 Serialization::Serialize(response, static_cast<int>(LogicCommand::SAVE));
289 Serialization::Serialize(response, commandId);
290 Serialization::Serialize(response, retCode);
291 Serialization::Serialize(response, static_cast<int>(dataType));
293 return response.Pop();
296 RawBuffer CKMLogic::removeData(
302 int retCode = CKM_API_SUCCESS;
304 if (0 < m_userDataMap.count(cred.uid)) {
306 auto erased = m_userDataMap[cred.uid].database.deleteDBRow(alias, cred.smackLabel);
307 // check if the data existed or not
309 LogError("No row for given alias and label");
310 retCode = CKM_API_ERROR_DB_ALIAS_UNKNOWN;
312 } Catch (CKM::Exception) {
313 LogError("Error in deleting row!");
314 retCode = CKM_API_ERROR_DB_ERROR;
317 retCode = CKM_API_ERROR_DB_LOCKED;
320 MessageBuffer response;
321 Serialization::Serialize(response, static_cast<int>(LogicCommand::REMOVE));
322 Serialization::Serialize(response, commandId);
323 Serialization::Serialize(response, retCode);
324 Serialization::Serialize(response, static_cast<int>(dataType));
326 return response.Pop();
329 int CKMLogic::getDataHelper(
333 const Password &password,
337 if (0 == m_userDataMap.count(cred.uid))
338 return CKM_API_ERROR_DB_LOCKED;
340 auto &handler = m_userDataMap[cred.uid];
342 DBCrypto::DBRowOptional row_optional;
343 if (dataType == DBDataType::CERTIFICATE || dataType == DBDataType::BINARY_DATA) {
344 row_optional = handler.database.getDBRow(alias, cred.smackLabel, dataType);
345 } else if ((static_cast<int>(dataType) >= static_cast<int>(DBDataType::DB_KEY_FIRST))
346 && (static_cast<int>(dataType) <= static_cast<int>(DBDataType::DB_KEY_LAST)))
348 row_optional = handler.database.getKeyDBRow(alias, cred.smackLabel);
350 LogError("Unknown type of requested data" << (int)dataType);
351 return CKM_API_ERROR_BAD_REQUEST;
354 LogError("No row for given alias, label and type");
355 return CKM_API_ERROR_DB_ALIAS_UNKNOWN;
360 if (!handler.crypto.haveKey(row.smackLabel)) {
362 auto key_optional = handler.database.getKey(row.smackLabel);
364 LogError("No key for given label in database");
365 return CKM_API_ERROR_DB_ERROR;
368 key = handler.keyProvider.getPureDEK(key);
369 handler.crypto.pushKey(cred.smackLabel, key);
371 handler.crypto.decryptRow(password, row);
373 return CKM_API_SUCCESS;
376 RawBuffer CKMLogic::getData(
381 const Password &password)
383 int retCode = CKM_API_SUCCESS;
387 retCode = getDataHelper(cred, dataType, alias, password, row);
388 } catch (const KeyProvider::Exception::Base &e) {
389 LogError("KeyProvider failed with error: " << e.GetMessage());
390 retCode = CKM_API_ERROR_SERVER_ERROR;
391 } catch (const CryptoLogic::Exception::Base &e) {
392 LogError("CryptoLogic failed with message: " << e.GetMessage());
393 retCode = CKM_API_ERROR_SERVER_ERROR;
394 } catch (const DBCrypto::Exception::Base &e) {
395 LogError("DBCrypto failed with message: " << e.GetMessage());
396 retCode = CKM_API_ERROR_DB_ERROR;
399 if (CKM_API_SUCCESS != retCode) {
401 row.dataType = dataType;
404 if ((CKM_API_SUCCESS == retCode) && (row.exportable == 0)) {
406 retCode = CKM_API_ERROR_NOT_EXPORTABLE;
409 MessageBuffer response;
410 Serialization::Serialize(response, static_cast<int>(LogicCommand::GET));
411 Serialization::Serialize(response, commandId);
412 Serialization::Serialize(response, retCode);
413 Serialization::Serialize(response, static_cast<int>(row.dataType));
414 Serialization::Serialize(response, row.data);
415 return response.Pop();
418 RawBuffer CKMLogic::getDataList(
423 int retCode = CKM_API_SUCCESS;
424 AliasVector aliasVector;
426 if (0 < m_userDataMap.count(cred.uid)) {
427 auto &handler = m_userDataMap[cred.uid];
429 if (dataType == DBDataType::CERTIFICATE || dataType == DBDataType::BINARY_DATA) {
430 handler.database.getAliases(dataType, cred.smackLabel, aliasVector);
432 handler.database.getKeyAliases(cred.smackLabel, aliasVector);
434 } Catch (CKM::Exception) {
435 LogError("Failed to get aliases");
436 retCode = CKM_API_ERROR_DB_ERROR;
439 retCode = CKM_API_ERROR_DB_LOCKED;
442 MessageBuffer response;
443 Serialization::Serialize(response, static_cast<int>(LogicCommand::GET_LIST));
444 Serialization::Serialize(response, commandId);
445 Serialization::Serialize(response, retCode);
446 Serialization::Serialize(response, static_cast<int>(dataType));
447 Serialization::Serialize(response, aliasVector);
448 return response.Pop();
452 int CKMLogic::createKeyPairHelper(
454 const KeyType key_type,
455 const int additional_param,
456 const Alias &aliasPrivate,
457 const Alias &aliasPublic,
458 const PolicySerializable &policyPrivate,
459 const PolicySerializable &policyPublic)
461 if (0 >= m_userDataMap.count(cred.uid))
462 return CKM_API_ERROR_DB_LOCKED;
464 auto &handler = m_userDataMap[cred.uid];
469 case KeyType::KEY_RSA_PUBLIC:
470 case KeyType::KEY_RSA_PRIVATE:
471 retCode = CryptoService::createKeyPairRSA(additional_param, prv, pub);
474 case KeyType::KEY_DSA_PUBLIC:
475 case KeyType::KEY_DSA_PRIVATE:
476 retCode = CryptoService::createKeyPairDSA(additional_param, prv, pub);
479 case KeyType::KEY_ECDSA_PUBLIC:
480 case KeyType::KEY_ECDSA_PRIVATE:
481 retCode = CryptoService::createKeyPairECDSA(static_cast<ElipticCurve>(additional_param), prv, pub);
485 return CKM_API_ERROR_INPUT_PARAM;
488 if (CKM_CRYPTO_CREATEKEY_SUCCESS != retCode)
490 LogDebug("CryptoService error with code: " << retCode);
491 return CKM_API_ERROR_SERVER_ERROR; // TODO error code
494 DBCrypto::Transaction transaction(&handler.database);
495 retCode = saveDataHelper(cred,
496 toDBDataType(prv.getType()),
501 if (CKM_API_SUCCESS != retCode)
504 retCode = saveDataHelper(cred,
505 toDBDataType(pub.getType()),
510 if (CKM_API_SUCCESS != retCode)
513 transaction.commit();
518 RawBuffer CKMLogic::createKeyPair(
520 LogicCommand protocol_cmd,
522 const int additional_param,
523 const Alias &aliasPrivate,
524 const Alias &aliasPublic,
525 const PolicySerializable &policyPrivate,
526 const PolicySerializable &policyPublic)
528 int retCode = CKM_API_SUCCESS;
530 KeyType key_type = KeyType::KEY_NONE;
533 case LogicCommand::CREATE_KEY_PAIR_RSA:
534 key_type = KeyType::KEY_RSA_PUBLIC;
536 case LogicCommand::CREATE_KEY_PAIR_DSA:
537 key_type = KeyType::KEY_DSA_PUBLIC;
539 case LogicCommand::CREATE_KEY_PAIR_ECDSA:
540 key_type = KeyType::KEY_ECDSA_PUBLIC;
547 retCode = createKeyPairHelper(
556 } catch (DBCrypto::Exception::AliasExists &e) {
557 LogDebug("DBCrypto error: alias exists: " << e.GetMessage());
558 retCode = CKM_API_ERROR_DB_ALIAS_EXISTS;
559 } catch (DBCrypto::Exception::TransactionError &e) {
560 LogDebug("DBCrypto error: transaction error: " << e.GetMessage());
561 retCode = CKM_API_ERROR_DB_ERROR;
562 } catch (CKM::CryptoLogic::Exception::Base &e) {
563 LogDebug("CryptoLogic error: " << e.GetMessage());
564 retCode = CKM_API_ERROR_SERVER_ERROR;
565 } catch (DBCrypto::Exception::InternalError &e) {
566 LogDebug("DBCrypto internal error: " << e.GetMessage());
567 retCode = CKM_API_ERROR_DB_ERROR;
570 MessageBuffer response;
571 Serialization::Serialize(response, static_cast<int>(protocol_cmd));
572 Serialization::Serialize(response, commandId);
573 Serialization::Serialize(response, retCode);
575 return response.Pop();
578 RawBuffer CKMLogic::getCertificateChain(
581 const RawBuffer &certificate,
582 const RawBufferVector &untrustedRawCertVector)
586 CertificateImpl cert(certificate, DataFormat::FORM_DER);
587 CertificateImplVector untrustedCertVector;
588 CertificateImplVector chainVector;
589 RawBufferVector chainRawVector;
591 for (auto &e: untrustedRawCertVector)
592 untrustedCertVector.push_back(CertificateImpl(e, DataFormat::FORM_DER));
594 LogDebug("Cert is empty: " << cert.empty());
596 int retCode = m_certStore.verifyCertificate(cert, untrustedCertVector, chainVector);
598 if (retCode == CKM_API_SUCCESS) {
599 for (auto &e : chainVector)
600 chainRawVector.push_back(e.getDER());
603 MessageBuffer response;
604 Serialization::Serialize(response, static_cast<int>(LogicCommand::GET_CHAIN_CERT));
605 Serialization::Serialize(response, commandId);
606 Serialization::Serialize(response, retCode);
607 Serialization::Serialize(response, chainRawVector);
608 return response.Pop();
611 RawBuffer CKMLogic::getCertificateChain(
614 const RawBuffer &certificate,
615 const AliasVector &aliasVector)
617 int retCode = CKM_API_SUCCESS;
618 RawBufferVector chainRawVector;
620 CertificateImpl cert(certificate, DataFormat::FORM_DER);
621 CertificateImplVector untrustedCertVector;
622 CertificateImplVector chainVector;
626 retCode = CKM_API_ERROR_SERVER_ERROR;
630 for (auto &i: aliasVector) {
631 retCode = getDataHelper(cred, DBDataType::CERTIFICATE, i, Password(), row);
633 if (retCode != CKM_API_SUCCESS)
636 untrustedCertVector.push_back(CertificateImpl(row.data, DataFormat::FORM_DER));
639 retCode = m_certStore.verifyCertificate(cert, untrustedCertVector, chainVector);
641 if (retCode != CKM_API_SUCCESS)
644 for (auto &i: chainVector)
645 chainRawVector.push_back(i.getDER());
647 } catch (const CryptoLogic::Exception::Base &e) {
648 LogError("DBCyptorModule failed with message: " << e.GetMessage());
649 retCode = CKM_API_ERROR_SERVER_ERROR;
650 } catch (const DBCrypto::Exception::Base &e) {
651 LogError("DBCrypto failed with message: " << e.GetMessage());
652 retCode = CKM_API_ERROR_DB_ERROR;
654 LogError("Unknown error.");
658 MessageBuffer response;
659 Serialization::Serialize(response, static_cast<int>(LogicCommand::GET_CHAIN_ALIAS));
660 Serialization::Serialize(response, commandId);
661 Serialization::Serialize(response, retCode);
662 Serialization::Serialize(response, chainRawVector);
663 return response.Pop();
666 RawBuffer CKMLogic::createSignature(
669 const Alias &privateKeyAlias,
670 const Password &password, // password for private_key
671 const RawBuffer &message,
672 const HashAlgorithm hash,
673 const RSAPaddingAlgorithm padding)
679 int retCode = CKM_API_SUCCESS;
683 retCode = getDataHelper(cred, DBDataType::DB_KEY_FIRST, privateKeyAlias, password, row);
684 if (CKM_API_SUCCESS != retCode) {
685 LogError("getDataHelper return error");
689 KeyImpl keyParsed(row.data, Password());
690 if (keyParsed.empty())
691 retCode = CKM_API_ERROR_SERVER_ERROR;
693 retCode = cs.createSignature(keyParsed, message, hash, padding, signature);
695 } catch (const KeyProvider::Exception::Base &e) {
696 LogError("KeyProvider failed with message: " << e.GetMessage());
697 retCode = CKM_API_ERROR_SERVER_ERROR;
698 } catch (const CryptoLogic::Exception::Base &e) {
699 LogError("CryptoLogic failed with message: " << e.GetMessage());
700 retCode = CKM_API_ERROR_SERVER_ERROR;
701 } catch (const DBCrypto::Exception::Base &e) {
702 LogError("DBCrypto failed with message: " << e.GetMessage());
703 retCode = CKM_API_ERROR_DB_ERROR;
704 } catch (const CKM::Exception &e) {
705 LogError("Unknown CKM::Exception: " << e.GetMessage());
706 retCode = CKM_API_ERROR_SERVER_ERROR;
709 MessageBuffer response;
710 Serialization::Serialize(response, static_cast<int>(LogicCommand::CREATE_SIGNATURE));
711 Serialization::Serialize(response, commandId);
712 Serialization::Serialize(response, retCode);
713 Serialization::Serialize(response, signature);
714 return response.Pop();
717 RawBuffer CKMLogic::verifySignature(
720 const Alias &publicKeyOrCertAlias,
721 const Password &password, // password for public_key (optional)
722 const RawBuffer &message,
723 const RawBuffer &signature,
724 const HashAlgorithm hash,
725 const RSAPaddingAlgorithm padding)
727 int retCode = CKM_API_ERROR_VERIFICATION_FAILED;
735 retCode = getDataHelper(cred, DBDataType::DB_KEY_FIRST, publicKeyOrCertAlias, password, row);
737 if (retCode == CKM_API_SUCCESS) {
738 key = KeyImpl(row.data);
739 } else if (retCode == CKM_API_ERROR_DB_ALIAS_UNKNOWN) {
740 retCode = getDataHelper(cred, DBDataType::CERTIFICATE, publicKeyOrCertAlias, password, row);
741 if (retCode != CKM_API_SUCCESS)
743 CertificateImpl cert(row.data, DataFormat::FORM_DER);
744 key = cert.getKeyImpl();
750 retCode = CKM_API_ERROR_SERVER_ERROR;
754 retCode = cs.verifySignature(key, message, signature, hash, padding);
756 } catch (const CryptoService::Exception::Crypto_internal &e) {
757 LogError("KeyProvider failed with message: " << e.GetMessage());
758 retCode = CKM_API_ERROR_SERVER_ERROR;
759 } catch (const CryptoService::Exception::opensslError &e) {
760 LogError("KeyProvider failed with message: " << e.GetMessage());
761 retCode = CKM_API_ERROR_SERVER_ERROR;
762 } catch (const KeyProvider::Exception::Base &e) {
763 LogError("KeyProvider failed with error: " << e.GetMessage());
764 retCode = CKM_API_ERROR_SERVER_ERROR;
765 } catch (const CryptoLogic::Exception::Base &e) {
766 LogError("CryptoLogic failed with message: " << e.GetMessage());
767 retCode = CKM_API_ERROR_SERVER_ERROR;
768 } catch (const DBCrypto::Exception::Base &e) {
769 LogError("DBCrypto failed with message: " << e.GetMessage());
770 retCode = CKM_API_ERROR_DB_ERROR;
771 } catch (const CKM::Exception &e) {
772 LogError("Unknown CKM::Exception: " << e.GetMessage());
773 retCode = CKM_API_ERROR_SERVER_ERROR;
776 MessageBuffer response;
777 Serialization::Serialize(response, static_cast<int>(LogicCommand::VERIFY_SIGNATURE));
778 Serialization::Serialize(response, commandId);
779 Serialization::Serialize(response, retCode);
781 return response.Pop();