1 use super::super::*; 2 use libc::*; 3 4 #[repr(C)] 5 pub struct X509_VAL { 6 pub notBefore: *mut ASN1_TIME, 7 pub notAfter: *mut ASN1_TIME, 8 } 9 10 pub enum X509_NAME_ENTRY {} 11 12 stack!(stack_st_X509_NAME); 13 14 pub enum X509_EXTENSION {} 15 16 stack!(stack_st_X509_EXTENSION); 17 18 stack!(stack_st_X509_ATTRIBUTE); 19 20 cfg_if! { 21 if #[cfg(any(ossl110, libressl350))] { 22 pub enum X509_REQ_INFO {} 23 } else { 24 #[repr(C)] 25 pub struct X509_REQ_INFO { 26 pub enc: ASN1_ENCODING, 27 pub version: *mut ASN1_INTEGER, 28 pub subject: *mut X509_NAME, 29 pubkey: *mut c_void, 30 pub attributes: *mut stack_st_X509_ATTRIBUTE, 31 } 32 } 33 } 34 35 cfg_if! { 36 if #[cfg(any(ossl110, libressl350))] { 37 pub enum X509_CRL {} 38 } else { 39 #[repr(C)] 40 pub struct X509_CRL { 41 pub crl: *mut X509_CRL_INFO, 42 sig_alg: *mut X509_ALGOR, 43 signature: *mut c_void, 44 references: c_int, 45 flags: c_int, 46 akid: *mut c_void, 47 idp: *mut c_void, 48 idp_flags: c_int, 49 idp_reasons: c_int, 50 crl_number: *mut ASN1_INTEGER, 51 base_crl_number: *mut ASN1_INTEGER, 52 sha1_hash: [c_uchar; 20], 53 issuers: *mut c_void, 54 meth: *const c_void, 55 meth_data: *mut c_void, 56 } 57 } 58 } 59 60 stack!(stack_st_X509_CRL); 61 62 cfg_if! { 63 if #[cfg(any(ossl110, libressl350))] { 64 pub enum X509_CRL_INFO {} 65 } else { 66 #[repr(C)] 67 pub struct X509_CRL_INFO { 68 version: *mut ASN1_INTEGER, 69 sig_alg: *mut X509_ALGOR, 70 pub issuer: *mut X509_NAME, 71 pub lastUpdate: *mut ASN1_TIME, 72 pub nextUpdate: *mut ASN1_TIME, 73 pub revoked: *mut stack_st_X509_REVOKED, 74 extensions: *mut stack_st_X509_EXTENSION, 75 enc: ASN1_ENCODING, 76 } 77 } 78 } 79 80 cfg_if! { 81 if #[cfg(any(ossl110, libressl350))] { 82 pub enum X509_REVOKED {} 83 } else { 84 #[repr(C)] 85 pub struct X509_REVOKED { 86 pub serialNumber: *mut ASN1_INTEGER, 87 pub revocationDate: *mut ASN1_TIME, 88 pub extensions: *mut stack_st_X509_EXTENSION, 89 issuer: *mut stack_st_GENERAL_NAME, 90 reason: c_int, 91 sequence: c_int, 92 } 93 } 94 } 95 96 stack!(stack_st_X509_REVOKED); 97 98 cfg_if! { 99 if #[cfg(any(ossl110, libressl350))] { 100 pub enum X509_REQ {} 101 } else { 102 #[repr(C)] 103 pub struct X509_REQ { 104 pub req_info: *mut X509_REQ_INFO, 105 sig_alg: *mut c_void, 106 signature: *mut c_void, 107 references: c_int, 108 } 109 } 110 } 111 112 cfg_if! { 113 if #[cfg(any(ossl110, libressl350))] { 114 pub enum X509_CINF {} 115 } else { 116 #[repr(C)] 117 pub struct X509_CINF { 118 version: *mut c_void, 119 serialNumber: *mut c_void, 120 signature: *mut c_void, 121 issuer: *mut c_void, 122 pub validity: *mut X509_VAL, 123 subject: *mut c_void, 124 key: *mut c_void, 125 issuerUID: *mut c_void, 126 subjectUID: *mut c_void, 127 pub extensions: *mut stack_st_X509_EXTENSION, 128 enc: ASN1_ENCODING, 129 } 130 } 131 } 132 133 stack!(stack_st_X509); 134 135 stack!(stack_st_X509_OBJECT); 136 137 stack!(stack_st_X509_LOOKUP); 138 139 extern "C" { X509_verify_cert_error_string(n: c_long) -> *const c_char140 pub fn X509_verify_cert_error_string(n: c_long) -> *const c_char; 141 X509_sign(x: *mut X509, pkey: *mut EVP_PKEY, md: *const EVP_MD) -> c_int142 pub fn X509_sign(x: *mut X509, pkey: *mut EVP_PKEY, md: *const EVP_MD) -> c_int; 143 X509_digest( x: *const X509, digest: *const EVP_MD, buf: *mut c_uchar, len: *mut c_uint, ) -> c_int144 pub fn X509_digest( 145 x: *const X509, 146 digest: *const EVP_MD, 147 buf: *mut c_uchar, 148 len: *mut c_uint, 149 ) -> c_int; 150 X509_REQ_sign(x: *mut X509_REQ, pkey: *mut EVP_PKEY, md: *const EVP_MD) -> c_int151 pub fn X509_REQ_sign(x: *mut X509_REQ, pkey: *mut EVP_PKEY, md: *const EVP_MD) -> c_int; 152 } 153 154 const_ptr_api! { 155 extern "C" { 156 pub fn i2d_X509_bio(b: *mut BIO, x: #[const_ptr_if(ossl300)] X509) -> c_int; 157 pub fn i2d_X509_REQ_bio(b: *mut BIO, x: #[const_ptr_if(ossl300)] X509_REQ) -> c_int; 158 pub fn i2d_PrivateKey_bio(b: *mut BIO, x: #[const_ptr_if(ossl300)] EVP_PKEY) -> c_int; 159 pub fn i2d_PUBKEY_bio(b: *mut BIO, x: #[const_ptr_if(ossl300)] EVP_PKEY) -> c_int; 160 161 pub fn i2d_PUBKEY(k: #[const_ptr_if(ossl300)] EVP_PKEY, buf: *mut *mut u8) -> c_int; 162 pub fn i2d_RSA_PUBKEY(k: #[const_ptr_if(ossl300)] RSA, buf: *mut *mut u8) -> c_int; 163 pub fn i2d_DSA_PUBKEY(a: #[const_ptr_if(ossl300)] DSA, pp: *mut *mut c_uchar) -> c_int; 164 pub fn i2d_PrivateKey(k: #[const_ptr_if(ossl300)] EVP_PKEY, buf: *mut *mut u8) -> c_int; 165 pub fn i2d_ECPrivateKey(ec_key: #[const_ptr_if(ossl300)] EC_KEY, pp: *mut *mut c_uchar) -> c_int; 166 pub fn i2d_EC_PUBKEY(a: #[const_ptr_if(ossl300)] EC_KEY, pp: *mut *mut c_uchar) -> c_int; 167 } 168 } 169 extern "C" { d2i_PUBKEY(k: *mut *mut EVP_PKEY, buf: *mut *const u8, len: c_long) -> *mut EVP_PKEY170 pub fn d2i_PUBKEY(k: *mut *mut EVP_PKEY, buf: *mut *const u8, len: c_long) -> *mut EVP_PKEY; d2i_RSA_PUBKEY(k: *mut *mut RSA, buf: *mut *const u8, len: c_long) -> *mut RSA171 pub fn d2i_RSA_PUBKEY(k: *mut *mut RSA, buf: *mut *const u8, len: c_long) -> *mut RSA; d2i_DSA_PUBKEY(k: *mut *mut DSA, pp: *mut *const c_uchar, length: c_long) -> *mut DSA172 pub fn d2i_DSA_PUBKEY(k: *mut *mut DSA, pp: *mut *const c_uchar, length: c_long) -> *mut DSA; d2i_EC_PUBKEY( a: *mut *mut EC_KEY, pp: *mut *const c_uchar, length: c_long, ) -> *mut EC_KEY173 pub fn d2i_EC_PUBKEY( 174 a: *mut *mut EC_KEY, 175 pp: *mut *const c_uchar, 176 length: c_long, 177 ) -> *mut EC_KEY; 178 d2i_ECPrivateKey( k: *mut *mut EC_KEY, pp: *mut *const c_uchar, length: c_long, ) -> *mut EC_KEY179 pub fn d2i_ECPrivateKey( 180 k: *mut *mut EC_KEY, 181 pp: *mut *const c_uchar, 182 length: c_long, 183 ) -> *mut EC_KEY; 184 } 185 186 const_ptr_api! { 187 extern "C" { 188 #[cfg(any(ossl102, libressl350))] 189 pub fn X509_ALGOR_get0( 190 paobj: *mut #[const_ptr_if(any(ossl110, libressl350))] ASN1_OBJECT, 191 pptype: *mut c_int, 192 ppval: *mut #[const_ptr_if(any(ossl110, libressl350))] c_void, 193 alg: #[const_ptr_if(any(ossl110, libressl350))] X509_ALGOR, 194 ); 195 } 196 } 197 198 extern "C" { X509_gmtime_adj(time: *mut ASN1_TIME, adj: c_long) -> *mut ASN1_TIME199 pub fn X509_gmtime_adj(time: *mut ASN1_TIME, adj: c_long) -> *mut ASN1_TIME; 200 X509_to_X509_REQ(x: *mut X509, pkey: *mut EVP_PKEY, md: *const EVP_MD) -> *mut X509_REQ201 pub fn X509_to_X509_REQ(x: *mut X509, pkey: *mut EVP_PKEY, md: *const EVP_MD) -> *mut X509_REQ; 202 X509_ALGOR_free(x: *mut X509_ALGOR)203 pub fn X509_ALGOR_free(x: *mut X509_ALGOR); 204 X509_REVOKED_new() -> *mut X509_REVOKED205 pub fn X509_REVOKED_new() -> *mut X509_REVOKED; X509_REVOKED_free(x: *mut X509_REVOKED)206 pub fn X509_REVOKED_free(x: *mut X509_REVOKED); 207 } 208 const_ptr_api! { 209 extern "C" { 210 #[cfg(any(ossl110, libressl270))] 211 pub fn X509_REVOKED_dup(rev: #[const_ptr_if(ossl300)] X509_REVOKED) -> *mut X509_REVOKED; 212 } 213 } 214 215 extern "C" { d2i_X509_REVOKED( a: *mut *mut X509_REVOKED, pp: *mut *const c_uchar, length: c_long, ) -> *mut X509_REVOKED216 pub fn d2i_X509_REVOKED( 217 a: *mut *mut X509_REVOKED, 218 pp: *mut *const c_uchar, 219 length: c_long, 220 ) -> *mut X509_REVOKED; 221 } 222 const_ptr_api! { 223 extern "C" { 224 pub fn i2d_X509_REVOKED(x: #[const_ptr_if(ossl300)] X509_REVOKED, buf: *mut *mut u8) -> c_int; 225 } 226 } 227 extern "C" { X509_CRL_new() -> *mut X509_CRL228 pub fn X509_CRL_new() -> *mut X509_CRL; X509_CRL_free(x: *mut X509_CRL)229 pub fn X509_CRL_free(x: *mut X509_CRL); d2i_X509_CRL( a: *mut *mut X509_CRL, pp: *mut *const c_uchar, length: c_long, ) -> *mut X509_CRL230 pub fn d2i_X509_CRL( 231 a: *mut *mut X509_CRL, 232 pp: *mut *const c_uchar, 233 length: c_long, 234 ) -> *mut X509_CRL; 235 } 236 const_ptr_api! { 237 extern "C" { 238 pub fn i2d_X509_CRL(x: #[const_ptr_if(ossl300)] X509_CRL, buf: *mut *mut u8) -> c_int; 239 #[cfg(any(ossl110, libressl270))] 240 pub fn X509_CRL_dup(x: #[const_ptr_if(ossl300)] X509_CRL) -> *mut X509_CRL; 241 } 242 } 243 244 extern "C" { X509_REQ_new() -> *mut X509_REQ245 pub fn X509_REQ_new() -> *mut X509_REQ; X509_REQ_free(x: *mut X509_REQ)246 pub fn X509_REQ_free(x: *mut X509_REQ); d2i_X509_REQ( a: *mut *mut X509_REQ, pp: *mut *const c_uchar, length: c_long, ) -> *mut X509_REQ247 pub fn d2i_X509_REQ( 248 a: *mut *mut X509_REQ, 249 pp: *mut *const c_uchar, 250 length: c_long, 251 ) -> *mut X509_REQ; 252 } 253 const_ptr_api! { 254 extern "C" { 255 pub fn i2d_X509_REQ(x: #[const_ptr_if(ossl300)] X509_REQ, buf: *mut *mut u8) -> c_int; 256 257 #[cfg(any(ossl102, libressl273))] 258 pub fn X509_get0_signature( 259 psig: *mut #[const_ptr_if(any(ossl110, libressl273))] ASN1_BIT_STRING, 260 palg: *mut #[const_ptr_if(any(ossl110, libressl273))] X509_ALGOR, 261 x: *const X509, 262 ); 263 264 #[cfg(any(ossl110, libressl270))] 265 pub fn X509_REQ_dup(x: #[const_ptr_if(ossl300)] X509_REQ) -> *mut X509_REQ; 266 } 267 } 268 extern "C" { 269 #[cfg(ossl102)] X509_get_signature_nid(x: *const X509) -> c_int270 pub fn X509_get_signature_nid(x: *const X509) -> c_int; 271 X509_EXTENSION_free(ext: *mut X509_EXTENSION)272 pub fn X509_EXTENSION_free(ext: *mut X509_EXTENSION); 273 X509_NAME_ENTRY_free(x: *mut X509_NAME_ENTRY)274 pub fn X509_NAME_ENTRY_free(x: *mut X509_NAME_ENTRY); 275 X509_NAME_new() -> *mut X509_NAME276 pub fn X509_NAME_new() -> *mut X509_NAME; X509_NAME_free(x: *mut X509_NAME)277 pub fn X509_NAME_free(x: *mut X509_NAME); 278 X509_new() -> *mut X509279 pub fn X509_new() -> *mut X509; X509_free(x: *mut X509)280 pub fn X509_free(x: *mut X509); 281 } 282 const_ptr_api! { 283 extern "C" { 284 pub fn i2d_X509(x: #[const_ptr_if(ossl300)] X509, buf: *mut *mut u8) -> c_int; 285 #[cfg(any(ossl110, libressl270))] 286 pub fn X509_NAME_dup(x: #[const_ptr_if(ossl300)] X509_NAME) -> *mut X509_NAME; 287 #[cfg(any(ossl110, libressl270))] 288 pub fn X509_dup(x: #[const_ptr_if(ossl300)] X509) -> *mut X509; 289 #[cfg(any(ossl101, libressl350))] 290 pub fn X509_NAME_add_entry( 291 name: *mut X509_NAME, 292 ne: #[const_ptr_if(any(ossl110, libressl))] X509_NAME_ENTRY, 293 loc: c_int, 294 set: c_int, 295 ) -> c_int; 296 } 297 } 298 extern "C" { d2i_X509(a: *mut *mut X509, pp: *mut *const c_uchar, length: c_long) -> *mut X509299 pub fn d2i_X509(a: *mut *mut X509, pp: *mut *const c_uchar, length: c_long) -> *mut X509; d2i_X509_bio(b: *mut BIO, a: *mut *mut X509) -> *mut X509300 pub fn d2i_X509_bio(b: *mut BIO, a: *mut *mut X509) -> *mut X509; 301 X509_get_pubkey(x: *mut X509) -> *mut EVP_PKEY302 pub fn X509_get_pubkey(x: *mut X509) -> *mut EVP_PKEY; 303 X509_set_version(x: *mut X509, version: c_long) -> c_int304 pub fn X509_set_version(x: *mut X509, version: c_long) -> c_int; 305 #[cfg(ossl110)] X509_get_version(x: *const X509) -> c_long306 pub fn X509_get_version(x: *const X509) -> c_long; X509_set_serialNumber(x: *mut X509, sn: *mut ASN1_INTEGER) -> c_int307 pub fn X509_set_serialNumber(x: *mut X509, sn: *mut ASN1_INTEGER) -> c_int; X509_get_serialNumber(x: *mut X509) -> *mut ASN1_INTEGER308 pub fn X509_get_serialNumber(x: *mut X509) -> *mut ASN1_INTEGER; 309 } 310 const_ptr_api! { 311 extern "C" { 312 pub fn X509_set_issuer_name(x: *mut X509, name: #[const_ptr_if(ossl300)] X509_NAME) -> c_int; 313 } 314 } 315 extern "C" { X509_issuer_name_hash(x: *mut X509) -> c_ulong316 pub fn X509_issuer_name_hash(x: *mut X509) -> c_ulong; X509_subject_name_hash(x: *mut X509) -> c_ulong317 pub fn X509_subject_name_hash(x: *mut X509) -> c_ulong; 318 } 319 const_ptr_api! { 320 extern "C" { 321 pub fn X509_get_issuer_name(x: #[const_ptr_if(any(ossl110, libressl280))] X509) -> *mut X509_NAME; 322 pub fn X509_set_subject_name(x: *mut X509, name: #[const_ptr_if(ossl300)] X509_NAME) -> c_int; 323 pub fn X509_get_subject_name(x: #[const_ptr_if(any(ossl110, libressl280))] X509) -> *mut X509_NAME; 324 } 325 } 326 cfg_if! { 327 if #[cfg(any(ossl110, libressl350))] { 328 extern "C" { 329 pub fn X509_set1_notBefore(x: *mut X509, tm: *const ASN1_TIME) -> c_int; 330 pub fn X509_set1_notAfter(x: *mut X509, tm: *const ASN1_TIME) -> c_int; 331 } 332 } else { 333 extern "C" { 334 pub fn X509_set_notBefore(x: *mut X509, tm: *const ASN1_TIME) -> c_int; 335 pub fn X509_set_notAfter(x: *mut X509, tm: *const ASN1_TIME) -> c_int; 336 } 337 } 338 } 339 extern "C" { 340 #[cfg(any(ossl110, libressl350))] X509_REQ_get_version(req: *const X509_REQ) -> c_long341 pub fn X509_REQ_get_version(req: *const X509_REQ) -> c_long; X509_REQ_set_version(req: *mut X509_REQ, version: c_long) -> c_int342 pub fn X509_REQ_set_version(req: *mut X509_REQ, version: c_long) -> c_int; 343 #[cfg(any(ossl110, libressl350))] X509_REQ_get_subject_name(req: *const X509_REQ) -> *mut X509_NAME344 pub fn X509_REQ_get_subject_name(req: *const X509_REQ) -> *mut X509_NAME; 345 } 346 const_ptr_api! { 347 extern "C" { 348 pub fn X509_REQ_set_subject_name(req: *mut X509_REQ, name: #[const_ptr_if(ossl300)] X509_NAME) -> c_int; 349 } 350 } 351 extern "C" { X509_REQ_set_pubkey(req: *mut X509_REQ, pkey: *mut EVP_PKEY) -> c_int352 pub fn X509_REQ_set_pubkey(req: *mut X509_REQ, pkey: *mut EVP_PKEY) -> c_int; X509_REQ_get_pubkey(req: *mut X509_REQ) -> *mut EVP_PKEY353 pub fn X509_REQ_get_pubkey(req: *mut X509_REQ) -> *mut EVP_PKEY; X509_REQ_get_extensions(req: *mut X509_REQ) -> *mut stack_st_X509_EXTENSION354 pub fn X509_REQ_get_extensions(req: *mut X509_REQ) -> *mut stack_st_X509_EXTENSION; 355 } 356 const_ptr_api! { 357 extern "C" { 358 pub fn X509_REQ_add_extensions(req: *mut X509_REQ, exts: #[const_ptr_if(ossl300)] stack_st_X509_EXTENSION) 359 -> c_int; 360 } 361 } 362 extern "C" { X509_set_pubkey(x: *mut X509, pkey: *mut EVP_PKEY) -> c_int363 pub fn X509_set_pubkey(x: *mut X509, pkey: *mut EVP_PKEY) -> c_int; X509_REQ_verify(req: *mut X509_REQ, pkey: *mut EVP_PKEY) -> c_int364 pub fn X509_REQ_verify(req: *mut X509_REQ, pkey: *mut EVP_PKEY) -> c_int; 365 #[cfg(any(ossl110, libressl273))] X509_getm_notBefore(x: *const X509) -> *mut ASN1_TIME366 pub fn X509_getm_notBefore(x: *const X509) -> *mut ASN1_TIME; 367 #[cfg(any(ossl110, libressl273))] X509_getm_notAfter(x: *const X509) -> *mut ASN1_TIME368 pub fn X509_getm_notAfter(x: *const X509) -> *mut ASN1_TIME; 369 #[cfg(any(ossl110, libressl273))] X509_up_ref(x: *mut X509) -> c_int370 pub fn X509_up_ref(x: *mut X509) -> c_int; 371 372 #[cfg(any(ossl110, libressl270))] X509_REVOKED_get0_serialNumber(req: *const X509_REVOKED) -> *const ASN1_INTEGER373 pub fn X509_REVOKED_get0_serialNumber(req: *const X509_REVOKED) -> *const ASN1_INTEGER; 374 #[cfg(any(ossl110, libressl270))] X509_REVOKED_get0_revocationDate(req: *const X509_REVOKED) -> *const ASN1_TIME375 pub fn X509_REVOKED_get0_revocationDate(req: *const X509_REVOKED) -> *const ASN1_TIME; 376 #[cfg(any(ossl110, libressl270))] X509_REVOKED_get0_extensions(r: *const X509_REVOKED) -> *const stack_st_X509_EXTENSION377 pub fn X509_REVOKED_get0_extensions(r: *const X509_REVOKED) -> *const stack_st_X509_EXTENSION; 378 X509_REVOKED_set_serialNumber(r: *mut X509_REVOKED, serial: *mut ASN1_INTEGER) -> c_int379 pub fn X509_REVOKED_set_serialNumber(r: *mut X509_REVOKED, serial: *mut ASN1_INTEGER) -> c_int; X509_REVOKED_set_revocationDate(r: *mut X509_REVOKED, tm: *mut ASN1_TIME) -> c_int380 pub fn X509_REVOKED_set_revocationDate(r: *mut X509_REVOKED, tm: *mut ASN1_TIME) -> c_int; 381 X509_CRL_sign(x: *mut X509_CRL, pkey: *mut EVP_PKEY, md: *const EVP_MD) -> c_int382 pub fn X509_CRL_sign(x: *mut X509_CRL, pkey: *mut EVP_PKEY, md: *const EVP_MD) -> c_int; X509_CRL_digest( x: *const X509_CRL, digest: *const EVP_MD, md: *mut c_uchar, len: *mut c_uint, ) -> c_int383 pub fn X509_CRL_digest( 384 x: *const X509_CRL, 385 digest: *const EVP_MD, 386 md: *mut c_uchar, 387 len: *mut c_uint, 388 ) -> c_int; X509_CRL_verify(crl: *mut X509_CRL, pkey: *mut EVP_PKEY) -> c_int389 pub fn X509_CRL_verify(crl: *mut X509_CRL, pkey: *mut EVP_PKEY) -> c_int; X509_CRL_get0_by_cert( x: *mut X509_CRL, ret: *mut *mut X509_REVOKED, cert: *mut X509, ) -> c_int390 pub fn X509_CRL_get0_by_cert( 391 x: *mut X509_CRL, 392 ret: *mut *mut X509_REVOKED, 393 cert: *mut X509, 394 ) -> c_int; 395 } 396 const_ptr_api! { 397 extern "C" { 398 pub fn X509_CRL_get0_by_serial( 399 x: *mut X509_CRL, 400 ret: *mut *mut X509_REVOKED, 401 serial: #[const_ptr_if(ossl300)] ASN1_INTEGER, 402 ) -> c_int; 403 } 404 } 405 406 extern "C" { 407 #[cfg(any(ossl110, libressl281))] X509_CRL_get_REVOKED(crl: *mut X509_CRL) -> *mut stack_st_X509_REVOKED408 pub fn X509_CRL_get_REVOKED(crl: *mut X509_CRL) -> *mut stack_st_X509_REVOKED; 409 #[cfg(any(ossl110, libressl281))] X509_CRL_get0_nextUpdate(x: *const X509_CRL) -> *const ASN1_TIME410 pub fn X509_CRL_get0_nextUpdate(x: *const X509_CRL) -> *const ASN1_TIME; 411 #[cfg(any(ossl110, libressl281))] X509_CRL_get0_lastUpdate(x: *const X509_CRL) -> *const ASN1_TIME412 pub fn X509_CRL_get0_lastUpdate(x: *const X509_CRL) -> *const ASN1_TIME; 413 #[cfg(any(ossl110, libressl281))] X509_CRL_get_issuer(x: *const X509_CRL) -> *mut X509_NAME414 pub fn X509_CRL_get_issuer(x: *const X509_CRL) -> *mut X509_NAME; 415 416 #[cfg(ossl110)] X509_get0_extensions(req: *const X509) -> *const stack_st_X509_EXTENSION417 pub fn X509_get0_extensions(req: *const X509) -> *const stack_st_X509_EXTENSION; 418 X509_CRL_set_version(crl: *mut X509_CRL, version: c_long) -> c_int419 pub fn X509_CRL_set_version(crl: *mut X509_CRL, version: c_long) -> c_int; 420 } 421 const_ptr_api! { 422 extern "C" { 423 pub fn X509_CRL_set_issuer_name(crl: *mut X509_CRL, name: #[const_ptr_if(ossl300)] X509_NAME) -> c_int; 424 } 425 } 426 extern "C" { X509_CRL_sort(crl: *mut X509_CRL) -> c_int427 pub fn X509_CRL_sort(crl: *mut X509_CRL) -> c_int; 428 429 #[cfg(any(ossl110, libressl270))] X509_CRL_up_ref(crl: *mut X509_CRL) -> c_int430 pub fn X509_CRL_up_ref(crl: *mut X509_CRL) -> c_int; X509_CRL_add0_revoked(crl: *mut X509_CRL, rev: *mut X509_REVOKED) -> c_int431 pub fn X509_CRL_add0_revoked(crl: *mut X509_CRL, rev: *mut X509_REVOKED) -> c_int; 432 } 433 cfg_if! { 434 if #[cfg(any(ossl110, libressl270))] { 435 extern "C" { 436 pub fn X509_CRL_set1_lastUpdate(crl: *mut X509_CRL, tm: *const ASN1_TIME) -> c_int; 437 pub fn X509_CRL_set1_nextUpdate(crl: *mut X509_CRL, tm: *const ASN1_TIME) -> c_int; 438 } 439 } else { 440 // libressl270 kept them, ossl110 "#define"s them to the variants above 441 extern "C" { 442 pub fn X509_CRL_set_lastUpdate(crl: *mut X509_CRL, tm: *const ASN1_TIME) -> c_int; 443 pub fn X509_CRL_set_nextUpdate(crl: *mut X509_CRL, tm: *const ASN1_TIME) -> c_int; 444 } 445 } 446 } 447 448 const_ptr_api! { 449 extern "C" { 450 pub fn X509_NAME_entry_count(n: #[const_ptr_if(any(ossl110, libressl280))] X509_NAME) -> c_int; 451 pub fn X509_NAME_get_index_by_NID(n: #[const_ptr_if(any(ossl300, libressl280))] X509_NAME, nid: c_int, last_pos: c_int) -> c_int; 452 pub fn X509_NAME_get_entry(n: #[const_ptr_if(any(ossl110, libressl280))] X509_NAME, loc: c_int) -> *mut X509_NAME_ENTRY; 453 pub fn X509_NAME_add_entry_by_NID( 454 x: *mut X509_NAME, 455 field: c_int, 456 ty: c_int, 457 bytes: #[const_ptr_if(any(ossl110, libressl280))] c_uchar, 458 len: c_int, 459 loc: c_int, 460 set: c_int, 461 ) -> c_int; 462 pub fn i2d_X509_NAME(n: #[const_ptr_if(ossl300)] X509_NAME, buf: *mut *mut u8) -> c_int; 463 pub fn X509_NAME_ENTRY_get_object(ne: #[const_ptr_if(any(ossl110, libressl280))] X509_NAME_ENTRY) -> *mut ASN1_OBJECT; 464 pub fn X509_NAME_ENTRY_get_data(ne: #[const_ptr_if(any(ossl110, libressl280))] X509_NAME_ENTRY) -> *mut ASN1_STRING; 465 } 466 } 467 extern "C" { X509_NAME_add_entry_by_txt( x: *mut X509_NAME, field: *const c_char, ty: c_int, bytes: *const c_uchar, len: c_int, loc: c_int, set: c_int, ) -> c_int468 pub fn X509_NAME_add_entry_by_txt( 469 x: *mut X509_NAME, 470 field: *const c_char, 471 ty: c_int, 472 bytes: *const c_uchar, 473 len: c_int, 474 loc: c_int, 475 set: c_int, 476 ) -> c_int; d2i_X509_NAME( n: *mut *mut X509_NAME, pp: *mut *const c_uchar, length: c_long, ) -> *mut X509_NAME477 pub fn d2i_X509_NAME( 478 n: *mut *mut X509_NAME, 479 pp: *mut *const c_uchar, 480 length: c_long, 481 ) -> *mut X509_NAME; 482 } 483 484 // "raw" X509_EXTENSION related functions 485 extern "C" { 486 // in X509 X509_delete_ext(x: *mut X509, loc: c_int) -> *mut X509_EXTENSION487 pub fn X509_delete_ext(x: *mut X509, loc: c_int) -> *mut X509_EXTENSION; X509_add_ext(x: *mut X509, ext: *mut X509_EXTENSION, loc: c_int) -> c_int488 pub fn X509_add_ext(x: *mut X509, ext: *mut X509_EXTENSION, loc: c_int) -> c_int; X509_add1_ext_i2d( x: *mut X509, nid: c_int, value: *mut c_void, crit: c_int, flags: c_ulong, ) -> c_int489 pub fn X509_add1_ext_i2d( 490 x: *mut X509, 491 nid: c_int, 492 value: *mut c_void, 493 crit: c_int, 494 flags: c_ulong, 495 ) -> c_int; 496 // in X509_CRL X509_CRL_delete_ext(x: *mut X509_CRL, loc: c_int) -> *mut X509_EXTENSION497 pub fn X509_CRL_delete_ext(x: *mut X509_CRL, loc: c_int) -> *mut X509_EXTENSION; X509_CRL_add_ext(x: *mut X509_CRL, ext: *mut X509_EXTENSION, loc: c_int) -> c_int498 pub fn X509_CRL_add_ext(x: *mut X509_CRL, ext: *mut X509_EXTENSION, loc: c_int) -> c_int; X509_CRL_add1_ext_i2d( x: *mut X509_CRL, nid: c_int, value: *mut c_void, crit: c_int, flags: c_ulong, ) -> c_int499 pub fn X509_CRL_add1_ext_i2d( 500 x: *mut X509_CRL, 501 nid: c_int, 502 value: *mut c_void, 503 crit: c_int, 504 flags: c_ulong, 505 ) -> c_int; 506 // in X509_REVOKED X509_REVOKED_delete_ext(x: *mut X509_REVOKED, loc: c_int) -> *mut X509_EXTENSION507 pub fn X509_REVOKED_delete_ext(x: *mut X509_REVOKED, loc: c_int) -> *mut X509_EXTENSION; X509_REVOKED_add_ext( x: *mut X509_REVOKED, ext: *mut X509_EXTENSION, loc: c_int, ) -> c_int508 pub fn X509_REVOKED_add_ext( 509 x: *mut X509_REVOKED, 510 ext: *mut X509_EXTENSION, 511 loc: c_int, 512 ) -> c_int; X509_REVOKED_add1_ext_i2d( x: *mut X509_REVOKED, nid: c_int, value: *mut c_void, crit: c_int, flags: c_ulong, ) -> c_int513 pub fn X509_REVOKED_add1_ext_i2d( 514 x: *mut X509_REVOKED, 515 nid: c_int, 516 value: *mut c_void, 517 crit: c_int, 518 flags: c_ulong, 519 ) -> c_int; 520 // X509_EXTENSION stack 521 // - these getters always used *const STACK X509v3_get_ext_count(x: *const stack_st_X509_EXTENSION) -> c_int522 pub fn X509v3_get_ext_count(x: *const stack_st_X509_EXTENSION) -> c_int; X509v3_get_ext_by_NID( x: *const stack_st_X509_EXTENSION, nid: c_int, lastpos: c_int, ) -> c_int523 pub fn X509v3_get_ext_by_NID( 524 x: *const stack_st_X509_EXTENSION, 525 nid: c_int, 526 lastpos: c_int, 527 ) -> c_int; X509v3_get_ext_by_critical( x: *const stack_st_X509_EXTENSION, crit: c_int, lastpos: c_int, ) -> c_int528 pub fn X509v3_get_ext_by_critical( 529 x: *const stack_st_X509_EXTENSION, 530 crit: c_int, 531 lastpos: c_int, 532 ) -> c_int; X509v3_get_ext(x: *const stack_st_X509_EXTENSION, loc: c_int) -> *mut X509_EXTENSION533 pub fn X509v3_get_ext(x: *const stack_st_X509_EXTENSION, loc: c_int) -> *mut X509_EXTENSION; X509v3_delete_ext(x: *mut stack_st_X509_EXTENSION, loc: c_int) -> *mut X509_EXTENSION534 pub fn X509v3_delete_ext(x: *mut stack_st_X509_EXTENSION, loc: c_int) -> *mut X509_EXTENSION; X509v3_add_ext( x: *mut *mut stack_st_X509_EXTENSION, ex: *mut X509_EXTENSION, loc: c_int, ) -> *mut stack_st_X509_EXTENSION535 pub fn X509v3_add_ext( 536 x: *mut *mut stack_st_X509_EXTENSION, 537 ex: *mut X509_EXTENSION, 538 loc: c_int, 539 ) -> *mut stack_st_X509_EXTENSION; 540 // - X509V3_add1_i2d in x509v3.rs 541 // X509_EXTENSION itself X509_EXTENSION_create_by_NID( ex: *mut *mut X509_EXTENSION, nid: c_int, crit: c_int, data: *mut ASN1_OCTET_STRING, ) -> *mut X509_EXTENSION542 pub fn X509_EXTENSION_create_by_NID( 543 ex: *mut *mut X509_EXTENSION, 544 nid: c_int, 545 crit: c_int, 546 data: *mut ASN1_OCTET_STRING, 547 ) -> *mut X509_EXTENSION; X509_EXTENSION_set_critical(ex: *mut X509_EXTENSION, crit: c_int) -> c_int548 pub fn X509_EXTENSION_set_critical(ex: *mut X509_EXTENSION, crit: c_int) -> c_int; X509_EXTENSION_set_data(ex: *mut X509_EXTENSION, data: *mut ASN1_OCTET_STRING) -> c_int549 pub fn X509_EXTENSION_set_data(ex: *mut X509_EXTENSION, data: *mut ASN1_OCTET_STRING) -> c_int; X509_EXTENSION_get_object(ext: *mut X509_EXTENSION) -> *mut ASN1_OBJECT550 pub fn X509_EXTENSION_get_object(ext: *mut X509_EXTENSION) -> *mut ASN1_OBJECT; X509_EXTENSION_get_data(ext: *mut X509_EXTENSION) -> *mut ASN1_OCTET_STRING551 pub fn X509_EXTENSION_get_data(ext: *mut X509_EXTENSION) -> *mut ASN1_OCTET_STRING; 552 } 553 const_ptr_api! { 554 extern "C" { 555 // in X509 556 pub fn X509_get_ext_count(x: #[const_ptr_if(any(ossl110, libressl280))] X509) -> c_int; 557 pub fn X509_get_ext_by_NID(x: #[const_ptr_if(any(ossl110, libressl280))] X509, nid: c_int, lastpos: c_int) -> c_int; 558 pub fn X509_get_ext_by_OBJ(x: #[const_ptr_if(any(ossl110, libressl280))] X509, obj: #[const_ptr_if(any(ossl110, libressl280))] ASN1_OBJECT, lastpos: c_int) -> c_int; 559 pub fn X509_get_ext_by_critical(x: #[const_ptr_if(any(ossl110, libressl280))] X509, crit: c_int, lastpos: c_int) -> c_int; 560 pub fn X509_get_ext(x: #[const_ptr_if(any(ossl110, libressl280))] X509, loc: c_int) -> *mut X509_EXTENSION; 561 pub fn X509_get_ext_d2i( 562 x: #[const_ptr_if(any(ossl110, libressl280))] X509, 563 nid: c_int, 564 crit: *mut c_int, 565 idx: *mut c_int, 566 ) -> *mut c_void; 567 // in X509_CRL 568 pub fn X509_CRL_get_ext_count(x: #[const_ptr_if(any(ossl110, libressl280))] X509_CRL) -> c_int; 569 pub fn X509_CRL_get_ext_by_NID(x: #[const_ptr_if(any(ossl110, libressl280))] X509_CRL, nid: c_int, lastpos: c_int) -> c_int; 570 pub fn X509_CRL_get_ext_by_OBJ(x: #[const_ptr_if(any(ossl110, libressl280))] X509_CRL, obj: #[const_ptr_if(any(ossl110, libressl280))] ASN1_OBJECT, lastpos: c_int) -> c_int; 571 pub fn X509_CRL_get_ext_by_critical(x: #[const_ptr_if(any(ossl110, libressl280))] X509_CRL, crit: c_int, lastpos: c_int) -> c_int; 572 pub fn X509_CRL_get_ext(x: #[const_ptr_if(any(ossl110, libressl280))] X509_CRL, loc: c_int) -> *mut X509_EXTENSION; 573 pub fn X509_CRL_get_ext_d2i( 574 x: #[const_ptr_if(any(ossl110, libressl280))] X509_CRL, 575 nid: c_int, 576 crit: *mut c_int, 577 idx: *mut c_int, 578 ) -> *mut c_void; 579 // in X509_REVOKED 580 pub fn X509_REVOKED_get_ext_count(x: #[const_ptr_if(any(ossl110, libressl280))] X509_REVOKED) -> c_int; 581 pub fn X509_REVOKED_get_ext_by_NID(x: #[const_ptr_if(any(ossl110, libressl280))] X509_REVOKED, nid: c_int, lastpos: c_int) -> c_int; 582 pub fn X509_REVOKED_get_ext_by_OBJ(x: #[const_ptr_if(any(ossl110, libressl280))] X509_REVOKED, obj: #[const_ptr_if(any(ossl110, libressl280))] ASN1_OBJECT, lastpos: c_int) -> c_int; 583 pub fn X509_REVOKED_get_ext_by_critical(x: #[const_ptr_if(any(ossl110, libressl280))] X509_REVOKED, crit: c_int, lastpos: c_int) -> c_int; 584 pub fn X509_REVOKED_get_ext(x: #[const_ptr_if(any(ossl110, libressl280))] X509_REVOKED, loc: c_int) -> *mut X509_EXTENSION; 585 pub fn X509_REVOKED_get_ext_d2i( 586 x: #[const_ptr_if(any(ossl110, libressl280))] X509_REVOKED, 587 nid: c_int, 588 crit: *mut c_int, 589 idx: *mut c_int, 590 ) -> *mut c_void; 591 // X509_EXTENSION stack 592 pub fn X509v3_get_ext_by_OBJ(x: *const stack_st_X509_EXTENSION, obj: #[const_ptr_if(any(ossl110, libressl280))] ASN1_OBJECT, lastpos: c_int) -> c_int; 593 // X509_EXTENSION itself 594 pub fn X509_EXTENSION_create_by_OBJ(ex: *mut *mut X509_EXTENSION, obj: #[const_ptr_if(any(ossl110, libressl280))] ASN1_OBJECT, crit: c_int, data: *mut ASN1_OCTET_STRING) -> *mut X509_EXTENSION; 595 pub fn X509_EXTENSION_set_object(ex: *mut X509_EXTENSION, obj: #[const_ptr_if(any(ossl110, libressl280))] ASN1_OBJECT) -> c_int; 596 pub fn X509_EXTENSION_get_critical(ex: #[const_ptr_if(any(ossl110, libressl280))] X509_EXTENSION) -> c_int; 597 } 598 } 599 600 extern "C" { X509_verify_cert(ctx: *mut X509_STORE_CTX) -> c_int601 pub fn X509_verify_cert(ctx: *mut X509_STORE_CTX) -> c_int; 602 } 603 604 const_ptr_api! { 605 extern "C" { 606 #[cfg(any(ossl110, libressl270))] 607 pub fn X509_STORE_get0_objects(ctx: #[const_ptr_if(ossl300)] X509_STORE) -> *mut stack_st_X509_OBJECT; 608 } 609 } 610 #[cfg(any(ossl110, libressl270))] 611 extern "C" { X509_OBJECT_get0_X509(x: *const X509_OBJECT) -> *mut X509612 pub fn X509_OBJECT_get0_X509(x: *const X509_OBJECT) -> *mut X509; 613 } 614 615 cfg_if! { 616 if #[cfg(any(ossl110, libressl350))] { 617 extern "C" { 618 pub fn X509_OBJECT_free(a: *mut X509_OBJECT); 619 } 620 } else { 621 extern "C" { 622 pub fn X509_OBJECT_free_contents(a: *mut X509_OBJECT); 623 } 624 } 625 } 626 627 extern "C" { X509_get_default_cert_file_env() -> *const c_char628 pub fn X509_get_default_cert_file_env() -> *const c_char; X509_get_default_cert_file() -> *const c_char629 pub fn X509_get_default_cert_file() -> *const c_char; X509_get_default_cert_dir_env() -> *const c_char630 pub fn X509_get_default_cert_dir_env() -> *const c_char; X509_get_default_cert_dir() -> *const c_char631 pub fn X509_get_default_cert_dir() -> *const c_char; 632 } 633 634 extern "C" { X509_cmp(a: *const X509, b: *const X509) -> c_int635 pub fn X509_cmp(a: *const X509, b: *const X509) -> c_int; X509_NAME_cmp(a: *const X509_NAME, b: *const X509_NAME) -> c_int636 pub fn X509_NAME_cmp(a: *const X509_NAME, b: *const X509_NAME) -> c_int; X509_issuer_and_serial_cmp(a: *const X509, b: *const X509) -> c_int637 pub fn X509_issuer_and_serial_cmp(a: *const X509, b: *const X509) -> c_int; X509_issuer_name_cmp(a: *const X509, b: *const X509) -> c_int638 pub fn X509_issuer_name_cmp(a: *const X509, b: *const X509) -> c_int; X509_subject_name_cmp(a: *const X509, b: *const X509) -> c_int639 pub fn X509_subject_name_cmp(a: *const X509, b: *const X509) -> c_int; X509_CRL_cmp(a: *const X509_CRL, b: *const X509_CRL) -> c_int640 pub fn X509_CRL_cmp(a: *const X509_CRL, b: *const X509_CRL) -> c_int; X509_CRL_match(a: *const X509_CRL, b: *const X509_CRL) -> c_int641 pub fn X509_CRL_match(a: *const X509_CRL, b: *const X509_CRL) -> c_int; 642 } 643 644 extern "C" { X509_print(bio: *mut BIO, x509: *mut X509) -> c_int645 pub fn X509_print(bio: *mut BIO, x509: *mut X509) -> c_int; X509_REQ_print(bio: *mut BIO, req: *mut X509_REQ) -> c_int646 pub fn X509_REQ_print(bio: *mut BIO, req: *mut X509_REQ) -> c_int; 647 } 648 649 #[repr(C)] 650 pub struct X509_PURPOSE { 651 pub purpose: c_int, 652 pub trust: c_int, // Default trust ID 653 pub flags: c_int, 654 pub check_purpose: 655 Option<unsafe extern "C" fn(*const X509_PURPOSE, *const X509, c_int) -> c_int>, 656 pub name: *mut c_char, 657 pub sname: *mut c_char, 658 pub usr_data: *mut c_void, 659 } 660 661 const_ptr_api! { 662 extern "C" { 663 pub fn X509_PURPOSE_get_by_sname(sname: #[const_ptr_if(any(ossl110, libressl280))] c_char) -> c_int; 664 pub fn X509_PURPOSE_get0(idx: c_int) -> *mut X509_PURPOSE; 665 } 666 } 667