1 /*
2  * Copyright (C) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef ASN1_DECODER_H
17 #define ASN1_DECODER_H
18 
19 #include <cstdbool>
20 #include <cstdint>
21 #include <list>
22 #include <vector>
23 #include "asn1_node.h"
24 #include "telephony_log_wrapper.h"
25 
26 namespace OHOS {
27 namespace Telephony {
28 class Asn1Decoder {
29 public:
30     Asn1Decoder(const std::vector<uint8_t> &src, uint32_t offset, uint32_t decodeLen);
31     bool Asn1HasNextNode();
32     std::shared_ptr<Asn1Node> Asn1NextNode();
33 
34 private:
35     std::shared_ptr<Asn1Node> BuildAsn1Node(const uint32_t tag, uint32_t offset, uint32_t tagStart);
36 
37 private:
38     std::vector<uint8_t> srcData_ = {};
39     uint32_t position_ = 0;
40     uint32_t end_ = 0;
41 };
42 } // namespace Telephony
43 } // namespace OHOS
44 #endif // ASN1_DECODER_H
45