Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added RNG for NPS, cleaned up telemetry config files
- Loading branch information
Showing
10 changed files
with
202 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<!DOCTYPE module SYSTEM "module.dtd"> | ||
|
||
<module name="telemetry_transparent_secure_gec" dir="datalink" task="datalink"> | ||
<doc> | ||
<description> | ||
Example of using secure telemetry over PPRZ protocol over UART | ||
|
||
This file serves only as an example and should not be used in real applications, | ||
because it only passes through all data (so it is equivalent to using plaintext data). | ||
|
||
However, this example should make it easier for users to devise their own encryption scheme. | ||
</description> | ||
|
||
</doc> | ||
|
||
<autoload name="telemetry" type="secure_common"/> | ||
<autoload name="rng"/> | ||
<autoload name="haclc"/> | ||
|
||
<makefile target="!fbw|sim"> | ||
<file name="gec_ke.c" dir="modules/datalink/gec"/> | ||
</makefile> | ||
|
||
</module> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Copyright (C) 2017 Michal Podhradsky <mpodhradsky@galois.com> | ||
* | ||
* This file is part of Paparazzi. | ||
* | ||
* Paparazzi is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2, or (at your option) | ||
* any later version. | ||
* | ||
* Paparazzi is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with Paparazzi; see the file COPYING. If not, write to | ||
* the Free Software Foundation, 59 Temple Place - Suite 330, | ||
* Boston, MA 02111-1307, USA. | ||
* | ||
*/ | ||
|
||
/** \file rng_arch.c | ||
* \brief arch specific Random Number Generator API | ||
* | ||
*/ | ||
#include "mcu_periph/rng.h" | ||
|
||
#include <fcntl.h> | ||
#include <unistd.h> | ||
#include <stdlib.h> | ||
#include <stdio.h> | ||
|
||
void rng_init(void) {} | ||
|
||
void rng_deinit(void) {} | ||
|
||
// Return true only if we got a new number | ||
// that is different from the previous one | ||
bool rng_get(uint32_t *rand_nr) | ||
{ | ||
int fd = open("/dev/urandom", O_RDONLY); | ||
if (fd == -1) { | ||
printf("Cannot open /dev/urandom\n"); | ||
return false; | ||
} | ||
|
||
uint8_t len = sizeof(uint32_t); | ||
uint8_t res = read(fd, rand_nr, len); | ||
if (res != len) { | ||
printf("Error on reading, expected %u bytes, got %u bytes\n", | ||
len, res); | ||
return false; | ||
} | ||
close(fd); | ||
return true; | ||
} | ||
|
||
// Wait until we get a new number that is different | ||
// from the previous one. We can wait forever here if | ||
// the clocks are not setup properly. | ||
uint32_t rng_wait_and_get(void) { | ||
uint32_t tmp = 0; | ||
while (!rng_get(&tmp)) {}; | ||
return tmp; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright (C) 2017 Michal Podhradsky <mpodhradsky@galois.com> | ||
* | ||
* This file is part of paparazzi. | ||
* | ||
* paparazzi is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2, or (at your option) | ||
* any later version. | ||
* | ||
* paparazzi is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with paparazzi; see the file COPYING. If not, see | ||
* <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
/** | ||
* @file datalink/gec/gec.c | ||
* | ||
* Galois embedded crypto iplementation | ||
* | ||
*/ | ||
#include "pprzlink/spprz_utils.h" // for incoming/outgoing functions | ||
#include "mcu_periph/rng.h" | ||
|
||
|
||
|
||
|
||
/** | ||
* Trivial implementation of the processing function | ||
* Shall be replaced by user implementation! | ||
* | ||
* This function only copies trans->trans_rx.payload into provided buf | ||
*/ | ||
bool spprz_process_incoming_packet(struct spprz_transport *trans, uint8_t *buf) | ||
{ | ||
for (uint8_t i = 0; i < trans->trans_rx.payload_len; i++) { | ||
buf[i] = trans->trans_rx.payload[i]; | ||
} | ||
return true; | ||
} | ||
|
||
/** | ||
* Trivial implementation of the processing function | ||
* Shall be replaced by user implementation! | ||
* | ||
* This function is only a pass-through. | ||
*/ | ||
bool spprz_process_outgoing_packet(struct spprz_transport *trans __attribute__((unused))) | ||
{ | ||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright (C) 2017 Michal Podhradsky <mpodhradsky@galois.com> | ||
* | ||
* This file is part of paparazzi. | ||
* | ||
* paparazzi is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2, or (at your option) | ||
* any later version. | ||
* | ||
* paparazzi is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with paparazzi; see the file COPYING. If not, see | ||
* <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
/** | ||
* @file datalink/gec/gec.h | ||
* | ||
* Galois embedded crypto iplementation | ||
* | ||
*/ | ||
#ifndef SPPRZ_GEC_KE_H | ||
#define SPPRZ_GEC_KE_H | ||
|
||
|
||
|
||
#endif /* SPPRZ_GEC_KE_H */ |