/// Encrypt a plaintext. /// /// The space provided in `output` needs to be larger than `input` by /// the value provided in `Aead::expansion`. /// /// # Errors /// /// If the input can't be protected or any input is too large for NSS. pubfn encrypt<'a>(
&self,
count: u64,
aad: &[u8],
input: &[u8],
output: &'a mut [u8],
) -> Res<&'a [u8]> { letmut l: c_uint = 0; unsafe {
SSL_AeadEncrypt(
*self.ctx,
count,
aad.as_ptr(),
c_uint::try_from(aad.len())?,
input.as_ptr(),
c_uint::try_from(input.len())?,
output.as_mut_ptr(),
&mut l,
c_uint::try_from(output.len())?,
)
}?;
Ok(&output[0..(l.try_into()?)])
}
/// Decrypt a ciphertext. /// /// Note that NSS insists upon having extra space available for decryption, so /// the buffer for `output` should be the same length as `input`, even though /// the final result will be shorter. /// /// # Errors /// /// If the input isn't authenticated or any input is too large for NSS. pubfn decrypt<'a>(
&self,
count: u64,
aad: &[u8],
input: &[u8],
output: &'a mut [u8],
) -> Res<&'a [u8]> { letmut l: c_uint = 0; unsafe {
SSL_AeadDecrypt(
*self.ctx,
count,
aad.as_ptr(),
c_uint::try_from(aad.len())?,
input.as_ptr(),
c_uint::try_from(input.len())?,
output.as_mut_ptr(),
&mut l,
c_uint::try_from(output.len())?,
)
}?;
Ok(&output[0..(l.try_into()?)])
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.