Replace AeadCipher::seal with AeadCipher::seal_to

This commit is contained in:
Jack Grigg 2019-06-05 13:55:17 +01:00
parent edf7bc144d
commit 6d03b5c1db
No known key found for this signature in database
GPG Key ID: 9E8255172BBF9898
1 changed files with 7 additions and 11 deletions

View File

@ -326,26 +326,22 @@ impl SaplingNoteEncryption {
) -> [u8; OUT_CIPHERTEXT_SIZE] { ) -> [u8; OUT_CIPHERTEXT_SIZE] {
let key = prf_ock(&self.ovk, &cv, &cmu, &self.epk); let key = prf_ock(&self.ovk, &cv, &cmu, &self.epk);
let mut buf = [0u8; OUT_CIPHERTEXT_SIZE]; let mut input = [0u8; OUT_PLAINTEXT_SIZE];
self.note.pk_d.write(&mut buf[0..32]).unwrap(); self.note.pk_d.write(&mut input[0..32]).unwrap();
self.esk self.esk
.into_repr() .into_repr()
.write_le(&mut buf[32..OUT_PLAINTEXT_SIZE]) .write_le(&mut input[32..OUT_PLAINTEXT_SIZE])
.unwrap(); .unwrap();
let mut output = [0u8; OUT_CIPHERTEXT_SIZE];
assert_eq!( assert_eq!(
ChachaPolyIetf::aead_cipher() ChachaPolyIetf::aead_cipher()
.seal( .seal_to(&mut output, &input, &[], key.as_bytes(), &[0u8; 12])
&mut buf,
OUT_PLAINTEXT_SIZE,
&[],
key.as_bytes(),
&[0u8; 12]
)
.unwrap(), .unwrap(),
OUT_CIPHERTEXT_SIZE OUT_CIPHERTEXT_SIZE
); );
buf
output
} }
} }