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>
13 #include "common/installer_context.h"
15 namespace fs = std::filesystem;
17 namespace common_installer {
21 Signature(RequestType request_type, std::string pkgid,
22 bool is_readonly_package, bool skip_check_reference,
23 CertificateInfo* cert_info) :
24 request_type_(request_type), pkgid_(pkgid),
25 is_readonly_package_(is_readonly_package),
26 skip_check_reference_(skip_check_reference),
27 cert_info_(cert_info) {}
28 virtual ~Signature() = default;
30 virtual bool CheckSignatures(bool check_reference, PrivilegeLevel* level,
31 std::filesystem::path sig_root_path,
32 std::string* error_message);
33 bool GetPrivilegeLevel(std::filesystem::path sig_root_path,
34 PrivilegeLevel* level,
35 std::string* error_message);
36 bool CheckMetadataPrivilege(PrivilegeLevel level, manifest_x* manifest,
37 std::string* error_message);
38 bool CheckSignatureMismatch(std::string* error_message);
40 bool StoreSignature(std::ofstream* ofs,
41 const ValidationCore::CertificatePtr& cert,
42 const ValidationCore::CertificatePtr& im_cert,
43 const ValidationCore::CertificatePtr& root_cert);
45 bool RemoveSignature(const fs::path& path);
46 bool SaveSignature(const fs::path& path);
47 const fs::path& GetFilePath() const;
48 const fs::path& GetBackupPath() const;
51 RequestType request_type_;
53 bool is_readonly_package_;
54 bool skip_check_reference_;
55 CertificateInfo* cert_info_;
57 fs::path backup_path_;
60 } // namespace common_installer
62 #endif // COMMON_SIGNATURE_H_