From b21cc1f37a323fc356872b7ae02ebb342e2e92f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Est=C3=A9vez?= Date: Mon, 15 Dec 2025 10:39:17 +0100 Subject: [PATCH] restructure repository as a cargo workspace This restructures the repository as a cargo workspace with two crates: - galileo-osnma, which contains the library and all the binaries that run on a host PC, including helpers that were previously in their own crate. - osnman-longan-nano, which contains the longan nano firmware. Additionally, just has been added as a command runner and the Github CI has been refactored. --- .../.cargo => .cargo}/config.toml | 3 - .github/workflows/ci.yml | 87 ++ .github/workflows/pycodestyle.yml | 14 - .github/workflows/rust.yml | 144 --- .github/workflows/test-vectors.yml | 25 - .gitignore | 5 +- .../Cargo.lock => Cargo.lock | 653 ++++++++++- Cargo.toml | 60 +- README.md | 56 +- galileo-osnma/Cargo.toml | 87 ++ build.rs => galileo-osnma/build.rs | 0 .../src/bin/galileo-osnma-sizeof.rs | 0 .../src/bin/galmon-filter-inav.rs | 0 .../src/bin/galmon-osnma.rs | 2 +- .../src/bin/osnma-longan-nano-client.rs | 35 +- .../src/bin/osnma-test-vectors-to-galmon.rs | 0 {src => galileo-osnma/src}/bitfields.rs | 0 {src => galileo-osnma/src}/dsm.rs | 0 {src => galileo-osnma/src}/galmon/mod.rs | 20 +- .../src}/galmon/navmon.proto | 0 .../src}/galmon/transport/test/data.rs | 0 {src => galileo-osnma/src}/gst.rs | 2 +- {src => galileo-osnma/src}/lib.rs | 0 {src => galileo-osnma/src}/mack.rs | 16 +- {src => galileo-osnma/src}/maclt.rs | 0 {src => galileo-osnma/src}/merkle_tree.rs | 0 {src => galileo-osnma/src}/navmessage.rs | 200 ++-- {src => galileo-osnma/src}/osnma.rs | 66 +- {src => galileo-osnma/src}/storage.rs | 0 {src => galileo-osnma/src}/subframe.rs | 0 {src => galileo-osnma/src}/svn.rs | 0 {src => galileo-osnma/src}/tesla.rs | 0 {src => galileo-osnma/src}/types.rs | 0 {src => galileo-osnma/src}/validation.rs | 0 galmon-osnma/Cargo.lock | 1033 ----------------- galmon-osnma/Cargo.toml | 26 - justfile | 45 + osnma-longan-nano-client/Cargo.lock | 969 ---------------- osnma-longan-nano-client/Cargo.toml | 19 - osnma-longan-nano-client/README.md | 21 - osnma-longan-nano/Cargo.toml | 28 +- osnma-longan-nano/README.md | 66 +- osnma-test-vectors-to-galmon/.gitignore | 1 - osnma-test-vectors-to-galmon/Cargo.toml | 21 - rustfmt.toml | 1 + utils/run_test_vectors.sh | 9 +- 46 files changed, 1131 insertions(+), 2583 deletions(-) rename {osnma-longan-nano/.cargo => .cargo}/config.toml (77%) create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/pycodestyle.yml delete mode 100644 .github/workflows/rust.yml delete mode 100644 .github/workflows/test-vectors.yml rename osnma-test-vectors-to-galmon/Cargo.lock => Cargo.lock (62%) create mode 100644 galileo-osnma/Cargo.toml rename build.rs => galileo-osnma/build.rs (100%) rename src/bin/sizeof.rs => galileo-osnma/src/bin/galileo-osnma-sizeof.rs (100%) rename galmon-osnma/src/bin/filter_inav.rs => galileo-osnma/src/bin/galmon-filter-inav.rs (100%) rename galmon-osnma/src/main.rs => galileo-osnma/src/bin/galmon-osnma.rs (98%) rename osnma-longan-nano-client/src/main.rs => galileo-osnma/src/bin/osnma-longan-nano-client.rs (84%) rename osnma-test-vectors-to-galmon/src/main.rs => galileo-osnma/src/bin/osnma-test-vectors-to-galmon.rs (100%) rename {src => galileo-osnma/src}/bitfields.rs (100%) rename {src => galileo-osnma/src}/dsm.rs (100%) rename {src => galileo-osnma/src}/galmon/mod.rs (94%) rename {src => galileo-osnma/src}/galmon/navmon.proto (100%) rename {src => galileo-osnma/src}/galmon/transport/test/data.rs (100%) rename {src => galileo-osnma/src}/gst.rs (98%) rename {src => galileo-osnma/src}/lib.rs (100%) rename {src => galileo-osnma/src}/mack.rs (92%) rename {src => galileo-osnma/src}/maclt.rs (100%) rename {src => galileo-osnma/src}/merkle_tree.rs (100%) rename {src => galileo-osnma/src}/navmessage.rs (86%) rename {src => galileo-osnma/src}/osnma.rs (94%) rename {src => galileo-osnma/src}/storage.rs (100%) rename {src => galileo-osnma/src}/subframe.rs (100%) rename {src => galileo-osnma/src}/svn.rs (100%) rename {src => galileo-osnma/src}/tesla.rs (100%) rename {src => galileo-osnma/src}/types.rs (100%) rename {src => galileo-osnma/src}/validation.rs (100%) delete mode 100644 galmon-osnma/Cargo.lock delete mode 100644 galmon-osnma/Cargo.toml create mode 100644 justfile delete mode 100644 osnma-longan-nano-client/Cargo.lock delete mode 100644 osnma-longan-nano-client/Cargo.toml delete mode 100644 osnma-longan-nano-client/README.md delete mode 100644 osnma-test-vectors-to-galmon/.gitignore delete mode 100644 osnma-test-vectors-to-galmon/Cargo.toml create mode 100644 rustfmt.toml diff --git a/osnma-longan-nano/.cargo/config.toml b/.cargo/config.toml similarity index 77% rename from osnma-longan-nano/.cargo/config.toml rename to .cargo/config.toml index 386841b..402dec1 100644 --- a/osnma-longan-nano/.cargo/config.toml +++ b/.cargo/config.toml @@ -4,6 +4,3 @@ rustflags = [ "-C", "link-arg=-Tmemory-cb.x", "-C", "link-arg=-Tlink.x", ] - -[build] -target = "riscv32imac-unknown-none-elf" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..e0cd646 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,87 @@ +name: ci + +on: + push: + branches: [main] + pull_request: + +env: + CARGO_TERM_COLOR: always + RUST_LOG_STYLE: always + RUSTDOCFLAGS: "-D warnings" + JUST_COLOR: always + +jobs: + rust: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + galmon: ["galmon", ""] + galmon-osnma: ["galmon-osnma", ""] + osnma-longan-nano: ["osnma-longan-nano", ""] + p521: ["p521", ""] + std: ["std", ""] + toolchain: ["stable", "1.88.0"] + steps: + - uses: actions/checkout@v6 + - name: Install toolchain + run: | + rustup install ${{ matrix.toolchain }} + rustup component add --toolchain ${{ matrix.toolchain }} rustfmt + rustup component add --toolchain ${{ matrix.toolchain }} clippy + rustup component add --toolchain ${{ matrix.toolchain }} llvm-tools + rustup target add --toolchain ${{ matrix.toolchain }} riscv32imac-unknown-none-elf + - uses: cargo-bins/cargo-binstall@main + - name: Install cargo-binutils + run: cargo binstall cargo-binutils + - uses: extractions/setup-just@v3 + - name: Install protoc + if: ${{ matrix.galmon != '' || matrix.galmon-osnma != '' || matrix.osnma-longan-nano != '' }} + run: | + sudo apt-get update + sudo apt-get install protobuf-compiler + - name: Install libudev-dev + if: ${{ matrix.osnma-longan-nano != '' }} + run: | + sudo apt-get update + sudo apt-get install libudev-dev + - name: Set environment + run: | + echo "RUSTUP_TOOLCHAIN=${{ matrix.toolchain }}" >> "$GITHUB_ENV" + echo "CARGO_FEATURES=${{matrix.galmon}},${{matrix.galmon-osnma}},${{matrix.osnma-longan-nano}},${{matrix.p521}},${{matrix.std}}" >> "$GITHUB_ENV" + - name: Format + run: cargo fmt --all -- --check + - name: Clippy + run: cargo clippy --all-targets --no-default-features --features $CARGO_FEATURES -- -D warnings + - name: Doc + run: cargo doc --no-default-features --features $CARGO_FEATURES + - name: Build + run: cargo build --verbose --no-default-features --features $CARGO_FEATURES + - name: Run tests + run: cargo test --verbose --no-default-features --features $CARGO_FEATURES + - name: Run clippy for osnma-longan-nano firmware + run: just clippy-osnma-longan-nano + - name: Build osnma-longan-nano firmware + run: just osnma-longan-nano + test-vectors: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + - name: Install protoc and libudev-dev + run: | + sudo apt-get update + sudo apt-get install protobuf-compiler libudev-dev + - name: Install ecdsa with pip + run: pip install ecdsa + - uses: extractions/setup-just@v3 + - name: Run test vectors + run: just test-vectors + pycodestyle: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + - name: Install pycodestyle with pip + run: pip install pycodestyle + - name: Run pycodestyle + run: pycodestyle . diff --git a/.github/workflows/pycodestyle.yml b/.github/workflows/pycodestyle.yml deleted file mode 100644 index 5063fc5..0000000 --- a/.github/workflows/pycodestyle.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: 'pycodestyle' - -on: [push, pull_request] - -jobs: - pycodestyle: - name: pycodestyle - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Install pycodestyle with pip - run: pip install pycodestyle - - name: Run pycodestyle - run: pycodestyle . diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml deleted file mode 100644 index e271e21..0000000 --- a/.github/workflows/rust.yml +++ /dev/null @@ -1,144 +0,0 @@ -name: Rust - -on: [push, pull_request] - -env: - CARGO_TERM_COLOR: always - -jobs: - default_features: - name: Default features - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Install protoc - run: | - sudo apt-get update - sudo apt-get install protobuf-compiler - - name: Format - run: cargo fmt --all -- --check - - name: Clippy - run: cargo clippy --all-targets --all-features -- -D warnings - - name: Doc - run: RUSTDOCFLAGS="-D warnings" cargo doc - - name: Build - run: cargo build --verbose - - name: Run tests - run: cargo test --verbose - - no_features: - name: No features - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Install protoc - run: | - sudo apt-get update - sudo apt-get install protobuf-compiler - - name: Format - run: cargo fmt --all -- --check - - name: Clippy - run: cargo clippy --all-targets --all-features -- -D warnings - - name: Doc - run: RUSTDOCFLAGS="-D warnings" cargo doc --no-default-features - - name: Build - run: cargo build --no-default-features --verbose - - name: Run tests - run: cargo test --no-default-features --verbose - - galmon_features: - name: Galmon features - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Install protoc - run: | - sudo apt-get update - sudo apt-get install protobuf-compiler - - name: Format - run: cargo fmt --all -- --check - - name: Clippy - run: cargo clippy --all-targets --all-features -- -D warnings - - name: Doc - run: RUSTDOCFLAGS="-D warnings" cargo doc --features galmon - - name: Build - run: cargo build --verbose --features galmon - - name: Run tests - run: cargo test --verbose --features galmon - - msrv: - name: MSRV - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Install protoc - run: | - sudo apt-get update - sudo apt-get install protobuf-compiler - - name: Install toolchain - run: rustup install 1.85.0 - - name: Doc - run: RUSTDOCFLAGS="-D warnings" cargo +1.85.0 doc --features galmon - - name: Build - run: cargo +1.85.0 build --verbose --features galmon - - name: Run tests - run: cargo +1.85.0 test --verbose --features galmon - - galmon: - name: Galmon - runs-on: ubuntu-latest - defaults: - run: - working-directory: galmon-osnma - steps: - - uses: actions/checkout@v4 - - name: Install protoc - run: | - sudo apt-get update - sudo apt-get install protobuf-compiler - - name: Format - run: cargo fmt --all -- --check - - name: Clippy - run: cargo clippy --all-targets --all-features -- -D warnings - - name: Build - run: cargo build --verbose - - name: Run tests - run: cargo test --verbose - - longan_nano: - name: Longan nano - runs-on: ubuntu-latest - defaults: - run: - working-directory: osnma-longan-nano - steps: - - uses: actions/checkout@v4 - - name: Install riscv32imac Rust target - run: rustup target add riscv32imac-unknown-none-elf - - name: Format - run: cargo fmt --all -- --check - - name: Clippy - run: cargo clippy --all-features -- -D warnings - - name: Build - run: cargo build --release --verbose - - longan_nano_client: - name: Longan nano client - runs-on: ubuntu-latest - defaults: - run: - working-directory: osnma-longan-nano-client - steps: - - uses: actions/checkout@v4 - - name: Install libudev and protoc - run: | - sudo apt-get update - sudo apt-get install libudev-dev protobuf-compiler - - name: Format - run: cargo fmt --all -- --check - - name: Clippy - run: cargo clippy --all-targets --all-features -- -D warnings - - name: Build - run: cargo build --verbose - - name: Run tests - run: cargo test --verbose diff --git a/.github/workflows/test-vectors.yml b/.github/workflows/test-vectors.yml deleted file mode 100644 index 8a6fa72..0000000 --- a/.github/workflows/test-vectors.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Test vectors - -on: [push, pull_request] - -env: - CARGO_TERM_COLOR: always - -jobs: - test_vectors: - name: Test vectors - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Install protoc - run: | - sudo apt-get update - sudo apt-get install protobuf-compiler - - name: Install ecdsa with pip - run: pip install ecdsa - - name: Download test vectors - run: | - wget --quiet https://www.gsc-europa.eu/sites/default/files/sites/all/files/Test_vectors.zip - unzip Test_vectors.zip - - name: Run test vectors - run: RUST_LOG_STYLE=always ./utils/run_test_vectors.sh Test_vectors diff --git a/.gitignore b/.gitignore index 16cfc92..43cab76 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,3 @@ /target -/galmon-osnma/target -/Cargo.lock *~ -/osnma-longan-nano/target -/osnma-longan-nano-client/target +/osnma-longan-nano-firmware.bin diff --git a/osnma-test-vectors-to-galmon/Cargo.lock b/Cargo.lock similarity index 62% rename from osnma-test-vectors-to-galmon/Cargo.lock rename to Cargo.lock index 8da5733..57f1170 100644 --- a/osnma-test-vectors-to-galmon/Cargo.lock +++ b/Cargo.lock @@ -67,7 +67,7 @@ version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" dependencies = [ - "windows-sys", + "windows-sys 0.61.2", ] [[package]] @@ -78,7 +78,7 @@ checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d" dependencies = [ "anstyle", "once_cell_polyfill", - "windows-sys", + "windows-sys 0.61.2", ] [[package]] @@ -93,12 +93,39 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" +[[package]] +name = "bare-metal" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5deb64efa5bd81e31fcd1938615a6d98c82eafcbcd787162b6f63b91d6bac5b3" +dependencies = [ + "rustc_version 0.2.3", +] + [[package]] name = "base16ct" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" +[[package]] +name = "base64ct" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e050f626429857a27ddccb31e0aca21356bfa709c04041aefddac081a8f068a" + +[[package]] +name = "bit_field" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e4b40c7323adcfc0a41c4b88143ed58346ff65a288fc144329c5c45e05d70c6" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + [[package]] name = "bitflags" version = "2.10.0" @@ -138,6 +165,15 @@ version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b35204fbdc0b3f4446b89fc1ac2cf84a8a68971995d0bf2e925ec7cd960f9cb3" +[[package]] +name = "cast" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c24dab4283a142afa2fdca129b80ad2c6284e073930f964c3a1293c225ee39a" +dependencies = [ + "rustc_version 0.4.1", +] + [[package]] name = "cc" version = "1.2.49" @@ -240,6 +276,16 @@ version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" +[[package]] +name = "core-foundation" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b55271e5c8c478ad3f38ad24ef34923091e0548492a266d19b3c0b4d82574c63" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "core-foundation-sys" version = "0.8.7" @@ -255,6 +301,12 @@ dependencies = [ "libc", ] +[[package]] +name = "critical-section" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "790eea4361631c5e7d22598ecd5723ff611904e3344ce8720784c93e3d83d40b" + [[package]] name = "crypto-bigint" version = "0.5.5" @@ -293,6 +345,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e7c1832837b905bbfb5101e07cc24c8deddf52f93225eee6ead5f4d63d53ddcb" dependencies = [ "const-oid", + "pem-rfc7468", "zeroize", ] @@ -319,6 +372,7 @@ dependencies = [ "elliptic-curve", "rfc6979", "signature", + "spki", ] [[package]] @@ -339,12 +393,62 @@ dependencies = [ "ff", "generic-array 0.14.7", "group", + "pem-rfc7468", + "pkcs8", "rand_core", "sec1", "subtle", "zeroize", ] +[[package]] +name = "embedded-dma" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46c8c02e4347a0267ca60813c952017f4c5948c232474c6010a381a337f1bda4" +dependencies = [ + "stable_deref_trait", +] + +[[package]] +name = "embedded-hal" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35949884794ad573cf46071e41c9b60efb0cb311e3ca01f7af807af1debc66ff" +dependencies = [ + "nb 0.1.3", + "void", +] + +[[package]] +name = "embedded-hal" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "361a90feb7004eca4019fb28352a9465666b24f840f5c3cddf0ff13920590b89" + +[[package]] +name = "env_filter" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bf3c259d255ca70051b30e2e95b5446cdb8949ac4cd22c0d7fd634d89f568e2" +dependencies = [ + "log", + "regex", +] + +[[package]] +name = "env_logger" +version = "0.11.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c863f0904021b108aa8b2f55046443e6b1ebde8fd4a15c399893aae4fa069f" +dependencies = [ + "anstream", + "anstyle", + "env_filter", + "jiff", + "log", +] + [[package]] name = "equivalent" version = "1.0.2" @@ -358,7 +462,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys", + "windows-sys 0.61.2", ] [[package]] @@ -397,27 +501,62 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "galileo-osnma" -version = "0.10.1" +version = "0.11.0" dependencies = [ "aes", + "anyhow", "bitvec", "bytes", + "chrono", + "clap", "cmac", "crypto-common", "ecdsa", + "env_logger", "generic-array 1.3.5", + "hex", + "hex-literal", "hmac", "log", "p256", "p521", "prost", "prost-build", + "serialport", "sha2", "sha3", "signature", + "spki", "typenum", ] +[[package]] +name = "gd32vf103-pac" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ffd430737a49edbd1c0241b58cabe79a7ac7ebe208f67dc838c1c981eb60e83" +dependencies = [ + "bare-metal", + "riscv 0.6.0", + "vcell", +] + +[[package]] +name = "gd32vf103xx-hal" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bdffb2f55a16c7916b5df9c02b1dab0dc1c8545237491821a7fd98c61378e4a" +dependencies = [ + "cast", + "embedded-dma", + "embedded-hal 0.2.7", + "gd32vf103-pac", + "nb 0.1.3", + "riscv 0.6.0", + "vcell", + "void", +] + [[package]] name = "generic-array" version = "0.14.7" @@ -439,6 +578,17 @@ dependencies = [ "typenum", ] +[[package]] +name = "getrandom" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + [[package]] name = "getrandom" version = "0.3.4" @@ -480,6 +630,12 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "hex-literal" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e712f64ec3850b98572bffac52e2c6f282b29fe6c5fa6d42334b30be438d95c1" + [[package]] name = "hmac" version = "0.12.1" @@ -532,6 +688,16 @@ dependencies = [ "generic-array 0.14.7", ] +[[package]] +name = "io-kit-sys" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "617ee6cf8e3f66f3b4ea67a4058564628cde41901316e19f559e14c7c72c5e7b" +dependencies = [ + "core-foundation-sys", + "mach2", +] + [[package]] name = "is_terminal_polyfill" version = "1.70.2" @@ -547,6 +713,30 @@ dependencies = [ "either", ] +[[package]] +name = "jiff" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49cce2b81f2098e7e3efc35bc2e0a6b7abec9d34128283d7a26fa8f32a6dbb35" +dependencies = [ + "jiff-static", + "log", + "portable-atomic", + "portable-atomic-util", + "serde_core", +] + +[[package]] +name = "jiff-static" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "980af8b43c3ad5d8d349ace167ec8170839f753a42d233ba19e08afe1850fa69" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "js-sys" version = "0.3.83" @@ -566,12 +756,38 @@ dependencies = [ "cpufeatures", ] +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + [[package]] name = "libc" version = "0.2.178" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37c93d8daa9d8a012fd8ab92f088405fb202ea0b6ab73ee2482ae66af4f42091" +[[package]] +name = "libudev" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78b324152da65df7bb95acfcaab55e3097ceaab02fb19b228a9eb74d55f135e0" +dependencies = [ + "libc", + "libudev-sys", +] + +[[package]] +name = "libudev-sys" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c8469b4a23b962c1396b9b451dda50ef5b283e8dd309d69033475fa9b334324" +dependencies = [ + "libc", + "pkg-config", +] + [[package]] name = "linux-raw-sys" version = "0.11.0" @@ -584,6 +800,27 @@ version = "0.4.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" +[[package]] +name = "longan-nano" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccee9f0becbcd65041ab8c52f048f9783f1c7872122670e3253c4affc2520dd5" +dependencies = [ + "embedded-hal 0.2.7", + "gd32vf103xx-hal", + "nb 1.1.0", + "riscv 0.6.0", +] + +[[package]] +name = "mach2" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d640282b302c0bb0a2a8e0233ead9035e3bed871f0b7e81fe4a1ec829765db44" +dependencies = [ + "libc", +] + [[package]] name = "memchr" version = "2.7.6" @@ -596,6 +833,32 @@ version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d87ecb2933e8aeadb3e3a02b828fed80a7528047e68b4f424523a0981a3a084" +[[package]] +name = "nb" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "801d31da0513b6ec5214e9bf433a77966320625a37860f910be265be6e18d06f" +dependencies = [ + "nb 1.1.0", +] + +[[package]] +name = "nb" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d5439c4ad607c3c23abf66de8c8bf57ba8adcd1f129e699851a6e43935d339d" + +[[package]] +name = "nix" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b" +dependencies = [ + "bitflags 1.3.2", + "cfg-if", + "libc", +] + [[package]] name = "num-traits" version = "0.2.19" @@ -618,15 +881,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" [[package]] -name = "osnma-test-vectors-to-galmon" +name = "osnma-longan-nano" version = "0.1.0" dependencies = [ - "anyhow", - "bitvec", - "chrono", - "clap", + "ecdsa", "galileo-osnma", "hex", + "longan-nano", + "nb 1.1.0", + "p256", + "panic-halt", + "riscv-rt", + "spki", ] [[package]] @@ -654,6 +920,27 @@ dependencies = [ "sha2", ] +[[package]] +name = "panic-halt" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a513e167849a384b7f9b746e517604398518590a9142f4846a32e3c2a4de7b11" + +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + +[[package]] +name = "pem-rfc7468" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" +dependencies = [ + "base64ct", +] + [[package]] name = "petgraph" version = "0.7.1" @@ -664,6 +951,37 @@ dependencies = [ "indexmap", ] +[[package]] +name = "pkcs8" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +dependencies = [ + "der", + "spki", +] + +[[package]] +name = "pkg-config" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" + +[[package]] +name = "portable-atomic" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483" + +[[package]] +name = "portable-atomic-util" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8a2f0d8d040d7848a709caf78912debcc3f33ee4b3cac47d73d1e1069e83507" +dependencies = [ + "portable-atomic", +] + [[package]] name = "prettyplease" version = "0.2.37" @@ -746,9 +1064,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.42" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a338cc41d27e6cc6dce6cefc13a0729dfbb81c262b1f519331575dd80ef3067f" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" dependencies = [ "proc-macro2", ] @@ -770,6 +1088,9 @@ name = "rand_core" version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom 0.2.16", +] [[package]] name = "regex" @@ -810,17 +1131,115 @@ dependencies = [ "subtle", ] +[[package]] +name = "riscv" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2f0b705d428e9d0f78e2bb73093887ee58a83c9688de3faedbb4c0631c4618e" +dependencies = [ + "bare-metal", + "bit_field", + "riscv-target", +] + +[[package]] +name = "riscv" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b05cfa3f7b30c84536a9025150d44d26b8e1cc20ddf436448d74cd9591eefb25" +dependencies = [ + "critical-section", + "embedded-hal 1.0.0", + "paste", + "riscv-macros", + "riscv-pac", +] + +[[package]] +name = "riscv-macros" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d323d13972c1b104aa036bc692cd08b822c8bbf23d79a27c526095856499799" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "riscv-pac" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8188909339ccc0c68cfb5a04648313f09621e8b87dc03095454f1a11f6c5d436" + +[[package]] +name = "riscv-rt" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d07b9f3a0eff773fc4df11f44ada4fa302e529bff4b7fe7e6a4b98a65ce9174" +dependencies = [ + "riscv 0.15.0", + "riscv-pac", + "riscv-rt-macros", + "riscv-target-parser", +] + +[[package]] +name = "riscv-rt-macros" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15c3138fdd8d128b2d81829842a3e0ce771b3712f7b6318ed1476b0695e7d330" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "riscv-target" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88aa938cda42a0cf62a20cfe8d139ff1af20c2e681212b5b34adb5a58333f222" +dependencies = [ + "lazy_static", + "regex", +] + +[[package]] +name = "riscv-target-parser" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1376b15f3ff160e9b1e8ea564ce427f2f6fcf77528cc0a8bf405cb476f9cea7" + +[[package]] +name = "rustc_version" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +dependencies = [ + "semver 0.9.0", +] + +[[package]] +name = "rustc_version" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" +dependencies = [ + "semver 1.0.27", +] + [[package]] name = "rustix" version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cd15f8a2c5551a84d56efdc1cd049089e409ac19a3072d5037a17fd70719ff3e" dependencies = [ - "bitflags", + "bitflags 2.10.0", "errno", "libc", "linux-raw-sys", - "windows-sys", + "windows-sys 0.61.2", ] [[package]] @@ -829,6 +1248,12 @@ version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + [[package]] name = "sec1" version = "0.7.3" @@ -838,10 +1263,72 @@ dependencies = [ "base16ct", "der", "generic-array 0.14.7", + "pkcs8", "subtle", "zeroize", ] +[[package]] +name = "semver" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +dependencies = [ + "semver-parser", +] + +[[package]] +name = "semver" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2" + +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" + +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serialport" +version = "4.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21f60a586160667241d7702c420fc223939fb3c0bb8d3fac84f78768e8970dee" +dependencies = [ + "bitflags 2.10.0", + "cfg-if", + "core-foundation", + "core-foundation-sys", + "io-kit-sys", + "libudev", + "mach2", + "nix", + "quote", + "scopeguard", + "unescaper", + "windows-sys 0.52.0", +] + [[package]] name = "sha2" version = "0.10.9" @@ -879,6 +1366,22 @@ dependencies = [ "rand_core", ] +[[package]] +name = "spki" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" +dependencies = [ + "base64ct", + "der", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + [[package]] name = "strsim" version = "0.11.1" @@ -915,10 +1418,30 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2d31c77bdf42a745371d260a26ca7163f1e0924b64afa0b688e61b5a9fa02f16" dependencies = [ "fastrand", - "getrandom", + "getrandom 0.3.4", "once_cell", "rustix", - "windows-sys", + "windows-sys 0.61.2", +] + +[[package]] +name = "thiserror" +version = "2.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f63587ca0f12b72a0600bcba1d40081f830876000bb46dd2337a3051618f4fc8" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913" +dependencies = [ + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -927,6 +1450,15 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "562d481066bde0658276a35467c4af00bdc6ee726305698a55b86e61d7ad82bb" +[[package]] +name = "unescaper" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4064ed685c487dbc25bd3f0e9548f2e34bab9d18cefc700f9ec2dba74ba1138e" +dependencies = [ + "thiserror", +] + [[package]] name = "unicode-ident" version = "1.0.22" @@ -939,12 +1471,30 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" +[[package]] +name = "vcell" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77439c1b53d2303b20d9459b1ade71a83c716e3f9c34f3228c00e6f185d6c002" + [[package]] name = "version_check" version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" +[[package]] +name = "void" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + [[package]] name = "wasip2" version = "1.0.1+wasi-0.2.4" @@ -1058,6 +1608,15 @@ dependencies = [ "windows-link", ] +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + [[package]] name = "windows-sys" version = "0.61.2" @@ -1067,6 +1626,70 @@ dependencies = [ "windows-link", ] +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + [[package]] name = "wit-bindgen" version = "0.46.0" diff --git a/Cargo.toml b/Cargo.toml index 2a6c162..9724848 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,50 +1,46 @@ -[package] -name = "galileo-osnma" -version = "0.10.1" -edition = "2024" -authors = ["Daniel Estevez "] -description = "Galileo OSNMA (Open Service Navigation Message Authentication)" -license = "MIT OR Apache-2.0" -homepage = "https://github.com/daniestevez/galileo-osnma/" -repository = "https://github.com/daniestevez/galileo-osnma/" -keywords = ["galileo", "gnss", "osnma", "authentication", "cryptography"] -categories = ["aerospace::space-protocols", "authentication", "embedded", "no-std"] -exclude = ["/.github"] -rust-version = "1.85.0" +[workspace] +resolver = "3" +members = ["galileo-osnma", "osnma-longan-nano"] +default-members = ["galileo-osnma"] -[package.metadata] - -[features] -default = ["p521"] -# Galmon protobuf transport format support -galmon = ["bytes", "prost", "prost-build", "std"] -std = [] - -[dependencies] +[workspace.dependencies] aes = "0.8" +anyhow = "1" bitvec = { version = "1", default-features = false } -bytes = { version = "1.1", optional = true } +bytes = "1.1" +clap = { version = "4.4", features = ["derive"] } +chrono = "0.4" cmac = "0.7" crypto-common = "0.1" ecdsa = "0.16" +env_logger = "0.11" generic-array = "1.0" +hex = { version = "0.4", default-features = false } +hex-literal = "1" hmac = "0.12" log = "0.4" +longan-nano = "0.3" +nb = "1" # These two would bring std with default-features p256 = { version = "0.13", features = ["ecdsa"], default-features = false } -p521 = { version = "0.13", features = ["ecdsa"], default-features = false, optional = true } -prost = { version = "0.14", optional = true } +p521 = { version = "0.13", features = ["ecdsa"], default-features = false } +panic-halt = "1" +prost = "0.14" +prost-build = "0.14" +riscv-rt = "0.16" # These two bring std with default-features sha2 = { version = "0.10", default-features = false } sha3 = { version = "0.10", default-features = false } +serialport = "4" signature = "2.2" +spki = { version = "0.7", features = ["pem"] } typenum = "1.15" -[build-dependencies] -prost-build = { version = "0.14", optional = true } - -[dev-dependencies] -hex-literal = "1" +[profile.release] +codegen-units = 1 +lto = true +panic = "abort" -[package.metadata.docs.rs] -features = ["galmon"] +[profile.embedded] +inherits = "release" +opt-level = "z" # Optimize for size. diff --git a/README.md b/README.md index 0a85211..d1d6135 100644 --- a/README.md +++ b/README.md @@ -46,21 +46,25 @@ The following reference documents from the Galileo system are relevant: ## Quick start using Galmon -galileo-osnma comes with a binary application that can read Galileo INAV pages -using the [Galmon](https://github.com/berthubert/galmon) [transport -protocol](https://github.com/berthubert/galmon#internals). This is located in -the `galmon-osnma` folder. +galileo-osnma comes with a binary application called `galmon-osnma` that can +read Galileo INAV pages using the [Galmon](https://github.com/berthubert/galmon) +[transport protocol](https://github.com/berthubert/galmon#internals). A quick way to see this working is to use the Galmon Galileo navigation data -feed, which streams from 86.82.68.237, TCP port 10000. From the `galmon-osnma` -folder, we can run +feed, which streams from 86.82.68.237, TCP port 10000. From the root of this +repository, run ``` -nc 86.82.68.237 10000 | \ - RUST_LOG=info cargo run --release -- --pubkey osnma-pubkey.pem --pkid N +just galmon-osnma-live-feed --pubkey osnma-pubkey.pem --pkid N ``` -to see galileo-osnma processing the OSNMA and navigation data streamed by Galmon. -The [env_logger](https://docs.rs/env_logger/latest/env_logger/) documentation describes -how the logging information produced by this application can be configured. +to see galileo-osnma processing the OSNMA and navigation data streamed by Galmon +(this and other common tasks need the [just](https://github.com/casey/just) +command runner). + +This application uses +[env_logger](https://docs.rs/env_logger/latest/env_logger/) to control +logging. The `env_logger` documentation describes how the logging information +can be configured through the `RUST_LOG` environment variable. By default, the +info log level is enabled. The file `osnma-pubkey.pem` should contain the Galileo OSNMA public key, and the number `N` should be its associated Public Key ID (PKID). See the section below @@ -74,8 +78,7 @@ some small problems with data or timestamps inconsistencies. Alternatively, you can use one of the tools of Galmon with your own GNSS receiver. For instance, an uBlox receiver can be used as ``` -ubxtool --wait --port /dev/ttyACM0 --station 1 --stdout --galileo \ - | RUST_LOG=info cargo run --release -- --pubkey osnma-pubkey.pem --pkid N +just galmon-osnma-ubxtool /dev/ttyACM0 --pubkey osnma-pubkey.pem --pkid N ``` ## Obtaining the Galileo OSNMA public key and Merkle tree root @@ -98,8 +101,8 @@ is broadcast in the signal-in-space. The public key and the Merkle tree root can be downloaded from the [European GNSS Service Centre](https://www.gsc-europa.eu/), under [GSC Products > -OSNMA_MERKLETREE](https://www.gsc-europa.eu/gsc-products/OSNMA/MT) and [GSC -Products > OSNMA_PUBLICKEY](https://www.gsc-europa.eu/gsc-products/OSNMA/PKI) +OSNMA_PUBLICKEY](https://www.gsc-europa.eu/gsc-products/OSNMA/PKI) and [GSC +Products > OSNMA_MERKLETREE](https://www.gsc-europa.eu/gsc-products/OSNMA/MT) respectively. It is necessary to register an account to obtain these files. The public key is downloaded as an x509 certificate. The Public Key ID is included @@ -194,26 +197,19 @@ When the script runs, it prints a description of what should happen in each test, but there are no automatic pass/fail criteria. The log outputs for each test need to be checked manually. The script is run as ``` -./utils/run_test_vectors.sh Test_vectors -``` -where `Test_vectors` is the path of the folder containing the test vectors. -It is recommended to run it as follows to capture all the output into `less` -using colours: -``` -RUST_LOG_STYLE=always ./utils/run_test_vectors.sh Test_vectors 2>&1 | less -R +just test-vectors ``` -By default, the log level is set to display only errors and warnings, and info -messages corresponding to successful authentication of new navigation data. -The log level can be overridden with the `RUST_LOG` environment variable as usual. +This downloads the test vectors and runs the test script. By default, the log +level is set to display only errors and warnings, and info messages +corresponding to successful authentication of new navigation data. The log +level can be overridden with the `RUST_LOG` environment variable as usual. -There is a [CI workflow](https://github.com/daniestevez/galileo-osnma/actions/workflows/test-vectors.yml) -that downloads the test vectors from the GSC website and runs the -`run_test_vectors.sh` script. The output of this workflow can serve as a demo of the -capabilities of galileo-osnma. +The test vectors test is also run as a CI job. The output of this job serves as +a demo of the capabilities of galileo-osnma. ## Minimum Supported Rust Version -Rust **1.83** or higher. +Rust **1.88** or higher. Minimum supported Rust version can be changed in the future, but it will be done with a minor version bump. diff --git a/galileo-osnma/Cargo.toml b/galileo-osnma/Cargo.toml new file mode 100644 index 0000000..afcf234 --- /dev/null +++ b/galileo-osnma/Cargo.toml @@ -0,0 +1,87 @@ +[package] +name = "galileo-osnma" +version = "0.11.0" +edition = "2024" +authors = ["Daniel Estevez "] +description = "Galileo OSNMA (Open Service Navigation Message Authentication)" +license = "MIT OR Apache-2.0" +homepage = "https://github.com/daniestevez/galileo-osnma/" +repository = "https://github.com/daniestevez/galileo-osnma/" +keywords = ["galileo", "gnss", "osnma", "authentication", "cryptography"] +categories = ["aerospace::space-protocols", "authentication", "embedded", "no-std"] +exclude = ["/.github"] +rust-version = "1.88.0" + +[[bin]] +name = "galmon-filter-inav" +required-features = ["galmon"] + +[[bin]] +name = "galmon-osnma" +required-features = ["galmon-osnma"] + +[[bin]] +name = "osnma-longan-nano-client" +required-features = ["osnma-longan-nano"] + +[[bin]] +name = "osnma-test-vectors-to-galmon" +required-features = ["galmon-osnma"] + +[features] +default = ["galmon-osnma", "osnma-longan-nano"] +# Galmon protobuf transport format support +galmon = ["dep:bytes", "dep:prost", "dep:prost-build", "std"] +# galmon-osnma and osnma-test-vectors-to-galmon CLI tools +galmon-osnma = [ + "galmon", + "p521", + "dep:anyhow", + "dep:clap", + "dep:chrono", + "dep:env_logger", + "dep:hex", + "dep:spki", + "bitvec/std", + "p256/pem", + "p256/std", +] +osnma-longan-nano = [ + "galmon", + "dep:anyhow", + "dep:clap", + "dep:hex", + "dep:serialport", +] +std = [] + +[dependencies] +aes = { workspace = true } +anyhow = { workspace = true, optional = true } +bitvec = { workspace = true } +bytes = { workspace = true, optional = true } +clap = { workspace = true, optional = true } +chrono = { workspace = true, optional = true } +cmac = { workspace = true } +crypto-common = { workspace = true } +ecdsa = { workspace = true } +env_logger = { workspace = true, optional = true } +generic-array = { workspace = true } +hex = { workspace = true, default-features = true, optional = true } +hmac = { workspace = true } +log = { workspace = true } +p256 = { workspace = true } +p521 = { workspace = true, optional = true } +prost = { workspace = true, optional = true } +sha2 = { workspace = true } +sha3 = { workspace = true } +serialport = { workspace = true, optional = true } +signature = { workspace = true } +spki = { workspace = true, optional = true } +typenum = { workspace = true } + +[build-dependencies] +prost-build = { workspace = true, optional = true } + +[dev-dependencies] +hex-literal = { workspace = true } diff --git a/build.rs b/galileo-osnma/build.rs similarity index 100% rename from build.rs rename to galileo-osnma/build.rs diff --git a/src/bin/sizeof.rs b/galileo-osnma/src/bin/galileo-osnma-sizeof.rs similarity index 100% rename from src/bin/sizeof.rs rename to galileo-osnma/src/bin/galileo-osnma-sizeof.rs diff --git a/galmon-osnma/src/bin/filter_inav.rs b/galileo-osnma/src/bin/galmon-filter-inav.rs similarity index 100% rename from galmon-osnma/src/bin/filter_inav.rs rename to galileo-osnma/src/bin/galmon-filter-inav.rs diff --git a/galmon-osnma/src/main.rs b/galileo-osnma/src/bin/galmon-osnma.rs similarity index 98% rename from galmon-osnma/src/main.rs rename to galileo-osnma/src/bin/galmon-osnma.rs index ca430dd..d777364 100644 --- a/galmon-osnma/src/main.rs +++ b/galileo-osnma/src/bin/galmon-osnma.rs @@ -45,7 +45,7 @@ fn load_pubkey_p521(hex: &str, pkid: u8) -> Result> { } fn main() -> Result<()> { - env_logger::init(); + env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init(); let args = Args::parse(); if args.merkle_root.is_none() && args.pubkey.is_none() && args.pubkey_p521.is_none() { diff --git a/osnma-longan-nano-client/src/main.rs b/galileo-osnma/src/bin/osnma-longan-nano-client.rs similarity index 84% rename from osnma-longan-nano-client/src/main.rs rename to galileo-osnma/src/bin/osnma-longan-nano-client.rs index bd8041c..95b2633 100644 --- a/osnma-longan-nano-client/src/main.rs +++ b/galileo-osnma/src/bin/osnma-longan-nano-client.rs @@ -1,18 +1,27 @@ +use anyhow::{Context, Result}; +use clap::Parser; use galileo_osnma::galmon::{navmon::nav_mon_message::GalileoInav, transport::ReadTransport}; use galileo_osnma::{ Gst, InavBand, Wn, types::{InavWord, OsnmaDataMessage}, }; -use std::error::Error; use std::io::{BufRead, BufReader}; +/// Read Galmon protobuf from stdin and send it to longan-nano by UART +#[derive(Parser, Debug)] +#[command(author, version, about, long_about = None)] +struct Args { + /// Serial port connecting to longan-nano. + serial: String, +} + struct Serial { writer: Box, reader: BufReader>, } impl Serial { - fn new(port: &str) -> Result> { + fn new(port: &str) -> Result { let port = serialport::new(port, 115_200) .timeout(std::time::Duration::from_secs(3600)) .open()?; @@ -21,7 +30,7 @@ impl Serial { Ok(Serial { writer, reader }) } - fn read_until_ready(&mut self) -> Result<(), Box> { + fn read_until_ready(&mut self) -> Result<()> { loop { let mut line = String::new(); self.reader.read_line(&mut line)?; @@ -32,7 +41,7 @@ impl Serial { } } - fn send_common(&mut self, svn: usize, gst: Gst, band: InavBand) -> Result<(), Box> { + fn send_common(&mut self, svn: usize, gst: Gst, band: InavBand) -> Result<()> { let band = match band { InavBand::E1B => "1", InavBand::E5B => "5", @@ -48,13 +57,7 @@ impl Serial { Ok(()) } - fn send_inav( - &mut self, - inav: &InavWord, - svn: usize, - gst: Gst, - band: InavBand, - ) -> Result<(), Box> { + fn send_inav(&mut self, inav: &InavWord, svn: usize, gst: Gst, band: InavBand) -> Result<()> { self.send_common(svn, gst, band)?; write!(&mut self.writer, "{}\r\n", hex::encode(inav))?; Ok(()) @@ -66,17 +69,17 @@ impl Serial { svn: usize, gst: Gst, band: InavBand, - ) -> Result<(), Box> { + ) -> Result<()> { self.send_common(svn, gst, band)?; write!(&mut self.writer, "{}\r\n", hex::encode(osnma))?; Ok(()) } } -fn main() -> Result<(), Box> { - let args: Vec<_> = std::env::args().collect(); - let port = &args[1]; - let mut serial = Serial::new(port)?; +fn main() -> Result<()> { + let args = Args::parse(); + let mut serial = Serial::new(&args.serial) + .with_context(|| format!("Failed to open serial port '{}'", args.serial))?; let mut read_galmon = ReadTransport::new(std::io::stdin()); let mut current_subframe = None; let mut last_tow_mod_30 = 0; diff --git a/osnma-test-vectors-to-galmon/src/main.rs b/galileo-osnma/src/bin/osnma-test-vectors-to-galmon.rs similarity index 100% rename from osnma-test-vectors-to-galmon/src/main.rs rename to galileo-osnma/src/bin/osnma-test-vectors-to-galmon.rs diff --git a/src/bitfields.rs b/galileo-osnma/src/bitfields.rs similarity index 100% rename from src/bitfields.rs rename to galileo-osnma/src/bitfields.rs diff --git a/src/dsm.rs b/galileo-osnma/src/dsm.rs similarity index 100% rename from src/dsm.rs rename to galileo-osnma/src/dsm.rs diff --git a/src/galmon/mod.rs b/galileo-osnma/src/galmon/mod.rs similarity index 94% rename from src/galmon/mod.rs rename to galileo-osnma/src/galmon/mod.rs index 44514aa..035a3cc 100644 --- a/src/galmon/mod.rs +++ b/galileo-osnma/src/galmon/mod.rs @@ -54,33 +54,33 @@ pub mod transport { match e.kind() { ErrorKind::UnexpectedEof => return Ok(None), _ => { - log::error!("could not read packet header: {}", e); + log::error!("could not read packet header: {e}"); return Err(e); } } } if &self.buffer[..4] != b"bert" { let err = "incorrect galmon magic value"; - log::error!("{}", err); + log::error!("{err}"); return Err(std::io::Error::new(std::io::ErrorKind::InvalidData, err)); } let size = usize::from(u16::from_be_bytes(self.buffer[4..6].try_into().unwrap())); if size > self.buffer.len() { - log::debug!("resize buffer to {}", size); + log::debug!("resize buffer to {size}"); self.buffer.resize(size, 0); } // Read protobuf frame if let Err(e) = self.read.read_exact(&mut self.buffer[..size]) { - log::error!("could not read protobuf frame: {}", e); + log::error!("could not read protobuf frame: {e}"); return Err(e); } let frame = match NavMonMessage::decode(&self.buffer[..size]) { Ok(f) => { - log::trace!("decoded protobuf frame: {:?}", f); + log::trace!("decoded protobuf frame: {f:?}"); f } Err(e) => { - log::error!("could not decode protobuf frame: {}", e); + log::error!("could not decode protobuf frame: {e}"); return Err(std::io::Error::new(std::io::ErrorKind::InvalidData, e)); } }; @@ -116,7 +116,7 @@ pub mod transport { let total_size = size + 6; let cap = self.buffer.capacity(); if total_size > cap { - log::debug!("resize buffer to {}", total_size); + log::debug!("resize buffer to {total_size}"); self.buffer.reserve(total_size - cap); } self.buffer.clear(); @@ -124,16 +124,16 @@ pub mod transport { let size_u16 = u16::try_from(size).unwrap(); self.buffer.extend_from_slice(&size_u16.to_be_bytes()); match packet.encode(&mut self.buffer) { - Ok(()) => log::trace!("encoded protobuf frame: {:?}", packet), + Ok(()) => log::trace!("encoded protobuf frame: {packet:?}"), Err(e) => { - log::error!("could not encoded protobuf frame: {}", e); + log::error!("could not encoded protobuf frame: {e}"); return Err(std::io::Error::new(std::io::ErrorKind::InvalidData, e)); } }; match self.write.write_all(&self.buffer) { Ok(()) => Ok(self.buffer.len()), Err(e) => { - log::error!("could not write: {}", e); + log::error!("could not write: {e}"); Err(e) } } diff --git a/src/galmon/navmon.proto b/galileo-osnma/src/galmon/navmon.proto similarity index 100% rename from src/galmon/navmon.proto rename to galileo-osnma/src/galmon/navmon.proto diff --git a/src/galmon/transport/test/data.rs b/galileo-osnma/src/galmon/transport/test/data.rs similarity index 100% rename from src/galmon/transport/test/data.rs rename to galileo-osnma/src/galmon/transport/test/data.rs diff --git a/src/gst.rs b/galileo-osnma/src/gst.rs similarity index 98% rename from src/gst.rs rename to galileo-osnma/src/gst.rs index ecb4ed2..5a85319 100644 --- a/src/gst.rs +++ b/galileo-osnma/src/gst.rs @@ -140,7 +140,7 @@ impl Gst { /// assert_eq!(gst.is_subframe(), false); /// assert_eq!(subframe.is_subframe(), true); pub fn is_subframe(&self) -> bool { - self.tow % SECS_PER_SUBFRAME == 0 + self.tow.is_multiple_of(SECS_PER_SUBFRAME) } /// Returns the difference in subframes between `other` and `self`. diff --git a/src/lib.rs b/galileo-osnma/src/lib.rs similarity index 100% rename from src/lib.rs rename to galileo-osnma/src/lib.rs diff --git a/src/mack.rs b/galileo-osnma/src/mack.rs similarity index 92% rename from src/mack.rs rename to galileo-osnma/src/mack.rs index 65b04cc..64eead6 100644 --- a/src/mack.rs +++ b/galileo-osnma/src/mack.rs @@ -81,15 +81,15 @@ impl MackStorage { // If write pointer points to a valid GST which is distinct // from the current, we advance the write pointer and erase // everything at the new write pointer location. - if let Some(g) = self.gsts[self.write_pointer] { - if g != gst { - log::trace!( - "got a new GST {gst:?} (current GST is {g:?}); \ + if let Some(g) = self.gsts[self.write_pointer] + && g != gst + { + log::trace!( + "got a new GST {gst:?} (current GST is {g:?}); \ advancing write pointer" - ); - self.write_pointer = (self.write_pointer + 1) % S::MackDepth::USIZE; - self.current_macks_as_mut().fill(None); - } + ); + self.write_pointer = (self.write_pointer + 1) % S::MackDepth::USIZE; + self.current_macks_as_mut().fill(None); } self.gsts[self.write_pointer] = Some(gst); } diff --git a/src/maclt.rs b/galileo-osnma/src/maclt.rs similarity index 100% rename from src/maclt.rs rename to galileo-osnma/src/maclt.rs diff --git a/src/merkle_tree.rs b/galileo-osnma/src/merkle_tree.rs similarity index 100% rename from src/merkle_tree.rs rename to galileo-osnma/src/merkle_tree.rs diff --git a/src/navmessage.rs b/galileo-osnma/src/navmessage.rs similarity index 86% rename from src/navmessage.rs rename to galileo-osnma/src/navmessage.rs index 73a3826..df8e353 100644 --- a/src/navmessage.rs +++ b/galileo-osnma/src/navmessage.rs @@ -135,49 +135,49 @@ impl CollectNavMessage { // current, we advance the write pointer and copy the old CED and status // and timing parameters to the new write pointer location. We increase // the stale counter of the copy. - if let Some(g) = self.gsts[self.write_pointer] { - if g != gst { - log::trace!( - "got a new GST {gst:?} (current GST is {g:?}); \ + if let Some(g) = self.gsts[self.write_pointer] + && g != gst + { + log::trace!( + "got a new GST {gst:?} (current GST is {g:?}); \ advancing write pointer" - ); - let new_pointer = (self.write_pointer + 1) % S::NavMessageDepth::USIZE; - self.ced_and_status.copy_within( - self.write_pointer * S::NUM_SATS..(self.write_pointer + 1) * S::NUM_SATS, - new_pointer * S::NUM_SATS, - ); - self.timing_parameters.copy_within( - self.write_pointer * S::NUM_SATS..(self.write_pointer + 1) * S::NUM_SATS, - new_pointer * S::NUM_SATS, - ); - self.write_pointer = new_pointer; - self.increase_age(); - if log::log_enabled!(log::Level::Debug) { - log::debug!("advanced write pointer to {gst:?}"); - log::debug!("CedAndStatus contents:"); - for elem in self.ced_and_status - [self.write_pointer * S::NUM_SATS..(self.write_pointer + 1) * S::NUM_SATS] - .iter() - { - log::debug!( - "SVN {:?}: age {:?} authbits {}", - elem.svn, - elem.age, - elem.authbits - ); - } - log::debug!("TimingParameters contents:"); - for elem in self.timing_parameters - [self.write_pointer * S::NUM_SATS..(self.write_pointer + 1) * S::NUM_SATS] - .iter() - { - log::debug!( - "SVN {:?}: age {:?} authbits {}", - elem.svn, - elem.age, - elem.authbits - ); - } + ); + let new_pointer = (self.write_pointer + 1) % S::NavMessageDepth::USIZE; + self.ced_and_status.copy_within( + self.write_pointer * S::NUM_SATS..(self.write_pointer + 1) * S::NUM_SATS, + new_pointer * S::NUM_SATS, + ); + self.timing_parameters.copy_within( + self.write_pointer * S::NUM_SATS..(self.write_pointer + 1) * S::NUM_SATS, + new_pointer * S::NUM_SATS, + ); + self.write_pointer = new_pointer; + self.increase_age(); + if log::log_enabled!(log::Level::Debug) { + log::debug!("advanced write pointer to {gst:?}"); + log::debug!("CedAndStatus contents:"); + for elem in self.ced_and_status + [self.write_pointer * S::NUM_SATS..(self.write_pointer + 1) * S::NUM_SATS] + .iter() + { + log::debug!( + "SVN {:?}: age {:?} authbits {}", + elem.svn, + elem.age, + elem.authbits + ); + } + log::debug!("TimingParameters contents:"); + for elem in self.timing_parameters + [self.write_pointer * S::NUM_SATS..(self.write_pointer + 1) * S::NUM_SATS] + .iter() + { + log::debug!( + "SVN {:?}: age {:?} authbits {}", + elem.svn, + elem.age, + elem.authbits + ); } } } @@ -338,22 +338,22 @@ impl CollectNavMessage { nma_status, CED_AND_STATUS_BITS, ); - } else if let Some(&navdata) = self.find_ced_and_status(prna, gst_navmessage) { - if navdata.max_age().saturating_add(1) <= mack.cop() { - // Try to validate tag0 - Self::validate_tag( - key, - mack.tag0(), - Adkd::InavCed, - gst_mack, - u8::from(prna), - prna, - 0, - nma_status, - &navdata, - self.ced_and_status_iter_authbits_mut(), - ); - } + } else if let Some(&navdata) = self.find_ced_and_status(prna, gst_navmessage) + && navdata.max_age().saturating_add(1) <= mack.cop() + { + // Try to validate tag0 + Self::validate_tag( + key, + mack.tag0(), + Adkd::InavCed, + gst_mack, + u8::from(prna), + prna, + 0, + nma_status, + &navdata, + self.ced_and_status_iter_authbits_mut(), + ); } // Try to validate InavCed and InavTiming tags @@ -392,21 +392,20 @@ impl CollectNavMessage { ); } else if let Some(&navdata) = self.find_ced_and_status(prnd_svn, gst_navmessage) + && navdata.max_age().saturating_add(1) <= tag.cop() { - if navdata.max_age().saturating_add(1) <= tag.cop() { - Self::validate_tag( - key, - tag.tag(), - tag.adkd(), - gst_mack, - prnd, - prna, - j, - nma_status, - &navdata, - self.ced_and_status_iter_authbits_mut(), - ); - } + Self::validate_tag( + key, + tag.tag(), + tag.adkd(), + gst_mack, + prnd, + prna, + j, + nma_status, + &navdata, + self.ced_and_status_iter_authbits_mut(), + ); } } Err(_) => { @@ -429,21 +428,20 @@ impl CollectNavMessage { ); } else if let Some(&navdata) = self.find_timing_parameters(prnd_svn, gst_navmessage) + && navdata.max_age().saturating_add(1) <= tag.cop() { - if navdata.max_age().saturating_add(1) <= tag.cop() { - Self::validate_tag( - key, - tag.tag(), - tag.adkd(), - gst_mack, - prnd, - prna, - j, - nma_status, - &navdata, - self.timing_parameters_iter_authbits_mut(), - ); - } + Self::validate_tag( + key, + tag.tag(), + tag.adkd(), + gst_mack, + prnd, + prna, + j, + nma_status, + &navdata, + self.timing_parameters_iter_authbits_mut(), + ); } } Err(_) => { @@ -517,21 +515,21 @@ impl CollectNavMessage { nma_status, CED_AND_STATUS_BITS, ); - } else if let Some(&navdata) = self.find_ced_and_status(prnd_svn, gst_navmessage) { - if navdata.max_age().saturating_add(1) <= tag.cop() { - Self::validate_tag( - key, - tag.tag(), - tag.adkd(), - gst_mack, - prnd, - prna, - j, - nma_status, - &navdata, - self.ced_and_status_iter_authbits_mut(), - ); - } + } else if let Some(&navdata) = self.find_ced_and_status(prnd_svn, gst_navmessage) + && navdata.max_age().saturating_add(1) <= tag.cop() + { + Self::validate_tag( + key, + tag.tag(), + tag.adkd(), + gst_mack, + prnd, + prna, + j, + nma_status, + &navdata, + self.ced_and_status_iter_authbits_mut(), + ); } } } diff --git a/src/osnma.rs b/galileo-osnma/src/osnma.rs similarity index 94% rename from src/osnma.rs rename to galileo-osnma/src/osnma.rs index 9270052..c9e1658 100644 --- a/src/osnma.rs +++ b/galileo-osnma/src/osnma.rs @@ -453,41 +453,41 @@ impl OsnmaData { } }); for svn in Svn::iter() { - if !self.only_slowmac { - if let Some((mack, nma_status)) = self.mack.get(svn, gst_mack) { - let mack = Mack::new( - mack, - current_key.chain().key_size_bits(), - current_key.chain().tag_size_bits(), - ); - if let Some(mack) = Self::validate_mack(mack, current_key, svn, gst_mack) { - self.navmessage - .process_mack(mack, current_key, svn, gst_mack, nma_status); - }; - } + if !self.only_slowmac + && let Some((mack, nma_status)) = self.mack.get(svn, gst_mack) + { + let mack = Mack::new( + mack, + current_key.chain().key_size_bits(), + current_key.chain().tag_size_bits(), + ); + if let Some(mack) = Self::validate_mack(mack, current_key, svn, gst_mack) { + self.navmessage + .process_mack(mack, current_key, svn, gst_mack, nma_status); + }; } // Try to validate Slow MAC // This needs fetching a tag which is 300 seconds older than for // the other ADKDs - if let Some(slowmac_key) = &slowmac_key { - if let Some((mack, nma_status)) = self.mack.get(svn, gst_slowmac) { - let mack = Mack::new( + if let Some(slowmac_key) = &slowmac_key + && let Some((mack, nma_status)) = self.mack.get(svn, gst_slowmac) + { + let mack = Mack::new( + mack, + current_key.chain().key_size_bits(), + current_key.chain().tag_size_bits(), + ); + // Note that slowmac_key is used for validation of the MACK, while + // current_key is used for validation of the Slow MAC tags it contains. + if let Some(mack) = Self::validate_mack(mack, slowmac_key, svn, gst_slowmac) { + self.navmessage.process_mack_slowmac( mack, - current_key.chain().key_size_bits(), - current_key.chain().tag_size_bits(), + current_key, + svn, + gst_slowmac, + nma_status, ); - // Note that slowmac_key is used for validation of the MACK, while - // current_key is used for validation of the Slow MAC tags it contains. - if let Some(mack) = Self::validate_mack(mack, slowmac_key, svn, gst_slowmac) { - self.navmessage.process_mack_slowmac( - mack, - current_key, - svn, - gst_slowmac, - nma_status, - ); - } } } } @@ -724,11 +724,11 @@ impl KeyStore { fn revoke(&mut self, cid: u8) { for k in &mut self.keys { - if let Some(key) = k { - if key.chain().chain_id() == cid { - log::warn!("revoking TESLA key {key:?}"); - *k = None; - } + if let Some(key) = k + && key.chain().chain_id() == cid + { + log::warn!("revoking TESLA key {key:?}"); + *k = None; } } } diff --git a/src/storage.rs b/galileo-osnma/src/storage.rs similarity index 100% rename from src/storage.rs rename to galileo-osnma/src/storage.rs diff --git a/src/subframe.rs b/galileo-osnma/src/subframe.rs similarity index 100% rename from src/subframe.rs rename to galileo-osnma/src/subframe.rs diff --git a/src/svn.rs b/galileo-osnma/src/svn.rs similarity index 100% rename from src/svn.rs rename to galileo-osnma/src/svn.rs diff --git a/src/tesla.rs b/galileo-osnma/src/tesla.rs similarity index 100% rename from src/tesla.rs rename to galileo-osnma/src/tesla.rs diff --git a/src/types.rs b/galileo-osnma/src/types.rs similarity index 100% rename from src/types.rs rename to galileo-osnma/src/types.rs diff --git a/src/validation.rs b/galileo-osnma/src/validation.rs similarity index 100% rename from src/validation.rs rename to galileo-osnma/src/validation.rs diff --git a/galmon-osnma/Cargo.lock b/galmon-osnma/Cargo.lock deleted file mode 100644 index ab18cab..0000000 --- a/galmon-osnma/Cargo.lock +++ /dev/null @@ -1,1033 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 4 - -[[package]] -name = "aes" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" -dependencies = [ - "cfg-if", - "cipher", - "cpufeatures", -] - -[[package]] -name = "aho-corasick" -version = "1.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" -dependencies = [ - "memchr", -] - -[[package]] -name = "anstream" -version = "0.6.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43d5b281e737544384e969a5ccad3f1cdd24b48086a0fc1b2a5262a26b8f4f4a" -dependencies = [ - "anstyle", - "anstyle-parse", - "anstyle-query", - "anstyle-wincon", - "colorchoice", - "is_terminal_polyfill", - "utf8parse", -] - -[[package]] -name = "anstyle" -version = "1.0.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78" - -[[package]] -name = "anstyle-parse" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2" -dependencies = [ - "utf8parse", -] - -[[package]] -name = "anstyle-query" -version = "1.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" -dependencies = [ - "windows-sys", -] - -[[package]] -name = "anstyle-wincon" -version = "3.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d" -dependencies = [ - "anstyle", - "once_cell_polyfill", - "windows-sys", -] - -[[package]] -name = "anyhow" -version = "1.0.100" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61" - -[[package]] -name = "base16ct" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" - -[[package]] -name = "base64ct" -version = "1.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e050f626429857a27ddccb31e0aca21356bfa709c04041aefddac081a8f068a" - -[[package]] -name = "bitflags" -version = "2.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3" - -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - -[[package]] -name = "block-buffer" -version = "0.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" -dependencies = [ - "generic-array 0.14.7", -] - -[[package]] -name = "bytes" -version = "1.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b35204fbdc0b3f4446b89fc1ac2cf84a8a68971995d0bf2e925ec7cd960f9cb3" - -[[package]] -name = "cfg-if" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" - -[[package]] -name = "cipher" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" -dependencies = [ - "crypto-common", - "inout", -] - -[[package]] -name = "clap" -version = "4.5.53" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9e340e012a1bf4935f5282ed1436d1489548e8f72308207ea5df0e23d2d03f8" -dependencies = [ - "clap_builder", - "clap_derive", -] - -[[package]] -name = "clap_builder" -version = "4.5.53" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d76b5d13eaa18c901fd2f7fca939fefe3a0727a953561fefdf3b2922b8569d00" -dependencies = [ - "anstream", - "anstyle", - "clap_lex", - "strsim", -] - -[[package]] -name = "clap_derive" -version = "4.5.49" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a0b5487afeab2deb2ff4e03a807ad1a03ac532ff5a2cee5d86884440c7f7671" -dependencies = [ - "heck", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "clap_lex" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d" - -[[package]] -name = "cmac" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8543454e3c3f5126effff9cd44d562af4e31fb8ce1cc0d3dcd8f084515dbc1aa" -dependencies = [ - "cipher", - "dbl", - "digest", -] - -[[package]] -name = "colorchoice" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" - -[[package]] -name = "const-oid" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" - -[[package]] -name = "cpufeatures" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" -dependencies = [ - "libc", -] - -[[package]] -name = "crypto-bigint" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" -dependencies = [ - "generic-array 0.14.7", - "rand_core", - "subtle", - "zeroize", -] - -[[package]] -name = "crypto-common" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" -dependencies = [ - "generic-array 0.14.7", - "typenum", -] - -[[package]] -name = "dbl" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd2735a791158376708f9347fe8faba9667589d82427ef3aed6794a8981de3d9" -dependencies = [ - "generic-array 0.14.7", -] - -[[package]] -name = "der" -version = "0.7.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7c1832837b905bbfb5101e07cc24c8deddf52f93225eee6ead5f4d63d53ddcb" -dependencies = [ - "const-oid", - "pem-rfc7468", - "zeroize", -] - -[[package]] -name = "digest" -version = "0.10.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" -dependencies = [ - "block-buffer", - "const-oid", - "crypto-common", - "subtle", -] - -[[package]] -name = "ecdsa" -version = "0.16.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" -dependencies = [ - "der", - "digest", - "elliptic-curve", - "rfc6979", - "signature", - "spki", -] - -[[package]] -name = "either" -version = "1.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" - -[[package]] -name = "elliptic-curve" -version = "0.13.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" -dependencies = [ - "base16ct", - "crypto-bigint", - "digest", - "ff", - "generic-array 0.14.7", - "group", - "pem-rfc7468", - "pkcs8", - "rand_core", - "sec1", - "subtle", - "zeroize", -] - -[[package]] -name = "env_filter" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bf3c259d255ca70051b30e2e95b5446cdb8949ac4cd22c0d7fd634d89f568e2" -dependencies = [ - "log", - "regex", -] - -[[package]] -name = "env_logger" -version = "0.11.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13c863f0904021b108aa8b2f55046443e6b1ebde8fd4a15c399893aae4fa069f" -dependencies = [ - "anstream", - "anstyle", - "env_filter", - "jiff", - "log", -] - -[[package]] -name = "equivalent" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" - -[[package]] -name = "errno" -version = "0.3.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" -dependencies = [ - "libc", - "windows-sys", -] - -[[package]] -name = "fastrand" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" - -[[package]] -name = "ff" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0b50bfb653653f9ca9095b427bed08ab8d75a137839d9ad64eb11810d5b6393" -dependencies = [ - "rand_core", - "subtle", -] - -[[package]] -name = "fixedbitset" -version = "0.5.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99" - -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - -[[package]] -name = "galileo-osnma" -version = "0.10.0" -dependencies = [ - "aes", - "bitvec", - "bytes", - "cmac", - "crypto-common", - "ecdsa", - "generic-array 1.3.5", - "hmac", - "log", - "p256", - "p521", - "prost", - "prost-build", - "sha2", - "sha3", - "signature", - "typenum", -] - -[[package]] -name = "galmon-osnma" -version = "0.1.0" -dependencies = [ - "anyhow", - "clap", - "ecdsa", - "env_logger", - "galileo-osnma", - "hex", - "log", - "p256", - "p521", - "spki", -] - -[[package]] -name = "generic-array" -version = "0.14.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" -dependencies = [ - "typenum", - "version_check", - "zeroize", -] - -[[package]] -name = "generic-array" -version = "1.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eaf57c49a95fd1fe24b90b3033bee6dc7e8f1288d51494cb44e627c295e38542" -dependencies = [ - "rustversion", - "typenum", -] - -[[package]] -name = "getrandom" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" -dependencies = [ - "cfg-if", - "libc", - "wasi", -] - -[[package]] -name = "getrandom" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" -dependencies = [ - "cfg-if", - "libc", - "r-efi", - "wasip2", -] - -[[package]] -name = "group" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" -dependencies = [ - "ff", - "rand_core", - "subtle", -] - -[[package]] -name = "hashbrown" -version = "0.16.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" - -[[package]] -name = "heck" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - -[[package]] -name = "hmac" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest", -] - -[[package]] -name = "indexmap" -version = "2.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ad4bb2b565bca0645f4d68c5c9af97fba094e9791da685bf83cb5f3ce74acf2" -dependencies = [ - "equivalent", - "hashbrown", -] - -[[package]] -name = "inout" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01" -dependencies = [ - "generic-array 0.14.7", -] - -[[package]] -name = "is_terminal_polyfill" -version = "1.70.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" - -[[package]] -name = "itertools" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" -dependencies = [ - "either", -] - -[[package]] -name = "jiff" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49cce2b81f2098e7e3efc35bc2e0a6b7abec9d34128283d7a26fa8f32a6dbb35" -dependencies = [ - "jiff-static", - "log", - "portable-atomic", - "portable-atomic-util", - "serde_core", -] - -[[package]] -name = "jiff-static" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "980af8b43c3ad5d8d349ace167ec8170839f753a42d233ba19e08afe1850fa69" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "keccak" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654" -dependencies = [ - "cpufeatures", -] - -[[package]] -name = "libc" -version = "0.2.178" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37c93d8daa9d8a012fd8ab92f088405fb202ea0b6ab73ee2482ae66af4f42091" - -[[package]] -name = "linux-raw-sys" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df1d3c3b53da64cf5760482273a98e575c651a67eec7f77df96b5b642de8f039" - -[[package]] -name = "log" -version = "0.4.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" - -[[package]] -name = "memchr" -version = "2.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" - -[[package]] -name = "multimap" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d87ecb2933e8aeadb3e3a02b828fed80a7528047e68b4f424523a0981a3a084" - -[[package]] -name = "once_cell" -version = "1.21.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" - -[[package]] -name = "once_cell_polyfill" -version = "1.70.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" - -[[package]] -name = "p256" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9863ad85fa8f4460f9c48cb909d38a0d689dba1f6f6988a5e3e0d31071bcd4b" -dependencies = [ - "ecdsa", - "elliptic-curve", - "primeorder", - "sha2", -] - -[[package]] -name = "p521" -version = "0.13.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fc9e2161f1f215afdfce23677034ae137bbd45016a880c2eb3ba8eb95f085b2" -dependencies = [ - "base16ct", - "ecdsa", - "elliptic-curve", - "primeorder", - "rand_core", - "sha2", -] - -[[package]] -name = "pem-rfc7468" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" -dependencies = [ - "base64ct", -] - -[[package]] -name = "petgraph" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3672b37090dbd86368a4145bc067582552b29c27377cad4e0a306c97f9bd7772" -dependencies = [ - "fixedbitset", - "indexmap", -] - -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der", - "spki", -] - -[[package]] -name = "portable-atomic" -version = "1.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483" - -[[package]] -name = "portable-atomic-util" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8a2f0d8d040d7848a709caf78912debcc3f33ee4b3cac47d73d1e1069e83507" -dependencies = [ - "portable-atomic", -] - -[[package]] -name = "prettyplease" -version = "0.2.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" -dependencies = [ - "proc-macro2", - "syn", -] - -[[package]] -name = "primeorder" -version = "0.13.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "353e1ca18966c16d9deb1c69278edbc5f194139612772bd9537af60ac231e1e6" -dependencies = [ - "elliptic-curve", -] - -[[package]] -name = "proc-macro2" -version = "1.0.103" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ee95bc4ef87b8d5ba32e8b7714ccc834865276eab0aed5c9958d00ec45f49e8" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "prost" -version = "0.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7231bd9b3d3d33c86b58adbac74b5ec0ad9f496b19d22801d773636feaa95f3d" -dependencies = [ - "bytes", - "prost-derive", -] - -[[package]] -name = "prost-build" -version = "0.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac6c3320f9abac597dcbc668774ef006702672474aad53c6d596b62e487b40b1" -dependencies = [ - "heck", - "itertools", - "log", - "multimap", - "once_cell", - "petgraph", - "prettyplease", - "prost", - "prost-types", - "regex", - "syn", - "tempfile", -] - -[[package]] -name = "prost-derive" -version = "0.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9120690fafc389a67ba3803df527d0ec9cbbc9cc45e4cc20b332996dfb672425" -dependencies = [ - "anyhow", - "itertools", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "prost-types" -version = "0.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9b4db3d6da204ed77bb26ba83b6122a73aeb2e87e25fbf7ad2e84c4ccbf8f72" -dependencies = [ - "prost", -] - -[[package]] -name = "quote" -version = "1.0.42" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a338cc41d27e6cc6dce6cefc13a0729dfbb81c262b1f519331575dd80ef3067f" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "r-efi" -version = "5.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" - -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - -[[package]] -name = "rand_core" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" -dependencies = [ - "getrandom 0.2.16", -] - -[[package]] -name = "regex" -version = "1.12.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "843bc0191f75f3e22651ae5f1e72939ab2f72a4bc30fa80a066bd66edefc24d4" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", -] - -[[package]] -name = "regex-automata" -version = "0.4.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5276caf25ac86c8d810222b3dbb938e512c55c6831a10f3e6ed1c93b84041f1c" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.8.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58" - -[[package]] -name = "rfc6979" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" -dependencies = [ - "hmac", - "subtle", -] - -[[package]] -name = "rustix" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd15f8a2c5551a84d56efdc1cd049089e409ac19a3072d5037a17fd70719ff3e" -dependencies = [ - "bitflags", - "errno", - "libc", - "linux-raw-sys", - "windows-sys", -] - -[[package]] -name = "rustversion" -version = "1.0.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" - -[[package]] -name = "sec1" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" -dependencies = [ - "base16ct", - "der", - "generic-array 0.14.7", - "pkcs8", - "subtle", - "zeroize", -] - -[[package]] -name = "serde_core" -version = "1.0.228" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.228" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "sha2" -version = "0.10.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest", -] - -[[package]] -name = "sha3" -version = "0.10.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" -dependencies = [ - "digest", - "keccak", -] - -[[package]] -name = "signature" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" -dependencies = [ - "digest", - "rand_core", -] - -[[package]] -name = "spki" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" -dependencies = [ - "base64ct", - "der", -] - -[[package]] -name = "strsim" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" - -[[package]] -name = "subtle" -version = "2.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" - -[[package]] -name = "syn" -version = "2.0.111" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "390cc9a294ab71bdb1aa2e99d13be9c753cd2d7bd6560c77118597410c4d2e87" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - -[[package]] -name = "tempfile" -version = "3.23.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d31c77bdf42a745371d260a26ca7163f1e0924b64afa0b688e61b5a9fa02f16" -dependencies = [ - "fastrand", - "getrandom 0.3.4", - "once_cell", - "rustix", - "windows-sys", -] - -[[package]] -name = "typenum" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "562d481066bde0658276a35467c4af00bdc6ee726305698a55b86e61d7ad82bb" - -[[package]] -name = "unicode-ident" -version = "1.0.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5" - -[[package]] -name = "utf8parse" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" - -[[package]] -name = "version_check" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" - -[[package]] -name = "wasi" -version = "0.11.1+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" - -[[package]] -name = "wasip2" -version = "1.0.1+wasi-0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0562428422c63773dad2c345a1882263bbf4d65cf3f42e90921f787ef5ad58e7" -dependencies = [ - "wit-bindgen", -] - -[[package]] -name = "windows-link" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" - -[[package]] -name = "windows-sys" -version = "0.61.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" -dependencies = [ - "windows-link", -] - -[[package]] -name = "wit-bindgen" -version = "0.46.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59" - -[[package]] -name = "wyz" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" -dependencies = [ - "tap", -] - -[[package]] -name = "zeroize" -version = "1.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0" diff --git a/galmon-osnma/Cargo.toml b/galmon-osnma/Cargo.toml deleted file mode 100644 index eebf1ca..0000000 --- a/galmon-osnma/Cargo.toml +++ /dev/null @@ -1,26 +0,0 @@ -[package] -name = "galmon-osnma" -version = "0.1.0" -edition = "2024" -authors = ["Daniel Estevez "] -description = "Galileo OSNMA processing of Galmon transport protocol" -license = "MIT OR Apache-2.0" -homepage = "https://github.com/daniestevez/galileo-osnma/" -repository = "https://github.com/daniestevez/galileo-osnma/" -keywords = ["galileo", "gnss", "osnma", "authentication", "cryptography"] -categories = ["aerospace::space-protocols", "authentication", "embedded", "no-std"] -default-run = "galmon-osnma" - -publish = false - -[dependencies] -anyhow = "1" -clap = { version = "4.4", features = ["derive"] } -ecdsa = { version = "0.16", features = ["pkcs8"] } -env_logger = "0.11" -galileo-osnma = { path = "..", features = ["galmon"] } -hex = "0.4" -log = "0.4" -p256 = { version = "0.13", features = ["ecdsa"] } -p521 = { version = "0.13", features = ["ecdsa"] } -spki = { version = "0.7", features = ["pem"] } diff --git a/justfile b/justfile new file mode 100644 index 0000000..6175264 --- /dev/null +++ b/justfile @@ -0,0 +1,45 @@ +# print just recipes +default: + just -l + +# build and run galmon-osnma with Galmon live feed +galmon-osnma-live-feed *args: + nc 86.82.68.237 10000 | \ + cargo run --release --bin galmon-osnma -- {{args}} + +# build and run galmon-osnma with ubxtool +galmon-osnma-ubxtool ubxtool-port *args: + ubxtool --wait --port {{ubxtool-port}} --station 1 --stdout --galileo | \ + cargo run --release --bin galmon-osnma -- {{args}} + +# build and run osnma-longan-nano client with Galmon live feed +osnma-longan-nano-live-feed longan-nano-serial: + nc 86.82.68.237 10000 | \ + cargo run --release --bin osnma-longan-nano-client -- {{longan-nano-serial}} + +# build and run osnma-longan-nano client with ubxtool +osnma-longan-nano-ubxtool ubxtool-port longan-nano-serial: + ubxtool --wait --port {{ubxtool-port}} --station 1 --stdout --galileo | \ + cargo run --release --bin osnma-longan-nano-client -- {{longan-nano-serial}} + +# process test vectors +test-vectors: + wget --quiet https://www.gsc-europa.eu/sites/default/files/sites/all/files/Test_vectors.zip + unzip Test_vectors.zip + rm -rf Test_vectors.zip + ./utils/run_test_vectors.sh Test_vectors + rm -rf Test_vectors readme.txt + +# build osnma-longan-nano firmware +osnma-longan-nano: + cargo objcopy -p osnma-longan-nano \ + --target riscv32imac-unknown-none-elf --profile embedded \ + -- -O binary osnma-longan-nano-firmware.bin + +# run clippy for osnma-longan-nano firmware +clippy-osnma-longan-nano: + cargo clippy --all-features -p osnma-longan-nano --target riscv32imac-unknown-none-elf -- -D warnings + +# flash osnma-longan-nano firmware +osnma-longan-nano-flash: osnma-longan-nano + dfu-util -a 0 -s 0x08000000:leave -D osnma-longan-nano-firmware.bin diff --git a/osnma-longan-nano-client/Cargo.lock b/osnma-longan-nano-client/Cargo.lock deleted file mode 100644 index da83bf0..0000000 --- a/osnma-longan-nano-client/Cargo.lock +++ /dev/null @@ -1,969 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 4 - -[[package]] -name = "aes" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" -dependencies = [ - "cfg-if", - "cipher", - "cpufeatures", -] - -[[package]] -name = "aho-corasick" -version = "1.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" -dependencies = [ - "memchr", -] - -[[package]] -name = "anyhow" -version = "1.0.100" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61" - -[[package]] -name = "base16ct" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" - -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "bitflags" -version = "2.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3" - -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - -[[package]] -name = "block-buffer" -version = "0.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" -dependencies = [ - "generic-array 0.14.7", -] - -[[package]] -name = "bytes" -version = "1.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b35204fbdc0b3f4446b89fc1ac2cf84a8a68971995d0bf2e925ec7cd960f9cb3" - -[[package]] -name = "cfg-if" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" - -[[package]] -name = "cipher" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" -dependencies = [ - "crypto-common", - "inout", -] - -[[package]] -name = "cmac" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8543454e3c3f5126effff9cd44d562af4e31fb8ce1cc0d3dcd8f084515dbc1aa" -dependencies = [ - "cipher", - "dbl", - "digest", -] - -[[package]] -name = "const-oid" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" - -[[package]] -name = "core-foundation" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b55271e5c8c478ad3f38ad24ef34923091e0548492a266d19b3c0b4d82574c63" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "core-foundation-sys" -version = "0.8.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" - -[[package]] -name = "cpufeatures" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" -dependencies = [ - "libc", -] - -[[package]] -name = "crypto-bigint" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" -dependencies = [ - "generic-array 0.14.7", - "rand_core", - "subtle", - "zeroize", -] - -[[package]] -name = "crypto-common" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" -dependencies = [ - "generic-array 0.14.7", - "typenum", -] - -[[package]] -name = "dbl" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd2735a791158376708f9347fe8faba9667589d82427ef3aed6794a8981de3d9" -dependencies = [ - "generic-array 0.14.7", -] - -[[package]] -name = "der" -version = "0.7.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7c1832837b905bbfb5101e07cc24c8deddf52f93225eee6ead5f4d63d53ddcb" -dependencies = [ - "const-oid", - "zeroize", -] - -[[package]] -name = "digest" -version = "0.10.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" -dependencies = [ - "block-buffer", - "const-oid", - "crypto-common", - "subtle", -] - -[[package]] -name = "ecdsa" -version = "0.16.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" -dependencies = [ - "der", - "digest", - "elliptic-curve", - "rfc6979", - "signature", -] - -[[package]] -name = "either" -version = "1.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" - -[[package]] -name = "elliptic-curve" -version = "0.13.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" -dependencies = [ - "base16ct", - "crypto-bigint", - "digest", - "ff", - "generic-array 0.14.7", - "group", - "rand_core", - "sec1", - "subtle", - "zeroize", -] - -[[package]] -name = "equivalent" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" - -[[package]] -name = "errno" -version = "0.3.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" -dependencies = [ - "libc", - "windows-sys 0.61.2", -] - -[[package]] -name = "fastrand" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" - -[[package]] -name = "ff" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0b50bfb653653f9ca9095b427bed08ab8d75a137839d9ad64eb11810d5b6393" -dependencies = [ - "rand_core", - "subtle", -] - -[[package]] -name = "fixedbitset" -version = "0.5.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99" - -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - -[[package]] -name = "galileo-osnma" -version = "0.10.1" -dependencies = [ - "aes", - "bitvec", - "bytes", - "cmac", - "crypto-common", - "ecdsa", - "generic-array 1.3.5", - "hmac", - "log", - "p256", - "p521", - "prost", - "prost-build", - "sha2", - "sha3", - "signature", - "typenum", -] - -[[package]] -name = "generic-array" -version = "0.14.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" -dependencies = [ - "typenum", - "version_check", - "zeroize", -] - -[[package]] -name = "generic-array" -version = "1.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eaf57c49a95fd1fe24b90b3033bee6dc7e8f1288d51494cb44e627c295e38542" -dependencies = [ - "rustversion", - "typenum", -] - -[[package]] -name = "getrandom" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" -dependencies = [ - "cfg-if", - "libc", - "r-efi", - "wasip2", -] - -[[package]] -name = "group" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" -dependencies = [ - "ff", - "rand_core", - "subtle", -] - -[[package]] -name = "hashbrown" -version = "0.16.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" - -[[package]] -name = "heck" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - -[[package]] -name = "hmac" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest", -] - -[[package]] -name = "indexmap" -version = "2.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ad4bb2b565bca0645f4d68c5c9af97fba094e9791da685bf83cb5f3ce74acf2" -dependencies = [ - "equivalent", - "hashbrown", -] - -[[package]] -name = "inout" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01" -dependencies = [ - "generic-array 0.14.7", -] - -[[package]] -name = "io-kit-sys" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "617ee6cf8e3f66f3b4ea67a4058564628cde41901316e19f559e14c7c72c5e7b" -dependencies = [ - "core-foundation-sys", - "mach2", -] - -[[package]] -name = "itertools" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" -dependencies = [ - "either", -] - -[[package]] -name = "keccak" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654" -dependencies = [ - "cpufeatures", -] - -[[package]] -name = "libc" -version = "0.2.178" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37c93d8daa9d8a012fd8ab92f088405fb202ea0b6ab73ee2482ae66af4f42091" - -[[package]] -name = "libudev" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78b324152da65df7bb95acfcaab55e3097ceaab02fb19b228a9eb74d55f135e0" -dependencies = [ - "libc", - "libudev-sys", -] - -[[package]] -name = "libudev-sys" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c8469b4a23b962c1396b9b451dda50ef5b283e8dd309d69033475fa9b334324" -dependencies = [ - "libc", - "pkg-config", -] - -[[package]] -name = "linux-raw-sys" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df1d3c3b53da64cf5760482273a98e575c651a67eec7f77df96b5b642de8f039" - -[[package]] -name = "log" -version = "0.4.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" - -[[package]] -name = "mach2" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d640282b302c0bb0a2a8e0233ead9035e3bed871f0b7e81fe4a1ec829765db44" -dependencies = [ - "libc", -] - -[[package]] -name = "memchr" -version = "2.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" - -[[package]] -name = "multimap" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d87ecb2933e8aeadb3e3a02b828fed80a7528047e68b4f424523a0981a3a084" - -[[package]] -name = "nix" -version = "0.26.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b" -dependencies = [ - "bitflags 1.3.2", - "cfg-if", - "libc", -] - -[[package]] -name = "once_cell" -version = "1.21.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" - -[[package]] -name = "osnma-longan-nano-client" -version = "0.1.0" -dependencies = [ - "galileo-osnma", - "hex", - "serialport", -] - -[[package]] -name = "p256" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9863ad85fa8f4460f9c48cb909d38a0d689dba1f6f6988a5e3e0d31071bcd4b" -dependencies = [ - "ecdsa", - "elliptic-curve", - "primeorder", - "sha2", -] - -[[package]] -name = "p521" -version = "0.13.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fc9e2161f1f215afdfce23677034ae137bbd45016a880c2eb3ba8eb95f085b2" -dependencies = [ - "base16ct", - "ecdsa", - "elliptic-curve", - "primeorder", - "sha2", -] - -[[package]] -name = "petgraph" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3672b37090dbd86368a4145bc067582552b29c27377cad4e0a306c97f9bd7772" -dependencies = [ - "fixedbitset", - "indexmap", -] - -[[package]] -name = "pkg-config" -version = "0.3.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" - -[[package]] -name = "prettyplease" -version = "0.2.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" -dependencies = [ - "proc-macro2", - "syn", -] - -[[package]] -name = "primeorder" -version = "0.13.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "353e1ca18966c16d9deb1c69278edbc5f194139612772bd9537af60ac231e1e6" -dependencies = [ - "elliptic-curve", -] - -[[package]] -name = "proc-macro2" -version = "1.0.103" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ee95bc4ef87b8d5ba32e8b7714ccc834865276eab0aed5c9958d00ec45f49e8" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "prost" -version = "0.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7231bd9b3d3d33c86b58adbac74b5ec0ad9f496b19d22801d773636feaa95f3d" -dependencies = [ - "bytes", - "prost-derive", -] - -[[package]] -name = "prost-build" -version = "0.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac6c3320f9abac597dcbc668774ef006702672474aad53c6d596b62e487b40b1" -dependencies = [ - "heck", - "itertools", - "log", - "multimap", - "once_cell", - "petgraph", - "prettyplease", - "prost", - "prost-types", - "regex", - "syn", - "tempfile", -] - -[[package]] -name = "prost-derive" -version = "0.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9120690fafc389a67ba3803df527d0ec9cbbc9cc45e4cc20b332996dfb672425" -dependencies = [ - "anyhow", - "itertools", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "prost-types" -version = "0.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9b4db3d6da204ed77bb26ba83b6122a73aeb2e87e25fbf7ad2e84c4ccbf8f72" -dependencies = [ - "prost", -] - -[[package]] -name = "quote" -version = "1.0.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "r-efi" -version = "5.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" - -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - -[[package]] -name = "rand_core" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" - -[[package]] -name = "regex" -version = "1.12.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "843bc0191f75f3e22651ae5f1e72939ab2f72a4bc30fa80a066bd66edefc24d4" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", -] - -[[package]] -name = "regex-automata" -version = "0.4.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5276caf25ac86c8d810222b3dbb938e512c55c6831a10f3e6ed1c93b84041f1c" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.8.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58" - -[[package]] -name = "rfc6979" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" -dependencies = [ - "hmac", - "subtle", -] - -[[package]] -name = "rustix" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd15f8a2c5551a84d56efdc1cd049089e409ac19a3072d5037a17fd70719ff3e" -dependencies = [ - "bitflags 2.10.0", - "errno", - "libc", - "linux-raw-sys", - "windows-sys 0.61.2", -] - -[[package]] -name = "rustversion" -version = "1.0.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" - -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - -[[package]] -name = "sec1" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" -dependencies = [ - "base16ct", - "der", - "generic-array 0.14.7", - "subtle", - "zeroize", -] - -[[package]] -name = "serialport" -version = "4.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21f60a586160667241d7702c420fc223939fb3c0bb8d3fac84f78768e8970dee" -dependencies = [ - "bitflags 2.10.0", - "cfg-if", - "core-foundation", - "core-foundation-sys", - "io-kit-sys", - "libudev", - "mach2", - "nix", - "quote", - "scopeguard", - "unescaper", - "windows-sys 0.52.0", -] - -[[package]] -name = "sha2" -version = "0.10.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest", -] - -[[package]] -name = "sha3" -version = "0.10.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" -dependencies = [ - "digest", - "keccak", -] - -[[package]] -name = "signature" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" -dependencies = [ - "digest", - "rand_core", -] - -[[package]] -name = "subtle" -version = "2.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" - -[[package]] -name = "syn" -version = "2.0.111" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "390cc9a294ab71bdb1aa2e99d13be9c753cd2d7bd6560c77118597410c4d2e87" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - -[[package]] -name = "tempfile" -version = "3.23.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d31c77bdf42a745371d260a26ca7163f1e0924b64afa0b688e61b5a9fa02f16" -dependencies = [ - "fastrand", - "getrandom", - "once_cell", - "rustix", - "windows-sys 0.61.2", -] - -[[package]] -name = "thiserror" -version = "2.0.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f63587ca0f12b72a0600bcba1d40081f830876000bb46dd2337a3051618f4fc8" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "2.0.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "typenum" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "562d481066bde0658276a35467c4af00bdc6ee726305698a55b86e61d7ad82bb" - -[[package]] -name = "unescaper" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4064ed685c487dbc25bd3f0e9548f2e34bab9d18cefc700f9ec2dba74ba1138e" -dependencies = [ - "thiserror", -] - -[[package]] -name = "unicode-ident" -version = "1.0.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5" - -[[package]] -name = "version_check" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" - -[[package]] -name = "wasip2" -version = "1.0.1+wasi-0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0562428422c63773dad2c345a1882263bbf4d65cf3f42e90921f787ef5ad58e7" -dependencies = [ - "wit-bindgen", -] - -[[package]] -name = "windows-link" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" - -[[package]] -name = "windows-sys" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" -dependencies = [ - "windows-targets", -] - -[[package]] -name = "windows-sys" -version = "0.61.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" -dependencies = [ - "windows-link", -] - -[[package]] -name = "windows-targets" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" -dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" - -[[package]] -name = "windows_i686_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" - -[[package]] -name = "windows_i686_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" - -[[package]] -name = "windows_i686_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" - -[[package]] -name = "wit-bindgen" -version = "0.46.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59" - -[[package]] -name = "wyz" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" -dependencies = [ - "tap", -] - -[[package]] -name = "zeroize" -version = "1.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0" diff --git a/osnma-longan-nano-client/Cargo.toml b/osnma-longan-nano-client/Cargo.toml deleted file mode 100644 index 33e728f..0000000 --- a/osnma-longan-nano-client/Cargo.toml +++ /dev/null @@ -1,19 +0,0 @@ -[package] -name = "osnma-longan-nano-client" -version = "0.1.0" -edition = "2024" -authors = ["Daniel Estevez "] -description = "Galileo OSNMA demo in a Longan Nano board (serial port client)" -license = "MIT OR Apache-2.0" -homepage = "https://github.com/daniestevez/galileo-osnma/" -repository = "https://github.com/daniestevez/galileo-osnma/" -keywords = ["galileo", "gnss", "osnma", "authentication", "cryptography"] -categories = ["aerospace::space-protocols", "authentication", "embedded", "no-std"] - -publish = false - -[dependencies] -hex = "0.4" -galileo-osnma = { path = "..", features = ["galmon"] } -serialport = "4.0" - diff --git a/osnma-longan-nano-client/README.md b/osnma-longan-nano-client/README.md deleted file mode 100644 index e3d3fe9..0000000 --- a/osnma-longan-nano-client/README.md +++ /dev/null @@ -1,21 +0,0 @@ -# osnma-longan-nano-client - -This is the host computer serial port client used with the -[osnma-longan-nano](https://github.com/daniestevez/galileo-osnma/tree/main/osnma-longan-nano) -demo of the galileo-osnma library running on a small RISC-V GD32V103 microcontroller. - -The instructions for this demo are available in the -[osnma-longan-nano README](https://github.com/daniestevez/galileo-osnma/tree/main/osnma-longan-nano) - -### Building - -The crate can be built using - -``` -cargo build --release -``` - -... and then run from the resulting path using the [demo instructions](https://github.com/daniestevez/galileo-osnma/tree/main/osnma-longan-nano): -``` -galileo-osnma/osnma-longan-nano-client/target/release/ -``` diff --git a/osnma-longan-nano/Cargo.toml b/osnma-longan-nano/Cargo.toml index ec55e9b..b2f4716 100644 --- a/osnma-longan-nano/Cargo.toml +++ b/osnma-longan-nano/Cargo.toml @@ -10,23 +10,17 @@ repository = "https://github.com/daniestevez/galileo-osnma/" keywords = ["galileo", "gnss", "osnma", "authentication", "cryptography"] categories = ["aerospace::space-protocols", "authentication", "embedded", "no-std"] -publish = false - [dependencies] -hex = { version = "0.4", default-features = false } -galileo-osnma = { path = "..", default-features = false } -longan-nano = "0.3" -nb = "1.0" -p256 = { version = "0.13", features = ["ecdsa"], default-features = false } -panic-halt = "1" -riscv-rt = "0.16" +hex = { workspace = true } +galileo-osnma = { path = "../galileo-osnma", default-features = false } +longan-nano = { workspace = true } +nb = { workspace = true } +p256 = { workspace = true } +panic-halt = { workspace = true } +riscv-rt = { workspace = true } [build-dependencies] -hex = "0.4" -ecdsa = { version = "0.16", features = ["pkcs8"] } -p256 = { version = "0.13", features = ["ecdsa"] } -spki = { version = "0.7", features = ["pem"] } - -[profile.release] -opt-level = "z" # Optimize for size. -lto = true +hex = { workspace = true, default-features = true } +ecdsa = { workspace = true, features = ["pkcs8"] } +p256 = { workspace = true, default-features = true } +spki = { workspace = true } diff --git a/osnma-longan-nano/README.md b/osnma-longan-nano/README.md index edfbe5c..fb6cd72 100644 --- a/osnma-longan-nano/README.md +++ b/osnma-longan-nano/README.md @@ -14,49 +14,50 @@ embedded microcontrollers. ### Building -The instructions to set up the Rust riscv32imac toolchain can be found in the -documentation for the [longan-nano](https://github.com/riscv-rust/longan-nano) -crate. +Building the firmware requires the following: + +- Rust riscv32imac toolchain. This can be installed with `rustup target add + riscv32imac-unknown-none-elf`. + +- [just](https://github.com/casey/just) + +- [cargo-binutils](https://github.com/rust-embedded/cargo-binutils/) The OSNMA ECDSA P-256 public key and the Merkle tree root are embedded in the binary during the build process. The public key is taken from the `pubkey.pem` file found in the root folder of this crate, and its Public Key ID is taken from the `pubkey_id.txt` file. The Merkle tree root is taken from the -`merkle_tree_root.txt` file. "Fake" files are provided so that osnma-longan-demo -can be built without access to the real cryptographic material. A binary built with -this fake cryptographic material will not work with the Galileo signal-in-space. - -The fake `pubkey.pem` needs to be replaced with the authentic key, using the -same PEM file format. Instructions about how to obtain the authentic public key -can be found in the [galileo-osnma +`merkle_tree_root.txt` file. Mock versions of these files containing random data +are provided so that osnma-longan-demo can be built without access to the real +cryptographic material. A binary built with this mock cryptographic material +will not work with the Galileo signal-in-space. + +The mock `pubkey.pem` needs to be replaced with the real key, using the same PEM +file format. Instructions about how to obtain the authentic public key can be +found in the [galileo-osnma README](https://github.com/daniestevez/galileo-osnma#quick-start-using-galmon). Likewise the Public Key ID in `pubkey_id.txt` needs to be replaced by the correct one, and the Merkle tree root needs to be written to the file `merkle_tree_root.txt`. -Once these files contain the real cryptographic material, the firmware can be -built using +The firmware is built by running + ``` -cargo build --release +just osnma-longan-nano ``` -Note that it is mandatory to build using the `--release` profile, since a binary -built without `--release` will not fit in the 128 KiB of flash, so `rust-lld` will -give an error. ### Flashing -After the binary is built, it can be flashed to the microcontroller using any of -the methods described in the -[longan-nano documentation](https://github.com/riscv-rust/longan-nano#longan-nano). -The easiest method for flashing is using dfu-util. This can be done by running +The firmware can be flashed by running + ``` -objcopy -O binary target/riscv32imac-unknown-none-elf/release/osnma-longan-nano firmware.bin -dfu-util -a 0 -s 0x08000000:leave -D firmware.bin +just osnma-longan-nano-flash ``` -The `objcopy` command must belong to a riscv toolchain, and when `dfu-util` is run -the microcontroller should be in DFU mode and connected by USB to the computer. DFU -mode is entered by holding the BOOT0 button on the board while the board is powered -on or resetted. + +This requires `dfu-util`. When this is run, the microcontroller should be in DFU +mode and connected by USB to the computer. DFU mode is entered by holding the +BOOT0 button on the board while the board boots (either from a powered off state +or from a reset button press). ### Serial port connection @@ -73,25 +74,24 @@ converter such as [this device](https://www.amazon.com/gp/product/B07D6LLX19) sh ### Running the serial port client The serial port client that runs on the host computer can be found in the -[osnma-longan-nano-client](https://github.com/daniestevez/galileo-osnma/tree/main/osnma-longan-nano-client) crate. +[galileo-osnma](https://github.com/daniestevez/galileo-osnma/tree/main/galileo-osnma) crate. The binary in this crate must be run by indicating the path to the computer serial port to use (for instance `/dev/ttyACM0` or `/dev/ttyUSB0`) and feeding to its standard input data using the Galmon transport protocol, in the same way as with the -`galmon-osnma` crate (see +`galmon-osnma` application (see [these instructions](https://github.com/daniestevez/galileo-osnma#quick-start-using-galmon)). The serial port client will send the INAV and OSNMA data to the board and print to the standard output all the lines received from the microcontroller through the UART. The UART communication is described below. -So, in the same way that navigation data can be piped to this application running on a local computer ([instructions](https://github.com/daniestevez/galileo-osnma#quick-start-using-galmon)), a web stream or 'live' data from a GNSS receiver can be piped to the [Longan nano](https://longan.sipeed.com/en/) via the [serial port client](https://github.com/daniestevez/galileo-osnma/tree/main/osnma-longan-nano-client). - -Example: (run from galileo-osnma/osnma-longan-nano-client/target/release/ & use correct /dev/tty* if different from /dev/ttyUSB0) +For example, ``` -nc 86.82.68.237 10000 | ./osnma-longan-nano-client /dev/ttyUSB0 +just osnma-longan-nano-live-feed /dev/ttyUSB0 ``` - +can be run to send data from the Galmon live feed to the serial port +`/dev/ttyUSB0`. After starting the serial port client, the microcontroller should be reset or powered on to start running the demo. diff --git a/osnma-test-vectors-to-galmon/.gitignore b/osnma-test-vectors-to-galmon/.gitignore deleted file mode 100644 index ea8c4bf..0000000 --- a/osnma-test-vectors-to-galmon/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/target diff --git a/osnma-test-vectors-to-galmon/Cargo.toml b/osnma-test-vectors-to-galmon/Cargo.toml deleted file mode 100644 index a10087d..0000000 --- a/osnma-test-vectors-to-galmon/Cargo.toml +++ /dev/null @@ -1,21 +0,0 @@ -[package] -name = "osnma-test-vectors-to-galmon" -version = "0.1.0" -edition = "2024" -authors = ["Daniel Estevez "] -description = "Converts Galileo OSNMA test vectors to Galmon transport protocol" -license = "MIT OR Apache-2.0" -homepage = "https://github.com/daniestevez/galileo-osnma/" -repository = "https://github.com/daniestevez/galileo-osnma/" -keywords = ["galileo", "gnss", "osnma", "authentication", "cryptography"] -categories = ["aerospace::space-protocols", "authentication", "embedded", "no-std"] - -publish = false - -[dependencies] -anyhow = "1" -bitvec = "1" -clap = { version = "4.4", features = ["derive"] } -chrono = "0.4" -galileo-osnma = { path = "..", features = ["galmon"] } -hex = "0.4" diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 0000000..f216078 --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1 @@ +edition = "2024" diff --git a/utils/run_test_vectors.sh b/utils/run_test_vectors.sh index f077bc8..69a6d9c 100755 --- a/utils/run_test_vectors.sh +++ b/utils/run_test_vectors.sh @@ -14,15 +14,12 @@ GALILEO_OSNMA_DIR="$(dirname "$0")/../" echo "Building software" -cd $GALILEO_OSNMA_DIR/osnma-test-vectors-to-galmon -cargo build --release -cd $ORIG_CWD -cd $GALILEO_OSNMA_DIR/galmon-osnma +cd $GALILEO_OSNMA_DIR cargo build --release cd $ORIG_CWD -CONVERT=$GALILEO_OSNMA_DIR/osnma-test-vectors-to-galmon/target/release/osnma-test-vectors-to-galmon -GALMON_OSNMA=$GALILEO_OSNMA_DIR/galmon-osnma/target/release/galmon-osnma +CONVERT=$GALILEO_OSNMA_DIR/target/release/osnma-test-vectors-to-galmon +GALMON_OSNMA=$GALILEO_OSNMA_DIR/target/release/galmon-osnma GET_MERKLE=$GALILEO_OSNMA_DIR/utils/extract_merkle_tree_root.py GET_PUBKEY=$GALILEO_OSNMA_DIR/utils/extract_public_key.py GET_PUBKEY_FROM_MERKLE=$GALILEO_OSNMA_DIR/utils/extract_merkle_tree_key.py