Skip to content

Commit ce5e9e4

Browse files
committed
Remove PkeyCtxRef::digest() getter
1 parent 7a66dad commit ce5e9e4

File tree

4 files changed

+3
-56
lines changed

4 files changed

+3
-56
lines changed

openssl-sys/CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
### Added
66

7-
* Added `OSSL_PARAM`, `OSSL_PARAM_construct_uint` , `OSSL_PARAM_construct_utf8_string`, `OSSL_PARAM_construct_end`.
7+
* Added `OSSL_PARAM`, `OSSL_PARAM_construct_uint` , `OSSL_PARAM_construct_end`.
88
* Added `EVP_PKEY_CTX_set_params` and `EVP_PKEY_CTX_get_params`.
99

1010
## [v0.9.99] - 2024-01-19

openssl-sys/src/handwritten/params.rs

-6
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,5 @@ extern "C" {
55
#[cfg(ossl300)]
66
pub fn OSSL_PARAM_construct_uint(key: *const c_char, buf: *mut c_uint) -> OSSL_PARAM;
77
#[cfg(ossl300)]
8-
pub fn OSSL_PARAM_construct_utf8_string(
9-
key: *const c_char,
10-
buf: *mut c_char,
11-
bsize: size_t,
12-
) -> OSSL_PARAM;
13-
#[cfg(ossl300)]
148
pub fn OSSL_PARAM_construct_end() -> OSSL_PARAM;
159
}

openssl/CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
### Added
66

7-
* Added `PkeyCtxRef::{digest, nonce_type, set_nonce_type}`.
7+
* Added `PkeyCtxRef::{nonce_type, set_nonce_type}`.
88

99
## [v0.10.63] - 2024-01-19
1010

openssl/src/pkey_ctx.rs

+1-48
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ let cmac_key = ctx.keygen().unwrap();
6767
#[cfg(not(boringssl))]
6868
use crate::cipher::CipherRef;
6969
use crate::error::ErrorStack;
70-
#[cfg(ossl300)]
71-
use crate::hash::MessageDigest;
7270
use crate::md::MdRef;
7371
use crate::pkey::{HasPrivate, HasPublic, Id, PKey, PKeyRef, Private};
7472
use crate::rsa::Padding;
@@ -81,7 +79,7 @@ use libc::c_int;
8179
use libc::c_uint;
8280
use openssl_macros::corresponds;
8381
use std::convert::TryFrom;
84-
#[cfg(ossl300)]
82+
#[cfg(ossl320)]
8583
use std::ffi::CString;
8684
use std::ptr;
8785

@@ -736,36 +734,6 @@ impl<T> PkeyCtxRef<T> {
736734
}
737735
}
738736

739-
/// Gets the digest algorithm for a private key context.
740-
///
741-
/// Requires OpenSSL 3.0.0 or newer.
742-
#[cfg(ossl300)]
743-
#[corresponds(EVP_PKEY_CTX_get_params)]
744-
pub fn digest(&mut self) -> Result<Option<MessageDigest>, ErrorStack> {
745-
use libc::c_char;
746-
// From openssl/internal/sizes.h
747-
let ossl_max_name_size = 50usize;
748-
let digest_field_name = CString::new("digest").unwrap();
749-
let digest: *mut c_char = CString::new(vec![1; ossl_max_name_size])
750-
.unwrap()
751-
.into_raw();
752-
unsafe {
753-
let param_digest = ffi::OSSL_PARAM_construct_utf8_string(
754-
digest_field_name.as_ptr(),
755-
digest,
756-
ossl_max_name_size,
757-
);
758-
let param_end = ffi::OSSL_PARAM_construct_end();
759-
let mut params = [param_digest, param_end];
760-
cvt(ffi::EVP_PKEY_CTX_get_params(
761-
self.as_ptr(),
762-
params.as_mut_ptr(),
763-
))?;
764-
let digest_str = CString::from_raw(digest);
765-
Ok(MessageDigest::from_name(digest_str.to_str().unwrap()))
766-
}
767-
}
768-
769737
/// Sets the nonce type for a private key context.
770738
///
771739
/// The nonce for DSA and ECDSA can be either random (the default) or deterministic (as defined by RFC 6979).
@@ -1098,21 +1066,6 @@ mod test {
10981066
assert_eq!(result_buf[length - digest.len()..length], digest);
10991067
}
11001068

1101-
#[test]
1102-
#[cfg(ossl300)]
1103-
fn set_signature_md() {
1104-
let key1 =
1105-
EcKey::generate(&EcGroup::from_curve_name(Nid::X9_62_PRIME256V1).unwrap()).unwrap();
1106-
let key1 = PKey::from_ec_key(key1).unwrap();
1107-
1108-
let mut ctx = PkeyCtx::new(&key1).unwrap();
1109-
ctx.sign_init().unwrap();
1110-
ctx.set_signature_md(Md::sha224()).unwrap();
1111-
let digest_nid = ctx.digest().unwrap().unwrap().type_();
1112-
assert_eq!(digest_nid, Md::sha224().type_());
1113-
assert!(ErrorStack::get().errors().is_empty());
1114-
}
1115-
11161069
#[test]
11171070
#[cfg(ossl320)]
11181071
fn set_nonce_type() {

0 commit comments

Comments
 (0)