|
@@ -29,7 +29,7 @@ use std::{marker::PhantomData, num::TryFromIntError, str::FromStr};
|
|
|
use strum_macros::{Display, EnumDiscriminants, EnumString};
|
|
|
use zeroize::ZeroizeOnDrop;
|
|
|
|
|
|
-#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
|
|
|
+#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)]
|
|
|
pub struct Ciphertext<T> {
|
|
|
data: Vec<u8>,
|
|
|
phantom: PhantomData<T>,
|
|
@@ -335,7 +335,7 @@ impl Display for Hash {
|
|
|
}
|
|
|
|
|
|
/// A cryptographic signature.
|
|
|
-#[derive(Debug, PartialEq, Serialize, Deserialize, Clone, Default)]
|
|
|
+#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone, Default)]
|
|
|
pub struct Signature {
|
|
|
kind: Sign,
|
|
|
data: Vec<u8>,
|
|
@@ -493,7 +493,7 @@ impl AeadKey {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-#[derive(Debug, PartialEq, Serialize, Deserialize, Clone, EnumDiscriminants, ZeroizeOnDrop)]
|
|
|
+#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone, EnumDiscriminants, ZeroizeOnDrop)]
|
|
|
#[strum_discriminants(name(SymKeyKind))]
|
|
|
pub enum SymKey {
|
|
|
/// A key for the AES 256 cipher in Cipher Block Chaining mode. Note that this includes the
|
|
@@ -620,7 +620,7 @@ pub enum SchemeKind {
|
|
|
Encrypt(Encrypt),
|
|
|
}
|
|
|
|
|
|
-#[derive(Deserialize, Serialize, Clone, Debug, PartialEq, Copy)]
|
|
|
+#[derive(Deserialize, Serialize, Clone, Debug, PartialEq, Eq, Copy)]
|
|
|
pub enum Encrypt {
|
|
|
RsaEsOaep(RsaEsOaep),
|
|
|
}
|
|
@@ -681,7 +681,7 @@ impl Encrypt {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-#[derive(Deserialize, Serialize, Clone, Debug, PartialEq, Copy)]
|
|
|
+#[derive(Deserialize, Serialize, Clone, Debug, PartialEq, Eq, Copy)]
|
|
|
pub enum Sign {
|
|
|
RsaSsaPss(RsaSsaPss),
|
|
|
}
|
|
@@ -769,7 +769,7 @@ impl Rsa {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-#[derive(Deserialize, Serialize, Clone, Debug, PartialEq, Copy)]
|
|
|
+#[derive(Deserialize, Serialize, Clone, Debug, PartialEq, Eq, Copy)]
|
|
|
pub struct RsaEsOaep {
|
|
|
key_len: KeyLen,
|
|
|
hash_kind: HashKind,
|
|
@@ -813,7 +813,7 @@ impl From<RsaEsOaep> for Encrypt {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-#[derive(Deserialize, Serialize, Clone, Debug, PartialEq, Copy)]
|
|
|
+#[derive(Deserialize, Serialize, Clone, Debug, PartialEq, Eq, Copy)]
|
|
|
pub struct RsaSsaPss {
|
|
|
key_bits: KeyLen,
|
|
|
hash_kind: HashKind,
|
|
@@ -1185,6 +1185,8 @@ pub trait Encrypter {
|
|
|
}
|
|
|
|
|
|
pub trait EncrypterExt: Encrypter {
|
|
|
+ /// Serializes the given value into a new vector, then encrypts it and returns the resulting
|
|
|
+ /// ciphertext.
|
|
|
fn ser_encrypt<T: Serialize>(&self, value: &T) -> Result<Ciphertext<T>> {
|
|
|
let data = to_vec(value)?;
|
|
|
let data = self.encrypt(&data)?;
|
|
@@ -1332,7 +1334,7 @@ impl BlockMeta {
|
|
|
|
|
|
/// The types of errors which can occur when verifying a writecap chain is authorized to write to
|
|
|
/// a given path.
|
|
|
-#[derive(Debug, PartialEq, Display)]
|
|
|
+#[derive(Debug, PartialEq, Eq, Display)]
|
|
|
pub enum WritecapAuthzErr {
|
|
|
/// The chain is not valid for use on the given path.
|
|
|
UnauthorizedPath,
|
|
@@ -1422,8 +1424,8 @@ mod tests {
|
|
|
fn encrypt_decrypt_block() {
|
|
|
const SECT_SZ: usize = 16;
|
|
|
const SECT_CT: usize = 8;
|
|
|
- let key = make_key_pair();
|
|
|
- let readcap = make_readcap_for(&key);
|
|
|
+ let creds = make_key_pair();
|
|
|
+ let readcap = make_readcap_for(&creds);
|
|
|
let mut block = make_block_with(readcap);
|
|
|
write_fill(&mut block, SECT_SZ, SECT_CT);
|
|
|
block.seek(SeekFrom::Start(0)).expect("seek failed");
|