Closed Dustin-Ray closed 1 year ago
This:
msg.pw_encrypt(&pw, 512);
msg.pw_decrypt(&pw, 512);
Should look like this:
msg.pw_encrypt(&pw, 512);
msg.pw_decrypt(&pw);
This issue links to https://github.com/drcapybara/capyCRYPT/issues/27
Decryption and signature verification should -> Err if Message.d is not a supported value or not set.
This can be solved by simply adding a d
parameter to the Message
struct, and setting it in every function that accepts d
as a parameter.
For Example, in pw_encrypt
fn pw_encrypt(&mut self, pw: &[u8], d: u64) {
self.d = Some(d);
...
...
}
Then, in pw_decrypt
:
fn pw_decrypt(&mut self, pw: &[u8]) {
let mut z_pw = self.sym_nonce.clone().unwrap();
z_pw.append(&mut pw.to_owned());
let ke_ka = kmac_xof(&mut z_pw, &vec![], 1024, "S", &self.d);
...
...
}
The we can call like this:
msg.pw_encrypt(&pw, 512);
msg.pw_decrypt(&pw);
We might run into the borrow checker with this one. .clone()
on d
isnt a terrible solution since d
isnt large but using immutable references to d
should be preferred.
decryption and signature verification both assume well-formed input, so no need to request d for these operations