9 #include "../firmware.h"
11 void Packet_sign_shake128(
const uint8_t *input, uint32_t input_length,
const uint8_t *key, uint32_t key_length, uint8_t *output)
22 void Packet_telecommand_512_encode(
packet_telecommand_512 *input_packet, uint8_t *output_buffer,
const uint16_t origin,
const uint8_t *key, uint32_t key_length)
24 input_packet->spacecraft = origin;
33 Util_pn9((uint8_t *)input_packet, 0, 64);
36 labrador_ldpc_copy_encode(LABRADOR_LDPC_CODE_TC512, (uint8_t *)input_packet, output_buffer);
37 labrador_ldpc_copy_encode(LABRADOR_LDPC_CODE_TC512, &((uint8_t *)input_packet)[32], &output_buffer[64]);
40 Packet_interleave_32x32(output_buffer);
43 bool Packet_telecommand_512_decode(uint8_t *input_buffer,
packet_telecommand_512 *output_packet,
const uint16_t destination,
const uint8_t *key, uint32_t key_length)
45 uint8_t ldpc_wa[LABRADOR_LDPC_BF_WORKING_LEN_TC512];
46 uint8_t ldpc_out[LABRADOR_LDPC_OUTPUT_LEN_TC512];
48 Packet_uninterleave_32x32(input_buffer);
51 if(!labrador_ldpc_decode_bf(LABRADOR_LDPC_CODE_TC512,
53 (uint8_t *)output_packet,
62 Util_pn9((uint8_t *)output_packet, 0, 32);
65 if(output_packet->spacecraft != destination)
71 if(!labrador_ldpc_decode_bf(LABRADOR_LDPC_CODE_TC512,
81 memcpy(&((uint8_t *)output_packet)[32], ldpc_out, 32);
84 Util_pn9(&((uint8_t *)output_packet)[32], 32, 32);
93 uint8_t packet_hash[16];
95 if(memcmp(packet_hash, output_packet->hash, 16) != 0)
106 input_packet->spacecraft = origin;
112 Util_pn9((uint8_t *)input_packet, 0, 128);
122 bool Packet_telemetry_1024_decode(uint8_t *input_buffer,
packet_telemetry_1024 *output_packet,
const uint16_t destination,
const uint8_t *key, uint32_t key_length)
131 Util_pn9((uint8_t *)output_packet, 0, 128);
134 if(output_packet->spacecraft != destination)
144 uint8_t packet_hash[16];
146 if(memcmp(packet_hash, output_packet->hash, 16) != 0)
void Util_shake_init(util_shake_ctx_t *c, uint8_t output_length)
void Packet_telemetry_1024_encode(packet_telemetry_1024 *input_packet, uint8_t *output_buffer, const uint16_t origin, const uint8_t *key, uint32_t key_length)
void Util_shake_out(util_shake_ctx_t *c, uint8_t *output)
uint16_t Util_crc16(const uint8_t *buf, uint32_t size)
void Util_pn9(uint8_t *buffer, uint32_t preroll, uint32_t length)
void Util_shake_update(util_shake_ctx_t *c, const uint8_t *data, uint32_t data_length)