sphinx-key: stop storing previous lss msg on sd card

This commit is contained in:
irriden
2023-10-18 15:18:38 +00:00
parent dce2daa3d0
commit 66045569ac
2 changed files with 0 additions and 93 deletions

View File

@@ -1,73 +0,0 @@
# MODE=debug
MODE=release
check_exists() {
command -v "$1" > /dev/null
}
check_port() {
cargo espflash board-info --port "$1" &> /dev/null
}
if ! check_exists esptool.py
then
echo "esptool.py not installed!"
echo "install with this command: pip install esptool"
exit 1
fi
if ! check_exists ldproxy
then
echo "ldproxy not installed!"
echo "install with this command: cargo install ldproxy"
exit 1
fi
if ! check_exists cargo-espflash
then
echo "cargo-espflash not installed!"
echo "install with this command: cargo install cargo-espflash"
exit 1
fi
if [ -z "$SSID" ]
then
echo "Please set environment variable SSID to the SSID of the wifi you'll use to configure your sphinx-key."
exit 1
fi
if [ -z "$PASS" ]
then
echo "Please set environment variable PASS to the password of the wifi you'll use to configure your sphinx-key."
exit 1
fi
if [ ${#PASS} -lt 8 ]
then
echo "Please set PASS to a password longer than 7 characters."
exit 1
fi
for FILE in /dev/tty.*
do
# Check for port on macOS
if check_port $FILE
then
PORT=$FILE
break
fi
done
if [ -z "$PORT" ]
then
# Check for port on linux
if check_port /dev/ttyUSB1
then
PORT=/dev/ttyUSB1
fi
fi
if [ -z "$PORT" ]
then
echo "ESP likely not connected! Exiting now."
echo "Make sure the ESP is connected with a data USB cable, and try again."
exit 1
fi
if [ $MODE = "release" ]
then
cargo build --release
else
cargo build
fi &&
esptool.py --chip esp32-c3 elf2image ../target/riscv32imc-esp-espidf/$MODE/sphinx-key &&
esptool.py --chip esp32c3 -b 460800 --before=default_reset --after=hard_reset write_flash --flash_mode dio --flash_freq 40m --flash_size 4MB 0x90000 ../target/riscv32imc-esp-espidf/$MODE/sphinx-key.bin &&
cargo espflash monitor --port $PORT

View File

@@ -94,7 +94,6 @@ pub fn make_event_loop(
} }
let kvv_store = FsKVVStore::new(&ROOT_STORE, signer_id.clone(), None).0; let kvv_store = FsKVVStore::new(&ROOT_STORE, signer_id.clone(), None).0;
let msg_store = FsKVVStore::new(&ROOT_STORE, signer_id.clone(), None).0;
let fs_persister = CloudKVVStore::new(kvv_store); let fs_persister = CloudKVVStore::new(kvv_store);
let _ = fs_persister.enter(); let _ = fs_persister.enter();
@@ -178,12 +177,6 @@ pub fn make_event_loop(
if let Some(server_hmac) = server_hmac_opt { if let Some(server_hmac) = server_hmac_opt {
// muts! send LSS first! // muts! send LSS first!
mqtt_pub(&mut mqtt, &client_id, topics::LSS_RES, &lss_b); mqtt_pub(&mut mqtt, &client_id, topics::LSS_RES, &lss_b);
msg_store
.set_raw("vls_b", &vls_b)
.map_err(|_e| anyhow::anyhow!("failed to put vls_b"))?;
msg_store
.set_raw("lss_b", &server_hmac)
.map_err(|_e| anyhow::anyhow!("failed to put lss_b"))?;
msgs = Some((vls_b, server_hmac)); msgs = Some((vls_b, server_hmac));
} else { } else {
// no muts, respond directly back! // no muts, respond directly back!
@@ -225,19 +218,6 @@ pub fn make_event_loop(
} }
} }
Event::LssMessage(msg_bytes) => { Event::LssMessage(msg_bytes) => {
if msgs.is_none() {
log::warn!("Restoring previous message from sd card");
let vls_b = msg_store
.get_raw("vls_b")
.map_err(|e| anyhow::anyhow!("failed to get vls_b: {:?}", e))?;
let lss_b = msg_store
.get_raw("lss_b")
.map_err(|e| anyhow::anyhow!("failed to get lss_b: {:?}", e))?;
let server_hmac: [u8; 32] = lss_b
.try_into()
.map_err(|e| anyhow::anyhow!("lss_b is not 32 bytes: {:?}", e))?;
msgs = Some((vls_b, server_hmac));
}
match lss::handle_lss_msg(&msg_bytes, msgs, &lss_signer) { match lss::handle_lss_msg(&msg_bytes, msgs, &lss_signer) {
Ok((ret_topic, bytes)) => { Ok((ret_topic, bytes)) => {
// set msgs back to None // set msgs back to None