Coverage Report

Created: 2025-12-18 07:52

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/serenity/Userland/Libraries/LibCrypto/ASN1/DER.h
Line
Count
Source
1
/*
2
 * Copyright (c) 2020, Ali Mohammad Pur <mpfard@serenityos.org>
3
 *
4
 * SPDX-License-Identifier: BSD-2-Clause
5
 */
6
7
#pragma once
8
9
#include <AK/BitmapView.h>
10
#include <AK/Result.h>
11
#include <AK/Types.h>
12
#include <LibCrypto/ASN1/ASN1.h>
13
#include <LibCrypto/BigInt/UnsignedBigInteger.h>
14
15
namespace Crypto::ASN1 {
16
17
class BitStringView {
18
public:
19
    BitStringView(ReadonlyBytes data, size_t unused_bits)
20
1.54k
        : m_data(data)
21
1.54k
        , m_unused_bits(unused_bits)
22
1.54k
    {
23
1.54k
    }
24
25
    ErrorOr<ReadonlyBytes> raw_bytes() const
26
1.95k
    {
27
1.95k
        if (m_unused_bits != 0)
28
29
            return Error::from_string_literal("ASN1::Decoder: BitStringView contains unexpected partial bytes");
29
1.92k
        return m_data;
30
1.95k
    }
31
32
    bool get(size_t index) const
33
304
    {
34
304
        if (index >= 8 * m_data.size() - m_unused_bits)
35
234
            return false;
36
70
        return 0 != (m_data[index / 8] & (1u << (7 - (index % 8))));
37
304
    }
38
39
0
    size_t unused_bits() const { return m_unused_bits; }
40
0
    size_t byte_length() const { return m_data.size(); }
41
42
0
    ReadonlyBytes underlying_bytes() const { return m_data; }
43
44
    // FIXME: Improve me! I am naive!
45
    bool operator==(BitStringView const& other) const
46
0
    {
47
0
        for (size_t bit_index = 0; bit_index < 8 * m_data.size() - m_unused_bits; ++bit_index) {
48
0
            if (get(bit_index) != other.get(bit_index))
49
0
                return false;
50
0
        }
51
0
        return true;
52
0
    }
53
54
private:
55
    ReadonlyBytes m_data;
56
    size_t m_unused_bits;
57
};
58
59
class Decoder {
60
public:
61
    Decoder(ReadonlyBytes data)
62
10.2k
    {
63
10.2k
        m_stack.append(data);
64
10.2k
    }
65
66
    // Read a tag without consuming it (and its data).
67
    ErrorOr<Tag> peek();
68
69
    bool eof() const;
70
71
    template<typename ValueType>
72
    struct TaggedValue {
73
        Tag tag;
74
        ValueType value;
75
    };
76
77
    ErrorOr<void> rewrite_tag(Kind kind)
78
405
    {
79
405
        if (m_stack.is_empty())
80
0
            return Error::from_string_literal("Nothing on stack to rewrite");
81
82
405
        if (eof())
83
3
            return Error::from_string_literal("Stream is empty");
84
85
402
        if (m_current_tag.has_value()) {
86
402
            m_current_tag->kind = kind;
87
402
            return {};
88
402
        }
89
90
0
        auto tag = TRY(read_tag());
91
0
        m_current_tag = tag;
92
0
        m_current_tag->kind = kind;
93
0
        return {};
94
0
    }
95
96
    ErrorOr<void> drop()
97
20
    {
98
20
        if (m_stack.is_empty())
99
0
            return Error::from_string_literal("ASN1::Decoder: Trying to drop using an empty stack");
100
101
20
        if (eof())
102
1
            return Error::from_string_literal("ASN1::Decoder: Trying to drop using a decoder that is EOF");
103
104
19
        auto previous_position = m_stack;
105
106
19
        auto tag_or_error = peek();
107
19
        if (tag_or_error.is_error()) {
108
0
            m_stack = move(previous_position);
109
0
            return tag_or_error.release_error();
110
0
        }
111
112
19
        auto length_or_error = read_length();
113
19
        if (length_or_error.is_error()) {
114
3
            m_stack = move(previous_position);
115
3
            return length_or_error.release_error();
116
3
        }
117
118
16
        auto length = length_or_error.value();
119
120
16
        auto bytes_result = read_bytes(length);
121
16
        if (bytes_result.is_error()) {
122
5
            m_stack = move(previous_position);
123
5
            return bytes_result.release_error();
124
5
        }
125
126
11
        m_current_tag.clear();
127
11
        return {};
128
16
    }
129
130
    template<typename ValueType>
131
    ErrorOr<ValueType> read(Optional<Class> class_override = {}, Optional<Kind> kind_override = {})
132
71.0k
    {
133
71.0k
        if (m_stack.is_empty())
134
0
            return Error::from_string_literal("ASN1::Decoder: Trying to read using an empty stack");
135
136
71.0k
        if (eof())
137
897
            return Error::from_string_literal("ASN1::Decoder: Trying to read using a decoder that is EOF");
138
139
70.1k
        auto previous_position = m_stack;
140
141
70.1k
        auto tag_or_error = peek();
142
70.1k
        if (tag_or_error.is_error()) {
143
123
            m_stack = move(previous_position);
144
123
            return tag_or_error.release_error();
145
123
        }
146
147
69.9k
        auto length_or_error = read_length();
148
69.9k
        if (length_or_error.is_error()) {
149
392
            m_stack = move(previous_position);
150
392
            return length_or_error.release_error();
151
392
        }
152
153
69.5k
        auto tag = tag_or_error.value();
154
69.5k
        auto length = length_or_error.value();
155
156
69.5k
        auto value_or_error = read_value<ValueType>(class_override.value_or(tag.class_), kind_override.value_or(tag.kind), length);
157
69.5k
        if (value_or_error.is_error()) {
158
3.79k
            m_stack = move(previous_position);
159
3.79k
            return value_or_error.release_error();
160
3.79k
        }
161
162
65.7k
        m_current_tag.clear();
163
164
65.7k
        return value_or_error.release_value();
165
69.5k
    }
AK::ErrorOr<AK::Vector<int, 0ul>, AK::Error> Crypto::ASN1::Decoder::read<AK::Vector<int, 0ul> >(AK::Optional<Crypto::ASN1::Class>, AK::Optional<Crypto::ASN1::Kind>)
Line
Count
Source
132
16.3k
    {
133
16.3k
        if (m_stack.is_empty())
134
0
            return Error::from_string_literal("ASN1::Decoder: Trying to read using an empty stack");
135
136
16.3k
        if (eof())
137
102
            return Error::from_string_literal("ASN1::Decoder: Trying to read using a decoder that is EOF");
138
139
16.2k
        auto previous_position = m_stack;
140
141
16.2k
        auto tag_or_error = peek();
142
16.2k
        if (tag_or_error.is_error()) {
143
8
            m_stack = move(previous_position);
144
8
            return tag_or_error.release_error();
145
8
        }
146
147
16.1k
        auto length_or_error = read_length();
148
16.1k
        if (length_or_error.is_error()) {
149
39
            m_stack = move(previous_position);
150
39
            return length_or_error.release_error();
151
39
        }
152
153
16.1k
        auto tag = tag_or_error.value();
154
16.1k
        auto length = length_or_error.value();
155
156
16.1k
        auto value_or_error = read_value<ValueType>(class_override.value_or(tag.class_), kind_override.value_or(tag.kind), length);
157
16.1k
        if (value_or_error.is_error()) {
158
191
            m_stack = move(previous_position);
159
191
            return value_or_error.release_error();
160
191
        }
161
162
15.9k
        m_current_tag.clear();
163
164
15.9k
        return value_or_error.release_value();
165
16.1k
    }
AK::ErrorOr<Crypto::UnsignedBigInteger, AK::Error> Crypto::ASN1::Decoder::read<Crypto::UnsignedBigInteger>(AK::Optional<Crypto::ASN1::Class>, AK::Optional<Crypto::ASN1::Kind>)
Line
Count
Source
132
14.1k
    {
133
14.1k
        if (m_stack.is_empty())
134
0
            return Error::from_string_literal("ASN1::Decoder: Trying to read using an empty stack");
135
136
14.1k
        if (eof())
137
781
            return Error::from_string_literal("ASN1::Decoder: Trying to read using a decoder that is EOF");
138
139
13.3k
        auto previous_position = m_stack;
140
141
13.3k
        auto tag_or_error = peek();
142
13.3k
        if (tag_or_error.is_error()) {
143
107
            m_stack = move(previous_position);
144
107
            return tag_or_error.release_error();
145
107
        }
146
147
13.2k
        auto length_or_error = read_length();
148
13.2k
        if (length_or_error.is_error()) {
149
339
            m_stack = move(previous_position);
150
339
            return length_or_error.release_error();
151
339
        }
152
153
12.9k
        auto tag = tag_or_error.value();
154
12.9k
        auto length = length_or_error.value();
155
156
12.9k
        auto value_or_error = read_value<ValueType>(class_override.value_or(tag.class_), kind_override.value_or(tag.kind), length);
157
12.9k
        if (value_or_error.is_error()) {
158
3.32k
            m_stack = move(previous_position);
159
3.32k
            return value_or_error.release_error();
160
3.32k
        }
161
162
9.61k
        m_current_tag.clear();
163
164
9.61k
        return value_or_error.release_value();
165
12.9k
    }
AK::ErrorOr<AK::StringView, AK::Error> Crypto::ASN1::Decoder::read<AK::StringView>(AK::Optional<Crypto::ASN1::Class>, AK::Optional<Crypto::ASN1::Kind>)
Line
Count
Source
132
36.2k
    {
133
36.2k
        if (m_stack.is_empty())
134
0
            return Error::from_string_literal("ASN1::Decoder: Trying to read using an empty stack");
135
136
36.2k
        if (eof())
137
7
            return Error::from_string_literal("ASN1::Decoder: Trying to read using a decoder that is EOF");
138
139
36.2k
        auto previous_position = m_stack;
140
141
36.2k
        auto tag_or_error = peek();
142
36.2k
        if (tag_or_error.is_error()) {
143
4
            m_stack = move(previous_position);
144
4
            return tag_or_error.release_error();
145
4
        }
146
147
36.2k
        auto length_or_error = read_length();
148
36.2k
        if (length_or_error.is_error()) {
149
7
            m_stack = move(previous_position);
150
7
            return length_or_error.release_error();
151
7
        }
152
153
36.2k
        auto tag = tag_or_error.value();
154
36.2k
        auto length = length_or_error.value();
155
156
36.2k
        auto value_or_error = read_value<ValueType>(class_override.value_or(tag.class_), kind_override.value_or(tag.kind), length);
157
36.2k
        if (value_or_error.is_error()) {
158
99
            m_stack = move(previous_position);
159
99
            return value_or_error.release_error();
160
99
        }
161
162
36.1k
        m_current_tag.clear();
163
164
36.1k
        return value_or_error.release_value();
165
36.2k
    }
AK::ErrorOr<AK::BitmapView, AK::Error> Crypto::ASN1::Decoder::read<AK::BitmapView>(AK::Optional<Crypto::ASN1::Class>, AK::Optional<Crypto::ASN1::Kind>)
Line
Count
Source
132
154
    {
133
154
        if (m_stack.is_empty())
134
0
            return Error::from_string_literal("ASN1::Decoder: Trying to read using an empty stack");
135
136
154
        if (eof())
137
2
            return Error::from_string_literal("ASN1::Decoder: Trying to read using a decoder that is EOF");
138
139
152
        auto previous_position = m_stack;
140
141
152
        auto tag_or_error = peek();
142
152
        if (tag_or_error.is_error()) {
143
2
            m_stack = move(previous_position);
144
2
            return tag_or_error.release_error();
145
2
        }
146
147
150
        auto length_or_error = read_length();
148
150
        if (length_or_error.is_error()) {
149
2
            m_stack = move(previous_position);
150
2
            return length_or_error.release_error();
151
2
        }
152
153
148
        auto tag = tag_or_error.value();
154
148
        auto length = length_or_error.value();
155
156
148
        auto value_or_error = read_value<ValueType>(class_override.value_or(tag.class_), kind_override.value_or(tag.kind), length);
157
148
        if (value_or_error.is_error()) {
158
148
            m_stack = move(previous_position);
159
148
            return value_or_error.release_error();
160
148
        }
161
162
0
        m_current_tag.clear();
163
164
0
        return value_or_error.release_value();
165
148
    }
Unexecuted instantiation: AK::ErrorOr<AK::Span<unsigned char const>, AK::Error> Crypto::ASN1::Decoder::read<AK::Span<unsigned char const> >(AK::Optional<Crypto::ASN1::Class>, AK::Optional<Crypto::ASN1::Kind>)
AK::ErrorOr<bool, AK::Error> Crypto::ASN1::Decoder::read<bool>(AK::Optional<Crypto::ASN1::Class>, AK::Optional<Crypto::ASN1::Kind>)
Line
Count
Source
132
422
    {
133
422
        if (m_stack.is_empty())
134
0
            return Error::from_string_literal("ASN1::Decoder: Trying to read using an empty stack");
135
136
422
        if (eof())
137
1
            return Error::from_string_literal("ASN1::Decoder: Trying to read using a decoder that is EOF");
138
139
421
        auto previous_position = m_stack;
140
141
421
        auto tag_or_error = peek();
142
421
        if (tag_or_error.is_error()) {
143
0
            m_stack = move(previous_position);
144
0
            return tag_or_error.release_error();
145
0
        }
146
147
421
        auto length_or_error = read_length();
148
421
        if (length_or_error.is_error()) {
149
1
            m_stack = move(previous_position);
150
1
            return length_or_error.release_error();
151
1
        }
152
153
420
        auto tag = tag_or_error.value();
154
420
        auto length = length_or_error.value();
155
156
420
        auto value_or_error = read_value<ValueType>(class_override.value_or(tag.class_), kind_override.value_or(tag.kind), length);
157
420
        if (value_or_error.is_error()) {
158
5
            m_stack = move(previous_position);
159
5
            return value_or_error.release_error();
160
5
        }
161
162
415
        m_current_tag.clear();
163
164
415
        return value_or_error.release_value();
165
420
    }
Unexecuted instantiation: AK::ErrorOr<decltype(nullptr), AK::Error> Crypto::ASN1::Decoder::read<decltype(nullptr)>(AK::Optional<Crypto::ASN1::Class>, AK::Optional<Crypto::ASN1::Kind>)
Unexecuted instantiation: AK::ErrorOr<AK::Utf8View, AK::Error> Crypto::ASN1::Decoder::read<AK::Utf8View>(AK::Optional<Crypto::ASN1::Class>, AK::Optional<Crypto::ASN1::Kind>)
AK::ErrorOr<void*, AK::Error> Crypto::ASN1::Decoder::read<void*>(AK::Optional<Crypto::ASN1::Class>, AK::Optional<Crypto::ASN1::Kind>)
Line
Count
Source
132
2.24k
    {
133
2.24k
        if (m_stack.is_empty())
134
0
            return Error::from_string_literal("ASN1::Decoder: Trying to read using an empty stack");
135
136
2.24k
        if (eof())
137
1
            return Error::from_string_literal("ASN1::Decoder: Trying to read using a decoder that is EOF");
138
139
2.24k
        auto previous_position = m_stack;
140
141
2.24k
        auto tag_or_error = peek();
142
2.24k
        if (tag_or_error.is_error()) {
143
1
            m_stack = move(previous_position);
144
1
            return tag_or_error.release_error();
145
1
        }
146
147
2.24k
        auto length_or_error = read_length();
148
2.24k
        if (length_or_error.is_error()) {
149
2
            m_stack = move(previous_position);
150
2
            return length_or_error.release_error();
151
2
        }
152
153
2.24k
        auto tag = tag_or_error.value();
154
2.24k
        auto length = length_or_error.value();
155
156
2.24k
        auto value_or_error = read_value<ValueType>(class_override.value_or(tag.class_), kind_override.value_or(tag.kind), length);
157
2.24k
        if (value_or_error.is_error()) {
158
12
            m_stack = move(previous_position);
159
12
            return value_or_error.release_error();
160
12
        }
161
162
2.23k
        m_current_tag.clear();
163
164
2.23k
        return value_or_error.release_value();
165
2.24k
    }
AK::ErrorOr<Crypto::ASN1::BitStringView, AK::Error> Crypto::ASN1::Decoder::read<Crypto::ASN1::BitStringView>(AK::Optional<Crypto::ASN1::Class>, AK::Optional<Crypto::ASN1::Kind>)
Line
Count
Source
132
1.44k
    {
133
1.44k
        if (m_stack.is_empty())
134
0
            return Error::from_string_literal("ASN1::Decoder: Trying to read using an empty stack");
135
136
1.44k
        if (eof())
137
3
            return Error::from_string_literal("ASN1::Decoder: Trying to read using a decoder that is EOF");
138
139
1.43k
        auto previous_position = m_stack;
140
141
1.43k
        auto tag_or_error = peek();
142
1.43k
        if (tag_or_error.is_error()) {
143
1
            m_stack = move(previous_position);
144
1
            return tag_or_error.release_error();
145
1
        }
146
147
1.43k
        auto length_or_error = read_length();
148
1.43k
        if (length_or_error.is_error()) {
149
2
            m_stack = move(previous_position);
150
2
            return length_or_error.release_error();
151
2
        }
152
153
1.43k
        auto tag = tag_or_error.value();
154
1.43k
        auto length = length_or_error.value();
155
156
1.43k
        auto value_or_error = read_value<ValueType>(class_override.value_or(tag.class_), kind_override.value_or(tag.kind), length);
157
1.43k
        if (value_or_error.is_error()) {
158
17
            m_stack = move(previous_position);
159
17
            return value_or_error.release_error();
160
17
        }
161
162
1.41k
        m_current_tag.clear();
163
164
1.41k
        return value_or_error.release_value();
165
1.43k
    }
166
167
    ErrorOr<void> enter();
168
    ErrorOr<void> leave();
169
170
    ErrorOr<ReadonlyBytes> peek_entry_bytes();
171
172
private:
173
    template<typename ValueType, typename DecodedType>
174
    ErrorOr<ValueType> with_type_check(DecodedType&& value)
175
830
    {
176
        if constexpr (requires { ValueType { value }; })
177
234
            return ValueType { value };
178
179
0
        return Error::from_string_literal("ASN1::Decoder: Trying to decode a value from an incompatible type");
180
830
    }
AK::ErrorOr<AK::Vector<int, 0ul>, AK::Error> Crypto::ASN1::Decoder::with_type_check<AK::Vector<int, 0ul>, AK::Span<unsigned char const>&>(AK::Span<unsigned char const>&)
Line
Count
Source
175
49
    {
176
        if constexpr (requires { ValueType { value }; })
177
            return ValueType { value };
178
179
49
        return Error::from_string_literal("ASN1::Decoder: Trying to decode a value from an incompatible type");
180
49
    }
AK::ErrorOr<AK::Vector<int, 0ul>, AK::Error> Crypto::ASN1::Decoder::with_type_check<AK::Vector<int, 0ul>, AK::StringView>(AK::StringView&&)
Line
Count
Source
175
2
    {
176
        if constexpr (requires { ValueType { value }; })
177
            return ValueType { value };
178
179
2
        return Error::from_string_literal("ASN1::Decoder: Trying to decode a value from an incompatible type");
180
2
    }
AK::ErrorOr<Crypto::UnsignedBigInteger, AK::Error> Crypto::ASN1::Decoder::with_type_check<Crypto::UnsignedBigInteger, AK::Span<unsigned char const>&>(AK::Span<unsigned char const>&)
Line
Count
Source
175
477
    {
176
        if constexpr (requires { ValueType { value }; })
177
            return ValueType { value };
178
179
477
        return Error::from_string_literal("ASN1::Decoder: Trying to decode a value from an incompatible type");
180
477
    }
AK::ErrorOr<Crypto::UnsignedBigInteger, AK::Error> Crypto::ASN1::Decoder::with_type_check<Crypto::UnsignedBigInteger, AK::StringView>(AK::StringView&&)
Line
Count
Source
175
40
    {
176
        if constexpr (requires { ValueType { value }; })
177
            return ValueType { value };
178
179
40
        return Error::from_string_literal("ASN1::Decoder: Trying to decode a value from an incompatible type");
180
40
    }
AK::ErrorOr<AK::StringView, AK::Error> Crypto::ASN1::Decoder::with_type_check<AK::StringView, AK::Span<unsigned char const>&>(AK::Span<unsigned char const>&)
Line
Count
Source
175
203
    {
176
        if constexpr (requires { ValueType { value }; })
177
203
            return ValueType { value };
178
179
0
        return Error::from_string_literal("ASN1::Decoder: Trying to decode a value from an incompatible type");
180
203
    }
AK::ErrorOr<AK::StringView, AK::Error> Crypto::ASN1::Decoder::with_type_check<AK::StringView, AK::StringView>(AK::StringView&&)
Line
Count
Source
175
31
    {
176
        if constexpr (requires { ValueType { value }; })
177
31
            return ValueType { value };
178
179
0
        return Error::from_string_literal("ASN1::Decoder: Trying to decode a value from an incompatible type");
180
31
    }
AK::ErrorOr<AK::BitmapView, AK::Error> Crypto::ASN1::Decoder::with_type_check<AK::BitmapView, AK::Span<unsigned char const>&>(AK::Span<unsigned char const>&)
Line
Count
Source
175
26
    {
176
        if constexpr (requires { ValueType { value }; })
177
            return ValueType { value };
178
179
26
        return Error::from_string_literal("ASN1::Decoder: Trying to decode a value from an incompatible type");
180
26
    }
AK::ErrorOr<AK::BitmapView, AK::Error> Crypto::ASN1::Decoder::with_type_check<AK::BitmapView, AK::StringView>(AK::StringView&&)
Line
Count
Source
175
2
    {
176
        if constexpr (requires { ValueType { value }; })
177
            return ValueType { value };
178
179
2
        return Error::from_string_literal("ASN1::Decoder: Trying to decode a value from an incompatible type");
180
2
    }
Unexecuted instantiation: AK::ErrorOr<bool, AK::Error> Crypto::ASN1::Decoder::with_type_check<bool, AK::Span<unsigned char const>&>(AK::Span<unsigned char const>&)
Unexecuted instantiation: AK::ErrorOr<bool, AK::Error> Crypto::ASN1::Decoder::with_type_check<bool, AK::StringView>(AK::StringView&&)
Unexecuted instantiation: AK::ErrorOr<decltype(nullptr), AK::Error> Crypto::ASN1::Decoder::with_type_check<decltype(nullptr), AK::Span<unsigned char const>&>(AK::Span<unsigned char const>&)
Unexecuted instantiation: AK::ErrorOr<decltype(nullptr), AK::Error> Crypto::ASN1::Decoder::with_type_check<decltype(nullptr), AK::StringView>(AK::StringView&&)
Unexecuted instantiation: AK::ErrorOr<AK::Utf8View, AK::Error> Crypto::ASN1::Decoder::with_type_check<AK::Utf8View, AK::Span<unsigned char const>&>(AK::Span<unsigned char const>&)
Unexecuted instantiation: AK::ErrorOr<AK::Utf8View, AK::Error> Crypto::ASN1::Decoder::with_type_check<AK::Utf8View, AK::StringView>(AK::StringView&&)
Unexecuted instantiation: AK::ErrorOr<void*, AK::Error> Crypto::ASN1::Decoder::with_type_check<void*, AK::Span<unsigned char const>&>(AK::Span<unsigned char const>&)
Unexecuted instantiation: AK::ErrorOr<void*, AK::Error> Crypto::ASN1::Decoder::with_type_check<void*, AK::StringView>(AK::StringView&&)
Unexecuted instantiation: AK::ErrorOr<Crypto::ASN1::BitStringView, AK::Error> Crypto::ASN1::Decoder::with_type_check<Crypto::ASN1::BitStringView, AK::Span<unsigned char const>&>(AK::Span<unsigned char const>&)
Unexecuted instantiation: AK::ErrorOr<Crypto::ASN1::BitStringView, AK::Error> Crypto::ASN1::Decoder::with_type_check<Crypto::ASN1::BitStringView, AK::StringView>(AK::StringView&&)
181
182
    template<typename ValueType, typename DecodedType>
183
    ErrorOr<ValueType> with_type_check(ErrorOr<DecodedType>&& value_or_error)
184
67.8k
    {
185
67.8k
        if (value_or_error.is_error())
186
1.44k
            return value_or_error.release_error();
187
188
66.4k
        if constexpr (IsSame<ValueType, bool> && !IsSame<DecodedType, bool>) {
189
0
            return Error::from_string_literal("ASN1::Decoder: Trying to decode a boolean from a non-boolean type");
190
66.4k
        } else {
191
66.4k
            auto&& value = value_or_error.value();
192
            if constexpr (requires { ValueType { value }; })
193
65.5k
                return ValueType { value };
194
66.4k
        }
195
196
0
        return Error::from_string_literal("ASN1::Decoder: Trying to decode a value from an incompatible type");
197
67.8k
    }
AK::ErrorOr<AK::Vector<int, 0ul>, AK::Error> Crypto::ASN1::Decoder::with_type_check<AK::Vector<int, 0ul>, bool>(AK::ErrorOr<bool, AK::Error>&&)
Line
Count
Source
184
11
    {
185
11
        if (value_or_error.is_error())
186
9
            return value_or_error.release_error();
187
188
        if constexpr (IsSame<ValueType, bool> && !IsSame<DecodedType, bool>) {
189
            return Error::from_string_literal("ASN1::Decoder: Trying to decode a boolean from a non-boolean type");
190
2
        } else {
191
2
            auto&& value = value_or_error.value();
192
            if constexpr (requires { ValueType { value }; })
193
2
                return ValueType { value };
194
2
        }
195
196
0
        return Error::from_string_literal("ASN1::Decoder: Trying to decode a value from an incompatible type");
197
11
    }
AK::ErrorOr<AK::Vector<int, 0ul>, AK::Error> Crypto::ASN1::Decoder::with_type_check<AK::Vector<int, 0ul>, Crypto::UnsignedBigInteger>(AK::ErrorOr<Crypto::UnsignedBigInteger, AK::Error>&&)
Line
Count
Source
184
27
    {
185
27
        if (value_or_error.is_error())
186
8
            return value_or_error.release_error();
187
188
        if constexpr (IsSame<ValueType, bool> && !IsSame<DecodedType, bool>) {
189
            return Error::from_string_literal("ASN1::Decoder: Trying to decode a boolean from a non-boolean type");
190
19
        } else {
191
19
            auto&& value = value_or_error.value();
192
            if constexpr (requires { ValueType { value }; })
193
                return ValueType { value };
194
19
        }
195
196
19
        return Error::from_string_literal("ASN1::Decoder: Trying to decode a value from an incompatible type");
197
27
    }
AK::ErrorOr<AK::Vector<int, 0ul>, AK::Error> Crypto::ASN1::Decoder::with_type_check<AK::Vector<int, 0ul>, AK::StringView>(AK::ErrorOr<AK::StringView, AK::Error>&&)
Line
Count
Source
184
22
    {
185
22
        if (value_or_error.is_error())
186
7
            return value_or_error.release_error();
187
188
        if constexpr (IsSame<ValueType, bool> && !IsSame<DecodedType, bool>) {
189
            return Error::from_string_literal("ASN1::Decoder: Trying to decode a boolean from a non-boolean type");
190
15
        } else {
191
15
            auto&& value = value_or_error.value();
192
            if constexpr (requires { ValueType { value }; })
193
                return ValueType { value };
194
15
        }
195
196
15
        return Error::from_string_literal("ASN1::Decoder: Trying to decode a value from an incompatible type");
197
22
    }
AK::ErrorOr<AK::Vector<int, 0ul>, AK::Error> Crypto::ASN1::Decoder::with_type_check<AK::Vector<int, 0ul>, decltype(nullptr)>(AK::ErrorOr<decltype(nullptr), AK::Error>&&)
Line
Count
Source
184
6
    {
185
6
        if (value_or_error.is_error())
186
3
            return value_or_error.release_error();
187
188
        if constexpr (IsSame<ValueType, bool> && !IsSame<DecodedType, bool>) {
189
            return Error::from_string_literal("ASN1::Decoder: Trying to decode a boolean from a non-boolean type");
190
3
        } else {
191
3
            auto&& value = value_or_error.value();
192
            if constexpr (requires { ValueType { value }; })
193
                return ValueType { value };
194
3
        }
195
196
3
        return Error::from_string_literal("ASN1::Decoder: Trying to decode a value from an incompatible type");
197
6
    }
AK::ErrorOr<AK::Vector<int, 0ul>, AK::Error> Crypto::ASN1::Decoder::with_type_check<AK::Vector<int, 0ul>, AK::Vector<int, 0ul> >(AK::ErrorOr<AK::Vector<int, 0ul>, AK::Error>&&)
Line
Count
Source
184
16.0k
    {
185
16.0k
        if (value_or_error.is_error())
186
47
            return value_or_error.release_error();
187
188
        if constexpr (IsSame<ValueType, bool> && !IsSame<DecodedType, bool>) {
189
            return Error::from_string_literal("ASN1::Decoder: Trying to decode a boolean from a non-boolean type");
190
15.9k
        } else {
191
15.9k
            auto&& value = value_or_error.value();
192
            if constexpr (requires { ValueType { value }; })
193
15.9k
                return ValueType { value };
194
15.9k
        }
195
196
0
        return Error::from_string_literal("ASN1::Decoder: Trying to decode a value from an incompatible type");
197
16.0k
    }
AK::ErrorOr<AK::Vector<int, 0ul>, AK::Error> Crypto::ASN1::Decoder::with_type_check<AK::Vector<int, 0ul>, Crypto::ASN1::BitStringView>(AK::ErrorOr<Crypto::ASN1::BitStringView, AK::Error>&&)
Line
Count
Source
184
8
    {
185
8
        if (value_or_error.is_error())
186
4
            return value_or_error.release_error();
187
188
        if constexpr (IsSame<ValueType, bool> && !IsSame<DecodedType, bool>) {
189
            return Error::from_string_literal("ASN1::Decoder: Trying to decode a boolean from a non-boolean type");
190
4
        } else {
191
4
            auto&& value = value_or_error.value();
192
            if constexpr (requires { ValueType { value }; })
193
                return ValueType { value };
194
4
        }
195
196
4
        return Error::from_string_literal("ASN1::Decoder: Trying to decode a value from an incompatible type");
197
8
    }
AK::ErrorOr<Crypto::UnsignedBigInteger, AK::Error> Crypto::ASN1::Decoder::with_type_check<Crypto::UnsignedBigInteger, bool>(AK::ErrorOr<bool, AK::Error>&&)
Line
Count
Source
184
2.16k
    {
185
2.16k
        if (value_or_error.is_error())
186
140
            return value_or_error.release_error();
187
188
        if constexpr (IsSame<ValueType, bool> && !IsSame<DecodedType, bool>) {
189
            return Error::from_string_literal("ASN1::Decoder: Trying to decode a boolean from a non-boolean type");
190
2.02k
        } else {
191
2.02k
            auto&& value = value_or_error.value();
192
            if constexpr (requires { ValueType { value }; })
193
2.02k
                return ValueType { value };
194
2.02k
        }
195
196
0
        return Error::from_string_literal("ASN1::Decoder: Trying to decode a value from an incompatible type");
197
2.16k
    }
AK::ErrorOr<Crypto::UnsignedBigInteger, AK::Error> Crypto::ASN1::Decoder::with_type_check<Crypto::UnsignedBigInteger, Crypto::UnsignedBigInteger>(AK::ErrorOr<Crypto::UnsignedBigInteger, AK::Error>&&)
Line
Count
Source
184
7.89k
    {
185
7.89k
        if (value_or_error.is_error())
186
311
            return value_or_error.release_error();
187
188
        if constexpr (IsSame<ValueType, bool> && !IsSame<DecodedType, bool>) {
189
            return Error::from_string_literal("ASN1::Decoder: Trying to decode a boolean from a non-boolean type");
190
7.58k
        } else {
191
7.58k
            auto&& value = value_or_error.value();
192
            if constexpr (requires { ValueType { value }; })
193
7.58k
                return ValueType { value };
194
7.58k
        }
195
196
0
        return Error::from_string_literal("ASN1::Decoder: Trying to decode a value from an incompatible type");
197
7.89k
    }
AK::ErrorOr<Crypto::UnsignedBigInteger, AK::Error> Crypto::ASN1::Decoder::with_type_check<Crypto::UnsignedBigInteger, AK::StringView>(AK::ErrorOr<AK::StringView, AK::Error>&&)
Line
Count
Source
184
774
    {
185
774
        if (value_or_error.is_error())
186
433
            return value_or_error.release_error();
187
188
        if constexpr (IsSame<ValueType, bool> && !IsSame<DecodedType, bool>) {
189
            return Error::from_string_literal("ASN1::Decoder: Trying to decode a boolean from a non-boolean type");
190
341
        } else {
191
341
            auto&& value = value_or_error.value();
192
            if constexpr (requires { ValueType { value }; })
193
                return ValueType { value };
194
341
        }
195
196
341
        return Error::from_string_literal("ASN1::Decoder: Trying to decode a value from an incompatible type");
197
774
    }
AK::ErrorOr<Crypto::UnsignedBigInteger, AK::Error> Crypto::ASN1::Decoder::with_type_check<Crypto::UnsignedBigInteger, decltype(nullptr)>(AK::ErrorOr<decltype(nullptr), AK::Error>&&)
Line
Count
Source
184
85
    {
185
85
        if (value_or_error.is_error())
186
64
            return value_or_error.release_error();
187
188
        if constexpr (IsSame<ValueType, bool> && !IsSame<DecodedType, bool>) {
189
            return Error::from_string_literal("ASN1::Decoder: Trying to decode a boolean from a non-boolean type");
190
21
        } else {
191
21
            auto&& value = value_or_error.value();
192
            if constexpr (requires { ValueType { value }; })
193
                return ValueType { value };
194
21
        }
195
196
21
        return Error::from_string_literal("ASN1::Decoder: Trying to decode a value from an incompatible type");
197
85
    }
AK::ErrorOr<Crypto::UnsignedBigInteger, AK::Error> Crypto::ASN1::Decoder::with_type_check<Crypto::UnsignedBigInteger, AK::Vector<int, 0ul> >(AK::ErrorOr<AK::Vector<int, 0ul>, AK::Error>&&)
Line
Count
Source
184
523
    {
185
523
        if (value_or_error.is_error())
186
236
            return value_or_error.release_error();
187
188
        if constexpr (IsSame<ValueType, bool> && !IsSame<DecodedType, bool>) {
189
            return Error::from_string_literal("ASN1::Decoder: Trying to decode a boolean from a non-boolean type");
190
287
        } else {
191
287
            auto&& value = value_or_error.value();
192
            if constexpr (requires { ValueType { value }; })
193
                return ValueType { value };
194
287
        }
195
196
287
        return Error::from_string_literal("ASN1::Decoder: Trying to decode a value from an incompatible type");
197
523
    }
AK::ErrorOr<Crypto::UnsignedBigInteger, AK::Error> Crypto::ASN1::Decoder::with_type_check<Crypto::UnsignedBigInteger, Crypto::ASN1::BitStringView>(AK::ErrorOr<Crypto::ASN1::BitStringView, AK::Error>&&)
Line
Count
Source
184
195
    {
185
195
        if (value_or_error.is_error())
186
75
            return value_or_error.release_error();
187
188
        if constexpr (IsSame<ValueType, bool> && !IsSame<DecodedType, bool>) {
189
            return Error::from_string_literal("ASN1::Decoder: Trying to decode a boolean from a non-boolean type");
190
120
        } else {
191
120
            auto&& value = value_or_error.value();
192
            if constexpr (requires { ValueType { value }; })
193
                return ValueType { value };
194
120
        }
195
196
120
        return Error::from_string_literal("ASN1::Decoder: Trying to decode a value from an incompatible type");
197
195
    }
AK::ErrorOr<AK::StringView, AK::Error> Crypto::ASN1::Decoder::with_type_check<AK::StringView, bool>(AK::ErrorOr<bool, AK::Error>&&)
Line
Count
Source
184
4
    {
185
4
        if (value_or_error.is_error())
186
2
            return value_or_error.release_error();
187
188
        if constexpr (IsSame<ValueType, bool> && !IsSame<DecodedType, bool>) {
189
            return Error::from_string_literal("ASN1::Decoder: Trying to decode a boolean from a non-boolean type");
190
2
        } else {
191
2
            auto&& value = value_or_error.value();
192
            if constexpr (requires { ValueType { value }; })
193
                return ValueType { value };
194
2
        }
195
196
2
        return Error::from_string_literal("ASN1::Decoder: Trying to decode a value from an incompatible type");
197
4
    }
AK::ErrorOr<AK::StringView, AK::Error> Crypto::ASN1::Decoder::with_type_check<AK::StringView, Crypto::UnsignedBigInteger>(AK::ErrorOr<Crypto::UnsignedBigInteger, AK::Error>&&)
Line
Count
Source
184
6
    {
185
6
        if (value_or_error.is_error())
186
2
            return value_or_error.release_error();
187
188
        if constexpr (IsSame<ValueType, bool> && !IsSame<DecodedType, bool>) {
189
            return Error::from_string_literal("ASN1::Decoder: Trying to decode a boolean from a non-boolean type");
190
4
        } else {
191
4
            auto&& value = value_or_error.value();
192
            if constexpr (requires { ValueType { value }; })
193
                return ValueType { value };
194
4
        }
195
196
4
        return Error::from_string_literal("ASN1::Decoder: Trying to decode a value from an incompatible type");
197
6
    }
AK::ErrorOr<AK::StringView, AK::Error> Crypto::ASN1::Decoder::with_type_check<AK::StringView, AK::StringView>(AK::ErrorOr<AK::StringView, AK::Error>&&)
Line
Count
Source
184
35.9k
    {
185
35.9k
        if (value_or_error.is_error())
186
54
            return value_or_error.release_error();
187
188
        if constexpr (IsSame<ValueType, bool> && !IsSame<DecodedType, bool>) {
189
            return Error::from_string_literal("ASN1::Decoder: Trying to decode a boolean from a non-boolean type");
190
35.9k
        } else {
191
35.9k
            auto&& value = value_or_error.value();
192
            if constexpr (requires { ValueType { value }; })
193
35.9k
                return ValueType { value };
194
35.9k
        }
195
196
0
        return Error::from_string_literal("ASN1::Decoder: Trying to decode a value from an incompatible type");
197
35.9k
    }
AK::ErrorOr<AK::StringView, AK::Error> Crypto::ASN1::Decoder::with_type_check<AK::StringView, decltype(nullptr)>(AK::ErrorOr<decltype(nullptr), AK::Error>&&)
Line
Count
Source
184
4
    {
185
4
        if (value_or_error.is_error())
186
2
            return value_or_error.release_error();
187
188
        if constexpr (IsSame<ValueType, bool> && !IsSame<DecodedType, bool>) {
189
            return Error::from_string_literal("ASN1::Decoder: Trying to decode a boolean from a non-boolean type");
190
2
        } else {
191
2
            auto&& value = value_or_error.value();
192
            if constexpr (requires { ValueType { value }; })
193
                return ValueType { value };
194
2
        }
195
196
2
        return Error::from_string_literal("ASN1::Decoder: Trying to decode a value from an incompatible type");
197
4
    }
AK::ErrorOr<AK::StringView, AK::Error> Crypto::ASN1::Decoder::with_type_check<AK::StringView, AK::Vector<int, 0ul> >(AK::ErrorOr<AK::Vector<int, 0ul>, AK::Error>&&)
Line
Count
Source
184
4
    {
185
4
        if (value_or_error.is_error())
186
2
            return value_or_error.release_error();
187
188
        if constexpr (IsSame<ValueType, bool> && !IsSame<DecodedType, bool>) {
189
            return Error::from_string_literal("ASN1::Decoder: Trying to decode a boolean from a non-boolean type");
190
2
        } else {
191
2
            auto&& value = value_or_error.value();
192
            if constexpr (requires { ValueType { value }; })
193
                return ValueType { value };
194
2
        }
195
196
2
        return Error::from_string_literal("ASN1::Decoder: Trying to decode a value from an incompatible type");
197
4
    }
AK::ErrorOr<AK::StringView, AK::Error> Crypto::ASN1::Decoder::with_type_check<AK::StringView, Crypto::ASN1::BitStringView>(AK::ErrorOr<Crypto::ASN1::BitStringView, AK::Error>&&)
Line
Count
Source
184
5
    {
185
5
        if (value_or_error.is_error())
186
2
            return value_or_error.release_error();
187
188
        if constexpr (IsSame<ValueType, bool> && !IsSame<DecodedType, bool>) {
189
            return Error::from_string_literal("ASN1::Decoder: Trying to decode a boolean from a non-boolean type");
190
3
        } else {
191
3
            auto&& value = value_or_error.value();
192
            if constexpr (requires { ValueType { value }; })
193
                return ValueType { value };
194
3
        }
195
196
3
        return Error::from_string_literal("ASN1::Decoder: Trying to decode a value from an incompatible type");
197
5
    }
AK::ErrorOr<AK::BitmapView, AK::Error> Crypto::ASN1::Decoder::with_type_check<AK::BitmapView, bool>(AK::ErrorOr<bool, AK::Error>&&)
Line
Count
Source
184
7
    {
185
7
        if (value_or_error.is_error())
186
5
            return value_or_error.release_error();
187
188
        if constexpr (IsSame<ValueType, bool> && !IsSame<DecodedType, bool>) {
189
            return Error::from_string_literal("ASN1::Decoder: Trying to decode a boolean from a non-boolean type");
190
2
        } else {
191
2
            auto&& value = value_or_error.value();
192
            if constexpr (requires { ValueType { value }; })
193
                return ValueType { value };
194
2
        }
195
196
2
        return Error::from_string_literal("ASN1::Decoder: Trying to decode a value from an incompatible type");
197
7
    }
AK::ErrorOr<AK::BitmapView, AK::Error> Crypto::ASN1::Decoder::with_type_check<AK::BitmapView, Crypto::UnsignedBigInteger>(AK::ErrorOr<Crypto::UnsignedBigInteger, AK::Error>&&)
Line
Count
Source
184
6
    {
185
6
        if (value_or_error.is_error())
186
2
            return value_or_error.release_error();
187
188
        if constexpr (IsSame<ValueType, bool> && !IsSame<DecodedType, bool>) {
189
            return Error::from_string_literal("ASN1::Decoder: Trying to decode a boolean from a non-boolean type");
190
4
        } else {
191
4
            auto&& value = value_or_error.value();
192
            if constexpr (requires { ValueType { value }; })
193
                return ValueType { value };
194
4
        }
195
196
4
        return Error::from_string_literal("ASN1::Decoder: Trying to decode a value from an incompatible type");
197
6
    }
AK::ErrorOr<AK::BitmapView, AK::Error> Crypto::ASN1::Decoder::with_type_check<AK::BitmapView, AK::StringView>(AK::ErrorOr<AK::StringView, AK::Error>&&)
Line
Count
Source
184
11
    {
185
11
        if (value_or_error.is_error())
186
2
            return value_or_error.release_error();
187
188
        if constexpr (IsSame<ValueType, bool> && !IsSame<DecodedType, bool>) {
189
            return Error::from_string_literal("ASN1::Decoder: Trying to decode a boolean from a non-boolean type");
190
9
        } else {
191
9
            auto&& value = value_or_error.value();
192
            if constexpr (requires { ValueType { value }; })
193
                return ValueType { value };
194
9
        }
195
196
9
        return Error::from_string_literal("ASN1::Decoder: Trying to decode a value from an incompatible type");
197
11
    }
AK::ErrorOr<AK::BitmapView, AK::Error> Crypto::ASN1::Decoder::with_type_check<AK::BitmapView, decltype(nullptr)>(AK::ErrorOr<decltype(nullptr), AK::Error>&&)
Line
Count
Source
184
8
    {
185
8
        if (value_or_error.is_error())
186
6
            return value_or_error.release_error();
187
188
        if constexpr (IsSame<ValueType, bool> && !IsSame<DecodedType, bool>) {
189
            return Error::from_string_literal("ASN1::Decoder: Trying to decode a boolean from a non-boolean type");
190
2
        } else {
191
2
            auto&& value = value_or_error.value();
192
            if constexpr (requires { ValueType { value }; })
193
                return ValueType { value };
194
2
        }
195
196
2
        return Error::from_string_literal("ASN1::Decoder: Trying to decode a value from an incompatible type");
197
8
    }
AK::ErrorOr<AK::BitmapView, AK::Error> Crypto::ASN1::Decoder::with_type_check<AK::BitmapView, AK::Vector<int, 0ul> >(AK::ErrorOr<AK::Vector<int, 0ul>, AK::Error>&&)
Line
Count
Source
184
7
    {
185
7
        if (value_or_error.is_error())
186
4
            return value_or_error.release_error();
187
188
        if constexpr (IsSame<ValueType, bool> && !IsSame<DecodedType, bool>) {
189
            return Error::from_string_literal("ASN1::Decoder: Trying to decode a boolean from a non-boolean type");
190
3
        } else {
191
3
            auto&& value = value_or_error.value();
192
            if constexpr (requires { ValueType { value }; })
193
                return ValueType { value };
194
3
        }
195
196
3
        return Error::from_string_literal("ASN1::Decoder: Trying to decode a value from an incompatible type");
197
7
    }
AK::ErrorOr<AK::BitmapView, AK::Error> Crypto::ASN1::Decoder::with_type_check<AK::BitmapView, Crypto::ASN1::BitStringView>(AK::ErrorOr<Crypto::ASN1::BitStringView, AK::Error>&&)
Line
Count
Source
184
8
    {
185
8
        if (value_or_error.is_error())
186
5
            return value_or_error.release_error();
187
188
        if constexpr (IsSame<ValueType, bool> && !IsSame<DecodedType, bool>) {
189
            return Error::from_string_literal("ASN1::Decoder: Trying to decode a boolean from a non-boolean type");
190
3
        } else {
191
3
            auto&& value = value_or_error.value();
192
            if constexpr (requires { ValueType { value }; })
193
                return ValueType { value };
194
3
        }
195
196
3
        return Error::from_string_literal("ASN1::Decoder: Trying to decode a value from an incompatible type");
197
8
    }
AK::ErrorOr<bool, AK::Error> Crypto::ASN1::Decoder::with_type_check<bool, bool>(AK::ErrorOr<bool, AK::Error>&&)
Line
Count
Source
184
418
    {
185
418
        if (value_or_error.is_error())
186
3
            return value_or_error.release_error();
187
188
        if constexpr (IsSame<ValueType, bool> && !IsSame<DecodedType, bool>) {
189
            return Error::from_string_literal("ASN1::Decoder: Trying to decode a boolean from a non-boolean type");
190
415
        } else {
191
415
            auto&& value = value_or_error.value();
192
            if constexpr (requires { ValueType { value }; })
193
415
                return ValueType { value };
194
415
        }
195
196
0
        return Error::from_string_literal("ASN1::Decoder: Trying to decode a value from an incompatible type");
197
418
    }
Unexecuted instantiation: AK::ErrorOr<bool, AK::Error> Crypto::ASN1::Decoder::with_type_check<bool, Crypto::UnsignedBigInteger>(AK::ErrorOr<Crypto::UnsignedBigInteger, AK::Error>&&)
Unexecuted instantiation: AK::ErrorOr<bool, AK::Error> Crypto::ASN1::Decoder::with_type_check<bool, AK::StringView>(AK::ErrorOr<AK::StringView, AK::Error>&&)
Unexecuted instantiation: AK::ErrorOr<bool, AK::Error> Crypto::ASN1::Decoder::with_type_check<bool, decltype(nullptr)>(AK::ErrorOr<decltype(nullptr), AK::Error>&&)
Unexecuted instantiation: AK::ErrorOr<bool, AK::Error> Crypto::ASN1::Decoder::with_type_check<bool, AK::Vector<int, 0ul> >(AK::ErrorOr<AK::Vector<int, 0ul>, AK::Error>&&)
Unexecuted instantiation: AK::ErrorOr<bool, AK::Error> Crypto::ASN1::Decoder::with_type_check<bool, Crypto::ASN1::BitStringView>(AK::ErrorOr<Crypto::ASN1::BitStringView, AK::Error>&&)
Unexecuted instantiation: AK::ErrorOr<decltype(nullptr), AK::Error> Crypto::ASN1::Decoder::with_type_check<decltype(nullptr), bool>(AK::ErrorOr<bool, AK::Error>&&)
Unexecuted instantiation: AK::ErrorOr<decltype(nullptr), AK::Error> Crypto::ASN1::Decoder::with_type_check<decltype(nullptr), Crypto::UnsignedBigInteger>(AK::ErrorOr<Crypto::UnsignedBigInteger, AK::Error>&&)
Unexecuted instantiation: AK::ErrorOr<decltype(nullptr), AK::Error> Crypto::ASN1::Decoder::with_type_check<decltype(nullptr), AK::StringView>(AK::ErrorOr<AK::StringView, AK::Error>&&)
Unexecuted instantiation: AK::ErrorOr<decltype(nullptr), AK::Error> Crypto::ASN1::Decoder::with_type_check<decltype(nullptr), decltype(nullptr)>(AK::ErrorOr<decltype(nullptr), AK::Error>&&)
Unexecuted instantiation: AK::ErrorOr<decltype(nullptr), AK::Error> Crypto::ASN1::Decoder::with_type_check<decltype(nullptr), AK::Vector<int, 0ul> >(AK::ErrorOr<AK::Vector<int, 0ul>, AK::Error>&&)
Unexecuted instantiation: AK::ErrorOr<decltype(nullptr), AK::Error> Crypto::ASN1::Decoder::with_type_check<decltype(nullptr), Crypto::ASN1::BitStringView>(AK::ErrorOr<Crypto::ASN1::BitStringView, AK::Error>&&)
Unexecuted instantiation: AK::ErrorOr<AK::Utf8View, AK::Error> Crypto::ASN1::Decoder::with_type_check<AK::Utf8View, bool>(AK::ErrorOr<bool, AK::Error>&&)
Unexecuted instantiation: AK::ErrorOr<AK::Utf8View, AK::Error> Crypto::ASN1::Decoder::with_type_check<AK::Utf8View, Crypto::UnsignedBigInteger>(AK::ErrorOr<Crypto::UnsignedBigInteger, AK::Error>&&)
Unexecuted instantiation: AK::ErrorOr<AK::Utf8View, AK::Error> Crypto::ASN1::Decoder::with_type_check<AK::Utf8View, AK::StringView>(AK::ErrorOr<AK::StringView, AK::Error>&&)
Unexecuted instantiation: AK::ErrorOr<AK::Utf8View, AK::Error> Crypto::ASN1::Decoder::with_type_check<AK::Utf8View, decltype(nullptr)>(AK::ErrorOr<decltype(nullptr), AK::Error>&&)
Unexecuted instantiation: AK::ErrorOr<AK::Utf8View, AK::Error> Crypto::ASN1::Decoder::with_type_check<AK::Utf8View, AK::Vector<int, 0ul> >(AK::ErrorOr<AK::Vector<int, 0ul>, AK::Error>&&)
Unexecuted instantiation: AK::ErrorOr<AK::Utf8View, AK::Error> Crypto::ASN1::Decoder::with_type_check<AK::Utf8View, Crypto::ASN1::BitStringView>(AK::ErrorOr<Crypto::ASN1::BitStringView, AK::Error>&&)
Unexecuted instantiation: AK::ErrorOr<void*, AK::Error> Crypto::ASN1::Decoder::with_type_check<void*, bool>(AK::ErrorOr<bool, AK::Error>&&)
Unexecuted instantiation: AK::ErrorOr<void*, AK::Error> Crypto::ASN1::Decoder::with_type_check<void*, Crypto::UnsignedBigInteger>(AK::ErrorOr<Crypto::UnsignedBigInteger, AK::Error>&&)
Unexecuted instantiation: AK::ErrorOr<void*, AK::Error> Crypto::ASN1::Decoder::with_type_check<void*, AK::StringView>(AK::ErrorOr<AK::StringView, AK::Error>&&)
AK::ErrorOr<void*, AK::Error> Crypto::ASN1::Decoder::with_type_check<void*, decltype(nullptr)>(AK::ErrorOr<decltype(nullptr), AK::Error>&&)
Line
Count
Source
184
2.23k
    {
185
2.23k
        if (value_or_error.is_error())
186
6
            return value_or_error.release_error();
187
188
        if constexpr (IsSame<ValueType, bool> && !IsSame<DecodedType, bool>) {
189
            return Error::from_string_literal("ASN1::Decoder: Trying to decode a boolean from a non-boolean type");
190
2.23k
        } else {
191
2.23k
            auto&& value = value_or_error.value();
192
            if constexpr (requires { ValueType { value }; })
193
2.23k
                return ValueType { value };
194
2.23k
        }
195
196
0
        return Error::from_string_literal("ASN1::Decoder: Trying to decode a value from an incompatible type");
197
2.23k
    }
Unexecuted instantiation: AK::ErrorOr<void*, AK::Error> Crypto::ASN1::Decoder::with_type_check<void*, AK::Vector<int, 0ul> >(AK::ErrorOr<AK::Vector<int, 0ul>, AK::Error>&&)
Unexecuted instantiation: AK::ErrorOr<void*, AK::Error> Crypto::ASN1::Decoder::with_type_check<void*, Crypto::ASN1::BitStringView>(AK::ErrorOr<Crypto::ASN1::BitStringView, AK::Error>&&)
Unexecuted instantiation: AK::ErrorOr<Crypto::ASN1::BitStringView, AK::Error> Crypto::ASN1::Decoder::with_type_check<Crypto::ASN1::BitStringView, bool>(AK::ErrorOr<bool, AK::Error>&&)
Unexecuted instantiation: AK::ErrorOr<Crypto::ASN1::BitStringView, AK::Error> Crypto::ASN1::Decoder::with_type_check<Crypto::ASN1::BitStringView, Crypto::UnsignedBigInteger>(AK::ErrorOr<Crypto::UnsignedBigInteger, AK::Error>&&)
Unexecuted instantiation: AK::ErrorOr<Crypto::ASN1::BitStringView, AK::Error> Crypto::ASN1::Decoder::with_type_check<Crypto::ASN1::BitStringView, AK::StringView>(AK::ErrorOr<AK::StringView, AK::Error>&&)
Unexecuted instantiation: AK::ErrorOr<Crypto::ASN1::BitStringView, AK::Error> Crypto::ASN1::Decoder::with_type_check<Crypto::ASN1::BitStringView, decltype(nullptr)>(AK::ErrorOr<decltype(nullptr), AK::Error>&&)
Unexecuted instantiation: AK::ErrorOr<Crypto::ASN1::BitStringView, AK::Error> Crypto::ASN1::Decoder::with_type_check<Crypto::ASN1::BitStringView, AK::Vector<int, 0ul> >(AK::ErrorOr<AK::Vector<int, 0ul>, AK::Error>&&)
AK::ErrorOr<Crypto::ASN1::BitStringView, AK::Error> Crypto::ASN1::Decoder::with_type_check<Crypto::ASN1::BitStringView, Crypto::ASN1::BitStringView>(AK::ErrorOr<Crypto::ASN1::BitStringView, AK::Error>&&)
Line
Count
Source
184
1.42k
    {
185
1.42k
        if (value_or_error.is_error())
186
10
            return value_or_error.release_error();
187
188
        if constexpr (IsSame<ValueType, bool> && !IsSame<DecodedType, bool>) {
189
            return Error::from_string_literal("ASN1::Decoder: Trying to decode a boolean from a non-boolean type");
190
1.41k
        } else {
191
1.41k
            auto&& value = value_or_error.value();
192
            if constexpr (requires { ValueType { value }; })
193
1.41k
                return ValueType { value };
194
1.41k
        }
195
196
0
        return Error::from_string_literal("ASN1::Decoder: Trying to decode a value from an incompatible type");
197
1.42k
    }
198
199
    template<typename ValueType>
200
    ErrorOr<ValueType> read_value(Class klass, Kind kind, size_t length)
201
69.5k
    {
202
69.5k
        auto data = TRY(read_bytes(length));
203
204
68.6k
        if constexpr (IsSame<ValueType, ReadonlyBytes>) {
205
0
            return data;
206
68.6k
        } else {
207
68.6k
            if (klass != Class::Universal)
208
201
                return with_type_check<ValueType>(data);
209
210
68.4k
            if (kind == Kind::Boolean)
211
2.60k
                return with_type_check<ValueType>(decode_boolean(data));
212
213
65.8k
            if (kind == Kind::Integer)
214
7.93k
                return with_type_check<ValueType>(decode_arbitrary_sized_integer(data));
215
216
57.9k
            if (kind == Kind::OctetString)
217
5.07k
                return with_type_check<ValueType>(decode_octet_string(data));
218
219
52.8k
            if (kind == Kind::Null)
220
2.34k
                return with_type_check<ValueType>(decode_null(data));
221
222
50.5k
            if (kind == Kind::ObjectIdentifier)
223
16.5k
                return with_type_check<ValueType>(decode_object_identifier(data));
224
225
33.9k
            if (kind == Kind::PrintableString || kind == Kind::IA5String || kind == Kind::UTCTime)
226
31.6k
                return with_type_check<ValueType>(decode_printable_string(data));
227
228
2.27k
            if (kind == Kind::Utf8String)
229
75
                return with_type_check<ValueType>(StringView { data.data(), data.size() });
230
231
2.19k
            if (kind == Kind::BitString)
232
1.64k
                return with_type_check<ValueType>(decode_bit_string(data));
233
234
554
            return with_type_check<ValueType>(data);
235
2.19k
        }
236
68.6k
    }
AK::ErrorOr<AK::Vector<int, 0ul>, AK::Error> Crypto::ASN1::Decoder::read_value<AK::Vector<int, 0ul> >(Crypto::ASN1::Class, Crypto::ASN1::Kind, unsigned long)
Line
Count
Source
201
16.1k
    {
202
16.1k
        auto data = TRY(read_bytes(length));
203
204
        if constexpr (IsSame<ValueType, ReadonlyBytes>) {
205
            return data;
206
16.1k
        } else {
207
16.1k
            if (klass != Class::Universal)
208
7
                return with_type_check<ValueType>(data);
209
210
16.1k
            if (kind == Kind::Boolean)
211
11
                return with_type_check<ValueType>(decode_boolean(data));
212
213
16.1k
            if (kind == Kind::Integer)
214
27
                return with_type_check<ValueType>(decode_arbitrary_sized_integer(data));
215
216
16.0k
            if (kind == Kind::OctetString)
217
6
                return with_type_check<ValueType>(decode_octet_string(data));
218
219
16.0k
            if (kind == Kind::Null)
220
6
                return with_type_check<ValueType>(decode_null(data));
221
222
16.0k
            if (kind == Kind::ObjectIdentifier)
223
16.0k
                return with_type_check<ValueType>(decode_object_identifier(data));
224
225
68
            if (kind == Kind::PrintableString || kind == Kind::IA5String || kind == Kind::UTCTime)
226
16
                return with_type_check<ValueType>(decode_printable_string(data));
227
228
52
            if (kind == Kind::Utf8String)
229
2
                return with_type_check<ValueType>(StringView { data.data(), data.size() });
230
231
50
            if (kind == Kind::BitString)
232
8
                return with_type_check<ValueType>(decode_bit_string(data));
233
234
42
            return with_type_check<ValueType>(data);
235
50
        }
236
16.1k
    }
AK::ErrorOr<Crypto::UnsignedBigInteger, AK::Error> Crypto::ASN1::Decoder::read_value<Crypto::UnsignedBigInteger>(Crypto::ASN1::Class, Crypto::ASN1::Kind, unsigned long)
Line
Count
Source
201
12.9k
    {
202
12.9k
        auto data = TRY(read_bytes(length));
203
204
        if constexpr (IsSame<ValueType, ReadonlyBytes>) {
205
            return data;
206
12.1k
        } else {
207
12.1k
            if (klass != Class::Universal)
208
96
                return with_type_check<ValueType>(data);
209
210
12.0k
            if (kind == Kind::Boolean)
211
2.16k
                return with_type_check<ValueType>(decode_boolean(data));
212
213
9.89k
            if (kind == Kind::Integer)
214
7.89k
                return with_type_check<ValueType>(decode_arbitrary_sized_integer(data));
215
216
1.99k
            if (kind == Kind::OctetString)
217
42
                return with_type_check<ValueType>(decode_octet_string(data));
218
219
1.95k
            if (kind == Kind::Null)
220
85
                return with_type_check<ValueType>(decode_null(data));
221
222
1.87k
            if (kind == Kind::ObjectIdentifier)
223
523
                return with_type_check<ValueType>(decode_object_identifier(data));
224
225
1.34k
            if (kind == Kind::PrintableString || kind == Kind::IA5String || kind == Kind::UTCTime)
226
732
                return with_type_check<ValueType>(decode_printable_string(data));
227
228
616
            if (kind == Kind::Utf8String)
229
40
                return with_type_check<ValueType>(StringView { data.data(), data.size() });
230
231
576
            if (kind == Kind::BitString)
232
195
                return with_type_check<ValueType>(decode_bit_string(data));
233
234
381
            return with_type_check<ValueType>(data);
235
576
        }
236
12.1k
    }
AK::ErrorOr<AK::StringView, AK::Error> Crypto::ASN1::Decoder::read_value<AK::StringView>(Crypto::ASN1::Class, Crypto::ASN1::Kind, unsigned long)
Line
Count
Source
201
36.2k
    {
202
36.2k
        auto data = TRY(read_bytes(length));
203
204
        if constexpr (IsSame<ValueType, ReadonlyBytes>) {
205
            return data;
206
36.2k
        } else {
207
36.2k
            if (klass != Class::Universal)
208
95
                return with_type_check<ValueType>(data);
209
210
36.1k
            if (kind == Kind::Boolean)
211
4
                return with_type_check<ValueType>(decode_boolean(data));
212
213
36.1k
            if (kind == Kind::Integer)
214
6
                return with_type_check<ValueType>(decode_arbitrary_sized_integer(data));
215
216
36.1k
            if (kind == Kind::OctetString)
217
5.02k
                return with_type_check<ValueType>(decode_octet_string(data));
218
219
31.0k
            if (kind == Kind::Null)
220
4
                return with_type_check<ValueType>(decode_null(data));
221
222
31.0k
            if (kind == Kind::ObjectIdentifier)
223
4
                return with_type_check<ValueType>(decode_object_identifier(data));
224
225
31.0k
            if (kind == Kind::PrintableString || kind == Kind::IA5String || kind == Kind::UTCTime)
226
30.9k
                return with_type_check<ValueType>(decode_printable_string(data));
227
228
144
            if (kind == Kind::Utf8String)
229
31
                return with_type_check<ValueType>(StringView { data.data(), data.size() });
230
231
113
            if (kind == Kind::BitString)
232
5
                return with_type_check<ValueType>(decode_bit_string(data));
233
234
108
            return with_type_check<ValueType>(data);
235
113
        }
236
36.2k
    }
AK::ErrorOr<AK::BitmapView, AK::Error> Crypto::ASN1::Decoder::read_value<AK::BitmapView>(Crypto::ASN1::Class, Crypto::ASN1::Kind, unsigned long)
Line
Count
Source
201
148
    {
202
148
        auto data = TRY(read_bytes(length));
203
204
        if constexpr (IsSame<ValueType, ReadonlyBytes>) {
205
            return data;
206
75
        } else {
207
75
            if (klass != Class::Universal)
208
3
                return with_type_check<ValueType>(data);
209
210
72
            if (kind == Kind::Boolean)
211
7
                return with_type_check<ValueType>(decode_boolean(data));
212
213
65
            if (kind == Kind::Integer)
214
6
                return with_type_check<ValueType>(decode_arbitrary_sized_integer(data));
215
216
59
            if (kind == Kind::OctetString)
217
2
                return with_type_check<ValueType>(decode_octet_string(data));
218
219
57
            if (kind == Kind::Null)
220
8
                return with_type_check<ValueType>(decode_null(data));
221
222
49
            if (kind == Kind::ObjectIdentifier)
223
7
                return with_type_check<ValueType>(decode_object_identifier(data));
224
225
42
            if (kind == Kind::PrintableString || kind == Kind::IA5String || kind == Kind::UTCTime)
226
9
                return with_type_check<ValueType>(decode_printable_string(data));
227
228
33
            if (kind == Kind::Utf8String)
229
2
                return with_type_check<ValueType>(StringView { data.data(), data.size() });
230
231
31
            if (kind == Kind::BitString)
232
8
                return with_type_check<ValueType>(decode_bit_string(data));
233
234
23
            return with_type_check<ValueType>(data);
235
31
        }
236
75
    }
Unexecuted instantiation: AK::ErrorOr<AK::Span<unsigned char const>, AK::Error> Crypto::ASN1::Decoder::read_value<AK::Span<unsigned char const> >(Crypto::ASN1::Class, Crypto::ASN1::Kind, unsigned long)
AK::ErrorOr<bool, AK::Error> Crypto::ASN1::Decoder::read_value<bool>(Crypto::ASN1::Class, Crypto::ASN1::Kind, unsigned long)
Line
Count
Source
201
420
    {
202
420
        auto data = TRY(read_bytes(length));
203
204
        if constexpr (IsSame<ValueType, ReadonlyBytes>) {
205
            return data;
206
418
        } else {
207
418
            if (klass != Class::Universal)
208
0
                return with_type_check<ValueType>(data);
209
210
418
            if (kind == Kind::Boolean)
211
418
                return with_type_check<ValueType>(decode_boolean(data));
212
213
0
            if (kind == Kind::Integer)
214
0
                return with_type_check<ValueType>(decode_arbitrary_sized_integer(data));
215
216
0
            if (kind == Kind::OctetString)
217
0
                return with_type_check<ValueType>(decode_octet_string(data));
218
219
0
            if (kind == Kind::Null)
220
0
                return with_type_check<ValueType>(decode_null(data));
221
222
0
            if (kind == Kind::ObjectIdentifier)
223
0
                return with_type_check<ValueType>(decode_object_identifier(data));
224
225
0
            if (kind == Kind::PrintableString || kind == Kind::IA5String || kind == Kind::UTCTime)
226
0
                return with_type_check<ValueType>(decode_printable_string(data));
227
228
0
            if (kind == Kind::Utf8String)
229
0
                return with_type_check<ValueType>(StringView { data.data(), data.size() });
230
231
0
            if (kind == Kind::BitString)
232
0
                return with_type_check<ValueType>(decode_bit_string(data));
233
234
0
            return with_type_check<ValueType>(data);
235
0
        }
236
418
    }
Unexecuted instantiation: AK::ErrorOr<decltype(nullptr), AK::Error> Crypto::ASN1::Decoder::read_value<decltype(nullptr)>(Crypto::ASN1::Class, Crypto::ASN1::Kind, unsigned long)
Unexecuted instantiation: AK::ErrorOr<AK::Utf8View, AK::Error> Crypto::ASN1::Decoder::read_value<AK::Utf8View>(Crypto::ASN1::Class, Crypto::ASN1::Kind, unsigned long)
AK::ErrorOr<void*, AK::Error> Crypto::ASN1::Decoder::read_value<void*>(Crypto::ASN1::Class, Crypto::ASN1::Kind, unsigned long)
Line
Count
Source
201
2.24k
    {
202
2.24k
        auto data = TRY(read_bytes(length));
203
204
        if constexpr (IsSame<ValueType, ReadonlyBytes>) {
205
            return data;
206
2.23k
        } else {
207
2.23k
            if (klass != Class::Universal)
208
0
                return with_type_check<ValueType>(data);
209
210
2.23k
            if (kind == Kind::Boolean)
211
0
                return with_type_check<ValueType>(decode_boolean(data));
212
213
2.23k
            if (kind == Kind::Integer)
214
0
                return with_type_check<ValueType>(decode_arbitrary_sized_integer(data));
215
216
2.23k
            if (kind == Kind::OctetString)
217
0
                return with_type_check<ValueType>(decode_octet_string(data));
218
219
2.23k
            if (kind == Kind::Null)
220
2.23k
                return with_type_check<ValueType>(decode_null(data));
221
222
0
            if (kind == Kind::ObjectIdentifier)
223
0
                return with_type_check<ValueType>(decode_object_identifier(data));
224
225
0
            if (kind == Kind::PrintableString || kind == Kind::IA5String || kind == Kind::UTCTime)
226
0
                return with_type_check<ValueType>(decode_printable_string(data));
227
228
0
            if (kind == Kind::Utf8String)
229
0
                return with_type_check<ValueType>(StringView { data.data(), data.size() });
230
231
0
            if (kind == Kind::BitString)
232
0
                return with_type_check<ValueType>(decode_bit_string(data));
233
234
0
            return with_type_check<ValueType>(data);
235
0
        }
236
2.23k
    }
AK::ErrorOr<Crypto::ASN1::BitStringView, AK::Error> Crypto::ASN1::Decoder::read_value<Crypto::ASN1::BitStringView>(Crypto::ASN1::Class, Crypto::ASN1::Kind, unsigned long)
Line
Count
Source
201
1.43k
    {
202
1.43k
        auto data = TRY(read_bytes(length));
203
204
        if constexpr (IsSame<ValueType, ReadonlyBytes>) {
205
            return data;
206
1.42k
        } else {
207
1.42k
            if (klass != Class::Universal)
208
0
                return with_type_check<ValueType>(data);
209
210
1.42k
            if (kind == Kind::Boolean)
211
0
                return with_type_check<ValueType>(decode_boolean(data));
212
213
1.42k
            if (kind == Kind::Integer)
214
0
                return with_type_check<ValueType>(decode_arbitrary_sized_integer(data));
215
216
1.42k
            if (kind == Kind::OctetString)
217
0
                return with_type_check<ValueType>(decode_octet_string(data));
218
219
1.42k
            if (kind == Kind::Null)
220
0
                return with_type_check<ValueType>(decode_null(data));
221
222
1.42k
            if (kind == Kind::ObjectIdentifier)
223
0
                return with_type_check<ValueType>(decode_object_identifier(data));
224
225
1.42k
            if (kind == Kind::PrintableString || kind == Kind::IA5String || kind == Kind::UTCTime)
226
0
                return with_type_check<ValueType>(decode_printable_string(data));
227
228
1.42k
            if (kind == Kind::Utf8String)
229
0
                return with_type_check<ValueType>(StringView { data.data(), data.size() });
230
231
1.42k
            if (kind == Kind::BitString)
232
1.42k
                return with_type_check<ValueType>(decode_bit_string(data));
233
234
0
            return with_type_check<ValueType>(data);
235
1.42k
        }
236
1.42k
    }
237
238
    ErrorOr<Tag> read_tag();
239
    ErrorOr<size_t> read_length();
240
    ErrorOr<u8> read_byte();
241
    ErrorOr<ReadonlyBytes> read_bytes(size_t length);
242
243
    static ErrorOr<bool> decode_boolean(ReadonlyBytes);
244
    static ErrorOr<UnsignedBigInteger> decode_arbitrary_sized_integer(ReadonlyBytes);
245
    static ErrorOr<StringView> decode_octet_string(ReadonlyBytes);
246
    static ErrorOr<nullptr_t> decode_null(ReadonlyBytes);
247
    static ErrorOr<Vector<int>> decode_object_identifier(ReadonlyBytes);
248
    static ErrorOr<StringView> decode_printable_string(ReadonlyBytes);
249
    static ErrorOr<BitStringView> decode_bit_string(ReadonlyBytes);
250
251
    Vector<ReadonlyBytes> m_stack;
252
    Optional<Tag> m_current_tag;
253
};
254
255
ErrorOr<void> pretty_print(Decoder&, Stream&, int indent = 0);
256
257
class Encoder {
258
public:
259
    Encoder()
260
0
    {
261
0
        m_buffer_stack.empend();
262
0
    }
263
264
0
    ReadonlyBytes active_bytes() const { return m_buffer_stack.last().bytes(); }
265
    ByteBuffer finish()
266
0
    {
267
0
        VERIFY(m_buffer_stack.size() == 1);
268
0
        return m_buffer_stack.take_last();
269
0
    }
Unexecuted instantiation: Crypto::ASN1::Encoder::finish()
Unexecuted instantiation: Crypto::ASN1::Encoder::finish()
270
271
    template<typename ValueType>
272
    ErrorOr<void> write(ValueType const& value, Optional<Class> class_override = {}, Optional<Kind> kind_override = {})
273
0
    {
274
        if constexpr (IsSame<ValueType, bool>) {
275
            return write_boolean(value, class_override, kind_override);
276
0
        } else if constexpr (IsSame<ValueType, UnsignedBigInteger> || (IsIntegral<ValueType> && IsUnsigned<ValueType>)) {
277
0
            return write_arbitrary_sized_integer(value, class_override, kind_override);
278
        } else if constexpr (IsOneOf<ValueType, StringView, String, ByteString>) {
279
            return write_printable_string(value, class_override, kind_override);
280
0
        } else if constexpr (IsOneOf<ValueType, ReadonlyBytes, ByteBuffer>) {
281
0
            return write_octet_string(value, class_override, kind_override);
282
0
        } else if constexpr (IsSame<ValueType, nullptr_t>) {
283
0
            return write_null(class_override, kind_override);
284
0
        } else if constexpr (IsOneOf<ValueType, Vector<int>, Span<int const>, Span<int>>) {
285
0
            return write_object_identifier(value, class_override, kind_override);
286
0
        } else if constexpr (IsSame<ValueType, BitStringView>) {
287
0
            return write_bit_string(value, class_override, kind_override);
288
        } else {
289
            dbgln("Unsupported type: {}", __PRETTY_FUNCTION__);
290
            return Error::from_string_literal("ASN1::Encoder: Trying to encode a value of an unsupported type");
291
        }
292
0
    }
Unexecuted instantiation: AK::ErrorOr<void, AK::Error> Crypto::ASN1::Encoder::write<AK::Span<int> >(AK::Span<int> const&, AK::Optional<Crypto::ASN1::Class>, AK::Optional<Crypto::ASN1::Kind>)
Unexecuted instantiation: AK::ErrorOr<void, AK::Error> Crypto::ASN1::Encoder::write<decltype(nullptr)>(decltype(nullptr) const&, AK::Optional<Crypto::ASN1::Class>, AK::Optional<Crypto::ASN1::Kind>)
Unexecuted instantiation: AK::ErrorOr<void, AK::Error> Crypto::ASN1::Encoder::write<Crypto::UnsignedBigInteger>(Crypto::UnsignedBigInteger const&, AK::Optional<Crypto::ASN1::Class>, AK::Optional<Crypto::ASN1::Kind>)
Unexecuted instantiation: AK::ErrorOr<void, AK::Error> Crypto::ASN1::Encoder::write<Crypto::ASN1::BitStringView>(Crypto::ASN1::BitStringView const&, AK::Optional<Crypto::ASN1::Class>, AK::Optional<Crypto::ASN1::Kind>)
Unexecuted instantiation: AK::ErrorOr<void, AK::Error> Crypto::ASN1::Encoder::write<unsigned int>(unsigned int const&, AK::Optional<Crypto::ASN1::Class>, AK::Optional<Crypto::ASN1::Kind>)
Unexecuted instantiation: AK::ErrorOr<void, AK::Error> Crypto::ASN1::Encoder::write<AK::Detail::ByteBuffer<32ul> >(AK::Detail::ByteBuffer<32ul> const&, AK::Optional<Crypto::ASN1::Class>, AK::Optional<Crypto::ASN1::Kind>)
293
294
    template<typename Fn>
295
    ErrorOr<void> write_constructed(Class class_, Kind kind, Fn&& fn)
296
0
    {
297
0
        return write_constructed(bit_cast<u8>(class_), bit_cast<u8>(kind), forward<Fn>(fn));
298
0
    }
Unexecuted instantiation: _ZN6Crypto4ASN17Encoder17write_constructedIZNS_2PK31wrap_in_subject_public_key_infoINS3_12RSAPublicKeyINS_18UnsignedBigIntegerEEEEEN2AK7ErrorOrINS8_6Detail10ByteBufferILm32EEENS8_5ErrorEEET_NS8_4SpanIiEEQrQSF__XcldtfL0p_13export_as_derEEEUlvE_EENS9_IvSD_EENS0_5ClassENS0_4KindEOSF_
Unexecuted instantiation: _ZN6Crypto4ASN17Encoder17write_constructedIZZNS_2PK31wrap_in_subject_public_key_infoINS3_12RSAPublicKeyINS_18UnsignedBigIntegerEEEEEN2AK7ErrorOrINS8_6Detail10ByteBufferILm32EEENS8_5ErrorEEET_NS8_4SpanIiEEQrQSF__XcldtfL1p_13export_as_derEEENKUlvE_clEvEUlvE_EENS9_IvSD_EENS0_5ClassENS0_4KindEOSF_
Unexecuted instantiation: AK::ErrorOr<void, AK::Error> Crypto::ASN1::Encoder::write_constructed<Crypto::PK::RSAPublicKey<Crypto::UnsignedBigInteger>::export_as_der() const::{lambda()#1}>(Crypto::ASN1::Class, Crypto::ASN1::Kind, Crypto::PK::RSAPublicKey<Crypto::UnsignedBigInteger>::export_as_der() const::{lambda()#1}&&)
Unexecuted instantiation: _ZN6Crypto4ASN17Encoder17write_constructedIZNS_2PK24wrap_in_private_key_infoINS3_13RSAPrivateKeyINS_18UnsignedBigIntegerEEEEEN2AK7ErrorOrINS8_6Detail10ByteBufferILm32EEENS8_5ErrorEEET_NS8_4SpanIiEEQrQSF__XcldtfL0p_13export_as_derEEEUlvE_EENS9_IvSD_EENS0_5ClassENS0_4KindEOSF_
Unexecuted instantiation: _ZN6Crypto4ASN17Encoder17write_constructedIZZNS_2PK24wrap_in_private_key_infoINS3_13RSAPrivateKeyINS_18UnsignedBigIntegerEEEEEN2AK7ErrorOrINS8_6Detail10ByteBufferILm32EEENS8_5ErrorEEET_NS8_4SpanIiEEQrQSF__XcldtfL1p_13export_as_derEEENKUlvE_clEvEUlvE_EENS9_IvSD_EENS0_5ClassENS0_4KindEOSF_
Unexecuted instantiation: AK::ErrorOr<void, AK::Error> Crypto::ASN1::Encoder::write_constructed<Crypto::PK::RSAPrivateKey<Crypto::UnsignedBigInteger>::export_as_der() const::{lambda()#1}>(Crypto::ASN1::Class, Crypto::ASN1::Kind, Crypto::PK::RSAPrivateKey<Crypto::UnsignedBigInteger>::export_as_der() const::{lambda()#1}&&)
Unexecuted instantiation: CryptoAlgorithms.cpp:AK::ErrorOr<void, AK::Error> Crypto::ASN1::Encoder::write_constructed<Web::Crypto::ECDSA::verify(Web::Crypto::AlgorithmParams const&, JS::NonnullGCPtr<Web::Crypto::CryptoKey>, AK::Detail::ByteBuffer<32ul> const&, AK::Detail::ByteBuffer<32ul> const&)::$_2>(Crypto::ASN1::Class, Crypto::ASN1::Kind, Web::Crypto::ECDSA::verify(Web::Crypto::AlgorithmParams const&, JS::NonnullGCPtr<Web::Crypto::CryptoKey>, AK::Detail::ByteBuffer<32ul> const&, AK::Detail::ByteBuffer<32ul> const&)::$_2&&)
299
300
    template<typename Fn>
301
    ErrorOr<void> write_constructed(u8 class_, u8 kind, Fn&& fn)
302
0
    {
303
0
        m_buffer_stack.empend();
304
0
        using ResultType = decltype(fn());
305
0
        if constexpr (IsSpecializationOf<ResultType, ErrorOr>) {
306
0
            TRY(fn());
307
0
        } else {
308
0
            fn();
309
0
        }
310
0
        auto buffer = m_buffer_stack.take_last();
311
312
0
        TRY(write_tag(bit_cast<Class>(class_), Type::Constructed, bit_cast<Kind>(kind)));
313
0
        TRY(write_length(buffer.size()));
314
0
        TRY(write_bytes(buffer.bytes()));
315
316
0
        return {};
317
0
    }
Unexecuted instantiation: _ZN6Crypto4ASN17Encoder17write_constructedIZNS_2PK31wrap_in_subject_public_key_infoINS3_12RSAPublicKeyINS_18UnsignedBigIntegerEEEEEN2AK7ErrorOrINS8_6Detail10ByteBufferILm32EEENS8_5ErrorEEET_NS8_4SpanIiEEQrQSF__XcldtfL0p_13export_as_derEEEUlvE_EENS9_IvSD_EEhhOSF_
Unexecuted instantiation: _ZN6Crypto4ASN17Encoder17write_constructedIZZNS_2PK31wrap_in_subject_public_key_infoINS3_12RSAPublicKeyINS_18UnsignedBigIntegerEEEEEN2AK7ErrorOrINS8_6Detail10ByteBufferILm32EEENS8_5ErrorEEET_NS8_4SpanIiEEQrQSF__XcldtfL1p_13export_as_derEEENKUlvE_clEvEUlvE_EENS9_IvSD_EEhhOSF_
Unexecuted instantiation: AK::ErrorOr<void, AK::Error> Crypto::ASN1::Encoder::write_constructed<Crypto::PK::RSAPublicKey<Crypto::UnsignedBigInteger>::export_as_der() const::{lambda()#1}>(unsigned char, unsigned char, Crypto::PK::RSAPublicKey<Crypto::UnsignedBigInteger>::export_as_der() const::{lambda()#1}&&)
Unexecuted instantiation: _ZN6Crypto4ASN17Encoder17write_constructedIZNS_2PK24wrap_in_private_key_infoINS3_13RSAPrivateKeyINS_18UnsignedBigIntegerEEEEEN2AK7ErrorOrINS8_6Detail10ByteBufferILm32EEENS8_5ErrorEEET_NS8_4SpanIiEEQrQSF__XcldtfL0p_13export_as_derEEEUlvE_EENS9_IvSD_EEhhOSF_
Unexecuted instantiation: _ZN6Crypto4ASN17Encoder17write_constructedIZZNS_2PK24wrap_in_private_key_infoINS3_13RSAPrivateKeyINS_18UnsignedBigIntegerEEEEEN2AK7ErrorOrINS8_6Detail10ByteBufferILm32EEENS8_5ErrorEEET_NS8_4SpanIiEEQrQSF__XcldtfL1p_13export_as_derEEENKUlvE_clEvEUlvE_EENS9_IvSD_EEhhOSF_
Unexecuted instantiation: AK::ErrorOr<void, AK::Error> Crypto::ASN1::Encoder::write_constructed<Crypto::PK::RSAPrivateKey<Crypto::UnsignedBigInteger>::export_as_der() const::{lambda()#1}>(unsigned char, unsigned char, Crypto::PK::RSAPrivateKey<Crypto::UnsignedBigInteger>::export_as_der() const::{lambda()#1}&&)
Unexecuted instantiation: CryptoAlgorithms.cpp:AK::ErrorOr<void, AK::Error> Crypto::ASN1::Encoder::write_constructed<Web::Crypto::ECDSA::verify(Web::Crypto::AlgorithmParams const&, JS::NonnullGCPtr<Web::Crypto::CryptoKey>, AK::Detail::ByteBuffer<32ul> const&, AK::Detail::ByteBuffer<32ul> const&)::$_2>(unsigned char, unsigned char, Web::Crypto::ECDSA::verify(Web::Crypto::AlgorithmParams const&, JS::NonnullGCPtr<Web::Crypto::CryptoKey>, AK::Detail::ByteBuffer<32ul> const&, AK::Detail::ByteBuffer<32ul> const&)::$_2&&)
318
319
private:
320
    ErrorOr<void> write_tag(Class, Type, Kind);
321
    ErrorOr<void> write_length(size_t);
322
    ErrorOr<void> write_bytes(ReadonlyBytes);
323
    ErrorOr<void> write_byte(u8);
324
325
    ErrorOr<void> write_boolean(bool, Optional<Class>, Optional<Kind>);
326
    ErrorOr<void> write_arbitrary_sized_integer(UnsignedBigInteger const&, Optional<Class>, Optional<Kind>);
327
    ErrorOr<void> write_printable_string(StringView, Optional<Class>, Optional<Kind>);
328
    ErrorOr<void> write_octet_string(ReadonlyBytes, Optional<Class>, Optional<Kind>);
329
    ErrorOr<void> write_null(Optional<Class>, Optional<Kind>);
330
    ErrorOr<void> write_object_identifier(Span<int const>, Optional<Class>, Optional<Kind>);
331
    ErrorOr<void> write_bit_string(BitStringView, Optional<Class>, Optional<Kind>);
332
333
    Vector<ByteBuffer> m_buffer_stack;
334
};
335
336
}