|
|
|
@ -34,7 +34,7 @@ pub struct Ident
|
|
|
|
|
email: Option<IDMaxString>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// A single completed post
|
|
|
|
|
/// A single completed post.
|
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
|
|
|
|
|
pub struct Post
|
|
|
|
|
{
|
|
|
|
@ -43,6 +43,11 @@ pub struct Post
|
|
|
|
|
|
|
|
|
|
/// Identifiers for this post
|
|
|
|
|
ident: Ident,
|
|
|
|
|
|
|
|
|
|
/// The client-side generated AES key used for decrypting the body's text.
|
|
|
|
|
///
|
|
|
|
|
/// This AES key can be encrypted with any number of RSA public keys on the client side. There must be at least one, or the post body is lost.
|
|
|
|
|
body_aes_keys: Vec<PostBodyString>,
|
|
|
|
|
|
|
|
|
|
/// The client-side encrypted body string
|
|
|
|
|
body: PostBodyString,
|
|
|
|
@ -147,11 +152,18 @@ impl Post
|
|
|
|
|
self.ident.tripcode.as_ref()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// The body of this post
|
|
|
|
|
/// The AES encrypted body of this post
|
|
|
|
|
pub fn body(&self) -> &PostBodyStr
|
|
|
|
|
{
|
|
|
|
|
self.body.as_ref()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// An iterator of RSA ciphertexts of the AES key used to encrypt the body text.
|
|
|
|
|
pub fn body_keys<'a>(&'a self) -> impl Iterator<Item = &'a PostBodyStr> + ExactSizeIterator + 'a
|
|
|
|
|
{
|
|
|
|
|
self.body_aes_keys.iter().map(|x| x.as_ref())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// The PEM formatted signature of this post, if there is one.
|
|
|
|
|
pub fn signature(&self) -> Option<&PEMFormattedStr>
|
|
|
|
|
{
|
|
|
|
@ -174,6 +186,7 @@ mod tests
|
|
|
|
|
tripcode: Some(super::Tripcode::generate("uhh hello").unwrap()),
|
|
|
|
|
},
|
|
|
|
|
body: super::PostBodyString::new(crate::hard_format::formats::Base64FormattedString::encode("Hello world").into()).unwrap(),
|
|
|
|
|
body_aes_keys: vec![super::PostBodyString::new(crate::hard_format::formats::Base64FormattedString::encode("TODO").into()).unwrap()],
|
|
|
|
|
signature: None,
|
|
|
|
|
hash: Default::default(),
|
|
|
|
|
|
|
|
|
|