9
9
//! Note, that this module is available only in OpenSSL 3.* and
10
10
//! only internally for this crate!
11
11
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
-
16
12
use crate :: bn:: { BigNum , BigNumRef } ;
17
13
use crate :: error:: ErrorStack ;
18
14
use crate :: util;
@@ -36,6 +32,7 @@ foreign_type_and_impl_send_sync! {
36
32
impl OsslParamRef {
37
33
/// Locates the `OsslParam` in the `OsslParam` array
38
34
#[ corresponds( OSSL_PARAM_locate ) ]
35
+ #[ cfg_attr( any( not( ossl320) , osslconf = "OPENSSL_NO_ARGON2" ) , allow( dead_code) ) ]
39
36
pub fn locate ( & self , key : & CStr ) -> Result < & OsslParamRef , ErrorStack > {
40
37
unsafe {
41
38
let param = cvt_p ( ffi:: OSSL_PARAM_locate ( self . as_ptr ( ) , key. as_ptr ( ) ) ) ?;
@@ -45,6 +42,7 @@ impl OsslParamRef {
45
42
46
43
/// Get `BigNum` from the current `OsslParam`
47
44
#[ corresponds( OSSL_PARAM_get_BN ) ]
45
+ #[ cfg_attr( any( not( ossl320) , osslconf = "OPENSSL_NO_ARGON2" ) , allow( dead_code) ) ]
48
46
pub fn get_bn ( & self ) -> Result < BigNum , ErrorStack > {
49
47
unsafe {
50
48
let mut bn: * mut ffi:: BIGNUM = ptr:: null_mut ( ) ;
@@ -55,6 +53,7 @@ impl OsslParamRef {
55
53
56
54
/// Get `&str` from the current `OsslParam`
57
55
#[ corresponds( OSSL_PARAM_get_utf8_string ) ]
56
+ #[ cfg_attr( any( not( ossl320) , osslconf = "OPENSSL_NO_ARGON2" ) , allow( dead_code) ) ]
58
57
pub fn get_utf8_string ( & self ) -> Result < & str , ErrorStack > {
59
58
unsafe {
60
59
let mut val: * const c_char = ptr:: null_mut ( ) ;
@@ -65,6 +64,7 @@ impl OsslParamRef {
65
64
66
65
/// Get octet string (as `&[u8]) from the current `OsslParam`
67
66
#[ corresponds( OSSL_PARAM_get_octet_string ) ]
67
+ #[ cfg_attr( any( not( ossl320) , osslconf = "OPENSSL_NO_ARGON2" ) , allow( dead_code) ) ]
68
68
pub fn get_octet_string ( & self ) -> Result < & [ u8 ] , ErrorStack > {
69
69
unsafe {
70
70
let mut val: * const c_void = ptr:: null_mut ( ) ;
@@ -94,6 +94,7 @@ impl OsslParamBuilder {
94
94
///
95
95
/// The array is initially empty.
96
96
#[ corresponds( OSSL_PARAM_BLD_new ) ]
97
+ #[ cfg_attr( any( not( ossl320) , osslconf = "OPENSSL_NO_ARGON2" ) , allow( dead_code) ) ]
97
98
pub fn new ( ) -> Result < OsslParamBuilder , ErrorStack > {
98
99
unsafe {
99
100
ffi:: init ( ) ;
@@ -102,8 +103,10 @@ impl OsslParamBuilder {
102
103
}
103
104
}
104
105
105
- /// Constructs the `OsslParam`.
106
+ /// Constructs the `OsslParam` and clears this builder .
106
107
#[ 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) ]
107
110
pub fn to_param ( & mut self ) -> Result < OsslParam , ErrorStack > {
108
111
unsafe {
109
112
let params = cvt_p ( ffi:: OSSL_PARAM_BLD_to_param ( self . 0 ) ) ?;
@@ -117,6 +120,7 @@ impl OsslParamBuilderRef {
117
120
///
118
121
/// Note, that both key and bn need to exist until the `to_param` is called!
119
122
#[ corresponds( OSSL_PARAM_BLD_push_BN ) ]
123
+ #[ cfg_attr( any( not( ossl320) , osslconf = "OPENSSL_NO_ARGON2" ) , allow( dead_code) ) ]
120
124
pub fn add_bn ( & mut self , key : & CStr , bn : & BigNumRef ) -> Result < ( ) , ErrorStack > {
121
125
unsafe {
122
126
cvt ( ffi:: OSSL_PARAM_BLD_push_BN (
@@ -132,6 +136,7 @@ impl OsslParamBuilderRef {
132
136
///
133
137
/// Note, that both `key` and `buf` need to exist until the `to_param` is called!
134
138
#[ corresponds( OSSL_PARAM_BLD_push_utf8_string ) ]
139
+ #[ cfg_attr( any( not( ossl320) , osslconf = "OPENSSL_NO_ARGON2" ) , allow( dead_code) ) ]
135
140
pub fn add_utf8_string ( & mut self , key : & CStr , buf : & str ) -> Result < ( ) , ErrorStack > {
136
141
unsafe {
137
142
cvt ( ffi:: OSSL_PARAM_BLD_push_utf8_string (
@@ -148,6 +153,7 @@ impl OsslParamBuilderRef {
148
153
///
149
154
/// Note, that both `key` and `buf` need to exist until the `to_param` is called!
150
155
#[ corresponds( OSSL_PARAM_BLD_push_octet_string ) ]
156
+ #[ cfg_attr( any( not( ossl320) , osslconf = "OPENSSL_NO_ARGON2" ) , allow( dead_code) ) ]
151
157
pub fn add_octet_string ( & mut self , key : & CStr , buf : & [ u8 ] ) -> Result < ( ) , ErrorStack > {
152
158
unsafe {
153
159
cvt ( ffi:: OSSL_PARAM_BLD_push_octet_string (
@@ -164,6 +170,7 @@ impl OsslParamBuilderRef {
164
170
///
165
171
/// Note, that both `key` and `buf` need to exist until the `to_param` is called!
166
172
#[ corresponds( OSSL_PARAM_BLD_push_uint ) ]
173
+ #[ cfg_attr( any( not( ossl320) , osslconf = "OPENSSL_NO_ARGON2" ) , allow( dead_code) ) ]
167
174
pub fn add_uint ( & mut self , key : & CStr , val : u32 ) -> Result < ( ) , ErrorStack > {
168
175
unsafe {
169
176
cvt ( ffi:: OSSL_PARAM_BLD_push_uint (
0 commit comments