2 * Copyright (c) 2015 -2019 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>
40 Item() : type(CKM::DataType::DB_LAST)
44 Item(const CKM::Alias &alias,
45 const CKM::DataType::Type type,
46 const CKM::Policy &policy)
47 : alias(alias), type(type), policy(policy)
52 CKM::DataType::Type type;
56 typedef std::vector<Item> Items;
60 typeFrom(CKM::DataType::DB_FIRST),
61 typeTo(CKM::DataType::DB_LAST),
62 exportableOnly(false),
67 explicit ItemFilter(CKM::DataType::Type type) :
70 exportableOnly(false),
75 ItemFilter(CKM::DataType::Type typeFrom, CKM::DataType::Type typeTo) :
78 exportableOnly(false),
83 bool Matches(const Item &item) const
85 if (item.type < typeFrom || item.type > typeTo)
88 if (exportableOnly && !item.policy.extractable)
91 if (noPassword && !item.policy.password.empty())
97 CKM::DataType::Type typeFrom;
98 CKM::DataType::Type typeTo;
108 void CheckAliasInfo();
109 void RemoveUserData();
111 void ReadAll(bool useWrongPass = false);
113 void EncryptDecrypt();
116 size_t CountObjects();
118 void CheckSchemeVersion(const ItemFilter &filter, int version);
123 void EnableDirectDbAccess();
124 void SignVerifyItem(const Item &itemPrv, const Item &itemPub);
125 void EncryptDecryptItem(const Item &item);
126 void EncryptDecryptItem(const Item &itemPrv, const Item &itemPub);
127 void CreateChainItem(const Item &leaf, const Items &certs);
129 CKM::ControlShPtr m_control;
130 CKM::ManagerShPtr m_mgr;
131 std::string m_origLabel;
134 std::unique_ptr<CKM::DB::Crypto> m_db;
135 bool m_directAccessEnabled;