LIEF: Library to Instrument Executable Formats Version 0.15.0
Loading...
Searching...
No Matches
ContentInfo.hpp
1/* Copyright 2017 - 2024 R. Thomas
2 * Copyright 2017 - 2024 Quarkslab
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16#ifndef LIEF_PE_CONTENT_INFO_H
17#define LIEF_PE_CONTENT_INFO_H
18
19#include <vector>
20#include <ostream>
21#include <memory>
22
23#include "LIEF/Object.hpp"
24#include "LIEF/visibility.h"
25
26#include "LIEF/PE/signature/types.hpp"
27#include "LIEF/PE/enums.hpp"
28
29namespace LIEF {
30namespace PE {
31
32class Parser;
33class SignatureParser;
34
78class LIEF_API ContentInfo : public Object {
79
80 friend class Parser;
81 friend class SignatureParser;
82
83 public:
84 class Content : public Object {
85 public:
86 Content(oid_t oid) :
87 type_(std::move(oid))
88 {}
89
90 const oid_t& content_type() const {
91 return type_;
92 }
93
94 virtual std::unique_ptr<Content> clone() const = 0;
95 virtual void print(std::ostream& os) const = 0;
96
97 LIEF_API friend std::ostream& operator<<(std::ostream& os, const Content& content) {
98 content.print(os);
99 return os;
100 }
101
102 ~Content() override = default;
103 private:
104 oid_t type_;
105 };
106 ContentInfo();
107 ContentInfo(const ContentInfo& other);
108 ContentInfo(ContentInfo&& other) noexcept = default;
109 ContentInfo& operator=(ContentInfo other);
110
111 void swap(ContentInfo& other) noexcept;
112
115 oid_t content_type() const {
116 return value_->content_type();
117 }
118
119 Content& value() {
120 return *value_;
121 }
122
123 const Content& value() const {
124 return *value_;
125 }
126
129 std::vector<uint8_t> digest() const;
130
134
135 void accept(Visitor& visitor) const override;
136
137 ~ContentInfo() override = default;
138
139 LIEF_API friend std::ostream& operator<<(std::ostream& os, const ContentInfo& content_info);
140
141 private:
142 std::unique_ptr<Content> value_;
143};
144
145}
146}
147
148#endif
Definition Object.hpp:25
Definition ContentInfo.hpp:84
Definition ContentInfo.hpp:78
std::vector< uint8_t > digest() const
Return the digest (authentihash) if the underlying content type is SPC_INDIRECT_DATA_OBJID Otherwise,...
ALGORITHMS digest_algorithm() const
Return the OID algorithm if the underlying content type is SPC_INDIRECT_DATA_OBJID Otherwise,...
oid_t content_type() const
Return the OID that describes the content wrapped by this object. It should match SPC_INDIRECT_DATA_O...
Definition ContentInfo.hpp:115
Main interface to parse PE binaries. In particular the static functions: Parser::parse should be used...
Definition PE/Parser.hpp:47
Definition SignatureParser.hpp:37
Definition Visitor.hpp:219
ALGORITHMS
Cryptography algorithms.
Definition PE/enums.hpp:686
LIEF namespace.
Definition Abstract/Binary.hpp:32