/src/rnp/src/lib/rawpacket.hpp
Line | Count | Source |
1 | | /* |
2 | | * Copyright (c) 2017-2025 [Ribose Inc](https://www.ribose.com). |
3 | | * All rights reserved. |
4 | | * |
5 | | * Redistribution and use in source and binary forms, with or without |
6 | | * modification, are permitted provided that the following conditions |
7 | | * are met: |
8 | | * 1. Redistributions of source code must retain the above copyright |
9 | | * notice, this list of conditions and the following disclaimer. |
10 | | * 2. Redistributions in binary form must reproduce the above copyright |
11 | | * notice, this list of conditions and the following disclaimer in the |
12 | | * documentation and/or other materials provided with the distribution. |
13 | | * |
14 | | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
15 | | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
16 | | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
17 | | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS |
18 | | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
19 | | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
20 | | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
21 | | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
22 | | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
23 | | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
24 | | * POSSIBILITY OF SUCH DAMAGE. |
25 | | */ |
26 | | #ifndef RNP_RAWPACKET_HPP_ |
27 | | #define RNP_RAWPACKET_HPP_ |
28 | | |
29 | | #include <vector> |
30 | | #include "types.h" |
31 | | #include "librepgp/stream-common.h" |
32 | | |
33 | | typedef struct pgp_key_pkt_t pgp_key_pkt_t; |
34 | | typedef struct pgp_userid_pkt_t pgp_userid_pkt_t; |
35 | | |
36 | | namespace rnp { |
37 | | class RawPacket { |
38 | | pgp_pkt_type_t tag_; |
39 | | std::vector<uint8_t> data_; |
40 | | |
41 | | public: |
42 | 333 | RawPacket() : tag_(PGP_PKT_RESERVED){}; |
43 | | RawPacket(const uint8_t *data, size_t len, pgp_pkt_type_t atag); |
44 | | RawPacket(const pgp::pkt::Signature &sig); |
45 | | RawPacket(pgp_key_pkt_t &key); |
46 | | RawPacket(const pgp_userid_pkt_t &uid); |
47 | | |
48 | | const std::vector<uint8_t> & |
49 | | data() const noexcept |
50 | 0 | { |
51 | 0 | return data_; |
52 | 0 | } |
53 | | |
54 | | pgp_pkt_type_t |
55 | | tag() const noexcept |
56 | 0 | { |
57 | 0 | return tag_; |
58 | 0 | } |
59 | | |
60 | | void write(pgp_dest_t &dst) const; |
61 | | }; |
62 | | } // namespace rnp |
63 | | |
64 | | #endif |