[no ci] wifibroadcast-ng: add custom keypair generator

pull/1688/head
viktorxda 2025-01-28 15:24:50 +01:00
parent e5ad5ae1db
commit 9176b9c77c
5 changed files with 71 additions and 5 deletions

View File

@ -26,7 +26,7 @@ build: defconfig
@$(BR_MAKE) all -j$(shell nproc)
br-%: defconfig
@$(BR_MAKE) $(subst br-,,$@)
@$(BR_MAKE) $(subst br-,,$@) -j$(shell nproc)
defconfig: prepare
@echo --- $(or $(CONFIG),$(error variable BOARD not found))

View File

@ -12,8 +12,7 @@ SIGMASTAR_OSDRV_INFINITY6_LICENSE_FILES = LICENSE
SIGMASTAR_OSDRV_INFINITY6_DEPENDENCIES = ipctool sigmastar-osdrv-sensors
define SIGMASTAR_OSDRV_INFINITY6_BUILD_CMDS
cp -rf $(SIGMASTAR_OSDRV_INFINITY6_PKGDIR)/files/src $(@D)
$(TARGET_CC) $(@D)/src/config_tool.c -o $(@D)/config_tool -lipchw -s
$(TARGET_CC) $(SIGMASTAR_OSDRV_INFINITY6_PKGDIR)/src/config_tool.c -o $(@D)/config_tool -lipchw -s
endef
define SIGMASTAR_OSDRV_INFINITY6_INSTALL_TARGET_CMDS

View File

@ -14,6 +14,10 @@ wfb_yaml() {
load_config() {
wfb_yaml /rom/etc/wfb.yaml
wfb_yaml /etc/wfb.yaml
if [ ! -e "$wfb_key" ]; then
wfb_key=/rom/etc/drone.key
fi
}
load_modules() {
@ -91,8 +95,9 @@ start_telemetry() {
if [ "$router" = "msposd" ]; then
echo "- Starting $router"
msposd --baudrate 115200 --channels 8 -osd --ahi 0 -r "$osd_fps" \
--master "$serial" --out 10.5.0.1:14551 > /dev/null &
size=$(curl -s localhost/api/v1/config.json | jsonfilter -e "@.video0.size")
msposd --baudrate 115200 --channels 8 --ahi 0 -osd -r "$osd_fps" \
--master "$serial" --out 10.5.0.1:14551 --size "${size:-1280x720}" > /dev/null &
elif [ "$router" = "mavfwd" ]; then
echo "- Starting $router"
mavfwd --baudrate 115200 --channels 8 -p 100 -a 15 -t \

View File

@ -0,0 +1,60 @@
// Copyright (C) 2017 - 2024 Vasily Evseenko <svpcom@p2ptech.org>
/*
* This program 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; version 3.
*
* This program 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 this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <fcntl.h>
#include <sodium.h>
int main(int argc, char **argv) {
unsigned char drone_publickey[crypto_box_PUBLICKEYBYTES];
unsigned char drone_secretkey[crypto_box_SECRETKEYBYTES];
unsigned char gs_publickey[crypto_box_PUBLICKEYBYTES];
unsigned char gs_secretkey[crypto_box_SECRETKEYBYTES];
FILE *fp;
if (argc != 2) {
printf("Passphrase is missing\n");
return 1;
}
if (sodium_init() < 0) {
printf("Libsodium init failed\n");
return 1;
}
const char *seed = argv[1];
printf("Using passphrase: %s\n", seed);
if (crypto_box_seed_keypair(drone_publickey, drone_secretkey, seed) != 0 ||
crypto_box_seed_keypair(gs_publickey, gs_secretkey, seed) != 0) {
printf("Unable to generate keys\n");
return 1;
}
const char *key = "/etc/drone.key";
if ((fp = fopen(key, "w")) == NULL) {
printf("Unable to save: %s\n", key);
return 1;
}
fwrite(drone_secretkey, crypto_box_SECRETKEYBYTES, 1, fp);
fwrite(gs_publickey, crypto_box_PUBLICKEYBYTES, 1, fp);
fclose(fp);
printf("Drone keypair saved: %s\n", key);
return 0;
}

View File

@ -12,6 +12,7 @@ WIFIBROADCAST_NG_DEPENDENCIES += libpcap libsodium
define WIFIBROADCAST_NG_BUILD_CMDS
$(MAKE) CC=$(TARGET_CC) CXX=$(TARGET_CXX) LDFLAGS=-s -C $(@D) all_bin
$(TARGET_CC) $(WIFIBROADCAST_NG_PKGDIR)/src/keypair.c -o $(@D)/keypair -lsodium -s
endef
define WIFIBROADCAST_NG_INSTALL_TARGET_CMDS
@ -23,6 +24,7 @@ define WIFIBROADCAST_NG_INSTALL_TARGET_CMDS
$(INSTALL) -m 755 -t $(TARGET_DIR)/etc/init.d $(WIFIBROADCAST_NG_PKGDIR)/files/S98wifibroadcast
$(INSTALL) -m 755 -d $(TARGET_DIR)/usr/bin
$(INSTALL) -m 755 -t $(TARGET_DIR)/usr/bin $(@D)/keypair
$(INSTALL) -m 755 -t $(TARGET_DIR)/usr/bin $(@D)/wfb_rx
$(INSTALL) -m 755 -t $(TARGET_DIR)/usr/bin $(@D)/wfb_tx
$(INSTALL) -m 755 -t $(TARGET_DIR)/usr/bin $(@D)/wfb_tx_cmd