Move CMS_* flags to the openssl-sys package

Also renames attributes in the bitflags struct.
This commit is contained in:
Umang Raghuvanshi 2018-05-10 20:26:57 +05:30
parent 043ad63a52
commit 90898e99c9
2 changed files with 55 additions and 24 deletions

View File

@ -1465,6 +1465,30 @@ pub const GEN_RID: c_int = 8;
pub const DTLS1_COOKIE_LENGTH: c_uint = 256; pub const DTLS1_COOKIE_LENGTH: c_uint = 256;
#[cfg(not(libressl))]
pub const CMS_TEXT: c_uint = 0x1;
pub const CMS_NOCERTS: c_uint = 0x2;
pub const CMS_NO_CONTENT_VERIFY: c_uint = 0x4;
pub const CMS_NO_ATTR_VERIFY: c_uint = 0x8;
pub const CMS_NOSIGS: c_uint = 0x4 | 0x8;
pub const CMS_NOINTERN: c_uint = 0x10;
pub const CMS_NO_SIGNER_CERT_VERIFY: c_uint = 0x20;
pub const CMS_NOVERIFY: c_uint = 0x20;
pub const CMS_DETACHED: c_uint = 0x40;
pub const CMS_BINARY: c_uint = 0x80;
pub const CMS_NOATTR: c_uint = 0x100;
pub const CMS_NOSMIMECAP: c_uint = 0x200;
pub const CMS_NOOLDMIMETYPE: c_uint = 0x400;
pub const CMS_CRLFEOL: c_uint = 0x800;
pub const CMS_STREAM: c_uint = 0x1000;
pub const CMS_NOCRL: c_uint = 0x2000;
pub const CMS_PARTIAL: c_uint = 0x4000;
pub const CMS_REUSE_DIGEST: c_uint = 0x8000;
pub const CMS_USE_KEYID: c_uint = 0x10000;
pub const CMS_DEBUG_DECRYPT: c_uint = 0x20000;
pub const CMS_KEY_PARAM: c_uint = 0x40000;
pub const CMS_ASCIICRLF: c_uint = 0x80000;
// macros // macros
pub unsafe fn BIO_get_mem_data(b: *mut BIO, pp: *mut *mut c_char) -> c_long { pub unsafe fn BIO_get_mem_data(b: *mut BIO, pp: *mut *mut c_char) -> c_long {
BIO_ctrl(b, BIO_CTRL_INFO, 0, pp as *mut c_void) BIO_ctrl(b, BIO_CTRL_INFO, 0, pp as *mut c_void)

View File

@ -11,35 +11,36 @@ use std::ptr;
use bio::{MemBio, MemBioSlice}; use bio::{MemBio, MemBioSlice};
use error::ErrorStack; use error::ErrorStack;
use libc::c_uint;
use pkey::{HasPrivate, PKeyRef}; use pkey::{HasPrivate, PKeyRef};
use stack::Stack; use stack::Stack;
use x509::X509; use x509::X509;
use {cvt, cvt_p}; use {cvt, cvt_p};
bitflags! { bitflags! {
pub struct CMSOptions : u32 { pub struct CMSOptions : c_uint {
const CMS_TEXT = 0x1; const TEXT = ffi::CMS_TEXT;
const CMS_NOCERTS = 0x2; const CMS_NOCERTS = ffi::CMS_NOCERTS;
const CMS_NO_CONTENT_VERIFY = 0x4; const NO_CONTENT_VERIFY = ffi::CMS_NO_CONTENT_VERIFY;
const CMS_NO_ATTR_VERIFY = 0x8; const NO_ATTR_VERIFY = ffi::CMS_NO_ATTR_VERIFY;
const CMS_NOSIGS = 0x4 | 0x8; const NOSIGS = ffi::CMS_NOSIGS;
const CMS_NOINTERN = 0x10; const NOINTERN = ffi::CMS_NOINTERN;
const CMS_NO_SIGNER_CERT_VERIFY = 0x20; const NO_SIGNER_CERT_VERIFY = ffi::CMS_NO_SIGNER_CERT_VERIFY;
const CMS_NOVERIFY = 0x20; const NOVERIFY = ffi::CMS_NOVERIFY;
const CMS_DETACHED = 0x40; const DETACHED = ffi::CMS_DETACHED;
const CMS_BINARY = 0x80; const BINARY = ffi::CMS_BINARY;
const CMS_NOATTR = 0x100; const NOATTR = ffi::CMS_NOATTR;
const CMS_NOSMIMECAP = 0x200; const NOSMIMECAP = ffi::CMS_NOSMIMECAP;
const CMS_NOOLDMIMETYPE = 0x400; const NOOLDMIMETYPE = ffi::CMS_NOOLDMIMETYPE;
const CMS_CRLFEOL = 0x800; const CRLFEOL = ffi::CMS_CRLFEOL;
const CMS_STREAM = 0x1000; const STREAM = ffi::CMS_STREAM;
const CMS_NOCRL = 0x2000; const NOCRL = ffi::CMS_NOCRL;
const CMS_PARTIAL = 0x4000; const PARTIAL = ffi::CMS_PARTIAL;
const CMS_REUSE_DIGEST = 0x8000; const REUSE_DIGEST = ffi::CMS_REUSE_DIGEST;
const CMS_USE_KEYID = 0x10000; const USE_KEYID = ffi::CMS_USE_KEYID;
const CMS_DEBUG_DECRYPT = 0x20000; const DEBUG_DECRYPT = ffi::CMS_DEBUG_DECRYPT;
const CMS_KEY_PARAM = 0x40000; const KEY_PARAM = ffi::CMS_KEY_PARAM;
const CMS_ASCIICRLF = 0x80000; const ASCIICRLF = ffi::CMS_ASCIICRLF;
} }
} }
@ -152,7 +153,13 @@ impl CmsContentInfo {
None => ptr::null_mut(), None => ptr::null_mut(),
}; };
let cms = cvt_p(ffi::CMS_sign(signcert, pkey, certs, data_bio_ptr, flags.bits()))?; let cms = cvt_p(ffi::CMS_sign(
signcert,
pkey,
certs,
data_bio_ptr,
flags.bits(),
))?;
Ok(CmsContentInfo::from_ptr(cms)) Ok(CmsContentInfo::from_ptr(cms))
} }