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.
27 #include <message-buffer.h>
28 #include <protocols.h>
29 #include <ckm/ckm-type.h>
30 #include <connection-info.h>
31 #include <db-crypto.h>
32 #include <key-provider.h>
33 #include <crypto-logic.h>
34 #include <certificate-store.h>
39 KeyProvider keyProvider;
47 CKMLogic(const CKMLogic &) = delete;
48 CKMLogic(CKMLogic &&) = delete;
49 CKMLogic& operator=(const CKMLogic &) = delete;
50 CKMLogic& operator=(CKMLogic &&) = delete;
53 RawBuffer unlockUserKey(uid_t user, const std::string &password);
55 RawBuffer lockUserKey(uid_t user);
57 RawBuffer removeUserData(uid_t user);
59 RawBuffer changeUserPassword(
61 const std::string &oldPassword,
62 const std::string &newPassword);
64 RawBuffer resetUserPassword(
66 const std::string &newPassword);
74 const PolicySerializable &policy);
87 const std::string &password);
89 RawBuffer getDataList(
94 RawBuffer createKeyPairRSA(
98 const Alias &aliasPrivate,
99 const Alias &alaisPublic,
100 const PolicySerializable &policyPrivate,
101 const PolicySerializable &policyPublic);
103 RawBuffer createKeyPairECDSA(
107 const Alias &aliasPrivate,
108 const Alias &aliasPublic,
109 const PolicySerializable &policyPrivate,
110 const PolicySerializable &policyPublic);
112 RawBuffer getCertificateChain(
115 const RawBuffer &certificate,
116 const RawBufferVector &untrustedCertificates);
118 RawBuffer getCertificateChain(
121 const RawBuffer &certificate,
122 const AliasVector &aliasVector);
124 RawBuffer createSignature(
127 const Alias &privateKeyAlias,
128 const std::string &password, // password for private_key
129 const RawBuffer &message,
130 const HashAlgorithm hash,
131 const RSAPaddingAlgorithm padding);
133 RawBuffer verifySignature(
136 const Alias &publicKeyOrCertAlias,
137 const std::string &password, // password for public_key (optional)
138 const RawBuffer &message,
139 const RawBuffer &signature,
140 const HashAlgorithm hash,
141 const RSAPaddingAlgorithm padding);
149 const RawBuffer &key,
150 const PolicySerializable &policy);
156 const std::string &password,
159 int createKeyPairRSAHelper(
162 const Alias &aliasPrivate,
163 const Alias &aliasPublic,
164 const PolicySerializable &policyPrivate,
165 const PolicySerializable &policyPublic);
167 int createKeyPairECDSAHelper(
170 const Alias &aliasPrivate,
171 const Alias &aliasPublic,
172 const PolicySerializable &policyPrivate,
173 const PolicySerializable &policyPublic);
177 const Alias &publicKeyOrCertAlias,
178 const std::string &password, // password for public_key (optional)
179 const GenericKey &genericKey);
181 std::map<uid_t, UserData> m_userDataMap;
182 CertificateStore m_certStore;