GNU Radio's M17 Package
m17_decoder_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_DECODER_IMPL_H
9#define INCLUDED_M17_M17_DECODER_IMPL_H
10
12#include "m17.h"
13
14#define AES
15#define ECC
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 bool _debug_data = false;
34 bool _debug_ctrl = false;
35 float _threshold = 0.9;
36 bool _callsign = false;
37 bool _signed_str = false;
38 // uint8_t _key[32];
39 uint8_t _key[64] = { 0 }; //public key
40 uint8_t _iv[16];
41 encr_t _encr_type = ENCR_NONE;
42//used for signatures
43 uint8_t _digest[16] = { 0 }; //16-byte field for the stream digest
44 uint8_t _sig[64] = { 0 }; //ECDSA signature
45 uint32_t _scrambler_key = 0; //keep set to initial value for seed calculation function
46
47#ifdef AES
48 typedef enum
49 {
50 AES128,
51 AES192,
52 AES256
53 } aes_t;
54 int8_t _aes_subtype = -1;
55#endif
56
57 float last[8] = { 0 }; //look-back buffer for finding syncwords
58 float _pld[SYM_PER_PLD]; //raw frame symbols
59 uint16_t soft_bit[2 * SYM_PER_PLD]; //raw frame soft bits
60 uint16_t d_soft_bit[2 * SYM_PER_PLD]; //deinterleaved soft bits
61 uint16_t _expected_next_fn;
62 uint16_t _fn;
63
64 lsf_t _lsf; //complete LSF (one byte extra needed for the Viterbi decoder)
65 uint16_t lich_chunk[96]; //raw, soft LSF chunk extracted from the LICH
66 uint8_t _lich_b[6]; //48-bit decoded LICH
67 uint8_t _lich_cnt; //LICH_CNT
68 uint8_t lich_chunks_rcvd = 0; //flags set for each LSF chunk received
69
70 uint16_t enc_data[272]; //raw frame data soft bits
71 uint8_t _frame_data[19]; //decoded frame data, 144 bits (16+128), plus 4 flushing bits
72 uint8_t digest[16] = { 0 };
73
74 uint8_t syncd = 0; //syncword found?
75 uint8_t fl = 0; //Frame=0 of LSF=1
76 uint8_t pushed; //counter for pushed symbols
77
78 uint8_t d_dst[12], d_src[12]; //decoded strings
79#ifdef ECC
80//Scrambler
81 uint8_t _seed[3]; //24-bit is the largest seed value
82 uint8_t _scr_bytes[16];
83 uint8_t _scrambler_pn[128];
84 uint32_t _scrambler_seed = 0;
85 int8_t _scrambler_subtype = -1;
86#endif
87 const struct uECC_Curve_t *_curve = uECC_secp256r1 ();
88
89 public:
90 m17_decoder_impl (bool debug_data, bool debug_ctrl, float threshold,
91 bool callsign, bool signed_str, int encr_type,
92 std::string key, std::string seed);
94 void set_debug_data (bool debug);
95 void set_key (std::string arg);
96 void set_seed (std::string seed);
97 void set_debug_ctrl (bool debug);
98 void set_callsign (bool callsign);
99 void set_threshold (float threshold);
100 void set_signed (bool signed_str);
101 void set_encr_type (int encr_type);
102 void parse_raw_key_string (uint8_t * dest, const char *inp);
104 uint32_t scrambler_seed_calculation (int8_t subtype, uint32_t key,
105 int fn);
106
107 // Where all the action really happens
108 void forecast (int noutput_items,
109 gr_vector_int & ninput_items_required);
110
111 int general_work (int noutput_items,
112 gr_vector_int & ninput_items,
113 gr_vector_const_void_star & input_items,
114 gr_vector_void_star & output_items);
115 };
116
117 } // namespace m17
118} // namespace gr
119
120#endif /* INCLUDED_M17_M17_DECODER_IMPL_H */
void set_signed(bool signed_str)
void set_threshold(float threshold)
void set_encr_type(int encr_type)
uint32_t scrambler_seed_calculation(int8_t subtype, uint32_t key, int fn)
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_seed(std::string seed)
void set_callsign(bool callsign)
void forecast(int noutput_items, gr_vector_int &ninput_items_required)
m17_decoder_impl(bool debug_data, bool debug_ctrl, float threshold, bool callsign, bool signed_str, int encr_type, std::string key, std::string seed)
void set_key(std::string arg)
<+description of block+>
Definition m17_decoder.h:25
encr_t
Definition m17_decoder.h:29
@ ENCR_NONE
Definition m17_decoder.h:30
#define SYM_PER_PLD
Definition m17.h:22
Definition m17_coder.h:15
Structure holding Link Setup Frame data.
Definition m17.h:94
uECC_Curve uECC_secp256r1(void)