1 use super::super::*; 2 use libc::*; 3 4 #[cfg(ossl300)] 5 #[repr(C)] 6 pub struct PKCS7_CTX { 7 libctx: *mut OSSL_LIB_CTX, 8 propq: *mut c_char, 9 } 10 11 #[repr(C)] 12 pub struct PKCS7_SIGNED { 13 pub version: *mut ASN1_INTEGER, /* version 1 */ 14 pub md_algs: *mut stack_st_X509_ALGOR, /* md used */ 15 pub cert: *mut stack_st_X509, /* [ 0 ] */ 16 pub crl: *mut stack_st_X509_CRL, /* [ 1 ] */ 17 pub signer_info: *mut stack_st_PKCS7_SIGNER_INFO, 18 pub contents: *mut PKCS7, 19 } 20 #[repr(C)] 21 pub struct PKCS7_ENC_CONTENT { 22 pub content_type: *mut ASN1_OBJECT, 23 pub algorithm: *mut X509_ALGOR, 24 pub enc_data: *mut ASN1_OCTET_STRING, /* [ 0 ] */ 25 pub cipher: *const EVP_CIPHER, 26 #[cfg(ossl300)] 27 pub ctx: *const PKCS7_CTX, 28 } 29 #[repr(C)] 30 pub struct PKCS7_ENVELOPE { 31 pub version: *mut ASN1_INTEGER, /* version 0 */ 32 pub recipientinfo: *mut stack_st_PKCS7_RECIP_INFO, 33 pub enc_data: *mut PKCS7_ENC_CONTENT, 34 } 35 #[repr(C)] 36 pub struct PKCS7_SIGN_ENVELOPE { 37 pub version: *mut ASN1_INTEGER, /* version 1 */ 38 pub md_algs: *mut stack_st_X509_ALGOR, /* md used */ 39 pub cert: *mut stack_st_X509, /* [ 0 ] */ 40 pub crl: *mut stack_st_X509_CRL, /* [ 1 ] */ 41 pub signer_info: *mut stack_st_PKCS7_SIGNER_INFO, 42 pub enc_data: *mut PKCS7_ENC_CONTENT, 43 pub recipientinfo: *mut stack_st_PKCS7_RECIP_INFO, 44 } 45 #[repr(C)] 46 pub struct PKCS7_DIGEST { 47 pub version: *mut ASN1_INTEGER, /* version 0 */ 48 pub md: *mut X509_ALGOR, /* md used */ 49 pub contents: *mut PKCS7, 50 pub digest: *mut ASN1_OCTET_STRING, 51 } 52 #[repr(C)] 53 pub struct PKCS7_ENCRYPT { 54 pub version: *mut ASN1_INTEGER, /* version 0 */ 55 pub enc_data: *mut PKCS7_ENC_CONTENT, 56 } 57 58 extern "C" { PKCS7_SIGNED_free(info: *mut PKCS7_SIGNED)59 pub fn PKCS7_SIGNED_free(info: *mut PKCS7_SIGNED); PKCS7_ENC_CONTENT_free(info: *mut PKCS7_ENC_CONTENT)60 pub fn PKCS7_ENC_CONTENT_free(info: *mut PKCS7_ENC_CONTENT); PKCS7_ENVELOPE_free(info: *mut PKCS7_ENVELOPE)61 pub fn PKCS7_ENVELOPE_free(info: *mut PKCS7_ENVELOPE); PKCS7_SIGN_ENVELOPE_free(info: *mut PKCS7_SIGN_ENVELOPE)62 pub fn PKCS7_SIGN_ENVELOPE_free(info: *mut PKCS7_SIGN_ENVELOPE); PKCS7_DIGEST_free(info: *mut PKCS7_DIGEST)63 pub fn PKCS7_DIGEST_free(info: *mut PKCS7_DIGEST); PKCS7_SIGNER_INFO_free(info: *mut PKCS7_SIGNER_INFO)64 pub fn PKCS7_SIGNER_INFO_free(info: *mut PKCS7_SIGNER_INFO); PKCS7_ENCRYPT_free(enc: *mut PKCS7_ENCRYPT)65 pub fn PKCS7_ENCRYPT_free(enc: *mut PKCS7_ENCRYPT); PKCS7_ISSUER_AND_SERIAL_free(ias: *mut PKCS7_ISSUER_AND_SERIAL)66 pub fn PKCS7_ISSUER_AND_SERIAL_free(ias: *mut PKCS7_ISSUER_AND_SERIAL); PKCS7_RECIP_INFO_free(info: *mut PKCS7_RECIP_INFO)67 pub fn PKCS7_RECIP_INFO_free(info: *mut PKCS7_RECIP_INFO); 68 } 69 70 #[repr(C)] 71 pub struct PKCS7 { 72 /* 73 * The following is non NULL if it contains ASN1 encoding of this 74 * structure 75 */ 76 pub asn1: *mut c_uchar, 77 pub length: c_long, 78 // # define PKCS7_S_HEADER 0 79 // # define PKCS7_S_BODY 1 80 // # define PKCS7_S_TAIL 2 81 pub state: c_int, /* used during processing */ 82 pub detached: c_int, 83 pub type_: *mut ASN1_OBJECT, 84 /* content as defined by the type */ 85 /* 86 * all encryption/message digests are applied to the 'contents', leaving 87 * out the 'type' field. 88 */ 89 pub d: PKCS7_data, 90 #[cfg(ossl300)] 91 pub ctx: PKCS7_CTX, 92 } 93 94 #[repr(C)] 95 pub union PKCS7_data { 96 pub ptr: *mut c_char, 97 /* NID_pkcs7_data */ 98 pub data: *mut ASN1_OCTET_STRING, 99 /* NID_pkcs7_signed */ 100 pub sign: *mut PKCS7_SIGNED, 101 /* NID_pkcs7_enveloped */ 102 pub enveloped: *mut PKCS7_ENVELOPE, 103 /* NID_pkcs7_signedAndEnveloped */ 104 pub signed_and_enveloped: *mut PKCS7_SIGN_ENVELOPE, 105 /* NID_pkcs7_digest */ 106 pub digest: *mut PKCS7_DIGEST, 107 /* NID_pkcs7_encrypted */ 108 pub encrypted: *mut PKCS7_ENCRYPT, 109 /* Anything else */ 110 pub other: *mut ASN1_TYPE, 111 } 112 113 #[repr(C)] 114 pub struct PKCS7_ISSUER_AND_SERIAL { 115 pub issuer: *mut X509_NAME, 116 pub serial: *mut ASN1_INTEGER, 117 } 118 119 #[repr(C)] 120 pub struct PKCS7_SIGNER_INFO { 121 pub version: *mut ASN1_INTEGER, /* version 1 */ 122 pub issuer_and_serial: *mut PKCS7_ISSUER_AND_SERIAL, 123 pub digest_alg: *mut X509_ALGOR, 124 pub auth_attr: *mut stack_st_X509_ATTRIBUTE, /* [ 0 ] */ 125 pub digest_enc_alg: *mut X509_ALGOR, 126 pub enc_digest: *mut ASN1_OCTET_STRING, 127 pub unauth_attr: *mut stack_st_X509_ATTRIBUTE, /* [ 1 ] */ 128 pub pkey: *mut EVP_PKEY, /* The private key to sign with */ 129 #[cfg(ossl300)] 130 pub ctx: *const PKCS7_CTX, 131 } 132 133 stack!(stack_st_PKCS7_SIGNER_INFO); 134 135 #[repr(C)] 136 pub struct PKCS7_RECIP_INFO { 137 pub version: *mut ASN1_INTEGER, /* version 0 */ 138 pub issuer_and_serial: *mut PKCS7_ISSUER_AND_SERIAL, 139 pub key_enc_algor: *mut X509_ALGOR, 140 pub enc_key: *mut ASN1_OCTET_STRING, 141 pub cert: *mut X509, /* get the pub-key from this */ 142 #[cfg(ossl300)] 143 pub ctx: *const PKCS7_CTX, 144 } 145 146 stack!(stack_st_PKCS7_RECIP_INFO); 147 148 extern "C" { d2i_PKCS7(a: *mut *mut PKCS7, pp: *mut *const c_uchar, length: c_long) -> *mut PKCS7149 pub fn d2i_PKCS7(a: *mut *mut PKCS7, pp: *mut *const c_uchar, length: c_long) -> *mut PKCS7; 150 } 151 152 const_ptr_api! { 153 extern "C" { 154 pub fn i2d_PKCS7(a: #[const_ptr_if(ossl300)] PKCS7, buf: *mut *mut u8) -> c_int; 155 pub fn i2d_PKCS7_bio(bio: *mut BIO, p7: #[const_ptr_if(ossl300)] PKCS7) -> c_int; 156 } 157 } 158 159 extern "C" { PKCS7_encrypt( certs: *mut stack_st_X509, b: *mut BIO, cipher: *const EVP_CIPHER, flags: c_int, ) -> *mut PKCS7160 pub fn PKCS7_encrypt( 161 certs: *mut stack_st_X509, 162 b: *mut BIO, 163 cipher: *const EVP_CIPHER, 164 flags: c_int, 165 ) -> *mut PKCS7; 166 PKCS7_verify( pkcs7: *mut PKCS7, certs: *mut stack_st_X509, store: *mut X509_STORE, indata: *mut BIO, out: *mut BIO, flags: c_int, ) -> c_int167 pub fn PKCS7_verify( 168 pkcs7: *mut PKCS7, 169 certs: *mut stack_st_X509, 170 store: *mut X509_STORE, 171 indata: *mut BIO, 172 out: *mut BIO, 173 flags: c_int, 174 ) -> c_int; 175 PKCS7_get0_signers( pkcs7: *mut PKCS7, certs: *mut stack_st_X509, flags: c_int, ) -> *mut stack_st_X509176 pub fn PKCS7_get0_signers( 177 pkcs7: *mut PKCS7, 178 certs: *mut stack_st_X509, 179 flags: c_int, 180 ) -> *mut stack_st_X509; 181 PKCS7_sign( signcert: *mut X509, pkey: *mut EVP_PKEY, certs: *mut stack_st_X509, data: *mut BIO, flags: c_int, ) -> *mut PKCS7182 pub fn PKCS7_sign( 183 signcert: *mut X509, 184 pkey: *mut EVP_PKEY, 185 certs: *mut stack_st_X509, 186 data: *mut BIO, 187 flags: c_int, 188 ) -> *mut PKCS7; 189 PKCS7_decrypt( pkcs7: *mut PKCS7, pkey: *mut EVP_PKEY, cert: *mut X509, data: *mut BIO, flags: c_int, ) -> c_int190 pub fn PKCS7_decrypt( 191 pkcs7: *mut PKCS7, 192 pkey: *mut EVP_PKEY, 193 cert: *mut X509, 194 data: *mut BIO, 195 flags: c_int, 196 ) -> c_int; 197 PKCS7_free(pkcs7: *mut PKCS7)198 pub fn PKCS7_free(pkcs7: *mut PKCS7); 199 SMIME_write_PKCS7( out: *mut BIO, pkcs7: *mut PKCS7, data: *mut BIO, flags: c_int, ) -> c_int200 pub fn SMIME_write_PKCS7( 201 out: *mut BIO, 202 pkcs7: *mut PKCS7, 203 data: *mut BIO, 204 flags: c_int, 205 ) -> c_int; 206 SMIME_read_PKCS7(bio: *mut BIO, bcont: *mut *mut BIO) -> *mut PKCS7207 pub fn SMIME_read_PKCS7(bio: *mut BIO, bcont: *mut *mut BIO) -> *mut PKCS7; 208 PKCS7_new() -> *mut PKCS7209 pub fn PKCS7_new() -> *mut PKCS7; 210 PKCS7_set_type(p7: *mut PKCS7, nid_pkcs7: c_int) -> c_int211 pub fn PKCS7_set_type(p7: *mut PKCS7, nid_pkcs7: c_int) -> c_int; 212 PKCS7_add_certificate(p7: *mut PKCS7, x509: *mut X509) -> c_int213 pub fn PKCS7_add_certificate(p7: *mut PKCS7, x509: *mut X509) -> c_int; 214 PKCS7_add_signature( p7: *mut PKCS7, x509: *mut X509, pkey: *mut EVP_PKEY, digest: *const EVP_MD, ) -> *mut PKCS7_SIGNER_INFO215 pub fn PKCS7_add_signature( 216 p7: *mut PKCS7, 217 x509: *mut X509, 218 pkey: *mut EVP_PKEY, 219 digest: *const EVP_MD, 220 ) -> *mut PKCS7_SIGNER_INFO; 221 PKCS7_set_signed_attributes( p7si: *mut PKCS7_SIGNER_INFO, attributes: *mut stack_st_X509_ATTRIBUTE, ) -> c_int222 pub fn PKCS7_set_signed_attributes( 223 p7si: *mut PKCS7_SIGNER_INFO, 224 attributes: *mut stack_st_X509_ATTRIBUTE, 225 ) -> c_int; 226 PKCS7_add_signed_attribute( p7si: *mut PKCS7_SIGNER_INFO, nid: c_int, attrtype: c_int, data: *mut c_void, ) -> c_int227 pub fn PKCS7_add_signed_attribute( 228 p7si: *mut PKCS7_SIGNER_INFO, 229 nid: c_int, 230 attrtype: c_int, 231 data: *mut c_void, 232 ) -> c_int; 233 PKCS7_content_new(p7: *mut PKCS7, nid_pkcs7: c_int) -> c_int234 pub fn PKCS7_content_new(p7: *mut PKCS7, nid_pkcs7: c_int) -> c_int; 235 PKCS7_dataInit(p7: *mut PKCS7, bio: *mut BIO) -> *mut BIO236 pub fn PKCS7_dataInit(p7: *mut PKCS7, bio: *mut BIO) -> *mut BIO; 237 PKCS7_dataFinal(p7: *mut PKCS7, bio: *mut BIO) -> c_int238 pub fn PKCS7_dataFinal(p7: *mut PKCS7, bio: *mut BIO) -> c_int; 239 PKCS7_get_signer_info(p7: *mut PKCS7) -> *mut stack_st_PKCS7_SIGNER_INFO240 pub fn PKCS7_get_signer_info(p7: *mut PKCS7) -> *mut stack_st_PKCS7_SIGNER_INFO; 241 PKCS7_SIGNER_INFO_get0_algs( si: *mut PKCS7_SIGNER_INFO, pk: *mut *mut EVP_PKEY, pdig: *mut *mut X509_ALGOR, psig: *mut *mut X509_ALGOR, )242 pub fn PKCS7_SIGNER_INFO_get0_algs( 243 si: *mut PKCS7_SIGNER_INFO, 244 pk: *mut *mut EVP_PKEY, 245 pdig: *mut *mut X509_ALGOR, 246 psig: *mut *mut X509_ALGOR, 247 ); 248 } 249 250 const_ptr_api! { 251 extern "C" { 252 pub fn PKCS7_get_signed_attribute( 253 si: #[const_ptr_if(ossl300)] PKCS7_SIGNER_INFO, 254 nid: c_int 255 ) -> *mut ASN1_TYPE; 256 } 257 } 258