Conditionally compile PEM functions for CMS

Apparently libressl does not quite support all CMS functions (well, at
least the bindings for CMS are currently compile-time guarded), so CI
checks inside the systest fail during the verification on libressl.
This is an attempt to fix it.
This commit is contained in:
Daniel Abramov 2019-06-12 15:10:05 +02:00
parent ed966a09ac
commit fab6ea4727
2 changed files with 4 additions and 2 deletions

View File

@ -147,12 +147,14 @@ extern "C" {
pub fn PEM_write_bio_PKCS7(bp: *mut BIO, x: *mut PKCS7) -> c_int;
#[cfg(ossl101)]
pub fn PEM_read_bio_CMS(
bio: *mut BIO,
out: *mut *mut CMS_ContentInfo,
callback: pem_password_cb,
user_data: *mut c_void,
) -> *mut CMS_ContentInfo;
#[cfg(ossl101)]
pub fn PEM_write_bio_CMS(bio: *mut BIO, cms: *const CMS_ContentInfo) -> c_int;
}

View File

@ -248,11 +248,10 @@ mod test {
let encrypt = CmsContentInfo::encrypt(&cert_stack, &input.as_bytes(), Cipher::des_ede3_cbc(), CMSOptions::empty())
.expect("failed create encrypted cms");
let encrypted_der = encrypt.to_der().expect("failed to create der from cms");
let encrypted_pem = encrypt.to_pem().expect("failed to create pem from cms");
// decrypt cms message using private key cert (DER)
{
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, &priv_cert.cert).expect("failed to decrypt cms");
let decrypt = String::from_utf8(decrypt).expect("failed to create string from cms content");
@ -261,6 +260,7 @@ mod test {
// 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 = 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");