multiple RSA ciphertexts of post body's AES key

new-idea
Avril 4 years ago
parent ab05c34637
commit 0a1f7e2293
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -34,7 +34,7 @@ pub struct Ident
email: Option<IDMaxString>, email: Option<IDMaxString>,
} }
/// A single completed post /// A single completed post.
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
pub struct Post pub struct Post
{ {
@ -43,6 +43,11 @@ pub struct Post
/// Identifiers for this post /// Identifiers for this post
ident: Ident, 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 /// The client-side encrypted body string
body: PostBodyString, body: PostBodyString,
@ -147,11 +152,18 @@ impl Post
self.ident.tripcode.as_ref() self.ident.tripcode.as_ref()
} }
/// The body of this post /// The AES encrypted body of this post
pub fn body(&self) -> &PostBodyStr pub fn body(&self) -> &PostBodyStr
{ {
self.body.as_ref() 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. /// The PEM formatted signature of this post, if there is one.
pub fn signature(&self) -> Option<&PEMFormattedStr> pub fn signature(&self) -> Option<&PEMFormattedStr>
{ {
@ -174,6 +186,7 @@ mod tests
tripcode: Some(super::Tripcode::generate("uhh hello").unwrap()), tripcode: Some(super::Tripcode::generate("uhh hello").unwrap()),
}, },
body: super::PostBodyString::new(crate::hard_format::formats::Base64FormattedString::encode("Hello world").into()).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, signature: None,
hash: Default::default(), hash: Default::default(),

Loading…
Cancel
Save