Crates.io | galileo-osnma |
lib.rs | galileo-osnma |
version | 0.8.0 |
source | src |
created_at | 2022-03-26 17:30:03.923061 |
updated_at | 2024-01-26 11:37:14.096011 |
description | Galileo OSNMA (Open Service Navigation Message Authentication) |
homepage | https://github.com/daniestevez/galileo-osnma/ |
repository | https://github.com/daniestevez/galileo-osnma/ |
max_upload_size | |
id | 556838 |
size | 299,323 |
galileo-osnma is a Rust implementation of the Galileo OSNMA (Open Service Navigation Message Authentication) protocol. This protocol is used by the Galileo GNSS to sign cryptographically the navigation message data transmitted by its satellites, in order to prevent spoofing. Briefly speaking, galileo-osnma can process the navigation message data and OSNMA cryptographic data and check all the cryptographic signatures against an ECDSA public key and/or Merkle tree, in order to check the authenticity of the navigation data.
galileo-osnma does not require the Rust Standard library (it can be built with
no_std
), allocates all its data statically on the stack, and has a relatively
small memory footprint for the data (~76 KiB if Slow MAC is used and data for 36
satellites in parallel is stored, and ~8.5 KiB if Slow MAC is not used and data
for only 12 satellites in parallel is stored). This makes it possible to use the
library in some embedded microcontrollers. A demo of galileo-osnma running in a
Longan nano GD32VF103 board is provided in the
osnma-longan-nano
crate. This is a RISC-V microcontroller with 128 KiB of flash and 32 KiB of RAM
that is similar to the popular STM32F103 ARM Cortex-M3 microcontroller.
The documentation for galileo-osnma is hosted in docs.rs.
The following reference documents from the Galileo system are relevant:
galileo-osnma comes with a binary application that can read Galileo INAV pages
using the Galmon transport
protocol. This is located in
the galmon-osnma
folder.
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
nc 86.82.68.237 10000 | \
RUST_LOG=info cargo run --release -- --pubkey osnma-pubkey.pem --pkid N
to see galileo-osnma processing the OSNMA and navigation data streamed by Galmon. The env_logger documentation describes how the logging information produced by this application can be configured.
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
for how to obtain this data.
Note that Galmon aggregates data from many receivers around the world and packets occasionally arrive out-of-order in the stream. This is not the main expected use case for galileo-osnma. Therefore, when running this, there can be 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
The OSNMA ECDSA public key and/or the Merkle tree root need to be obtained to
run galmon-osnma
and other example applications, as well as to make full use
of the library. The current ECDSA public key is needed to validate OSNMA
cryptographic data (more precisely, TESLA root keys) transmitted in the
signal-in-space. The Merkle tree root is needed to validate ECDSA public keys
broadcast in the signal-in-space. These keys are transmitted only every 6
hours (at 00:00, 06:00, 12:00, and 18:00 GST).
The galmon-osnma
application can be run using either the ECDSA public key
(using the --pubkey
and --pkid
arguments), the Merkle tree root (using the
--merkle-root
argument), or both. If only the ECDSA public key is given, the
application will not be able to use new public keys that are broadcast in the
signal-in-space for a public key renewal or revocation. If only the Merkle tree
root is given, it will be necessary to wait until the current ECDSA public key
is broadcast in the signal-in-space.
The public key and the Merkle tree root can be downloaded from the European GNSS Service Centre, under GSC Products > OSNMA_PUBLICKEY. 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
in the filename, and it is also listed elsewhere in the GSC Products website.
The current certificate file is OSNMA_PublicKey_20240115100000_newPKID_1.crt
,
and the corresponding Public Key ID is 1
. The key in PEM format, as required by
galmon-osnma
can be extracted with
openssl x509 -in OSNMA_PublicKey_20240115100000_newPKID_1.crt -noout -pubkey > osnma-pubkey.pem
The Merkle tree information is downloaded in an XML file. The current file is
OSNMA_MerkleTree_20240115100000_newPKID_1.xml
. The tree root,
expressed as a 256-bit hexadecimal number can be extracted from the XML file
with
./utils/extract_merkle_tree_root.py OSNMA_MerkleTree_20240115100000_newPKID_1.xml
This 256-bit hexadecimal format is the one that is directly used by the galmon-osnma
--merkle-root
argument. The tree root is also listed in other parts of the GSC Products
website.
The public key is also given as 264-bit compressed point in hexadecimal, both in
an XML file containing the public key, and in the Merkle tree XML file, as well
as in other parts of the GSC Products website. The scripts
extract_public_key.py
and extract_merkle_tree_key.py
in the utils
folder can be used to extract the key in hexadecimal from these XML
files. The sec1_to_pem.py
script in the utils
folder can be used to
convert this hexadecimal representation to PEM format.
galileo-osnma has been usable since its first release during the public test phase of OSNMA, and then updated for the OSNMA ICD changes done in the service phase. Currently it is in-line with the OSNMA SIS ICD v1.1. galileo-osnma can authenticate all the types of navigation data currently supported by OSNMA using the ECDSA public keys and Merkle tree. There are some features of the OSNMA protocol and some roadmap features that are not implemented yet. These are listed below.
Supported features:
p521
feature used to enable or disable P-521 support. This feature is
enabled by default. It is disabled in the osnma-longan-nano
demo, since
otherwise the firmware size is too large for the target microcontroller. The
galmon-osnma
application can only load P-256 keys in PEM format. The
--pubkey-p521
argument can be used to load a P-521 key in hexadecimal format
instead.Unsupported features:
Roadmap features. These are not features of OSNMA itself, but will add to the functionality and usability of galileo-osnma:
There is a script run_test_vectors.sh
that is used to run the
OSNMA Test Vectors
provided as an annex to the
OSNMA Receiver Guidelines v1.3.
The script uses the small application in the osnma-test-vectors-to-galmon
folder to convert the CSV test vectors into the Galmon transport format, and
pipes this data into the galmon-osnma
application.
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
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
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.
Rust 1.70 or higher.
Minimum supported Rust version can be changed in the future, but it will be done with a minor version bump.
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.