Skip to content

Commit de28d5b

Browse files
authored
Try #225:
2 parents 8b17c8f + 7abdc1b commit de28d5b

File tree

6 files changed

+256
-191
lines changed

6 files changed

+256
-191
lines changed

ct.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ if [ $TRAVIS_RUST_VERSION = "stable" ] || [ $TRAVIS_RUST_VERSION = "beta" ] || [
2222
cargo test --features pkcs12_rc2
2323
cargo test --features force_aesni_support
2424
cargo test --features dsa
25+
# without these, tests marked with tokio::test do not run, but report OK.
26+
cargo test --features=std,threading,tokio,tokio/net,tokio/io-util,tokio/macros,tokio/rt
2527

2628
elif [ $TRAVIS_RUST_VERSION = $CORE_IO_NIGHTLY ]; then
2729
cargo +$CORE_IO_NIGHTLY test --no-default-features --features core_io,rdrand,time,custom_time,custom_gmtime_r

mbedtls/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ tokio = { version = "0.3", optional = true }
3636
rs-libc = "0.1.0"
3737

3838
[dependencies.mbedtls-sys-auto]
39-
version = "2.25.2"
39+
version = "2.28.0"
4040
default-features = false
4141
features = ["custom_printf", "trusted_cert_callback"]
4242

@@ -92,7 +92,7 @@ required-features = ["std"]
9292
[[test]]
9393
name = "async_session"
9494
path = "tests/async_session.rs"
95-
required-features = ["std", "threading", "tokio", "tokio/net", "tokio/io-util", "tokio/macros"]
95+
required-features = ["std", "threading", "tokio", "tokio/net", "tokio/io-util", "tokio/macros", "tokio/rt"]
9696

9797
[[test]]
9898
name = "client_server"

mbedtls/src/pk/mod.rs

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ extern "C" fn alloc_custom_pk_ctx() -> *mut c_void {
111111
}
112112

113113
unsafe extern "C" fn free_custom_pk_ctx(p: *mut c_void) {
114-
Box::from_raw(p as *mut CustomPkContext);
114+
let _ = Box::from_raw(p as *mut CustomPkContext);
115115
}
116116

117117
extern "C" fn custom_pk_can_do(_t: u32) -> i32 {
@@ -953,7 +953,7 @@ impl Pk {
953953
#[cfg(test)]
954954
mod tests {
955955
use super::*;
956-
use crate::hash::Type;
956+
use crate::hash::{Type, MdInfo};
957957
use crate::pk::Type as PkType;
958958

959959
// This is test data that must match library output *exactly*
@@ -1155,7 +1155,7 @@ iy6KC991zzvaWY/Ys+q/84Afqa+0qJKQnPuy/7F5GkVdQA/lfbhi
11551155
fn rsa_sign_verify_pkcs1v15() {
11561156
let mut pk =
11571157
Pk::generate_rsa(&mut crate::test_support::rand::test_rng(), 2048, 0x10001).unwrap();
1158-
let data = b"SIGNATURE TEST SIGNATURE TEST SI";
1158+
let data = b"SIGNATURE TEST SIGNATURE TEST SIGNATURE TEST SIGNATURE TEST SIGN";
11591159
let mut signature = vec![0u8; (pk.len() + 7) / 8];
11601160

11611161
let digests = [
@@ -1171,24 +1171,30 @@ iy6KC991zzvaWY/Ys+q/84Afqa+0qJKQnPuy/7F5GkVdQA/lfbhi
11711171
Type::Ripemd,
11721172
];
11731173

1174-
for digest in &digests {
1174+
for &digest in &digests {
1175+
let data = if let Some(md @ MdInfo { .. }) = digest.into() {
1176+
&data[..md.size()]
1177+
} else {
1178+
&data[..]
1179+
};
1180+
11751181
let len = pk
11761182
.sign(
1177-
*digest,
1183+
digest,
11781184
data,
11791185
&mut signature,
11801186
&mut crate::test_support::rand::test_rng(),
11811187
)
11821188
.unwrap();
1183-
pk.verify(*digest, data, &signature[0..len]).unwrap();
1189+
pk.verify(digest, data, &signature[0..len]).unwrap();
11841190
}
11851191
}
11861192

11871193
#[test]
11881194
fn rsa_sign_verify_pss() {
11891195
let mut pk =
11901196
Pk::generate_rsa(&mut crate::test_support::rand::test_rng(), 2048, 0x10001).unwrap();
1191-
let data = b"SIGNATURE TEST SIGNATURE TEST SI";
1197+
let data = b"SIGNATURE TEST SIGNATURE TEST SIGNATURE TEST SIGNATURE TEST SIGN";
11921198
let mut signature = vec![0u8; (pk.len() + 7) / 8];
11931199

11941200
let digests = [
@@ -1204,15 +1210,21 @@ iy6KC991zzvaWY/Ys+q/84Afqa+0qJKQnPuy/7F5GkVdQA/lfbhi
12041210
Type::Ripemd,
12051211
];
12061212

1207-
for digest in &digests {
1213+
for &digest in &digests {
1214+
let data = if let Some(md @ MdInfo { .. }) = digest.into() {
1215+
&data[..md.size()]
1216+
} else {
1217+
&data[..]
1218+
};
1219+
12081220
pk.set_options(Options::Rsa {
1209-
padding: RsaPadding::Pkcs1V21 { mgf: *digest },
1221+
padding: RsaPadding::Pkcs1V21 { mgf: digest },
12101222
});
12111223

1212-
if *digest == Type::None {
1224+
if digest == Type::None {
12131225
assert!(pk
12141226
.sign(
1215-
*digest,
1227+
digest,
12161228
data,
12171229
&mut signature,
12181230
&mut crate::test_support::rand::test_rng()
@@ -1221,13 +1233,13 @@ iy6KC991zzvaWY/Ys+q/84Afqa+0qJKQnPuy/7F5GkVdQA/lfbhi
12211233
} else {
12221234
let len = pk
12231235
.sign(
1224-
*digest,
1236+
digest,
12251237
data,
12261238
&mut signature,
12271239
&mut crate::test_support::rand::test_rng(),
12281240
)
12291241
.unwrap();
1230-
pk.verify(*digest, data, &signature[0..len]).unwrap();
1242+
pk.verify(digest, data, &signature[0..len]).unwrap();
12311243
}
12321244
}
12331245
}

mbedtls/src/x509/certificate.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,7 @@ cYp0bH/RcPTC0Z+ZaqSWMtfxRrk63MJQF9EXpDCdvQRcTMD9D85DJrMKn8aumq0M
929929
}
930930

931931
#[test]
932+
#[ignore] // Reason: expired certs
932933
fn verify_chain() {
933934
const C_LEAF: &'static str = concat!(include_str!("../../tests/data/chain-leaf.crt"),"\0");
934935
const C_INT1: &'static str = concat!(include_str!("../../tests/data/chain-int1.crt"),"\0");

mbedtls/src/x509/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ pub use self::profile::Profile;
2828
use mbedtls_sys::*;
2929
use mbedtls_sys::types::raw_types::c_uint;
3030
bitflags! {
31-
#[doc(inline)]
3231
pub struct KeyUsage: c_uint {
3332
const DIGITAL_SIGNATURE = X509_KU_DIGITAL_SIGNATURE as c_uint;
3433
const NON_REPUDIATION = X509_KU_NON_REPUDIATION as c_uint;
@@ -43,7 +42,6 @@ bitflags! {
4342
}
4443

4544
bitflags! {
46-
#[doc(inline)]
4745
pub struct VerifyError: u32 {
4846
const CERT_BAD_KEY = X509_BADCERT_BAD_KEY as u32;
4947
const CERT_BAD_MD = X509_BADCERT_BAD_MD as u32;

0 commit comments

Comments
 (0)