Skip to content

Commit 08f2b36

Browse files
Add several library configurations from os-check.yml to the Rust wrapper CI build
1 parent bc615a2 commit 08f2b36

11 files changed

Lines changed: 124 additions & 4 deletions

File tree

.github/workflows/rust-wrapper.yml

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,55 @@ jobs:
2424
uses: wolfSSL/actions-build-autotools-project@v1
2525
with:
2626
path: wolfssl
27-
configure: --enable-all
27+
configure: ${{ matrix.config }}
2828
- name: Build Rust Wrapper
2929
working-directory: wolfssl
3030
run: make -C wrapper/rust
3131
- name: Run Rust Wrapper Tests
3232
working-directory: wolfssl
3333
run: make -C wrapper/rust test
34+
strategy:
35+
matrix:
36+
config: [
37+
# Add new configs here
38+
'',
39+
'--enable-all --enable-asn=template',
40+
'--enable-all --enable-asn=original',
41+
'--enable-all --enable-asn=template CPPFLAGS=-DWOLFSSL_OLD_OID_SUM',
42+
'--enable-all --enable-asn=original CPPFLAGS=-DWOLFSSL_OLD_OID_SUM',
43+
'--enable-harden-tls',
44+
'--enable-tls13 --enable-session-ticket --enable-dtls --enable-dtls13
45+
--enable-opensslextra --enable-sessioncerts
46+
CPPFLAGS=''-DWOLFSSL_DTLS_NO_HVR_ON_RESUME -DHAVE_EXT_CACHE
47+
-DWOLFSSL_TICKET_HAVE_ID -DHAVE_EX_DATA -DSESSION_CACHE_DYNAMIC_MEM'' ',
48+
'--enable-all --enable-secure-renegotiation',
49+
'--enable-all --enable-haproxy --enable-quic',
50+
'--enable-dtls --enable-dtls13 --enable-earlydata
51+
--enable-session-ticket --enable-psk
52+
CPPFLAGS=''-DWOLFSSL_DTLS13_NO_HRR_ON_RESUME'' ',
53+
'--enable-experimental --enable-kyber --enable-dtls --enable-dtls13
54+
--enable-dtls-frag-ch',
55+
'--enable-all --enable-dtls13 --enable-dtls-frag-ch',
56+
'--enable-dtls --enable-dtls13 --enable-dtls-frag-ch
57+
--enable-dtls-mtu',
58+
'--enable-dtls --enable-dtlscid --enable-dtls13 --enable-secure-renegotiation
59+
--enable-psk --enable-aesccm --enable-nullcipher
60+
CPPFLAGS=-DWOLFSSL_STATIC_RSA',
61+
'--enable-ascon --enable-experimental',
62+
'--enable-ascon CPPFLAGS=-DWOLFSSL_ASCON_UNROLL --enable-experimental',
63+
'--enable-sniffer --enable-curve25519 --enable-curve448 --enable-enckeys
64+
CPPFLAGS=-DWOLFSSL_DH_EXTRA',
65+
'--enable-dtls --enable-dtls13 --enable-dtls-frag-ch
66+
--enable-dtls-mtu CPPFLAGS=-DWOLFSSL_DTLS_RECORDS_CAN_SPAN_DATAGRAMS',
67+
'--enable-opensslextra CPPFLAGS=''-DWOLFSSL_NO_CA_NAMES'' ',
68+
'--enable-opensslextra=x509small',
69+
'CPPFLAGS=''-DWOLFSSL_EXTRA'' ',
70+
'--enable-lms=small,verify-only --enable-xmss=small,verify-only',
71+
'--disable-sys-ca-certs',
72+
'--enable-all CPPFLAGS=-DWOLFSSL_DEBUG_CERTS ',
73+
'--enable-coding=no',
74+
'--enable-dtls --enable-dtls13 --enable-ocspstapling --enable-ocspstapling2
75+
--enable-cert-setup-cb --enable-sessioncerts',
76+
'--disable-sni --disable-ecc --disable-tls13 --disable-secure-renegotiation-info',
77+
'CPPFLAGS=-DWOLFSSL_BLIND_PRIVATE_KEY',
78+
]

