Skip to content

Commit 4b1564e

Browse files
committed
Fix mutability of oneshot sign/verify methods
1 parent 972c7ae commit 4b1564e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

openssl/src/sign.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ impl<'a> Signer<'a> {
354354
///
355355
/// [`EVP_DigestSign`]: https://www.openssl.org/docs/man1.1.1/man3/EVP_DigestSign.html
356356
#[cfg(ossl111)]
357-
pub fn sign_oneshot(&self, sig_buf: &mut [u8], data_buf: &[u8]) -> Result<usize, ErrorStack> {
357+
pub fn sign_oneshot(&mut self, sig_buf: &mut [u8], data_buf: &[u8]) -> Result<usize, ErrorStack> {
358358
unsafe {
359359
let mut sig_len = sig_buf.len();
360360
cvt(ffi::EVP_DigestSign(
@@ -372,7 +372,7 @@ impl<'a> Signer<'a> {
372372
///
373373
/// This is a simple convenience wrapper over `len` and `sign_oneshot`.
374374
#[cfg(ossl111)]
375-
pub fn sign_oneshot_to_vec(&self, data_buf: &[u8]) -> Result<Vec<u8>, ErrorStack> {
375+
pub fn sign_oneshot_to_vec(&mut self, data_buf: &[u8]) -> Result<Vec<u8>, ErrorStack> {
376376
let mut sig_buf = vec![0; self.len()?];
377377
let len = self.sign_oneshot(&mut sig_buf, data_buf)?;
378378
// The advertised length is not always equal to the real length for things like DSA
@@ -584,7 +584,7 @@ impl<'a> Verifier<'a> {
584584
///
585585
/// [`EVP_DigestVerify`]: https://www.openssl.org/docs/man1.1.1/man3/EVP_DigestVerify.html
586586
#[cfg(ossl111)]
587-
pub fn verify_oneshot(&self, signature: &[u8], buf: &[u8]) -> Result<bool, ErrorStack> {
587+
pub fn verify_oneshot(&mut self, signature: &[u8], buf: &[u8]) -> Result<bool, ErrorStack> {
588588
unsafe {
589589
let r = ffi::EVP_DigestVerify(
590590
self.md_ctx,
@@ -831,10 +831,10 @@ mod test {
831831
fn eddsa() {
832832
let key = PKey::generate_ed25519().unwrap();
833833

834-
let signer = Signer::new_without_digest(&key).unwrap();
834+
let mut signer = Signer::new_without_digest(&key).unwrap();
835835
let signature = signer.sign_oneshot_to_vec(b"hello world").unwrap();
836836

837-
let verifier = Verifier::new_without_digest(&key).unwrap();
837+
let mut verifier = Verifier::new_without_digest(&key).unwrap();
838838
assert!(verifier.verify_oneshot(&signature, b"hello world").unwrap());
839839
}
840840

0 commit comments

Comments
 (0)