Skip to content

Commit

Permalink
Fix broken tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shanecurran committed Mar 4, 2021
1 parent 2bb6fb1 commit b82dd10
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions openssl/src/cms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,24 +289,35 @@ mod test {
let encrypted_der = encrypt.to_der().expect("failed to create der from cms");
let decrypt =
CmsContentInfo::from_der(&encrypted_der).expect("failed read cms from der");
let decrypt = decrypt
.decrypt(&priv_cert.pkey, Some(&priv_cert.cert))

let decrypt_with_cert_check = decrypt
.decrypt(&priv_cert.pkey, &priv_cert.cert)
.expect("failed to decrypt cms");
let decrypt =
String::from_utf8(decrypt).expect("failed to create string from cms content");
assert_eq!(input, decrypt);
let decrypt_with_cert_check =
String::from_utf8(decrypt_with_cert_check).expect("failed to create string from cms content");

let decrypt_without_cert_check = decrypt
.decrypt_without_cert_check(&priv_cert.pkey)
.expect("failed to decrypt cms");
let decrypt_without_cert_check = String::from_utf8(decrypt_without_cert_check)
.expect("failed to create string from cms content");

assert_eq!(input, decrypt_with_cert_check);
assert_eq!(input, decrypt_without_cert_check);
}

// decrypt cms message using private key cert (PEM)
{
let encrypted_pem = encrypt.to_pem().expect("failed to create pem from cms");
let decrypt =
CmsContentInfo::from_pem(&encrypted_pem).expect("failed read cms from pem");

let decrypt_with_cert_check = decrypt
.decrypt(&priv_cert.pkey, &priv_cert.cert)
.expect("failed to decrypt cms");
let decrypt_with_cert_check = String::from_utf8(decrypt_with_cert_check)
.expect("failed to create string from cms content");

let decrypt_without_cert_check = decrypt
.decrypt_without_cert_check(&priv_cert.pkey)
.expect("failed to decrypt cms");
Expand Down

0 comments on commit b82dd10

Please sign in to comment.