Skip to content

Commit 131cddd

Browse files
committed
Remove allow dead code from param builder
1 parent 00e12f7 commit 131cddd

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

openssl/src/ossl_param.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@
99
//! Note, that this module is available only in OpenSSL 3.* and
1010
//! only internally for this crate!
1111
12-
// Depending on which version of OpenSSL is used, and which algorithms
13-
// are exposed in the bindings, not all of these functions are used.
14-
#![allow(dead_code)]
15-
1612
use crate::bn::{BigNum, BigNumRef};
1713
use crate::error::ErrorStack;
1814
use crate::util;
@@ -36,6 +32,7 @@ foreign_type_and_impl_send_sync! {
3632
impl OsslParamRef {
3733
/// Locates the `OsslParam` in the `OsslParam` array
3834
#[corresponds(OSSL_PARAM_locate)]
35+
#[cfg_attr(any(not(ossl320), osslconf = "OPENSSL_NO_ARGON2"), allow(dead_code))]
3936
pub fn locate(&self, key: &CStr) -> Result<&OsslParamRef, ErrorStack> {
4037
unsafe {
4138
let param = cvt_p(ffi::OSSL_PARAM_locate(self.as_ptr(), key.as_ptr()))?;
@@ -45,6 +42,7 @@ impl OsslParamRef {
4542

4643
/// Get `BigNum` from the current `OsslParam`
4744
#[corresponds(OSSL_PARAM_get_BN)]
45+
#[cfg_attr(any(not(ossl320), osslconf = "OPENSSL_NO_ARGON2"), allow(dead_code))]
4846
pub fn get_bn(&self) -> Result<BigNum, ErrorStack> {
4947
unsafe {
5048
let mut bn: *mut ffi::BIGNUM = ptr::null_mut();
@@ -55,6 +53,7 @@ impl OsslParamRef {
5553

5654
/// Get `&str` from the current `OsslParam`
5755
#[corresponds(OSSL_PARAM_get_utf8_string)]
56+
#[cfg_attr(any(not(ossl320), osslconf = "OPENSSL_NO_ARGON2"), allow(dead_code))]
5857
pub fn get_utf8_string(&self) -> Result<&str, ErrorStack> {
5958
unsafe {
6059
let mut val: *const c_char = ptr::null_mut();
@@ -65,6 +64,7 @@ impl OsslParamRef {
6564

6665
/// Get octet string (as `&[u8]) from the current `OsslParam`
6766
#[corresponds(OSSL_PARAM_get_octet_string)]
67+
#[cfg_attr(any(not(ossl320), osslconf = "OPENSSL_NO_ARGON2"), allow(dead_code))]
6868
pub fn get_octet_string(&self) -> Result<&[u8], ErrorStack> {
6969
unsafe {
7070
let mut val: *const c_void = ptr::null_mut();
@@ -94,6 +94,7 @@ impl OsslParamBuilder {
9494
///
9595
/// The array is initially empty.
9696
#[corresponds(OSSL_PARAM_BLD_new)]
97+
#[cfg_attr(any(not(ossl320), osslconf = "OPENSSL_NO_ARGON2"), allow(dead_code))]
9798
pub fn new() -> Result<OsslParamBuilder, ErrorStack> {
9899
unsafe {
99100
ffi::init();
@@ -102,8 +103,10 @@ impl OsslParamBuilder {
102103
}
103104
}
104105

105-
/// Constructs the `OsslParam`.
106+
/// Constructs the `OsslParam` and clears this builder.
106107
#[corresponds(OSSL_PARAM_BLD_to_param)]
108+
#[cfg_attr(any(not(ossl320), osslconf = "OPENSSL_NO_ARGON2"), allow(dead_code))]
109+
#[allow(clippy::wrong_self_convention)]
107110
pub fn to_param(&mut self) -> Result<OsslParam, ErrorStack> {
108111
unsafe {
109112
let params = cvt_p(ffi::OSSL_PARAM_BLD_to_param(self.0))?;
@@ -117,6 +120,7 @@ impl OsslParamBuilderRef {
117120
///
118121
/// Note, that both key and bn need to exist until the `to_param` is called!
119122
#[corresponds(OSSL_PARAM_BLD_push_BN)]
123+
#[cfg_attr(any(not(ossl320), osslconf = "OPENSSL_NO_ARGON2"), allow(dead_code))]
120124
pub fn add_bn(&mut self, key: &CStr, bn: &BigNumRef) -> Result<(), ErrorStack> {
121125
unsafe {
122126
cvt(ffi::OSSL_PARAM_BLD_push_BN(
@@ -132,6 +136,7 @@ impl OsslParamBuilderRef {
132136
///
133137
/// Note, that both `key` and `buf` need to exist until the `to_param` is called!
134138
#[corresponds(OSSL_PARAM_BLD_push_utf8_string)]
139+
#[cfg_attr(any(not(ossl320), osslconf = "OPENSSL_NO_ARGON2"), allow(dead_code))]
135140
pub fn add_utf8_string(&mut self, key: &CStr, buf: &str) -> Result<(), ErrorStack> {
136141
unsafe {
137142
cvt(ffi::OSSL_PARAM_BLD_push_utf8_string(
@@ -148,6 +153,7 @@ impl OsslParamBuilderRef {
148153
///
149154
/// Note, that both `key` and `buf` need to exist until the `to_param` is called!
150155
#[corresponds(OSSL_PARAM_BLD_push_octet_string)]
156+
#[cfg_attr(any(not(ossl320), osslconf = "OPENSSL_NO_ARGON2"), allow(dead_code))]
151157
pub fn add_octet_string(&mut self, key: &CStr, buf: &[u8]) -> Result<(), ErrorStack> {
152158
unsafe {
153159
cvt(ffi::OSSL_PARAM_BLD_push_octet_string(
@@ -164,6 +170,7 @@ impl OsslParamBuilderRef {
164170
///
165171
/// Note, that both `key` and `buf` need to exist until the `to_param` is called!
166172
#[corresponds(OSSL_PARAM_BLD_push_uint)]
173+
#[cfg_attr(any(not(ossl320), osslconf = "OPENSSL_NO_ARGON2"), allow(dead_code))]
167174
pub fn add_uint(&mut self, key: &CStr, val: u32) -> Result<(), ErrorStack> {
168175
unsafe {
169176
cvt(ffi::OSSL_PARAM_BLD_push_uint(

0 commit comments

Comments
 (0)