mirror of
https://github.com/trussed-dev/trussed-staging.git
synced 2026-06-20 04:16:23 -07:00
Merge pull request #10 from Nitrokey/visibility
Fix visiblity to allow out-of-crate implementations
This commit is contained in:
+1
-1
@@ -41,4 +41,4 @@ log-warn = []
|
||||
log-error = []
|
||||
|
||||
[patch.crates-io]
|
||||
trussed = { git = "https://github.com/trussed-dev/trussed.git", rev = "51e68500d7601d04f884f5e95567d14b9018a6cb" }
|
||||
trussed = { git = "https://github.com/trussed-dev/trussed.git", rev = "df720980888e3e0d5487250bd14a28db02a5f13b" }
|
||||
|
||||
@@ -430,7 +430,7 @@ impl ExtensionImpl<ChunkedExtension> for super::StagingBackend {
|
||||
resources: &mut ServiceResources<P>,
|
||||
) -> Result<ChunkedReply, Error> {
|
||||
let rng = &mut resources.rng()?;
|
||||
let keystore = &mut resources.keystore(core_ctx)?;
|
||||
let keystore = &mut resources.keystore(core_ctx.path.clone())?;
|
||||
let filestore = &mut resources.filestore(core_ctx.path.clone());
|
||||
let client_id = &core_ctx.path;
|
||||
let store = resources.platform_mut().store();
|
||||
@@ -482,7 +482,8 @@ impl ExtensionImpl<ChunkedExtension> for super::StagingBackend {
|
||||
Ok(reply::WriteChunk {}.into())
|
||||
}
|
||||
ChunkedRequest::AbortChunkedWrite(_request) => {
|
||||
let Some(ChunkedIoState::Write(ref write_state)) = backend_ctx.chunked_io_state else {
|
||||
let Some(ChunkedIoState::Write(ref write_state)) = backend_ctx.chunked_io_state
|
||||
else {
|
||||
return Ok(reply::AbortChunkedWrite { aborted: false }.into());
|
||||
};
|
||||
let aborted = store::abort_chunked_write(
|
||||
@@ -673,7 +674,9 @@ fn read_encrypted_chunk(
|
||||
ctx: &mut StagingContext,
|
||||
) -> Result<ChunkedReply, Error> {
|
||||
let Some(ChunkedIoState::EncryptedRead(ref mut read_state)) = ctx.chunked_io_state else {
|
||||
unreachable!("Read encrypted chunk can only be called in the context encrypted chunk reads");
|
||||
unreachable!(
|
||||
"Read encrypted chunk can only be called in the context encrypted chunk reads"
|
||||
);
|
||||
};
|
||||
let (mut data, len): (Bytes<{ MAX_MESSAGE_LENGTH + POLY1305_TAG_LEN }>, usize) =
|
||||
store::filestore_read_chunk(
|
||||
@@ -765,7 +768,7 @@ pub trait ChunkedClient: ExtensionClient<ChunkedExtension> + FilesystemClient {
|
||||
/// Begin writing an encrypted file that can be larger than 1KiB
|
||||
///
|
||||
/// More chunks can be written with [`write_file_chunk`](ChunkedClient::write_file_chunk).
|
||||
/// The data is flushed and becomes readable when a chunk smaller than the maximum capacity of a [`Message`](trussed::types::Message) is transfered.
|
||||
/// The data is flushed and becomes readable when a chunk smaller than the maximum capacity of a [`Message`] is transfered.
|
||||
#[cfg(feature = "encrypted-chunked")]
|
||||
fn start_encrypted_chunked_write(
|
||||
&mut self,
|
||||
@@ -787,7 +790,7 @@ pub trait ChunkedClient: ExtensionClient<ChunkedExtension> + FilesystemClient {
|
||||
/// Begin reading a file that can be larger than 1KiB
|
||||
///
|
||||
/// More chunks can be read with [`read_file_chunk`](ChunkedClient::read_file_chunk).
|
||||
/// The read is over once a chunk of size smaller than the maximum capacity of a [`Message`](trussed::types::Message) is transfered.
|
||||
/// The read is over once a chunk of size smaller than the maximum capacity of a [`Message`] is transfered.
|
||||
fn start_chunked_read(
|
||||
&mut self,
|
||||
location: Location,
|
||||
@@ -799,7 +802,7 @@ pub trait ChunkedClient: ExtensionClient<ChunkedExtension> + FilesystemClient {
|
||||
/// Begin reading an encrypted file that can be larger than 1KiB
|
||||
///
|
||||
/// More chunks can be read with [`read_file_chunk`](ChunkedClient::read_file_chunk).
|
||||
/// The read is over once a chunk of size smaller than the maximum capacity of a [`Message`](trussed::types::Message) is transfered.
|
||||
/// The read is over once a chunk of size smaller than the maximum capacity of a [`Message`] is transfered.
|
||||
/// Only once the entire file has been read does the data have been properly authenticated.
|
||||
#[cfg(feature = "encrypted-chunked")]
|
||||
fn start_encrypted_chunked_read(
|
||||
|
||||
@@ -268,9 +268,9 @@ pub fn abort_chunked_write(
|
||||
path: &PathBuf,
|
||||
location: Location,
|
||||
) -> bool {
|
||||
let Ok(path) = chunks_path(client_id,path, location) else {
|
||||
return false;
|
||||
};
|
||||
let Ok(path) = chunks_path(client_id, path, location) else {
|
||||
return false;
|
||||
};
|
||||
trussed::store::delete(store, Location::Volatile, &path)
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
// Copyright (C) Nitrokey GmbH
|
||||
// SPDX-License-Identifier: Apache-2.0 or MIT
|
||||
|
||||
//! Wrapper around [`trussed::virt`][] that provides clients with both the core backend and the [`StagingBackend`](crate::StagingBackend) backend.
|
||||
//! Wrapper around [`trussed::virt`][] that provides clients with both the core backend and the [`StagingBackend`] backend.
|
||||
|
||||
#[cfg(feature = "wrap-key-to-file")]
|
||||
use crate::wrap_key_to_file::WrapKeyToFileExtension;
|
||||
|
||||
@@ -28,7 +28,7 @@ pub enum WrapKeyToFileRequest {
|
||||
UnwrapKeyFromFile(request::UnwrapKeyFromFile),
|
||||
}
|
||||
|
||||
mod request {
|
||||
pub mod request {
|
||||
use super::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use trussed::types::{KeyId, Location, Mechanism, Message, PathBuf};
|
||||
@@ -94,13 +94,13 @@ pub enum WrapKeyToFileReply {
|
||||
UnwrapKeyFromFile(reply::UnwrapKeyFromFile),
|
||||
}
|
||||
|
||||
mod reply {
|
||||
pub mod reply {
|
||||
use serde::{Deserialize, Serialize};
|
||||
use trussed::{types::KeyId, Error};
|
||||
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
#[derive(Debug, Deserialize, Serialize, Default)]
|
||||
#[non_exhaustive]
|
||||
pub struct WrapKeyToFile {}
|
||||
|
||||
@@ -248,7 +248,7 @@ impl ExtensionImpl<WrapKeyToFileExtension> for super::StagingBackend {
|
||||
request: &WrapKeyToFileRequest,
|
||||
resources: &mut ServiceResources<P>,
|
||||
) -> Result<WrapKeyToFileReply, Error> {
|
||||
let keystore = &mut resources.keystore(core_ctx)?;
|
||||
let keystore = &mut resources.keystore(core_ctx.path.clone())?;
|
||||
let filestore = &mut resources.filestore(core_ctx.path.clone());
|
||||
match request {
|
||||
WrapKeyToFileRequest::WrapKeyToFile(request) => {
|
||||
|
||||
Reference in New Issue
Block a user