16#ifndef LIEF_PE_SIGNATURE_H
17#define LIEF_PE_SIGNATURE_H
47 static std::vector<uint8_t>
hash(
const std::vector<uint8_t>& input,
ALGORITHMS algo) {
48 return hash(input.data(), input.size(), algo);
51 static std::vector<uint8_t>
hash(
const uint8_t* buffer,
size_t size,
ALGORITHMS algo);
70 INVALID_SIGNER = 1 << 0,
71 UNSUPPORTED_ALGORITHM = 1 << 1,
72 INCONSISTENT_DIGEST_ALGORITHM = 1 << 2,
73 CERT_NOT_FOUND = 1 << 3,
74 CORRUPTED_CONTENT_INFO = 1 << 4,
75 CORRUPTED_AUTH_DATA = 1 << 5,
76 MISSING_PKCS9_MESSAGE_DIGEST = 1 << 6,
78 BAD_SIGNATURE = 1 << 8,
79 NO_SIGNATURE = 1 << 9,
80 CERT_EXPIRED = 1 << 10,
81 CERT_FUTURE = 1 << 11,
94 LIFETIME_SIGNING = 1 << 2,
95 SKIP_CERT_TIME = 1 << 3,
114 return digest_algorithm_;
119 return content_info_;
124 return certificates_;
128 return certificates_;
142 return original_raw_signature_;
189 uint32_t version_ = 0;
190 ALGORITHMS digest_algorithm_ = ALGORITHMS::UNKNOWN;
192 std::vector<x509> certificates_;
193 std::vector<SignerInfo> signers_;
195 uint64_t content_info_start_ = 0;
196 uint64_t content_info_end_ = 0;
198 std::vector<uint8_t> original_raw_signature_;
Class which represents a PE binary This is the main interface to manage and modify a PE executable.
Definition PE/Binary.hpp:52
Definition ContentInfo.hpp:78
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
Main interface for the PKCS #7 signature scheme.
Definition Signature.hpp:39
const x509 * find_crt_issuer(const std::string &issuer, const std::vector< uint8_t > &serialno) const
Find x509 certificate according to its issuer AND serial number.
it_signers_t signers()
Definition Signature.hpp:136
const x509 * find_crt(const std::vector< uint8_t > &serialno) const
Find x509 certificate according to its serial number.
static std::vector< uint8_t > hash(const uint8_t *buffer, size_t size, ALGORITHMS algo)
Signature & operator=(Signature &&)
VERIFICATION_FLAGS check(VERIFICATION_CHECKS checks=VERIFICATION_CHECKS::DEFAULT) const
Check if this signature is valid according to the Authenticode/PKCS #7 verification scheme.
span< const uint8_t > raw_der() const
Return the raw original PKCS7 signature.
Definition Signature.hpp:141
static std::string flag_to_string(VERIFICATION_FLAGS flag)
Convert a verification flag into a humman representation. e.g VERIFICATION_FLAGS.BAD_DIGEST | VERIFIC...
const ContentInfo & content_info() const
Return the ContentInfo.
Definition Signature.hpp:118
Signature(const Signature &)
it_crt certificates()
Definition Signature.hpp:127
Signature & operator=(const Signature &)
const x509 * find_crt_issuer(const std::string &issuer) const
Find x509 certificate according to its issuer.
static std::vector< uint8_t > hash(const std::vector< uint8_t > &input, ALGORITHMS algo)
Hash the input given the algorithm.
Definition Signature.hpp:47
const x509 * find_crt_subject(const std::string &subject) const
Find x509 certificate according to its subject.
VERIFICATION_CHECKS
Flags to tweak the verification process of the signature.
Definition Signature.hpp:91
void accept(Visitor &visitor) const override
it_const_signers_t signers() const
Return an iterator over the signers (SignerInfo) defined in the PKCS #7 signature.
Definition Signature.hpp:132
it_const_crt certificates() const
Return an iterator over x509 certificates.
Definition Signature.hpp:123
const x509 * find_crt_subject(const std::string &subject, const std::vector< uint8_t > &serialno) const
Find x509 certificate according to its subject AND serial number.
uint32_t version() const
Should be 1.
Definition Signature.hpp:106
friend std::ostream & operator<<(std::ostream &os, const Signature &signature)
ALGORITHMS digest_algorithm() const
Algorithm used to digest the file.
Definition Signature.hpp:113
VERIFICATION_FLAGS
Flags returned by the verification functions.
Definition Signature.hpp:68
Interface over a x509 certificate.
Definition x509.hpp:43
Definition Visitor.hpp:224
Iterator which returns reference on container's values.
Definition iterators.hpp:48
#define ENABLE_BITMASK_OPERATORS(X)
Definition enums.hpp:24
ALGORITHMS
Cryptography algorithms.
Definition PE/enums.hpp:686
LIEF namespace.
Definition Abstract/Binary.hpp:32
tcb::span< ElementType, Extent > span
Definition span.hpp:22
Hash::value_type hash(const Object &v)
#define LIEF_API
Definition visibility.h:41