Commit Graph

170 Commits

Author SHA1 Message Date
Jan Nordholz 5b0bfaede5 Fix SetServiceBackends so clients don't lock themselves out.
* Solution: Reject service backend arrays without "Software" in it.
* don't skip zeroes for Id::hex()
2022-11-10 13:36:28 +01:00
Jan Nordholz df7fd035bd Add new syscall to modify the chosen service backends.
This syscall can be used by clients to modify the selection, the
relative priority and the accompanying parameter structs for the
backends the client wants to use. As it doesn't fit any specific
category of existing Client trait, add it into the basic
PollClient - basically it's a meta-syscall, so this is the best fit.
2022-11-09 12:33:31 +01:00
Markus Meissner 6ec0a1045c ClientContext improvements
* use impl Into<ClientContext> for add_endpoint
* add ClientContextBuilder
* some symbol renaming `client_id` -> `client_ctx`
* fix tests
2022-11-09 12:33:28 +01:00
Jan Nordholz 479988c2a4 Add ServiceBackend trait, expand Platform macro. 2022-11-09 12:32:45 +01:00
Jan Nordholz faa079f39b Add abstraction for multiple service backends. 2022-11-09 12:32:45 +01:00
Jan Nordholz 88cd4ecc90 Move read_dir*state from ServiceResources to ClientId.
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 ClientId struct instead.
2022-11-09 12:32:45 +01:00
Jan Nordholz d7dbe261e4 (API Change) upgrade ClientId to a ClientContext struct.
The 'service' module uses ClientContext (via pipe::ServiceEndpoint::client_ctx) to
carry client-specific metadata. Previously, this was only the ID string, so
a type alias for PathBuf was sufficient. With the upcoming dynamic syscall
dispatch, the amount of client-specific state Trussed has to keep is going
to grow significantly. This commit creates the necessary scaffolding.

Minor changes:
  - in the filesystem-based software store implementations, use an explicit
    PathBuf - drop the ClientContext type import / alias redeclaration
  - pass ClientId around as a mutable reference in the reply_to() machinery,
    as we do not want to clone this structure arbitrarily when it gets large
    (as a sentinel, also stop deriving Clone for it)
