2 * Copyright (c) 2015 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 Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
28 #include <ckm/ckm-control.h>
29 #include <ckm/ckm-manager.h>
31 #include <data-type.h>
41 Item(const CKM::Alias& alias,
42 const CKM::DataType::Type type,
43 const CKM::Policy& policy)
44 : alias(alias), type(type), policy(policy)
49 CKM::DataType::Type type;
53 typedef std::vector<Item> Items;
57 typeFrom(CKM::DataType::DB_FIRST),
58 typeTo(CKM::DataType::DB_LAST),
59 exportableOnly(false),
63 explicit ItemFilter(CKM::DataType::Type type) :
66 exportableOnly(false),
70 ItemFilter(CKM::DataType::Type typeFrom, CKM::DataType::Type typeTo) :
73 exportableOnly(false),
77 bool Matches(const Item& item) const {
78 if(item.type < typeFrom || item.type > typeTo)
80 if(exportableOnly && !item.policy.extractable)
82 if(noPassword && !item.policy.password.empty())
87 CKM::DataType::Type typeFrom;
88 CKM::DataType::Type typeTo;
98 void RemoveUserData();
100 void ReadAll(bool useWrongPass = false);
102 void EncryptDecrypt();
105 size_t CountObjects();
107 void CheckSchemeVersion(const ItemFilter& filter, int version);
112 void EnableDirectDbAccess();
113 void SignVerifyItem(const Item& itemPrv, const Item& itemPub);
114 void EncryptDecryptItem(const Item& item);
115 void EncryptDecryptItem(const Item& itemPrv, const Item& itemPub);
116 void CreateChainItem(const Item& leaf, const Items& certs);
118 CKM::ControlShPtr m_control;
119 CKM::ManagerShPtr m_mgr;
120 std::string m_origLabel;
123 std::unique_ptr<CKM::DB::Crypto> m_db;
124 bool m_directAccessEnabled;