Include integrity hash in serialized bytes
This commit is contained in:
@@ -11,8 +11,8 @@ use reqwest::{Method, Response};
|
||||
use ring::rand::SystemRandom;
|
||||
use ring::signature::{ECDSA_P256_SHA256_FIXED_SIGNING, EcdsaKeyPair, EcdsaSigningAlgorithm};
|
||||
use serde::Deserialize;
|
||||
use store::Serialize;
|
||||
use store::write::Archiver;
|
||||
use store::{Serialize, SerializedVersion};
|
||||
use trc::AddContext;
|
||||
use trc::event::conv::AssertSuccess;
|
||||
|
||||
@@ -210,6 +210,12 @@ pub struct SerializedCert {
|
||||
pub private_key: Vec<u8>,
|
||||
}
|
||||
|
||||
impl SerializedVersion for SerializedCert {
|
||||
fn serialize_version() -> u8 {
|
||||
0
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Directory {
|
||||
|
||||
@@ -13,7 +13,10 @@ use rustls::{
|
||||
sign::CertifiedKey,
|
||||
};
|
||||
use rustls_pki_types::{CertificateDer, PrivateKeyDer, PrivatePkcs8KeyDer};
|
||||
use store::{dispatch::lookup::KeyValue, write::Archive};
|
||||
use store::{
|
||||
dispatch::lookup::KeyValue,
|
||||
write::{AlignedBytes, Archive},
|
||||
};
|
||||
use trc::AcmeEvent;
|
||||
|
||||
use crate::{KV_ACME, Server};
|
||||
@@ -48,7 +51,7 @@ impl Server {
|
||||
pub(crate) async fn build_acme_certificate(&self, domain: &str) -> Option<Arc<CertifiedKey>> {
|
||||
match self
|
||||
.in_memory_store()
|
||||
.key_get::<Archive>(KeyValue::<()>::build_key(KV_ACME, domain))
|
||||
.key_get::<Archive<AlignedBytes>>(KeyValue::<()>::build_key(KV_ACME, domain))
|
||||
.await
|
||||
{
|
||||
Ok(Some(cert_)) => match cert_.unarchive::<SerializedCert>() {
|
||||
|
||||
@@ -7,8 +7,9 @@
|
||||
use ahash::AHashMap;
|
||||
use jmap_proto::types::{collection::Collection, property::Property};
|
||||
use store::{
|
||||
Deserialize, IndexKey, IterateParams, SerializeInfallible, U32_LEN, ValueKey,
|
||||
write::{Archive, ValueClass, key::DeserializeBigEndian},
|
||||
Deserialize, IndexKey, IterateParams, SerializeInfallible, SerializedVersion, U32_LEN,
|
||||
ValueKey,
|
||||
write::{AlignedBytes, Archive, ValueClass, key::DeserializeBigEndian},
|
||||
};
|
||||
use trc::AddContext;
|
||||
use utils::topological::{TopologicalSort, TopologicalSortIterator};
|
||||
@@ -48,7 +49,7 @@ impl Server {
|
||||
collection: Collection,
|
||||
) -> trc::Result<ExpandedFolders>
|
||||
where
|
||||
T: rkyv::Archive,
|
||||
T: rkyv::Archive + SerializedVersion,
|
||||
T::Archived: FolderHierarchy
|
||||
+ for<'a> rkyv::bytecheck::CheckBytes<
|
||||
rkyv::api::high::HighValidator<'a, rkyv::rancor::Error>,
|
||||
@@ -79,7 +80,7 @@ impl Server {
|
||||
),
|
||||
|key, value| {
|
||||
let document_id = key.deserialize_be_u32(key.len() - U32_LEN)?;
|
||||
let archive = <Archive as Deserialize>::deserialize(value)?;
|
||||
let archive = <Archive<AlignedBytes> as Deserialize>::deserialize(value)?;
|
||||
let folder = archive.unarchive::<T>()?;
|
||||
let parent_id = folder.parent_id();
|
||||
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
use jmap_proto::types::{property::Property, value::AclGrant};
|
||||
use std::{borrow::Cow, collections::HashSet, fmt::Debug};
|
||||
use store::{
|
||||
Serialize, SerializeInfallible,
|
||||
Serialize, SerializeInfallible, SerializedVersion,
|
||||
write::{
|
||||
Archiver, BatchBuilder, BitmapClass, BlobOp, DirectoryClass, IntoOperations, Operation,
|
||||
assert::HashedValue,
|
||||
Archive, Archiver, BatchBuilder, BitmapClass, BlobOp, DirectoryClass, IntoOperations,
|
||||
Operation,
|
||||
},
|
||||
};
|
||||
use utils::BlobHash;
|
||||
@@ -35,6 +35,7 @@ pub trait IndexableObject: Sync + Send {
|
||||
|
||||
pub trait IndexableAndSerializableObject:
|
||||
IndexableObject
|
||||
+ SerializedVersion
|
||||
+ rkyv::Archive
|
||||
+ for<'a> rkyv::Serialize<
|
||||
rkyv::api::high::HighSerializer<
|
||||
@@ -49,7 +50,7 @@ pub trait IndexableAndSerializableObject:
|
||||
#[derive(Debug)]
|
||||
pub struct ObjectIndexBuilder<C: IndexableObject, N: IndexableAndSerializableObject> {
|
||||
tenant_id: Option<u32>,
|
||||
current: Option<HashedValue<C>>,
|
||||
current: Option<Archive<C>>,
|
||||
changes: Option<N>,
|
||||
}
|
||||
|
||||
@@ -68,7 +69,7 @@ impl<C: IndexableObject, N: IndexableAndSerializableObject> ObjectIndexBuilder<C
|
||||
}
|
||||
}
|
||||
|
||||
pub fn with_current(mut self, current: HashedValue<C>) -> Self {
|
||||
pub fn with_current(mut self, current: Archive<C>) -> Self {
|
||||
self.current = Some(current);
|
||||
self
|
||||
}
|
||||
@@ -78,7 +79,7 @@ impl<C: IndexableObject, N: IndexableAndSerializableObject> ObjectIndexBuilder<C
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_current_opt(mut self, current: Option<HashedValue<C>>) -> Self {
|
||||
pub fn with_current_opt(mut self, current: Option<Archive<C>>) -> Self {
|
||||
self.current = current;
|
||||
self
|
||||
}
|
||||
@@ -91,7 +92,7 @@ impl<C: IndexableObject, N: IndexableAndSerializableObject> ObjectIndexBuilder<C
|
||||
self.changes.as_mut()
|
||||
}
|
||||
|
||||
pub fn current(&self) -> Option<&HashedValue<C>> {
|
||||
pub fn current(&self) -> Option<&Archive<C>> {
|
||||
self.current.as_ref()
|
||||
}
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@ use std::slice::IterMut;
|
||||
|
||||
use jmap_proto::types::property::Property;
|
||||
use store::{
|
||||
Serialize,
|
||||
write::{Archiver, BatchBuilder, MaybeDynamicId, TagValue, ValueClass, assert::HashedValue},
|
||||
Serialize, SerializedVersion,
|
||||
write::{Archive, Archiver, BatchBuilder, MaybeDynamicId, TagValue, ValueClass},
|
||||
};
|
||||
|
||||
pub struct TagManager<
|
||||
@@ -27,7 +27,7 @@ pub struct TagManager<
|
||||
>,
|
||||
>,
|
||||
> {
|
||||
current: HashedValue<Vec<T>>,
|
||||
current: Archive<Vec<T>>,
|
||||
added: Vec<T>,
|
||||
removed: Vec<T>,
|
||||
last: LastTag,
|
||||
@@ -45,6 +45,7 @@ impl<
|
||||
+ Clone
|
||||
+ Sync
|
||||
+ Send
|
||||
+ SerializedVersion
|
||||
+ rkyv::Archive
|
||||
+ for<'a> rkyv::Serialize<
|
||||
rkyv::api::high::HighSerializer<
|
||||
@@ -55,7 +56,7 @@ impl<
|
||||
>,
|
||||
> TagManager<T>
|
||||
{
|
||||
pub fn new(current: HashedValue<Vec<T>>) -> Self {
|
||||
pub fn new(current: Archive<Vec<T>>) -> Self {
|
||||
Self {
|
||||
current,
|
||||
added: Vec::new(),
|
||||
|
||||
Reference in New Issue
Block a user