Commit Graph

222 Commits

Author SHA1 Message Date
Sosthène Guédon 8fdeefdee1 Fix pipe tests
I don't really understand why the size is that high.
The size of the `Message` struct is 2416.
The channel is a message in an unsafecell + 1 atomicU8 and 2 atomic bools.
It should only 3 more bytes but for some reason it's 16
2023-02-22 17:49:21 +01:00
Sosthène Guédon 494490432a Simplifiy tests 2023-02-22 17:08:49 +01:00
Sosthène Guédon dc930cc086 Fix serde extensions feature 2023-02-22 17:08:49 +01:00
Sosthène Guédon a3fdf6efe5 Fix tests 2023-02-22 17:08:49 +01:00
Sosthène Guédon 46c4f6a176 Adapt virt to previous changes 2023-02-17 10:54:35 +01:00
Sosthène Guédon 1e26606573 Let the runner define the interchange
This allows removing the client-N feature flags
2023-02-17 10:54:35 +01:00
Sosthène Guédon c8befcb97b Remove unused patch section 2023-02-17 10:54:35 +01:00
Sosthène Guédon fdfa082c31 Remove unused consts 2023-02-17 10:53:22 +01:00
Sosthène Guédon 67b4ee9c6c Add raw RSA mechanism 2023-02-16 10:18:44 +01:00
Robin Krahl c62c1c8b44 Add assertions for interchange size
This patch adds assertions on the size of the Request, Reply and
TrussedInterchange types so that we don’t accidentally increase it.
2023-02-14 11:30:26 +01:00
Sosthène Guédon 6a82b78253 Update changelog 2023-02-13 17:08:53 +01:00
Sosthène Guédon 34844bf7c3 Migrate to interchange 0.3.0 2023-02-13 17:08:53 +01:00
Robin Krahl 51477a4c5d Drop P parameter from backend and extension traits
The Backend, Dispatch, ExtensionImpl and ExtensionDispatch traits don’t
need to have the platform as a type parameter P.  It is sufficient if
the request handling methods receive it as a type parameter.  This makes
it easier to implement the traits.
2023-02-08 13:10:17 +01:00
Sosthène Guédon 2e4c74cae3 Add missing dispatch parameter for the virtual Client 2023-02-08 10:44:18 +01:00
Robin Krahl d5896c6cfb Simplify ClientBuilder
Instead of having different methods to build a client from a generic
Syscall implementation, a &mut Service or a Service, introduce a
two-step process:  firstly allocating the endpoint and the interchange
using a &mut Service; secondly creating the client using a Syscall
implementation.
2023-02-08 10:38:58 +01:00
Sosthène Guédon 20c7d622ec Fix key serialization length to accomodate RSA 2023-02-08 01:29:43 +01:00
Sosthène Guédon 964dad64fb Add RSA key kinds 2023-02-08 01:29:43 +01:00
Sosthène Guédon 3132d1afca Add RSA mechanisms and key serialization 2023-02-08 01:29:43 +01:00
Robin Krahl 1c55b3b2dd Add serde_extension documentation
This patch adds some basic documentation for the serde_extensions
module.
2023-02-07 12:03:14 +01:00
Nicolas Stalder 882c3591ad Extend serde-extensions test with additional extension and backend 2023-02-07 12:03:14 +01:00
Nicolas Stalder 78fd34b87e Reduce extension-related types 2023-02-07 12:03:14 +01:00
Robin Krahl e65d5031b8 Add API extensions
This patch adds API extensions to Trussed.  To avoid having to add a
type parameter to Request and Reply, we serialize the requests and
replies.  Extensions can be implemented by custom backends and are
executed by the dispatch implementation provided to the Service.  An
additional type parameter is needed for ClientImplementation to express
the supported extensions.  See tests/ext.rs for an example
implementation.

The serialization and deserialization of the requests and replies of
course adds additional overhead.  An alternative would be to make
Request and Reply generic over the set of extensions.
2023-02-07 12:03:14 +01:00
Robin Krahl 9fc19904b5 Add backend-specific context
This patch allows backends to store per-client context.  The
ClientContext struct is replaced by a Context struct that has two
fields: the context used by the standard Trussed implementation, and the
backend-specific context.
2023-02-05 21:10:57 +01:00
Robin Krahl fcb9371b3e Add support for multiple backends 2023-02-05 21:10:57 +01:00
Sosthène Guédon 3a847d509f Rename {Request,Reply}Data to {Request,Reply}Variant 2023-02-05 13:41:25 +01:00
Sosthène Guédon d11abc5610 Remove "Corresponding" prefix 2023-02-05 13:41:25 +01:00
Sosthène Guédon 92a3b38737 Introduce type-based linking of requests and replies
This ensures that `PollClient::request` always matches the correct Request and Reply

