1 // Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
2 // Use of this source code is governed by a apache 2.0 license that can be
3 // found in the LICENSE file.
5 #ifndef COMMON_SIGNATURE_H_
6 #define COMMON_SIGNATURE_H_
8 #include <pkgmgrinfo_basic.h>
10 #include <boost/iostreams/stream.hpp>
11 #include <boost/iostreams/device/file_descriptor.hpp>
15 #include "common/installer_context.h"
17 namespace bf = boost::filesystem;
18 namespace bi = boost::iostreams;
20 namespace common_installer {
24 Signature(RequestType request_type, std::string pkgid,
25 bool is_readonly_package, bool skip_check_reference,
26 CertificateInfo* cert_info) :
27 request_type_(request_type), pkgid_(pkgid),
28 is_readonly_package_(is_readonly_package),
29 skip_check_reference_(skip_check_reference),
30 cert_info_(cert_info) {}
32 virtual bool CheckSignatures(bool check_reference, PrivilegeLevel* level,
33 boost::filesystem::path sig_root_path,
34 std::string* error_message);
35 bool GetPrivilegeLevel(boost::filesystem::path sig_root_path,
36 PrivilegeLevel* level,
37 std::string* error_message);
38 bool CheckMetadataPrivilege(PrivilegeLevel level, manifest_x* manifest,
39 std::string* error_message);
40 bool CheckSignatureMismatch(std::string* error_message);
42 bool StoreSignature(bi::stream<bi::file_descriptor_sink> *ofs,
43 const ValidationCore::CertificatePtr& cert,
44 const ValidationCore::CertificatePtr& im_cert,
45 const ValidationCore::CertificatePtr& root_cert);
47 bool RemoveSignature(const bf::path& path);
48 bool SaveSignature(const bf::path& path);
49 const bf::path& GetFilePath() const;
50 const bf::path& GetBackupPath() const;
53 RequestType request_type_;
55 bool is_readonly_package_;
56 bool skip_check_reference_;
57 CertificateInfo* cert_info_;
59 bf::path backup_path_;
62 } // namespace common_installer
64 #endif // COMMON_SIGNATURE_H_