wolfssl/wolfcrypt/rsa.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,13 +330,15 @@ WOLFSSL_API int wc_RsaPrivateDecrypt(const byte* in, word32 inLen, byte* out,
330330
word32 outLen, RsaKey* key);
331331
WOLFSSL_API int wc_RsaSSL_Sign(const byte* in, word32 inLen, byte* out,
332332
word32 outLen, RsaKey* key, WC_RNG* rng);
333+
#ifdef WC_RSA_PSS
333334
WOLFSSL_API int wc_RsaPSS_Sign(const byte* in, word32 inLen, byte* out,
334335
word32 outLen, enum wc_HashType hash, int mgf,
335336
RsaKey* key, WC_RNG* rng);
336337
WOLFSSL_API int wc_RsaPSS_Sign_ex(const byte* in, word32 inLen, byte* out,
337338
word32 outLen, enum wc_HashType hash,
338339
int mgf, int saltLen, RsaKey* key,
339340
WC_RNG* rng);
341+
#endif
340342
WOLFSSL_API int wc_RsaSSL_VerifyInline(byte* in, word32 inLen, byte** out,
341343
RsaKey* key);
342344
WOLFSSL_API int wc_RsaSSL_Verify(const byte* in, word32 inLen, byte* out,
@@ -346,6 +348,7 @@ WOLFSSL_API int wc_RsaSSL_Verify_ex(const byte* in, word32 inLen, byte* out,
346348
WOLFSSL_API int wc_RsaSSL_Verify_ex2(const byte* in, word32 inLen, byte* out,
347349
word32 outLen, RsaKey* key, int pad_type,
348350
enum wc_HashType hash);
351+
#ifdef WC_RSA_PSS
349352
WOLFSSL_API int wc_RsaPSS_VerifyInline(byte* in, word32 inLen, byte** out,
350353
enum wc_HashType hash, int mgf,
351354
RsaKey* key);
@@ -378,6 +381,7 @@ WOLFSSL_API int wc_RsaPSS_VerifyCheck(const byte* in, word32 inLen,
378381
const byte* digest, word32 digestLen,
379382
enum wc_HashType hash, int mgf,
380383
RsaKey* key);
384+
#endif
381385

382386
WOLFSSL_API int wc_RsaEncryptSize(const RsaKey* key);
383387

wrapper/rust/wolfssl/build.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@ fn scan_cfg() -> Result<()> {
125125
/* dh */
126126
check_cfg(&binding, "wc_InitDhKey", "dh");
127127
check_cfg(&binding, "wc_DhGenerateParams", "dh_keygen");
128+
check_cfg(&binding, "wc_Dh_ffdhe2048_Get", "dh_ffdhe_2048");
129+
check_cfg(&binding, "wc_Dh_ffdhe3072_Get", "dh_ffdhe_3072");
130+
check_cfg(&binding, "wc_Dh_ffdhe4096_Get", "dh_ffdhe_4096");
131+
check_cfg(&binding, "wc_Dh_ffdhe6144_Get", "dh_ffdhe_6144");
132+
check_cfg(&binding, "wc_Dh_ffdhe8192_Get", "dh_ffdhe_8192");
128133

129134
/* ecc */
130135
check_cfg(&binding, "wc_ecc_init", "ecc");
@@ -155,6 +160,9 @@ fn scan_cfg() -> Result<()> {
155160
check_cfg(&binding, "wc_ed448_verify_msg_ex", "ed448_verify");
156161
check_cfg(&binding, "wc_ed448_verify_msg_init", "ed448_streaming_verify");
157162

163+
/* hkdf */
164+
check_cfg(&binding, "wc_HKDF_Extract_ex", "hkdf");
165+
158166
/* kdf */
159167
check_cfg(&binding, "wc_PBKDF2", "kdf_pbkdf2");
160168
check_cfg(&binding, "wc_PKCS12_PBKDF_ex", "kdf_pkcs12");
@@ -169,6 +177,7 @@ fn scan_cfg() -> Result<()> {
169177
check_cfg(&binding, "wc_InitRsaKey", "rsa");
170178
check_cfg(&binding, "wc_RsaDirect", "rsa_direct");
171179
check_cfg(&binding, "wc_MakeRsaKey", "rsa_keygen");
180+
check_cfg(&binding, "wc_RsaPSS_Sign", "rsa_pss");
172181

173182
/* sha */
174183
check_cfg(&binding, "wc_InitSha", "sha");

wrapper/rust/wolfssl/src/wolfcrypt/dh.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,19 @@ pub struct DH {
3838

3939
impl DH {
4040
/// ffdhe2048 named parameter group.
41+
#[cfg(dh_ffdhe_2048)]
4142
pub const FFDHE_2048: i32 = sys::WC_FFDHE_2048 as i32;
4243
/// ffdhe3072 named parameter group.
44+
#[cfg(dh_ffdhe_3072)]
4345
pub const FFDHE_3072: i32 = sys::WC_FFDHE_3072 as i32;
4446
/// ffdhe4096 named parameter group.
47+
#[cfg(dh_ffdhe_4096)]
4548
pub const FFDHE_4096: i32 = sys::WC_FFDHE_4096 as i32;
4649
/// ffdhe6144 named parameter group.
50+
#[cfg(dh_ffdhe_6144)]
4751
pub const FFDHE_6144: i32 = sys::WC_FFDHE_6144 as i32;
4852
/// ffdhe8192 named parameter group.
53+
#[cfg(dh_ffdhe_8192)]
4954
pub const FFDHE_8192: i32 = sys::WC_FFDHE_8192 as i32;
5055

5156
/// Perform quick validity check of public key value against prime.
@@ -68,6 +73,8 @@ impl DH {
6873
/// # Example
6974
///
7075
/// ```rust
76+
/// #[cfg(dh_ffdhe_2048)]
77+
/// {
7178
/// use wolfssl::wolfcrypt::random::RNG;
7279
/// use wolfssl::wolfcrypt::dh::DH;
7380
/// let mut rng = RNG::new().expect("Failed to create RNG");
@@ -87,6 +94,7 @@ impl DH {
8794
/// dh.export_params_raw(&mut p, &mut p_size, &mut q, &mut q_size, &mut g, &mut g_size).expect("Error with export_params_raw()");
8895
/// let p = &p[0..(p_size as usize)];
8996
/// DH::check_pub_value(p, public).expect("Error with check_pub_value()");
97+
/// }
9098
/// ```
9199
pub fn check_pub_value(prime: &[u8], public: &[u8]) -> Result<(), i32> {
92100
let prime_size = prime.len() as u32;
@@ -117,6 +125,8 @@ impl DH {
117125
/// # Example
118126
///
119127
/// ```rust
128+
/// #[cfg(dh_ffdhe_2048)]
129+
/// {
120130
/// use wolfssl::wolfcrypt::random::RNG;
121131
/// use wolfssl::wolfcrypt::dh::DH;
122132
/// let mut dh = DH::new_named(DH::FFDHE_2048).expect("Error with new_named()");
@@ -130,6 +140,7 @@ impl DH {
130140
/// let p = &p[0..(p_size as usize)];
131141
/// let g = &g[0..(g_size as usize)];
132142
/// assert!(DH::compare_named_key(DH::FFDHE_2048, p, g, None));
143+
/// }
133144
/// ```
134145
pub fn compare_named_key(name: i32, p: &[u8], g: &[u8], q: Option<&[u8]>) -> bool {
135146
let p_size = p.len() as u32;
@@ -244,10 +255,13 @@ impl DH {
244255
/// # Example
245256
///
246257
/// ```rust
258+
/// #[cfg(dh_ffdhe_2048)]
259+
/// {
247260
/// use wolfssl::wolfcrypt::random::RNG;
248261
/// use wolfssl::wolfcrypt::dh::DH;
249262
/// let min_key_size = DH::get_min_key_size_for_named_parameters(DH::FFDHE_2048);
250263
/// assert_eq!(min_key_size, 29);
264+
/// }
251265
/// ```
252266
pub fn get_min_key_size_for_named_parameters(name: i32) -> u32 {
253267
unsafe { sys::wc_DhGetNamedKeyMinSize(name) }
@@ -265,12 +279,15 @@ impl DH {
265279
/// # Example
266280
///
267281
/// ```rust
282+
/// #[cfg(dh_ffdhe_2048)]
283+
/// {
268284
/// use wolfssl::wolfcrypt::random::RNG;
269285
/// use wolfssl::wolfcrypt::dh::DH;
270286
/// let mut p_size = 0u32;
271287
/// let mut g_size = 0u32;
272288
/// let mut q_size = 0u32;
273289
/// DH::get_named_parameter_sizes(DH::FFDHE_2048, &mut p_size, &mut g_size, &mut q_size);
290+
/// }
274291
/// ```
275292
pub fn get_named_parameter_sizes(name: i32, p_size: &mut u32, g_size: &mut u32, q_size: &mut u32) {
276293
unsafe {
@@ -292,9 +309,12 @@ impl DH {
292309
/// # Example
293310
///
294311
/// ```rust
312+
/// #[cfg(dh_ffdhe_2048)]
313+
/// {
295314
/// use wolfssl::wolfcrypt::random::RNG;
296315
/// use wolfssl::wolfcrypt::dh::DH;
297316
/// let mut dh = DH::new_named(DH::FFDHE_2048).expect("Error with new_named()");
317+
/// }
298318
/// ```
299319
pub fn new_named(name: i32) -> Result<Self, i32> {
300320
Self::new_named_ex(name, None, None)
@@ -317,9 +337,12 @@ impl DH {
317337
/// # Example
318338
///
319339
/// ```rust
340+
/// #[cfg(dh_ffdhe_2048)]
341+
/// {
320342
/// use wolfssl::wolfcrypt::random::RNG;
321343
/// use wolfssl::wolfcrypt::dh::DH;
322344
/// let mut dh = DH::new_named_ex(DH::FFDHE_2048, None, None).expect("Error with new_named_ex()");
345+
/// }
323346
/// ```
324347
pub fn new_named_ex(name: i32, heap: Option<*mut std::os::raw::c_void>, dev_id: Option<i32>) -> Result<Self, i32> {
325348
let mut wc_dhkey: MaybeUninit<sys::DhKey> = MaybeUninit::uninit();
@@ -1023,6 +1046,8 @@ impl DH {
10231046
/// # Example
10241047
///
10251048
/// ```rust
1049+
/// #[cfg(dh_ffdhe_2048)]
1050+
/// {
10261051
/// use wolfssl::wolfcrypt::random::RNG;
10271052
/// use wolfssl::wolfcrypt::dh::DH;
10281053
/// let mut rng = RNG::new().expect("Error with RNG::new()");
@@ -1035,6 +1060,7 @@ impl DH {
10351060
/// let private = &private[0..(private_size as usize)];
10361061
/// let public = &public[0..(public_size as usize)];
10371062
/// dh.check_key_pair(public, private).expect("Error with check_key_pair()");
1063+
/// }
10381064
/// ```
10391065
pub fn check_key_pair(&mut self, public: &[u8], private: &[u8]) -> Result<(), i32> {
10401066
let public_size = public.len() as u32;
@@ -1066,6 +1092,8 @@ impl DH {
10661092
/// # Example
10671093
///
10681094
/// ```rust
1095+
/// #[cfg(dh_ffdhe_2048)]
1096+
/// {
10691097
/// use wolfssl::wolfcrypt::random::RNG;
10701098
/// use wolfssl::wolfcrypt::dh::DH;
10711099
/// let mut rng = RNG::new().expect("Error with RNG::new()");
@@ -1077,6 +1105,7 @@ impl DH {
10771105
/// dh.generate_key_pair(&mut rng, &mut private, &mut private_size, &mut public, &mut public_size).expect("Error with generate_key_pair()");
10781106
/// let private = &private[0..(private_size as usize)];
10791107
/// dh.check_priv_key(private).expect("Error with check_priv_key()");
1108+
/// }
10801109
/// ```
10811110
pub fn check_priv_key(&mut self, private: &[u8]) -> Result<(), i32> {
10821111
let private_size = private.len() as u32;
@@ -1230,6 +1259,8 @@ impl DH {
12301259
/// # Example
12311260
///
12321261
/// ```rust
1262+
/// #[cfg(dh_ffdhe_2048)]
1263+
/// {
12331264
/// use wolfssl::wolfcrypt::random::RNG;
12341265
/// use wolfssl::wolfcrypt::dh::DH;
12351266
/// let mut rng = RNG::new().expect("Error with RNG::new()");
@@ -1241,6 +1272,7 @@ impl DH {
12411272
/// dh.generate_key_pair(&mut rng, &mut private, &mut private_size, &mut public, &mut public_size).expect("Error with generate_key_pair()");
12421273
/// let public = &public[0..(public_size as usize)];
12431274
/// dh.check_pub_key(public).expect("Error with check_pub_key()");
1275+
/// }
12441276
/// ```
12451277
pub fn check_pub_key(&mut self, public: &[u8]) -> Result<(), i32> {
12461278
let public_size = public.len() as u32;
@@ -1429,6 +1461,8 @@ impl DH {
14291461
/// # Example
14301462
///
14311463
/// ```rust
1464+
/// #[cfg(dh_ffdhe_2048)]
1465+
/// {
14321466
/// use wolfssl::wolfcrypt::random::RNG;
14331467
/// use wolfssl::wolfcrypt::dh::DH;
14341468
/// let mut rng = RNG::new().expect("Failed to create RNG");
@@ -1438,6 +1472,7 @@ impl DH {
14381472
/// let mut public = [0u8; 256];
14391473
/// let mut public_size = 0u32;
14401474
/// dh.generate_key_pair(&mut rng, &mut private, &mut private_size, &mut public, &mut public_size).expect("Error with generate_key_pair()");
1475+
/// }
14411476
/// ```
14421477
pub fn generate_key_pair(&mut self, rng: &mut RNG,
14431478
private: &mut [u8], private_size: &mut u32,
@@ -1471,6 +1506,8 @@ impl DH {
14711506
/// # Example
14721507
///
14731508
/// ```rust
1509+
/// #[cfg(dh_ffdhe_2048)]
1510+
/// {
14741511
/// use wolfssl::wolfcrypt::random::RNG;
14751512
/// use wolfssl::wolfcrypt::dh::DH;
14761513
/// let mut rng = RNG::new().expect("Error with RNG::new()");
@@ -1488,6 +1525,7 @@ impl DH {
14881525
/// let mut ss0 = [0u8; 256];
14891526
/// let ss0_size = dh.shared_secret(&mut ss0, &private0, &public1).expect("Error with shared_secret()");
14901527
/// let ss0 = &ss0[0..ss0_size];
1528+
/// }
14911529
/// ```
14921530
pub fn shared_secret(&mut self, dout: &mut [u8], private: &[u8], other_pub: &[u8]) -> Result<usize, i32> {
14931531
let mut dout_size = dout.len() as u32;

wrapper/rust/wolfssl/src/wolfcrypt/hkdf.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ This module provides a Rust wrapper for the wolfCrypt library's HMAC Key
2323
Derivation Function (HKDF) functionality.
2424
*/
2525

26+
#![cfg(hkdf)]
27+
2628
use crate::sys;
2729
use crate::wolfcrypt::hmac::HMAC;
2830

wrapper/rust/wolfssl/src/wolfcrypt/kdf.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Function (KDF) functionality.
2424
*/
2525

2626
use crate::sys;
27+
#[cfg(kdf_tls13)]
2728
use crate::wolfcrypt::hmac::HMAC;
2829

2930
#[cfg(kdf_srtp)]

0 commit comments

Comments
 (0)