diff options
| author | Steven Fackler <[email protected]> | 2017-05-20 15:53:45 -0700 |
|---|---|---|
| committer | Steven Fackler <[email protected]> | 2017-05-20 15:53:45 -0700 |
| commit | 7d587e2c93348a699dbd3b46286f4d5eda6ccd11 (patch) | |
| tree | d904246914caceec04e6cfc7e4df9042435b9616 /openssl-sys/src/libressl | |
| parent | Release v0.9.12 (diff) | |
| download | rust-openssl-7d587e2c93348a699dbd3b46286f4d5eda6ccd11.tar.xz rust-openssl-7d587e2c93348a699dbd3b46286f4d5eda6ccd11.zip | |
Rustfmt
Diffstat (limited to 'openssl-sys/src/libressl')
| -rw-r--r-- | openssl-sys/src/libressl/mod.rs | 226 | ||||
| -rw-r--r-- | openssl-sys/src/libressl/v250.rs | 17 | ||||
| -rw-r--r-- | openssl-sys/src/libressl/v25x.rs | 2 |
3 files changed, 142 insertions, 103 deletions
diff --git a/openssl-sys/src/libressl/mod.rs b/openssl-sys/src/libressl/mod.rs index 951ab4d3..aa7dc650 100644 --- a/openssl-sys/src/libressl/mod.rs +++ b/openssl-sys/src/libressl/mod.rs @@ -66,21 +66,21 @@ pub struct _STACK { pub data: *mut *mut c_char, pub sorted: c_int, pub num_alloc: c_int, - pub comp: Option<unsafe extern fn(*const c_void, *const c_void) -> c_int>, + pub comp: Option<unsafe extern "C" fn(*const c_void, *const c_void) -> c_int>, } #[repr(C)] pub struct BIO_METHOD { pub type_: c_int, pub name: *const c_char, - pub bwrite: Option<unsafe extern fn(*mut ::BIO, *const c_char, c_int) -> c_int>, - pub bread: Option<unsafe extern fn(*mut ::BIO, *mut c_char, c_int) -> c_int>, - pub bputs: Option<unsafe extern fn(*mut ::BIO, *const c_char) -> c_int>, - pub bgets: Option<unsafe extern fn(*mut ::BIO, *mut c_char, c_int) -> c_int>, - pub ctrl: Option<unsafe extern fn(*mut ::BIO, c_int, c_long, *mut c_void) -> c_long>, - pub create: Option<unsafe extern fn(*mut ::BIO) -> c_int>, - pub destroy: Option<unsafe extern fn(*mut ::BIO) -> c_int>, - pub callback_ctrl: Option<unsafe extern fn(*mut ::BIO, c_int, ::bio_info_cb) -> c_long>, + pub bwrite: Option<unsafe extern "C" fn(*mut ::BIO, *const c_char, c_int) -> c_int>, + pub bread: Option<unsafe extern "C" fn(*mut ::BIO, *mut c_char, c_int) -> c_int>, + pub bputs: Option<unsafe extern "C" fn(*mut ::BIO, *const c_char) -> c_int>, + pub bgets: Option<unsafe extern "C" fn(*mut ::BIO, *mut c_char, c_int) -> c_int>, + pub ctrl: Option<unsafe extern "C" fn(*mut ::BIO, c_int, c_long, *mut c_void) -> c_long>, + pub create: Option<unsafe extern "C" fn(*mut ::BIO) -> c_int>, + pub destroy: Option<unsafe extern "C" fn(*mut ::BIO) -> c_int>, + pub callback_ctrl: Option<unsafe extern "C" fn(*mut ::BIO, c_int, ::bio_info_cb) -> c_long>, } #[repr(C)] @@ -148,7 +148,7 @@ pub struct EVP_PKEY { #[repr(C)] pub struct BIO { pub method: *mut ::BIO_METHOD, - pub callback: Option<unsafe extern fn(*mut ::BIO, + pub callback: Option<unsafe extern "C" fn(*mut ::BIO, c_int, *const c_char, c_int, @@ -182,7 +182,7 @@ pub struct EVP_MD_CTX { flags: c_ulong, md_data: *mut c_void, pctx: *mut ::EVP_PKEY_CTX, - update: *mut c_void + update: *mut c_void, } #[repr(C)] @@ -192,24 +192,23 @@ pub struct EVP_CIPHER { pub key_len: c_int, pub iv_len: c_int, pub flags: c_ulong, - pub init: Option<unsafe extern fn(*mut ::EVP_CIPHER_CTX, - *const c_uchar, - *const c_uchar, - c_int) -> c_int>, - pub do_cipher: Option<unsafe extern fn(*mut ::EVP_CIPHER_CTX, - *mut c_uchar, - *const c_uchar, - size_t) -> c_int>, - pub cleanup: Option<unsafe extern fn(*mut ::EVP_CIPHER_CTX) -> c_int>, + pub init: Option<unsafe extern "C" fn(*mut ::EVP_CIPHER_CTX, + *const c_uchar, + *const c_uchar, + c_int) + -> c_int>, + pub do_cipher: Option<unsafe extern "C" fn(*mut ::EVP_CIPHER_CTX, + *mut c_uchar, + *const c_uchar, + size_t) + -> c_int>, + pub cleanup: Option<unsafe extern "C" fn(*mut ::EVP_CIPHER_CTX) -> c_int>, pub ctx_size: c_int, - pub set_asn1_parameters: Option<unsafe extern fn(*mut ::EVP_CIPHER_CTX, - *mut ::ASN1_TYPE) -> c_int>, - pub get_asn1_parameters: Option<unsafe extern fn(*mut ::EVP_CIPHER_CTX, - *mut ::ASN1_TYPE) -> c_int>, - pub ctrl: Option<unsafe extern fn(*mut ::EVP_CIPHER_CTX, - c_int, - c_int, - *mut c_void) -> c_int>, + pub set_asn1_parameters: + Option<unsafe extern "C" fn(*mut ::EVP_CIPHER_CTX, *mut ::ASN1_TYPE) -> c_int>, + pub get_asn1_parameters: + Option<unsafe extern "C" fn(*mut ::EVP_CIPHER_CTX, *mut ::ASN1_TYPE) -> c_int>, + pub ctrl: Option<unsafe extern "C" fn(*mut ::EVP_CIPHER_CTX, c_int, c_int, *mut c_void) -> c_int>, pub app_data: *mut c_void, } @@ -220,7 +219,7 @@ pub struct HMAC_CTX { i_ctx: ::EVP_MD_CTX, o_ctx: ::EVP_MD_CTX, key_length: c_uint, - key: [c_uchar; 128] + key: [c_uchar; 128], } #[repr(C)] @@ -320,7 +319,7 @@ pub struct X509_REQ_INFO { pub version: *mut ::ASN1_INTEGER, pub subject: *mut ::X509_NAME, pubkey: *mut c_void, - pub attributes: *mut stack_st_X509_ATTRIBUTE + pub attributes: *mut stack_st_X509_ATTRIBUTE, } #[repr(C)] @@ -328,7 +327,7 @@ pub struct X509_REQ { pub req_info: *mut X509_REQ_INFO, sig_alg: *mut c_void, signature: *mut c_void, - references: c_int + references: c_int, } pub enum X509_VERIFY_PARAM_ID {} @@ -339,78 +338,78 @@ pub const SSL_CTRL_OPTIONS: c_int = 32; pub const SSL_CTRL_CLEAR_OPTIONS: c_int = 77; pub const SSL_CTRL_SET_ECDH_AUTO: c_int = 94; -pub const SSL_OP_ALL: c_ulong = 0x80000014; -pub const SSL_OP_CISCO_ANYCONNECT: c_ulong = 0x0; -pub const SSL_OP_NO_COMPRESSION: c_ulong = 0x0; -pub const SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION: c_ulong = 0x0; -pub const SSL_OP_NO_SSLv3: c_ulong = 0x0; -pub const SSL_OP_MICROSOFT_SESS_ID_BUG: c_ulong = 0x0; -pub const SSL_OP_NETSCAPE_CHALLENGE_BUG: c_ulong = 0x0; -pub const SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG: c_ulong = 0x0; -pub const SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER: c_ulong = 0x0; -pub const SSL_OP_SSLEAY_080_CLIENT_DH_BUG: c_ulong = 0x0; -pub const SSL_OP_TLS_D5_BUG: c_ulong = 0x0; -pub const SSL_OP_TLS_BLOCK_PADDING_BUG: c_ulong = 0x0; -pub const SSL_OP_SINGLE_ECDH_USE: c_ulong = 0x00080000; -pub const SSL_OP_SINGLE_DH_USE: c_ulong = 0x00100000; -pub const SSL_OP_NO_SSLv2: c_ulong = 0x0; +pub const SSL_OP_ALL: c_ulong = 0x80000014; +pub const SSL_OP_CISCO_ANYCONNECT: c_ulong = 0x0; +pub const SSL_OP_NO_COMPRESSION: c_ulong = 0x0; +pub const SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION: c_ulong = 0x0; +pub const SSL_OP_NO_SSLv3: c_ulong = 0x0; +pub const SSL_OP_MICROSOFT_SESS_ID_BUG: c_ulong = 0x0; +pub const SSL_OP_NETSCAPE_CHALLENGE_BUG: c_ulong = 0x0; +pub const SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG: c_ulong = 0x0; +pub const SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER: c_ulong = 0x0; +pub const SSL_OP_SSLEAY_080_CLIENT_DH_BUG: c_ulong = 0x0; +pub const SSL_OP_TLS_D5_BUG: c_ulong = 0x0; +pub const SSL_OP_TLS_BLOCK_PADDING_BUG: c_ulong = 0x0; +pub const SSL_OP_SINGLE_ECDH_USE: c_ulong = 0x00080000; +pub const SSL_OP_SINGLE_DH_USE: c_ulong = 0x00100000; +pub const SSL_OP_NO_SSLv2: c_ulong = 0x0; pub const SSL_MAX_SSL_SESSION_ID_LENGTH: c_int = 32; pub const SSL_MAX_SID_CTX_LENGTH: c_int = 32; pub const SSL_MAX_MASTER_KEY_LENGTH: c_int = 48; -pub const SSLEAY_VERSION : c_int = 0; -pub const SSLEAY_CFLAGS : c_int = 2; -pub const SSLEAY_BUILT_ON : c_int = 3; -pub const SSLEAY_PLATFORM : c_int = 4; -pub const SSLEAY_DIR : c_int = 5; +pub const SSLEAY_VERSION: c_int = 0; +pub const SSLEAY_CFLAGS: c_int = 2; +pub const SSLEAY_BUILT_ON: c_int = 3; +pub const SSLEAY_PLATFORM: c_int = 4; +pub const SSLEAY_DIR: c_int = 5; pub const CRYPTO_LOCK_X509: c_int = 3; pub const CRYPTO_LOCK_SSL_CTX: c_int = 12; pub const CRYPTO_LOCK_SSL_SESSION: c_int = 14; static mut MUTEXES: *mut Vec<Mutex<()>> = 0 as *mut Vec<Mutex<()>>; -static mut GUARDS: *mut Vec<Option<MutexGuard<'static, ()>>> = 0 as *mut Vec<Option<MutexGuard<'static, ()>>>; +static mut GUARDS: *mut Vec<Option<MutexGuard<'static, ()>>> = + 0 as *mut Vec<Option<MutexGuard<'static, ()>>>; -unsafe extern fn locking_function(mode: c_int, n: c_int, _file: *const c_char, - _line: c_int) { +unsafe extern "C" fn locking_function(mode: c_int, n: c_int, _file: *const c_char, _line: c_int) { let mutex = &(*MUTEXES)[n as usize]; if mode & ::CRYPTO_LOCK != 0 { (*GUARDS)[n as usize] = Some(mutex.lock().unwrap()); } else { - &(*GUARDS)[n as usize].take().expect("lock already unlocked"); + &(*GUARDS)[n as usize] + .take() + .expect("lock already unlocked"); } } pub fn init() { static INIT: Once = ONCE_INIT; - INIT.call_once(|| { - unsafe { - SSL_library_init(); - SSL_load_error_strings(); - OPENSSL_add_all_algorithms_noconf(); + INIT.call_once(|| unsafe { + SSL_library_init(); + SSL_load_error_strings(); + OPENSSL_add_all_algorithms_noconf(); - let num_locks = ::CRYPTO_num_locks(); - let mut mutexes = Box::new(Vec::new()); - for _ in 0..num_locks { - mutexes.push(Mutex::new(())); - } - MUTEXES = mem::transmute(mutexes); - let guards: Box<Vec<Option<MutexGuard<()>>>> = - Box::new((0..num_locks).map(|_| None).collect()); - GUARDS = mem::transmute(guards); + let num_locks = ::CRYPTO_num_locks(); + let mut mutexes = Box::new(Vec::new()); + for _ in 0..num_locks { + mutexes.push(Mutex::new(())); + } + MUTEXES = mem::transmute(mutexes); + let guards: Box<Vec<Option<MutexGuard<()>>>> = + Box::new((0..num_locks).map(|_| None).collect()); + GUARDS = mem::transmute(guards); - CRYPTO_set_locking_callback(locking_function); - set_id_callback(); - } - }) + CRYPTO_set_locking_callback(locking_function); + set_id_callback(); + }) } #[cfg(unix)] fn set_id_callback() { - unsafe extern fn thread_id() -> c_ulong { + unsafe extern "C" fn thread_id() -> c_ulong { ::libc::pthread_self() as c_ulong } @@ -425,18 +424,24 @@ fn set_id_callback() {} // macros pub unsafe fn SSL_CTX_set_ecdh_auto(ctx: *mut SSL_CTX, onoff: c_int) -> c_int { - ::SSL_CTX_ctrl(ctx, SSL_CTRL_SET_ECDH_AUTO, onoff as c_long, ptr::null_mut()) as c_int + ::SSL_CTX_ctrl(ctx, + SSL_CTRL_SET_ECDH_AUTO, + onoff as c_long, + ptr::null_mut()) as c_int } pub unsafe fn SSL_set_ecdh_auto(ssl: *mut ::SSL, onoff: c_int) -> c_int { - ::SSL_ctrl(ssl, SSL_CTRL_SET_ECDH_AUTO, onoff as c_long, ptr::null_mut()) as c_int + ::SSL_ctrl(ssl, + SSL_CTRL_SET_ECDH_AUTO, + onoff as c_long, + ptr::null_mut()) as c_int } pub unsafe fn SSL_session_reused(ssl: *mut ::SSL) -> c_int { ::SSL_ctrl(ssl, SSL_CTRL_GET_SESSION_REUSED, 0, ptr::null_mut()) as c_int } -extern { +extern "C" { pub fn BIO_new(type_: *mut BIO_METHOD) -> *mut BIO; pub fn BIO_s_file() -> *mut BIO_METHOD; pub fn BIO_s_mem() -> *mut BIO_METHOD; @@ -463,10 +468,14 @@ extern { pub fn RSA_generate_key(modsz: c_int, e: c_ulong, - cb: Option<extern fn(c_int, c_int, *mut c_void)>, - cbarg: *mut c_void) -> *mut RSA; + cb: Option<extern "C" fn(c_int, c_int, *mut c_void)>, + cbarg: *mut c_void) + -> *mut RSA; - pub fn OCSP_cert_to_id(dgst: *const ::EVP_MD, subject: *mut ::X509, issuer: *mut ::X509) -> *mut ::OCSP_CERTID; + pub fn OCSP_cert_to_id(dgst: *const ::EVP_MD, + subject: *mut ::X509, + issuer: *mut ::X509) + -> *mut ::OCSP_CERTID; pub fn PKCS12_create(pass: *mut c_char, friendly_name: *mut c_char, @@ -477,7 +486,8 @@ extern { nid_cert: c_int, iter: c_int, mac_iter: c_int, - keytype: c_int) -> *mut PKCS12; + keytype: c_int) + -> *mut PKCS12; pub fn SSL_library_init() -> c_int; pub fn SSL_load_error_strings(); @@ -489,44 +499,66 @@ extern { pub fn TLSv1_1_method() -> *const ::SSL_METHOD; pub fn TLSv1_2_method() -> *const ::SSL_METHOD; pub fn DTLSv1_method() -> *const ::SSL_METHOD; - pub fn SSL_get_ex_new_index(argl: c_long, argp: *mut c_void, + pub fn SSL_get_ex_new_index(argl: c_long, + argp: *mut c_void, new_func: Option<::CRYPTO_EX_new>, dup_func: Option<::CRYPTO_EX_dup>, free_func: Option<::CRYPTO_EX_free>) -> c_int; pub fn SSL_set_tmp_ecdh_callback(ssl: *mut ::SSL, - ecdh: unsafe extern fn(ssl: *mut ::SSL, - is_export: c_int, - keylength: c_int) - -> *mut ::EC_KEY); + ecdh: unsafe extern "C" fn(ssl: *mut ::SSL, + is_export: c_int, + keylength: c_int) + -> *mut ::EC_KEY); pub fn SSL_CIPHER_get_version(cipher: *const ::SSL_CIPHER) -> *mut c_char; - pub fn SSL_CTX_get_ex_new_index(argl: c_long, argp: *mut c_void, + pub fn SSL_CTX_get_ex_new_index(argl: c_long, + argp: *mut c_void, new_func: Option<::CRYPTO_EX_new>, dup_func: Option<::CRYPTO_EX_dup>, free_func: Option<::CRYPTO_EX_free>) -> c_int; pub fn SSL_CTX_set_tmp_ecdh_callback(ctx: *mut ::SSL_CTX, - ecdh: unsafe extern fn(ssl: *mut ::SSL, - is_export: c_int, - keylength: c_int) - -> *mut ::EC_KEY); + ecdh: unsafe extern "C" fn(ssl: *mut ::SSL, + is_export: c_int, + keylength: c_int) + -> *mut ::EC_KEY); pub fn X509_get_subject_name(x: *mut ::X509) -> *mut ::X509_NAME; pub fn X509_set_notAfter(x: *mut ::X509, tm: *const ::ASN1_TIME) -> c_int; pub fn X509_set_notBefore(x: *mut ::X509, tm: *const ::ASN1_TIME) -> c_int; - pub fn X509_get_ext_d2i(x: *mut ::X509, nid: c_int, crit: *mut c_int, idx: *mut c_int) -> *mut c_void; - pub fn X509_NAME_add_entry_by_NID(x: *mut ::X509_NAME, field: c_int, ty: c_int, bytes: *mut c_uchar, len: c_int, loc: c_int, set: c_int) -> c_int; + pub fn X509_get_ext_d2i(x: *mut ::X509, + nid: c_int, + crit: *mut c_int, + idx: *mut c_int) + -> *mut c_void; + pub fn X509_NAME_add_entry_by_NID(x: *mut ::X509_NAME, + field: c_int, + ty: c_int, + bytes: *mut c_uchar, + len: c_int, + loc: c_int, + set: c_int) + -> c_int; pub fn X509_NAME_get_entry(n: *mut ::X509_NAME, loc: c_int) -> *mut ::X509_NAME_ENTRY; pub fn X509_NAME_ENTRY_get_data(ne: *mut ::X509_NAME_ENTRY) -> *mut ::ASN1_STRING; pub fn X509_STORE_CTX_get_chain(ctx: *mut ::X509_STORE_CTX) -> *mut stack_st_X509; - pub fn X509V3_EXT_nconf_nid(conf: *mut ::CONF, ctx: *mut ::X509V3_CTX, ext_nid: c_int, value: *mut c_char) -> *mut ::X509_EXTENSION; - pub fn X509V3_EXT_nconf(conf: *mut ::CONF, ctx: *mut ::X509V3_CTX, name: *mut c_char, value: *mut c_char) -> *mut ::X509_EXTENSION; + pub fn X509V3_EXT_nconf_nid(conf: *mut ::CONF, + ctx: *mut ::X509V3_CTX, + ext_nid: c_int, + value: *mut c_char) + -> *mut ::X509_EXTENSION; + pub fn X509V3_EXT_nconf(conf: *mut ::CONF, + ctx: *mut ::X509V3_CTX, + name: *mut c_char, + value: *mut c_char) + -> *mut ::X509_EXTENSION; pub fn ASN1_STRING_to_UTF8(out: *mut *mut c_uchar, s: *mut ::ASN1_STRING) -> c_int; pub fn ASN1_STRING_data(x: *mut ::ASN1_STRING) -> *mut c_uchar; pub fn CRYPTO_add_lock(pointer: *mut c_int, amount: c_int, type_: c_int, file: *const c_char, - line: c_int) -> c_int; + line: c_int) + -> c_int; pub fn EVP_MD_CTX_create() -> *mut EVP_MD_CTX; pub fn EVP_MD_CTX_destroy(ctx: *mut EVP_MD_CTX); pub fn EVP_PKEY_bits(key: *mut EVP_PKEY) -> c_int; @@ -536,7 +568,7 @@ extern { pub fn sk_value(st: *const _STACK, n: c_int) -> *mut c_void; pub fn sk_free(st: *mut _STACK); pub fn sk_push(st: *mut _STACK, data: *mut c_void) -> c_int; - pub fn sk_pop_free(st: *mut _STACK, free: Option<unsafe extern "C" fn (*mut c_void)>); + pub fn sk_pop_free(st: *mut _STACK, free: Option<unsafe extern "C" fn(*mut c_void)>); pub fn sk_pop(st: *mut _STACK) -> *mut c_void; pub fn SSLeay() -> c_ulong; diff --git a/openssl-sys/src/libressl/v250.rs b/openssl-sys/src/libressl/v250.rs index 39306f8d..25b6b9f1 100644 --- a/openssl-sys/src/libressl/v250.rs +++ b/openssl-sys/src/libressl/v250.rs @@ -12,7 +12,7 @@ pub struct SSL { bbio: *mut c_void, rwstate: c_int, in_handshake: c_int, - handshake_func: Option<unsafe extern fn(*mut SSL) -> c_int>, + handshake_func: Option<unsafe extern "C" fn(*mut SSL) -> c_int>, pub server: c_int, new_session: c_int, quiet_shutdown: c_int, @@ -28,7 +28,13 @@ pub struct SSL { s3: *mut c_void, d1: *mut c_void, read_ahead: c_int, - msg_callback: Option<unsafe extern fn(c_int, c_int, c_int, *const c_void, size_t, *mut SSL, *mut c_void)>, + msg_callback: Option<unsafe extern "C" fn(c_int, + c_int, + c_int, + *const c_void, + size_t, + *mut SSL, + *mut c_void)>, msg_callback_arg: *mut c_void, hit: c_int, param: *mut c_void, @@ -47,8 +53,8 @@ pub struct SSL { session: *mut ::SSL_SESSION, generate_session_id: ::GEN_SESSION_CB, verify_mode: c_int, - verify_callback: Option<unsafe extern fn(c_int, *mut ::X509_STORE_CTX) -> c_int>, - info_callback: Option<unsafe extern fn(*mut SSL, c_int, c_int)>, + verify_callback: Option<unsafe extern "C" fn(c_int, *mut ::X509_STORE_CTX) -> c_int>, + info_callback: Option<unsafe extern "C" fn(*mut SSL, c_int, c_int)>, error: c_int, error_code: c_int, ctx: *mut ::SSL_CTX, @@ -63,7 +69,8 @@ pub struct SSL { first_packet: c_int, client_version: c_int, max_send_fragment: c_uint, - tlsext_debug_cb: Option<unsafe extern fn(*mut SSL, c_int, c_int, *mut c_uchar, c_int, *mut c_void)>, + tlsext_debug_cb: + Option<unsafe extern "C" fn(*mut SSL, c_int, c_int, *mut c_uchar, c_int, *mut c_void)>, tlsext_debug_arg: *mut c_void, tlsext_hostname: *mut c_char, servername_done: c_int, diff --git a/openssl-sys/src/libressl/v25x.rs b/openssl-sys/src/libressl/v25x.rs index 1654f52e..7e7023ec 100644 --- a/openssl-sys/src/libressl/v25x.rs +++ b/openssl-sys/src/libressl/v25x.rs @@ -55,7 +55,7 @@ pub struct SSL_CTX { pub struct SSL_SESSION { ssl_version: c_int, pub master_key_length: c_int, - pub master_key: [c_uchar; 48 /*::SSL_MAX_MASTER_KEY_LENGTH as usize */], + pub master_key: [c_uchar; 48], session_id_length: c_uint, session_id: [c_uchar; ::SSL_MAX_SSL_SESSION_ID_LENGTH as usize], sid_ctx_length: c_uint, |