LIEF: Library to Instrument Executable Formats Version 0.15.0
Loading...
Searching...
No Matches
ASN1Reader.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_ASN1_READER_H
17#define LIEF_ASN1_READER_H
18
19#include <vector>
20#include <memory>
21#include <cstdint>
22#include <string>
23
24#include "LIEF/errors.hpp"
25
26struct mbedtls_x509_crt;
27struct mbedtls_x509_time;
28
29namespace LIEF {
30class BinaryStream;
31
33 public:
34 ASN1Reader() = delete;
35
36 ASN1Reader(BinaryStream& stream) :
37 stream_(stream)
38 {}
39
40 ASN1Reader(const ASN1Reader&) = delete;
41 ASN1Reader& operator=(const ASN1Reader&) = delete;
42
43
44 result<bool> is_tag(int tag);
45
46 result<size_t> read_tag(int tag);
47 result<size_t> read_len();
48 result<std::string> read_alg();
49 result<std::string> read_oid();
50 result<bool> read_bool();
51 result<int32_t> read_int();
52 result<int64_t> read_int64();
53 result<std::vector<uint8_t>> read_large_int();
54
55 result<std::vector<uint8_t>> read_bitstring();
56 result<std::vector<uint8_t>> read_octet_string();
57 result<std::string> read_utf8_string();
59 result<std::string> x509_read_names();
60 result<std::vector<uint8_t>> x509_read_serial();
62
63 std::string get_str_tag();
64
65 static std::string tag2str(int tag);
66
67 private:
68 BinaryStream& stream_;
69};
70
71}
72#endif
Definition ASN1Reader.hpp:32
Class that is used to a read stream of data from different sources.
Definition BinaryStream.hpp:34
LIEF namespace.
Definition Abstract/Binary.hpp:32
tl::expected< T, lief_errors > result
Wrapper that contains an Object (T) or an error.
Definition errors.hpp:72