2 * Copyright (c) 2000 - 2013 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.
31 #include <ckm/ckm-raw-buffer.h>
32 #include <ckm/ckm-password.h>
34 #define KEY_MANAGER_API __attribute__((visibility("default")))
38 // used to pass password and raw key data
39 typedef std::vector<RawBuffer> RawBufferVector;
40 typedef std::string Alias;
41 typedef std::string Label;
42 typedef std::vector<Alias> AliasVector;
44 enum class KeyType : int {
55 enum class DataFormat : int {
61 enum class ElipticCurve : int {
67 enum class CertificateFieldId : int {
73 Policy(const Password &pass = Password(), bool extract = true)
75 , extractable(extract)
78 Password password; // byte array used to encrypt data inside CKM
79 bool extractable; // if true key may be extracted from storage
82 enum class HashAlgorithm : int {
90 enum class RSAPaddingAlgorithm : int {
96 enum class DBCMAlgType : int {
102 typedef int PermissionMask;
103 enum Permission: int {
107 // keep in sync with ckmc_permission_e !
110 const char * ErrorToString(int error);
112 // algorithm parameters
113 enum class ParamName : int {
114 // encryption & decryption
124 GEN_EC, // elliptic curve (ElipticCurve)
127 SV_HASH_ALGO = 201, // hash algorithm (HashAlgorithm)
128 SV_RSA_PADDING, // RSA padding (RSAPaddingAlgorithm)
132 enum class AlgoType : int {
143 class KEY_MANAGER_API BaseParam {
145 virtual int getBuffer(RawBuffer&) const;
146 virtual int getInt(uint64_t&) const;
147 virtual ~BaseParam() {}
152 typedef std::unique_ptr<BaseParam> BaseParamPtr;
154 class KEY_MANAGER_API BufferParam : public BaseParam {
156 int getBuffer(RawBuffer& buffer) const;
157 static BaseParamPtr create(const RawBuffer& buffer);
159 explicit BufferParam(const RawBuffer& value) : m_buffer(value) {}
164 class KEY_MANAGER_API IntParam : public BaseParam {
166 static BaseParamPtr create(uint64_t value);
167 int getInt(uint64_t& value) const;
169 explicit IntParam(uint64_t value) : m_int(value) {}
174 // cryptographic algorithm description
175 struct CryptoAlgorithm {
177 std::map<ParamName, BaseParamPtr> m_params;