This patch also fixes https://github.com/trussed-dev/trussed/issues/84 and replaces the
`From` that used `unreachable_unchecked` with `TryFrom`.
2023-02-05 13:41:25 +01:00
Robin Krahl 1eb9ec76a7 Enforce namespace in FilesystemClient
This patch adds a check to FilesystemClient that makes sure that clients
cannot read out files that belong to other clients or that are not in
the data directory for the client.  To keep the check simple, we
completely forbid `..` in paths.

This is a breaking change as the Error enum is extended.

Fixes https://github.com/trussed-dev/trussed/issues/65
2023-02-03 17:10:32 +01:00
Robin Krahl 5c9bc60eae Add changelog
So far, we did not have a changelog.  This patch adds one and tries to
list all merged changes since the v0.1.0 release.
2023-02-03 10:28:18 +01:00
Robin Krahl db65ff08b9 Fix test command in readme
Executing the tests requires the `virt` feature.
2023-02-03 09:12:46 +01:00
Robin Krahl 47afe55313 Simplify ServiceResources implementation
This patch simplifies ServiceResources::reply_to by moving the store
construction into separate methods.  This will also make it possible for
custom backends to easily access the stores.
2023-01-31 10:39:49 +01:00
Robin Krahl 305bf1f44f Add docs check to CI 2023-01-30 16:02:27 +01:00
Sosthène Guédon 214baa029f Fix warning when building docs 2023-01-30 15:02:50 +01:00
Robin Krahl 199df9dbb9 Pin Rust version to 1.66.1
This fixes an issue with Rust 1.67.0 and littlefs2, see:
	https://github.com/trussed-dev/littlefs2/issues/26
2023-01-27 14:35:45 +01:00
Robin Krahl 1f672f2d1c Run clippy in CI 2023-01-26 18:24:50 +01:00
Robin Krahl 9808868695 Fix trivial clippy lints 2023-01-26 18:24:50 +01:00
Robin Krahl 22cdb6cca2 Ignore clippy lints that we don’t want to fix
We don’t want to fix some clippy lints to avoid breaking compatibility,
so we ignore them for the time being.
2023-01-26 18:24:50 +01:00
Robin Krahl 0f05d974c2 Disable clippy missing_safety_doc lint
clippy currently complains about missing safety docs.  This is not
trivial to fix because documentation is still sparse within Trussed, but
we want to ignore this for the time being to be able to use clippy in
the CI.
2023-01-26 18:24:50 +01:00
Robin Krahl 1f3cb9db10 Add cargo check --all-features --all-targets to CI 2023-01-25 12:34:42 +01:00
Robin Krahl 7d4137d487 Fix test-attestation-cert-ids feature 2023-01-25 12:34:42 +01:00
Robin Krahl ba5f1aeb63 Fix hmac{blake2s,sha512} mechanisms 2023-01-25 12:34:42 +01:00
Robin Krahl 58776db4cb Trigger syscall in PollClient::request
We can trigger the syscall as soon as we placed the request in the
interchange.  Doing that directly in PollClient::request instead of
calling PollClient::syscall afterwards makes the code a lot simpler.
2023-01-25 11:32:41 +01:00
Robin Krahl 75a8b59934 Simplify client implementations 2023-01-24 10:09:18 +01:00
Jan Nordholz 88de4c6b3a Move state from ServiceResources to ClientContext
The syscalls ReadDirFirst, ReadDirNext, ReadDirFilesFirst,
ReadDirFilesNext implement Trussed-based filesystem traversal. The
"cursor" is however kept in two quasi-global variables, so concurrent
walks interfere with each other.  Move these two cursor variables into
the new ClientContext struct instead.

Fixes https://github.com/trussed-dev/trussed/issues/64
2023-01-23 11:39:49 +01:00
Jan Nordholz d6c3e0f9ad Upgrade ClientId to a ClientContext struct
The service module uses ClientContext to carry client-specific metadata.
Previously, this was only the ID string, so a type alias for PathBuf was
sufficient. With the new ClientContext struct, we can keep track of
additional metadata like the state of state-ful syscalls.
2023-01-23 11:39:49 +01:00
Robin Krahl 9d2dfbde98 Fix formatting and check format in CI
This patch fixes a formatting error and adds a check to the CI that runs
`cargo fmt -- --check`.
2023-01-22 18:53:50 +01:00
Robin Krahl 9b9662d08e Build embedded runner for nk3 in CI 2022-12-20 15:25:14 +01:00
Robin Krahl 84219ec991 virt: Manually allocate and mount filesystems
This makes it possible to provide access to the raw IFS.  This is for
example required for the solo2/nk3 provisioner app.
2022-12-15 13:46:15 +01:00
Robin Krahl 5410707d1f virt: Make StoreProvider::store an associated function 2022-12-15 13:46:15 +01:00
Robin Krahl 292418bb6f virt: Move interchanges reset into with_platform
This makes sure that each caller of with_platform receives a clean state
even if Service::from is not called.
2022-12-15 13:46:15 +01:00