-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement
RopsMap::encrypt{,_with_saved_nonces}()
.
- Loading branch information
Showing
11 changed files
with
233 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
use std::marker::PhantomData; | ||
|
||
use serde::{Deserialize, Serialize}; | ||
|
||
use crate::*; | ||
|
||
#[derive(Debug, PartialEq, Serialize, Deserialize)] | ||
#[serde(transparent)] | ||
pub struct RopsFileFormatMap<S: RopsFileState, F: FileFormat> { | ||
#[serde(flatten)] | ||
inner: F::Map, | ||
#[serde(skip)] | ||
state_marker: PhantomData<S>, | ||
} | ||
|
||
// IMPROVEMENT: Might be worth splitting distinguishing decrypted and | ||
// encrypted map to tree errors by separating then into two enums. | ||
#[derive(Debug, thiserror::Error)] | ||
pub enum FormatToInternalMapError { | ||
#[error("only string keys are supported, found: {0}")] | ||
NonStringKey(String), | ||
#[error("integer out of range, allowed values must fit inside an i64, found: {0}")] | ||
IntegerOutOfRange(u64), | ||
#[error("unable to parse encrypted value components: {0}")] | ||
EncryptedRopsValue(#[from] EncryptedRopsValueFromStrError), | ||
// TEMP: Deprecate once partial encryption feature arrives. | ||
#[error("invalid valid for an encrypted file")] | ||
InvalidValueForEncrypted(String), | ||
} | ||
|
||
impl<S: RopsFileState, F: FileFormat> RopsFileFormatMap<S, F> { | ||
pub fn into_inner_map(self) -> F::Map { | ||
self.inner | ||
} | ||
|
||
#[cfg(feature = "test-utils")] | ||
pub fn from_inner_map(inner: F::Map) -> Self { | ||
Self { | ||
inner, | ||
state_marker: PhantomData, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.