2022-11-09 12:32:44 +01:00
Markus Meissner 369d32509b change *KeyStore<P> to KeyStore<S: Store>
* Generic `<P: Platform>` is never needed within `*KeyStore`
* KeyStore only needs `P::S` which is `Store`
* Now consistent with the other `*Store`s (which only use <S>)
2022-11-02 09:20:17 +01:00
Sosthène Guédon 28478f8abe Remove once-cell dependency
Since 1.63, Mutex::new is const
2022-10-11 16:59:37 +02:00
Sosthène Guédon 114f9081e0 Document virt module 2022-10-11 16:59:37 +02:00
Sosthène Guédon 6de826f3bc unsafe_inject_key: Add support for Aes256Cbc 2022-10-04 16:10:46 +02:00
Sosthène Guédon 4f7f79ef08 Remove deprecation comment 2022-10-04 16:10:46 +02:00
Sosthène Guédon ed931ac2ca Add unsafe_inject_ley support for Ed255 2022-10-04 16:10:46 +02:00
Sosthène Guédon 73ea4687d9 Add unsafe_inject_key support for P256 2022-10-04 16:10:46 +02:00
Sosthène Guédon 11766c2bbb Implement UnsafeInjectKey for X255 2022-10-04 16:10:46 +02:00
Sosthène Guédon c728c0ea57 Virt: require Sync + Send for the UI
This is needed for testing Opcard-rs with openpgp-card v 0.3
2022-09-29 21:17:15 +02:00
Sosthène Guédon ed4fdccd01 Fix off by one error in the RandomBytes request 2022-09-29 17:22:50 +02:00
Sosthène Guédon baab96d27e Add SharedSecret mechanism used for serialization 2022-09-13 21:35:36 +02:00
Sosthène Guédon de939265cb Add Serializable field to StorageAttributes
When used with `agree`, this flag enables the use of serialize on the
resulting shared secret
2022-09-13 21:35:36 +02:00
Sosthène Guédon 71dd2e50e9 Make StorageAttributes #[non_exhaustive]
It already has a builder which allows adding new fields without making
it a breaking changes in the future. This commit is a breaking change
2022-09-13 21:35:36 +02:00
Sosthène Guédon 1e2b12a2b5 Add test for key confusion 2022-09-11 22:52:32 +02:00
Sosthène Guédon e371bf90f4 Add tests for AES and TDES 2022-09-11 22:52:32 +02:00
Sosthène Guédon b0212a4c06 Fix key confusion for symmetric ciphers 2022-09-11 22:52:32 +02:00
Robin Krahl 9efe4f9696 Document key flags
This patch adds documentation for the existing key flags.
2022-09-11 22:29:49 +02:00
Nicolas Stalder 8e347abf99 Run cargo fmt 2022-09-11 22:28:21 +02:00
Robin Krahl 3da56d8e41 virt: Add StoreProvider trait
With this patch, we separate the store management (i. e. resetting it
when a Service is constructed) from the actual Store implementation.
This allows us to have a static lifetime for our clients as we can take
ownership of all required resources.
2022-07-26 00:07:56 +02:00
Sosthène Guédon a69f4bd80e Add basic filesystem tests 2022-07-26 00:05:42 +02:00
Sosthène Guédon 8006bfd426 Add entry_metadata method to FilesystemClient 2022-07-26 00:05:42 +02:00
Sosthène Guédon 471f5e0604 Fix needless_borrow clippy warnings 2022-07-21 22:20:17 +02:00
Robin Krahl feb5971a38 virt: Fix typo in comment 2022-07-21 16:29:06 +02:00
Robin Krahl a305edadda Enable virt feature on docs.rs 2022-07-21 16:29:06 +02:00
Robin Krahl 6cf923b2a5 Require virt feature in tests 2022-07-21 16:29:06 +02:00
Robin Krahl 2a6210266b virt: Add Client typedef 2022-07-21 16:29:06 +02:00
Robin Krahl d9daf6b8c7 virt: Add filesystem store 2022-07-21 16:29:06 +02:00
Robin Krahl 1cc4fd9694 Enable virt feature for tests in CI 2022-07-21 16:29:06 +02:00
Robin Krahl f203946b61 Add virtual client implementation 2022-07-21 16:29:06 +02:00
Sosthène Guédon b26fe646c8 Add try_into_new_client method to Service
This is similar to try_as_new_client except that the resulting
ClientImplementation owns the service instead of a mutable reference to
it, making it 'static
2022-07-21 16:27:15 +02:00
Sosthène Guédon 9f89f70a78 Implement Syscall for Service
Syscall was previously only implemented for &mut Syscall
which was limiting for generics over owned Service
2022-07-21 16:27:15 +02:00
Sosthène Guédon bc16c7df79 Return an Option<Metadata> 2022-07-21 16:25:15 +02:00
Sosthène Guédon 5f07124050 Add metadata method to the FilesystemClient and Filestore traits
This method allows efficient probing of files and directories, and is especially useful to know if
they exist or not
2022-07-21 16:25:15 +02:00
Jan Nordholz 258fe26ce8 Add a low-level ctor to the store macro: $store::init_raw().
Existing constructors (allocate(), mount(), attach_else_format()) all do
the heavy lifting of the construction. Users might want to do those steps
on their own to have more fine-grained control over which areas of storage
are safe to reformat and generally better error handling. Therefore add a
low-level constructor that only creates the Fs wrappers and populates the
ifs/efs/vfs globals.
2022-07-03 11:57:24 +02:00
Markus Meissner dc01d5aaa9 Cargo.toml set clients-5, best representation of prior state 2022-07-03 11:57:24 +02:00
Jan Nordholz 768ea1aaa6 Set config::MAX_SERVICE_CLIENTS based on clients-$N feature
The number of supported clients is configurable through a crate feature,
but the feature is only honored in the Interchange handling in src/pipe.rs.
The config::MAX_SERVICE_CLIENTS type, which is used to set the size of the
"endpoints" Vec<> in src/service.rs, was still hardcoded to consts::U5.
2022-07-03 11:57:24 +02:00
Markus Meissner 05dbdcad7f gh-act: build solo2/nk3-fw repos for trussed-main 2022-06-27 13:56:35 +02:00
Nicolas Stalder 269e71ab71 Homepage 0.1.0 2022-03-17 03:28:37 +01:00
Nicolas Stalder 8ddbd0e48f More 2021 edition 2022-03-17 03:26:23 +01:00
Nicolas Stalder 916e90d004 2021 edition 2022-03-17 03:22:36 +01:00
Nicolas Stalder 91998fbfcc Remove wildcard constraint 2022-03-17 03:22:00 +01:00
Nicolas Stalder 790ee230e9 Don't panic 2022-03-15 23:14:49 +01:00
Nicolas Stalder eb8b08a45b Platform.status method 2022-03-08 22:39:47 +01:00