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>
30 #include <generic-key.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.getDomainKEK();
63 if (wrappedDomainKEK.empty()) {
64 wrappedDomainKEK = KeyProvider::generateDomainKEK(std::to_string(user), password);
65 fs.saveDomainKEK(wrappedDomainKEK);
68 handle.keyProvider = KeyProvider(wrappedDomainKEK, password);
70 RawBuffer key = handle.keyProvider.getPureDomainKEK();
71 handle.database = DBCrypto(fs.getDBPath(), key);
72 handle.crypto = CryptoLogic();
75 } catch (const KeyProvider::Exception::PassWordError &e) {
76 LogError("Incorrect Password " << e.GetMessage());
77 retCode = CKM_API_ERROR_AUTHENTICATION_FAILED;
78 } catch (const KeyProvider::Exception::Base &e) {
79 LogError("Error in KeyProvider " << e.GetMessage());
80 retCode = CKM_API_ERROR_SERVER_ERROR;
81 } catch (const CryptoLogic::Exception::Base &e) {
82 LogError("CryptoLogic error: " << e.GetMessage());
83 retCode = CKM_API_ERROR_SERVER_ERROR;
84 } catch (const CKM::Exception &e) {
85 LogError("CKM::Exception: " << e.GetMessage());
86 retCode = CKM_API_ERROR_SERVER_ERROR;
89 MessageBuffer response;
90 Serialization::Serialize(response, retCode);
91 return response.Pop();
94 RawBuffer CKMLogic::lockUserKey(uid_t user) {
95 int retCode = CKM_API_SUCCESS;
96 // TODO try catch for all errors that should be supported by error code
97 m_userDataMap.erase(user);
99 MessageBuffer response;
100 Serialization::Serialize(response, retCode);
101 return response.Pop();
104 RawBuffer CKMLogic::removeUserData(uid_t user) {
105 int retCode = CKM_API_SUCCESS;
106 // TODO try catch for all errors that should be supported by error code
107 m_userDataMap.erase(user);
112 MessageBuffer response;
113 Serialization::Serialize(response, retCode);
114 return response.Pop();
117 RawBuffer CKMLogic::changeUserPassword(
119 const Password &oldPassword,
120 const Password &newPassword)
122 int retCode = CKM_API_SUCCESS;
125 auto wrappedDomainKEK = fs.getDomainKEK();
126 if (wrappedDomainKEK.empty()) {
127 retCode = CKM_API_ERROR_BAD_REQUEST;
129 wrappedDomainKEK = KeyProvider::reencrypt(wrappedDomainKEK, oldPassword, newPassword);
130 fs.saveDomainKEK(wrappedDomainKEK);
132 } catch (const KeyProvider::Exception::PassWordError &e) {
133 LogError("Incorrect Password " << e.GetMessage());
134 retCode = CKM_API_ERROR_AUTHENTICATION_FAILED;
135 } catch (const KeyProvider::Exception::Base &e) {
136 LogError("Error in KeyProvider " << e.GetMessage());
137 retCode = CKM_API_ERROR_SERVER_ERROR;
138 } catch (const CKM::Exception &e) {
139 LogError("CKM::Exception: " << e.GetMessage());
140 retCode = CKM_API_ERROR_SERVER_ERROR;
143 MessageBuffer response;
144 Serialization::Serialize(response, retCode);
145 return response.Pop();
148 RawBuffer CKMLogic::resetUserPassword(
150 const Password &newPassword)
152 int retCode = CKM_API_SUCCESS;
154 if (0 == m_userDataMap.count(user)) {
155 retCode = CKM_API_ERROR_BAD_REQUEST;
157 auto &handler = m_userDataMap[user];
159 fs.saveDomainKEK(handler.keyProvider.getWrappedDomainKEK(newPassword));
162 MessageBuffer response;
163 Serialization::Serialize(response, retCode);
164 return response.Pop();
167 int CKMLogic::saveDataHelper(
171 const RawBuffer &key,
172 const PolicySerializable &policy)
174 if (0 == m_userDataMap.count(cred.uid))
175 return CKM_API_ERROR_DB_LOCKED;
177 DBRow row = { alias, cred.smackLabel, policy.restricted,
178 policy.extractable, dataType, DBCMAlgType::NONE,
179 0, RawBuffer(), static_cast<int>(key.size()), key };
181 auto &handler = m_userDataMap[cred.uid];
182 DBCrypto::Transaction transaction(&handler.database);
183 if (!handler.crypto.haveKey(cred.smackLabel)) {
185 auto key_optional = handler.database.getKey(cred.smackLabel);
187 LogDebug("No Key in database found. Generating new one for label: "
189 key = handler.keyProvider.generateDEK(cred.smackLabel);
190 handler.database.saveKey(cred.smackLabel, key);
192 LogDebug("Key from DB");
196 key = handler.keyProvider.getPureDEK(key);
197 handler.crypto.pushKey(cred.smackLabel, key);
199 handler.crypto.encryptRow(policy.password, row);
200 handler.database.saveDBRow(row);
201 transaction.commit();
202 return CKM_API_SUCCESS;
205 RawBuffer CKMLogic::saveData(
210 const RawBuffer &key,
211 const PolicySerializable &policy)
213 int retCode = CKM_API_SUCCESS;
215 retCode = saveDataHelper(cred, dataType, alias, key, policy);
216 LogDebug("SaveDataHelper returned: " << retCode);
217 } catch (const KeyProvider::Exception::Base &e) {
218 LogError("KeyProvider failed with message: " << e.GetMessage());
219 retCode = CKM_API_ERROR_SERVER_ERROR;
220 } catch (const CryptoLogic::Exception::Base &e) {
221 LogError("CryptoLogic failed with message: " << e.GetMessage());
222 retCode = CKM_API_ERROR_SERVER_ERROR;
223 } catch (const DBCrypto::Exception::InternalError &e) {
224 LogError("DBCrypto failed with message: " << e.GetMessage());
225 retCode = CKM_API_ERROR_DB_ERROR;
226 } catch (const DBCrypto::Exception::AliasExists &e) {
227 LogError("DBCrypto couldn't save duplicate alias");
228 retCode = CKM_API_ERROR_DB_ALIAS_EXISTS;
229 } catch (const DBCrypto::Exception::TransactionError &e) {
230 LogError("DBCrypto transaction failed with message " << e.GetMessage());
231 retCode = CKM_API_ERROR_DB_ERROR;
234 MessageBuffer response;
235 Serialization::Serialize(response, static_cast<int>(LogicCommand::SAVE));
236 Serialization::Serialize(response, commandId);
237 Serialization::Serialize(response, retCode);
238 Serialization::Serialize(response, static_cast<int>(dataType));
240 return response.Pop();
243 RawBuffer CKMLogic::removeData(
249 int retCode = CKM_API_SUCCESS;
251 if (0 < m_userDataMap.count(cred.uid)) {
253 auto erased = m_userDataMap[cred.uid].database.deleteDBRow(alias, cred.smackLabel);
254 // check if the data existed or not
256 LogError("No row for given alias and label");
257 retCode = CKM_API_ERROR_DB_ALIAS_UNKNOWN;
259 } Catch (CKM::Exception) {
260 LogError("Error in deleting row!");
261 retCode = CKM_API_ERROR_DB_ERROR;
264 retCode = CKM_API_ERROR_DB_LOCKED;
267 MessageBuffer response;
268 Serialization::Serialize(response, static_cast<int>(LogicCommand::REMOVE));
269 Serialization::Serialize(response, commandId);
270 Serialization::Serialize(response, retCode);
271 Serialization::Serialize(response, static_cast<int>(dataType));
273 return response.Pop();
276 int CKMLogic::getDataHelper(
280 const Password &password,
284 if (0 == m_userDataMap.count(cred.uid))
285 return CKM_API_ERROR_DB_LOCKED;
287 auto &handler = m_userDataMap[cred.uid];
289 DBCrypto::DBRowOptional row_optional;
290 if (dataType == DBDataType::CERTIFICATE || dataType == DBDataType::BINARY_DATA) {
291 row_optional = handler.database.getDBRow(alias, cred.smackLabel, dataType);
292 } else if ((static_cast<int>(dataType) >= static_cast<int>(DBDataType::DB_KEY_FIRST))
293 && (static_cast<int>(dataType) <= static_cast<int>(DBDataType::DB_KEY_LAST)))
295 row_optional = handler.database.getKeyDBRow(alias, cred.smackLabel);
297 LogError("Unknown type of requested data" << (int)dataType);
298 return CKM_API_ERROR_BAD_REQUEST;
301 LogError("No row for given alias, label and type");
302 return CKM_API_ERROR_DB_ALIAS_UNKNOWN;
307 if (!handler.crypto.haveKey(row.smackLabel)) {
309 auto key_optional = handler.database.getKey(row.smackLabel);
311 LogError("No key for given label in database");
312 return CKM_API_ERROR_DB_ERROR;
315 key = handler.keyProvider.getPureDEK(key);
316 handler.crypto.pushKey(cred.smackLabel, key);
318 handler.crypto.decryptRow(password, row);
320 return CKM_API_SUCCESS;
323 RawBuffer CKMLogic::getData(
328 const Password &password)
330 int retCode = CKM_API_SUCCESS;
334 retCode = getDataHelper(cred, dataType, alias, password, row);
335 } catch (const KeyProvider::Exception::Base &e) {
336 LogError("KeyProvider failed with error: " << e.GetMessage());
337 retCode = CKM_API_ERROR_SERVER_ERROR;
338 } catch (const CryptoLogic::Exception::Base &e) {
339 LogError("CryptoLogic failed with message: " << e.GetMessage());
340 retCode = CKM_API_ERROR_SERVER_ERROR;
341 } catch (const DBCrypto::Exception::Base &e) {
342 LogError("DBCrypto failed with message: " << e.GetMessage());
343 retCode = CKM_API_ERROR_DB_ERROR;
346 if (CKM_API_SUCCESS != retCode) {
348 row.dataType = dataType;
351 MessageBuffer response;
352 Serialization::Serialize(response, static_cast<int>(LogicCommand::GET));
353 Serialization::Serialize(response, commandId);
354 Serialization::Serialize(response, retCode);
355 Serialization::Serialize(response, static_cast<int>(row.dataType));
356 Serialization::Serialize(response, row.data);
357 return response.Pop();
360 RawBuffer CKMLogic::getDataList(
365 int retCode = CKM_API_SUCCESS;
366 AliasVector aliasVector;
368 if (0 < m_userDataMap.count(cred.uid)) {
369 auto &handler = m_userDataMap[cred.uid];
371 if (dataType == DBDataType::CERTIFICATE || dataType == DBDataType::BINARY_DATA) {
372 handler.database.getAliases(dataType, cred.smackLabel, aliasVector);
374 handler.database.getKeyAliases(cred.smackLabel, aliasVector);
376 } Catch (CKM::Exception) {
377 LogError("Failed to get aliases");
378 retCode = CKM_API_ERROR_DB_ERROR;
381 retCode = CKM_API_ERROR_DB_LOCKED;
384 MessageBuffer response;
385 Serialization::Serialize(response, static_cast<int>(LogicCommand::GET_LIST));
386 Serialization::Serialize(response, commandId);
387 Serialization::Serialize(response, retCode);
388 Serialization::Serialize(response, static_cast<int>(dataType));
389 Serialization::Serialize(response, aliasVector);
390 return response.Pop();
393 int CKMLogic::createKeyPairRSAHelper(
396 const Alias &aliasPrivate,
397 const Alias &aliasPublic,
398 const PolicySerializable &policyPrivate,
399 const PolicySerializable &policyPublic)
401 if (0 >= m_userDataMap.count(cred.uid))
402 return CKM_API_ERROR_DB_LOCKED;
404 auto &handler = m_userDataMap[cred.uid];
408 if (CKM_CRYPTO_CREATEKEY_SUCCESS !=
409 (retCode = CryptoService::createKeyPairRSA(size, prv, pub)))
411 LogDebug("CryptoService error with code: " << retCode);
412 return CKM_API_ERROR_SERVER_ERROR; // TODO error code
415 DBCrypto::Transaction transaction(&handler.database);
416 retCode = saveDataHelper(cred,
417 toDBDataType(prv.getType()),
422 if (CKM_API_SUCCESS != retCode)
425 retCode = saveDataHelper(cred,
426 toDBDataType(pub.getType()),
431 if (CKM_API_SUCCESS != retCode)
434 transaction.commit();
439 RawBuffer CKMLogic::createKeyPairRSA(
443 const Alias &aliasPrivate,
444 const Alias &aliasPublic,
445 const PolicySerializable &policyPrivate,
446 const PolicySerializable &policyPublic)
448 int retCode = CKM_API_SUCCESS;
451 retCode = createKeyPairRSAHelper(
459 } catch (DBCrypto::Exception::AliasExists &e) {
460 LogDebug("DBCrypto error: alias exists: " << e.GetMessage());
461 retCode = CKM_API_ERROR_DB_ALIAS_EXISTS;
462 } catch (DBCrypto::Exception::TransactionError &e) {
463 LogDebug("DBCrypto error: transaction error: " << e.GetMessage());
464 retCode = CKM_API_ERROR_DB_ERROR;
465 } catch (CKM::CryptoLogic::Exception::Base &e) {
466 LogDebug("CryptoLogic error: " << e.GetMessage());
467 retCode = CKM_API_ERROR_SERVER_ERROR;
468 } catch (DBCrypto::Exception::InternalError &e) {
469 LogDebug("DBCrypto internal error: " << e.GetMessage());
470 retCode = CKM_API_ERROR_DB_ERROR;
473 MessageBuffer response;
474 Serialization::Serialize(response, static_cast<int>(LogicCommand::CREATE_KEY_PAIR_RSA));
475 Serialization::Serialize(response, commandId);
476 Serialization::Serialize(response, retCode);
478 return response.Pop();
481 int CKMLogic::createKeyPairECDSAHelper(
484 const Alias &aliasPrivate,
485 const Alias &aliasPublic,
486 const PolicySerializable &policyPrivate,
487 const PolicySerializable &policyPublic)
489 if (0 >= m_userDataMap.count(cred.uid))
490 return CKM_API_ERROR_DB_LOCKED;
492 auto &handler = m_userDataMap[cred.uid];
496 if (CKM_CRYPTO_CREATEKEY_SUCCESS !=
497 (retCode = CryptoService::createKeyPairECDSA(static_cast<ElipticCurve>(type), prv, pub)))
499 LogError("CryptoService failed with code: " << retCode);
500 return CKM_API_ERROR_SERVER_ERROR; // TODO error code
503 DBCrypto::Transaction transaction(&handler.database);
505 retCode = saveDataHelper(cred,
506 toDBDataType(prv.getType()),
511 if (CKM_API_SUCCESS != retCode)
514 retCode = saveDataHelper(cred,
515 toDBDataType(pub.getType()),
520 if (CKM_API_SUCCESS != retCode)
523 transaction.commit();
528 RawBuffer CKMLogic::createKeyPairECDSA(
532 const Alias &aliasPrivate,
533 const Alias &aliasPublic,
534 const PolicySerializable &policyPrivate,
535 const PolicySerializable &policyPublic)
537 int retCode = CKM_API_SUCCESS;
540 retCode = createKeyPairECDSAHelper(
547 } catch (const DBCrypto::Exception::AliasExists &e) {
548 LogDebug("DBCrypto error: alias exists: " << e.GetMessage());
549 retCode = CKM_API_ERROR_DB_ALIAS_EXISTS;
550 } catch (const DBCrypto::Exception::TransactionError &e) {
551 LogDebug("DBCrypto error: transaction error: " << e.GetMessage());
552 retCode = CKM_API_ERROR_DB_ERROR;
553 } catch (const CKM::CryptoLogic::Exception::Base &e) {
554 LogDebug("CryptoLogic error: " << e.GetMessage());
555 retCode = CKM_API_ERROR_SERVER_ERROR;
556 } catch (const DBCrypto::Exception::InternalError &e) {
557 LogDebug("DBCrypto internal error: " << e.GetMessage());
558 retCode = CKM_API_ERROR_DB_ERROR;
561 MessageBuffer response;
562 Serialization::Serialize(response, static_cast<int>(LogicCommand::CREATE_KEY_PAIR_RSA));
563 Serialization::Serialize(response, commandId);
564 Serialization::Serialize(response, retCode);
566 return response.Pop();
569 RawBuffer CKMLogic::getCertificateChain(
572 const RawBuffer &certificate,
573 const RawBufferVector &untrustedRawCertVector)
577 CertificateImpl cert(certificate, DataFormat::FORM_DER);
578 CertificateImplVector untrustedCertVector;
579 CertificateImplVector chainVector;
580 RawBufferVector chainRawVector;
582 for (auto &e: untrustedRawCertVector)
583 untrustedCertVector.push_back(CertificateImpl(e, DataFormat::FORM_DER));
585 LogDebug("Cert is empty: " << cert.empty());
587 int retCode = m_certStore.verifyCertificate(cert, untrustedCertVector, chainVector);
589 if (retCode == CKM_API_SUCCESS) {
590 for (auto &e : chainVector)
591 chainRawVector.push_back(e.getDER());
594 MessageBuffer response;
595 Serialization::Serialize(response, static_cast<int>(LogicCommand::GET_CHAIN_CERT));
596 Serialization::Serialize(response, commandId);
597 Serialization::Serialize(response, retCode);
598 Serialization::Serialize(response, chainRawVector);
599 return response.Pop();
602 RawBuffer CKMLogic::getCertificateChain(
605 const RawBuffer &certificate,
606 const AliasVector &aliasVector)
608 int retCode = CKM_API_SUCCESS;
609 RawBufferVector chainRawVector;
611 CertificateImpl cert(certificate, DataFormat::FORM_DER);
612 CertificateImplVector untrustedCertVector;
613 CertificateImplVector chainVector;
617 retCode = CKM_API_ERROR_SERVER_ERROR;
621 for (auto &i: aliasVector) {
622 retCode = getDataHelper(cred, DBDataType::CERTIFICATE, i, Password(), row);
624 if (retCode != CKM_API_SUCCESS)
627 untrustedCertVector.push_back(CertificateImpl(row.data, DataFormat::FORM_DER));
630 retCode = m_certStore.verifyCertificate(cert, untrustedCertVector, chainVector);
632 if (retCode != CKM_API_SUCCESS)
635 for (auto &i: chainVector)
636 chainRawVector.push_back(i.getDER());
638 } catch (const CryptoLogic::Exception::Base &e) {
639 LogError("DBCyptorModule failed with message: " << e.GetMessage());
640 retCode = CKM_API_ERROR_SERVER_ERROR;
641 } catch (const DBCrypto::Exception::Base &e) {
642 LogError("DBCrypto failed with message: " << e.GetMessage());
643 retCode = CKM_API_ERROR_DB_ERROR;
645 LogError("Unknown error.");
649 MessageBuffer response;
650 Serialization::Serialize(response, static_cast<int>(LogicCommand::GET_CHAIN_ALIAS));
651 Serialization::Serialize(response, commandId);
652 Serialization::Serialize(response, retCode);
653 Serialization::Serialize(response, chainRawVector);
654 return response.Pop();
657 RawBuffer CKMLogic::createSignature(
660 const Alias &privateKeyAlias,
661 const Password &password, // password for private_key
662 const RawBuffer &message,
663 const HashAlgorithm hash,
664 const RSAPaddingAlgorithm padding)
670 int retCode = CKM_API_SUCCESS;
674 retCode = getDataHelper(cred, DBDataType::KEY_RSA_PUBLIC, privateKeyAlias, password, row);
675 if (CKM_API_SUCCESS != retCode) {
676 LogError("getDataHelper return error");
680 GenericKey keyParsed(row.data, Password());
681 if (keyParsed.empty())
682 retCode = CKM_API_ERROR_SERVER_ERROR;
684 cs.createSignature(keyParsed, message, hash, padding, signature);
686 } catch (const KeyProvider::Exception::Base &e) {
687 LogError("KeyProvider failed with message: " << e.GetMessage());
688 retCode = CKM_API_ERROR_SERVER_ERROR;
689 } catch (const CryptoLogic::Exception::Base &e) {
690 LogError("CryptoLogic failed with message: " << e.GetMessage());
691 retCode = CKM_API_ERROR_SERVER_ERROR;
692 } catch (const DBCrypto::Exception::Base &e) {
693 LogError("DBCrypto failed with message: " << e.GetMessage());
694 retCode = CKM_API_ERROR_DB_ERROR;
695 } catch (const CKM::Exception &e) {
696 LogError("Unknown CKM::Exception: " << e.GetMessage());
697 retCode = CKM_API_ERROR_SERVER_ERROR;
700 MessageBuffer response;
701 Serialization::Serialize(response, static_cast<int>(LogicCommand::CREATE_SIGNATURE));
702 Serialization::Serialize(response, commandId);
703 Serialization::Serialize(response, retCode);
704 Serialization::Serialize(response, signature);
705 return response.Pop();
708 RawBuffer CKMLogic::verifySignature(
711 const Alias &publicKeyOrCertAlias,
712 const Password &password, // password for public_key (optional)
713 const RawBuffer &message,
714 const RawBuffer &signature,
715 const HashAlgorithm hash,
716 const RSAPaddingAlgorithm padding)
718 int retCode = CKM_API_ERROR_VERIFICATION_FAILED;
726 retCode = getDataHelper(cred, DBDataType::DB_KEY_FIRST, publicKeyOrCertAlias, password, row);
728 if (retCode == CKM_API_SUCCESS) {
729 key = GenericKey(row.data);
730 } else if (retCode == CKM_API_ERROR_DB_ALIAS_UNKNOWN) {
731 retCode = getDataHelper(cred, DBDataType::CERTIFICATE, publicKeyOrCertAlias, password, row);
732 if (retCode != CKM_API_SUCCESS)
734 CertificateImpl cert(row.data, DataFormat::FORM_DER);
735 key = cert.getGenericKey();
741 retCode = CKM_API_ERROR_SERVER_ERROR;
745 retCode = cs.verifySignature(key, message, signature, hash, padding);
747 } catch (const CryptoService::Exception::Crypto_internal &e) {
748 LogError("KeyProvider failed with message: " << e.GetMessage());
749 retCode = CKM_API_ERROR_SERVER_ERROR;
750 } catch (const CryptoService::Exception::opensslError &e) {
751 LogError("KeyProvider failed with message: " << e.GetMessage());
752 retCode = CKM_API_ERROR_SERVER_ERROR;
753 } catch (const KeyProvider::Exception::Base &e) {
754 LogError("KeyProvider failed with error: " << e.GetMessage());
755 retCode = CKM_API_ERROR_SERVER_ERROR;
756 } catch (const CryptoLogic::Exception::Base &e) {
757 LogError("CryptoLogic failed with message: " << e.GetMessage());
758 retCode = CKM_API_ERROR_SERVER_ERROR;
759 } catch (const DBCrypto::Exception::Base &e) {
760 LogError("DBCrypto failed with message: " << e.GetMessage());
761 retCode = CKM_API_ERROR_DB_ERROR;
762 } catch (const CKM::Exception &e) {
763 LogError("Unknown CKM::Exception: " << e.GetMessage());
764 retCode = CKM_API_ERROR_SERVER_ERROR;
767 MessageBuffer response;
768 Serialization::Serialize(response, static_cast<int>(LogicCommand::VERIFY_SIGNATURE));
769 Serialization::Serialize(response, commandId);
770 Serialization::Serialize(response, retCode);
772 return response.Pop();