LIEF: Library to Instrument Executable Formats Version 0.15.0
Loading...
Searching...
No Matches
PKCS9MessageDigest.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_ATTRIBUTES_PKCS9_MESSAGE_DIGEST_H
17#define LIEF_PE_ATTRIBUTES_PKCS9_MESSAGE_DIGEST_H
18
19#include "LIEF/visibility.h"
20#include "LIEF/errors.hpp"
21#include "LIEF/PE/signature/Attribute.hpp"
22#include "LIEF/span.hpp"
23
24#include <vector>
25
26namespace LIEF {
27class VectorStream;
28namespace PE {
29
30class Parser;
31class SignatureParser;
32
48class LIEF_API PKCS9MessageDigest : public Attribute {
49
50 friend class Parser;
51 friend class SignatureParser;
52
53 public:
54 PKCS9MessageDigest() = delete;
55 PKCS9MessageDigest(std::vector<uint8_t> digest) :
56 Attribute(Attribute::TYPE::PKCS9_MESSAGE_DIGEST),
57 digest_{std::move(digest)}
58 {}
59
60 PKCS9MessageDigest(const PKCS9MessageDigest&) = default;
61 PKCS9MessageDigest& operator=(const PKCS9MessageDigest&) = default;
62
63 std::unique_ptr<Attribute> clone() const override {
64 return std::unique_ptr<Attribute>(new PKCS9MessageDigest{*this});
65 }
66
68 span<const uint8_t> digest() const {
69 return digest_;
70 }
71
73 std::string print() const override;
74
75 static bool classof(const Attribute* attr) {
76 return attr->type() == Attribute::TYPE::PKCS9_MESSAGE_DIGEST;
77 }
78
79 void accept(Visitor& visitor) const override;
80
81 ~PKCS9MessageDigest() override = default;
82
83 private:
84 std::vector<uint8_t> digest_;
85};
86
87}
88}
89
90#endif
Interface over PKCS #7 attribute.
Definition Attribute.hpp:30
virtual TYPE type() const
Concrete type of the attribute.
Definition Attribute.hpp:60
Interface over the structure described by the OID 1.2.840.113549.1.9.4 (PKCS #9)
Definition PKCS9MessageDigest.hpp:48
std::string print() const override
Print information about the attribute.
span< const uint8_t > digest() const
Message digeset as a blob of bytes as described in the RFC.
Definition PKCS9MessageDigest.hpp:68
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
LIEF namespace.
Definition Abstract/Binary.hpp:32