GNU Radio's M17 Package
m17_coder_impl.h
Go to the documentation of this file.
1/* -*- c++ -*- */
2/*
3 * Copyright 2023 jmfriedt.
4 *
5 * SPDX-License-Identifier: GPL-3.0-or-later
6 */
7
8#ifndef INCLUDED_M17_M17_CODER_IMPL_H
9#define INCLUDED_M17_M17_CODER_IMPL_H
10
11#define AES
12#define ECC
13
15#include "m17.h" // lsf_t declaration
16
17#ifdef AES
18#include "aes.h"
19#endif
20
21#ifdef ECC
22#include "uECC.h"
23#endif
24
25namespace gr
26{
27 namespace m17
28 {
29
31 {
32 private:
33 unsigned char _src_id[10], _dst_id[10]; // 9 character callsign
34 int _mode, _data;
35 uint16_t _type;
36 uint16_t _send_preamble;
37 int _encr_subtype;
38//encryption
39#ifdef AES
40//encryption
41 int8_t _aes_subtype = -1;
42 const struct uECC_Curve_t *_curve = uECC_secp256r1 ();
43 encr_t _encr_type= ENCR_NONE;
44//AES
45 typedef enum
46 {
47 AES128,
48 AES192,
49 AES256
50 } aes_t;
51 uint8_t _key[32];
52 uint8_t _iv[16];
53 time_t epoch = 1577836800L; //Jan 1, 2020, 00:00:00 UTC
54#endif
55 int _can;
56 lsf_t _lsf, _next_lsf;
57 std::string _meta;
58 int _got_lsf = 0;
59 uint16_t _fn = 0; //16-bit Frame Number (for the stream mode)
60 uint8_t _lich_cnt = 0; //0..5 LICH counter, derived from the Frame Number
61 bool _debug = 0;
62 bool _signed_str = false, _finished = false;
63
64 uint8_t _digest[16] = { 0 }; //16-byte field for the stream digest
65 bool _priv_key_loaded = false; //do we have a sig key loaded?
66 uint8_t _priv_key[32] = { 0 }; //private key
67 uint8_t _sig[64] = { 0 }; //ECDSA signature
68 bool _init_frame;
69
70#ifdef ECC
71//Scrambler
72 uint8_t _seed[3]; //24-bit is the largest seed value
73 uint8_t _scr_bytes[16];
74 uint8_t _scrambler_pn[128];
75 uint32_t _scrambler_seed = 0;
76 int8_t _scrambler_subtype = -1;
77#endif
78
79 public:
80 void parse_raw_key_string (uint8_t *, const char *);
82 void set_src_id (std::string src_id);
83 void set_dst_id (std::string dst_id);
84 void set_key (std::string key);
85 void set_priv_key (std::string key);
86 void set_meta (std::string meta);
87 void set_seed (std::string meta);
88 void set_type (int mode, int data, encr_t encr_type, int encr_subtype,
89 int can);
90 void set_mode (int mode);
91 void set_data (int data);
92 void set_encr_type (int encr_type);
93 void set_encr_subtype (int encr_subtype);
94 void set_aes_subtype (int aes_subtype, int encr_type);
95 void set_can (int can);
96 void set_debug (bool debug);
97 void set_signed (bool signed_str);
98 void end_of_transmission(const pmt::pmt_t& msg);
99
100 m17_coder_impl (std::string src_id, std::string dst_id, int mode,
101 int data, int encr_type, int encr_subtype, int aes_subtype, int can,
102 std::string meta, std::string key, std::string priv_key,
103 bool debug, bool signed_str, std::string seed);
105
106 // Where all the action really happens
107 void forecast (int noutput_items,
108 gr_vector_int & ninput_items_required);
109
110 int general_work (int noutput_items,
111 gr_vector_int & ninput_items,
112 gr_vector_const_void_star & input_items,
113 gr_vector_void_star & output_items);
114 };
115
116 } // namespace m17
117} // namespace gr
118
119#endif /* INCLUDED_M17_M17_CODER_IMPL_H */
void forecast(int noutput_items, gr_vector_int &ninput_items_required)
void set_dst_id(std::string dst_id)
void set_priv_key(std::string key)
m17_coder_impl(std::string src_id, std::string dst_id, int mode, int data, int encr_type, int encr_subtype, int aes_subtype, int can, std::string meta, std::string key, std::string priv_key, bool debug, bool signed_str, std::string seed)
void set_meta(std::string meta)
void set_aes_subtype(int aes_subtype, int encr_type)
int general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
void set_key(std::string key)
void set_type(int mode, int data, encr_t encr_type, int encr_subtype, int can)
void set_encr_subtype(int encr_subtype)
void set_mode(int mode)
void set_signed(bool signed_str)
void set_src_id(std::string src_id)
void set_seed(std::string meta)
void set_encr_type(int encr_type)
void end_of_transmission(const pmt::pmt_t &msg)
void set_data(int data)
<+description of block+>
Definition m17_coder.h:25
encr_t
Definition m17_coder.h:29
@ ENCR_NONE
Definition m17_coder.h:30
Definition m17_coder.h:15
Structure holding Link Setup Frame data.
Definition m17.h:94
uECC_Curve uECC_secp256r1(void)