@@ -9,7 +9,8 @@ use std::sync::Mutex;
9
9
use std:: { fs, io, path:: PathBuf } ;
10
10
11
11
use openssl_sys:: {
12
- stack_st_X509, OPENSSL_malloc , X509 , X509_STORE , X509_STORE_CTX , X509_V_ERR_UNSPECIFIED ,
12
+ stack_st_X509, OPENSSL_malloc , EVP_PKEY , X509 , X509_STORE , X509_STORE_CTX ,
13
+ X509_V_ERR_UNSPECIFIED ,
13
14
} ;
14
15
15
16
use crate :: bio:: { Bio , BIO , BIO_METHOD } ;
@@ -901,6 +902,202 @@ num_enum! {
901
902
}
902
903
}
903
904
905
+ // --- unimplemented stubs below here ---
906
+
907
+ macro_rules! entry_stub {
908
+ ( pub fn $name: ident( $( $args: tt) * ) ; ) => {
909
+ #[ no_mangle]
910
+ pub extern "C" fn $name( $( $args) * ) {
911
+ ffi_panic_boundary! {
912
+ Error :: not_supported( stringify!( $name) ) . raise( ) . into( )
913
+ }
914
+ }
915
+ } ;
916
+ ( pub fn $name: ident( $( $args: tt) * ) -> $ret: ty; ) => {
917
+ #[ no_mangle]
918
+ pub extern "C" fn $name( $( $args) * ) -> $ret {
919
+ ffi_panic_boundary! {
920
+ Error :: not_supported( stringify!( $name) ) . raise( ) . into( )
921
+ }
922
+ }
923
+ } ;
924
+ }
925
+
926
+ // things we support and should be able to implement to
927
+ // some extent:
928
+
929
+ entry_stub ! {
930
+ pub fn _SSL_CTX_set_ex_data( _ssl: * mut SSL_CTX , _idx: c_int, _data: * mut c_void) -> c_int;
931
+ }
932
+
933
+ entry_stub ! {
934
+ pub fn _SSL_CTX_get_ex_data( _ssl: * const SSL_CTX , _idx: c_int) -> * mut c_void;
935
+ }
936
+
937
+ entry_stub ! {
938
+ pub fn _SSL_set_ex_data( _ssl: * mut SSL , _idx: c_int, _data: * mut c_void) -> c_int;
939
+ }
940
+
941
+ entry_stub ! {
942
+ pub fn _SSL_get_ex_data( _ssl: * const SSL , _idx: c_int) -> * mut c_void;
943
+ }
944
+
945
+ entry_stub ! {
946
+ pub fn _SSL_get_certificate( _ssl: * const SSL ) -> * mut X509 ;
947
+ }
948
+
949
+ entry_stub ! {
950
+ pub fn _SSL_get_privatekey( _ssl: * const SSL ) -> * mut EVP_PKEY ;
951
+ }
952
+
953
+ entry_stub ! {
954
+ pub fn _SSL_set_session( _ssl: * mut SSL , _session: * mut SSL_SESSION ) -> c_int;
955
+ }
956
+
957
+ entry_stub ! {
958
+ pub fn _SSL_CTX_set_keylog_callback( _ctx: * mut SSL_CTX , _cb: SSL_CTX_keylog_cb_func ) ;
959
+ }
960
+
961
+ pub type SSL_CTX_keylog_cb_func =
962
+ Option < unsafe extern "C" fn ( ssl : * const SSL , line : * const c_char ) > ;
963
+
964
+ entry_stub ! {
965
+ pub fn _SSL_CTX_add_client_CA( _ctx: * mut SSL_CTX , _x: * mut X509 ) -> c_int;
966
+ }
967
+
968
+ entry_stub ! {
969
+ pub fn _SSL_CTX_check_private_key( _ctx: * const SSL_CTX ) -> c_int;
970
+ }
971
+
972
+ entry_stub ! {
973
+ pub fn _SSL_CTX_sess_set_new_cb( _ctx: * mut SSL_CTX , _new_session_cb: SSL_CTX_new_session_cb ) ;
974
+ }
975
+
976
+ pub type SSL_CTX_new_session_cb =
977
+ Option < unsafe extern "C" fn ( _ssl : * mut SSL , _sess : * mut SSL_SESSION ) -> c_int > ;
978
+
979
+ entry_stub ! {
980
+ pub fn _SSL_CTX_set_cipher_list( _ctx: * mut SSL_CTX , _s: * const c_char) -> c_int;
981
+ }
982
+
983
+ entry_stub ! {
984
+ pub fn _SSL_CTX_set_ciphersuites( _ctx: * mut SSL_CTX , _s: * const c_char) -> c_int;
985
+ }
986
+
987
+ entry_stub ! {
988
+ pub fn _SSL_CTX_use_PrivateKey( _ctx: * mut SSL_CTX , _pkey: * mut EVP_PKEY ) -> c_int;
989
+ }
990
+
991
+ entry_stub ! {
992
+ pub fn _SSL_CTX_use_PrivateKey_file(
993
+ _ctx: * mut SSL_CTX ,
994
+ _file: * const c_char,
995
+ _type: c_int,
996
+ ) -> c_int;
997
+ }
998
+
999
+ entry_stub ! {
1000
+ pub fn _SSL_CTX_use_certificate( _ctx: * mut SSL_CTX , _x: * mut X509 ) -> c_int;
1001
+ }
1002
+
1003
+ entry_stub ! {
1004
+ pub fn _SSL_CTX_use_certificate_chain_file( _ctx: * mut SSL_CTX , _file: * const c_char) -> c_int;
1005
+ }
1006
+
1007
+ entry_stub ! {
1008
+ pub fn _SSL_CTX_use_certificate_file(
1009
+ _ctx: * mut SSL_CTX ,
1010
+ _file: * const c_char,
1011
+ _type_: c_int,
1012
+ ) -> c_int;
1013
+ }
1014
+
1015
+ pub struct SSL_SESSION ;
1016
+
1017
+ entry_stub ! {
1018
+ pub fn _SSL_SESSION_free( _sess: * mut SSL_SESSION ) ;
1019
+ }
1020
+
1021
+ // no individual message logging
1022
+
1023
+ entry_stub ! {
1024
+ pub fn _SSL_CTX_set_msg_callback( _ctx: * mut SSL_CTX , _cb: SSL_CTX_msg_cb_func ) ;
1025
+ }
1026
+
1027
+ pub type SSL_CTX_msg_cb_func = Option <
1028
+ unsafe extern "C" fn (
1029
+ write_p : c_int ,
1030
+ version : c_int ,
1031
+ content_type : c_int ,
1032
+ buf : * const c_void ,
1033
+ len : usize ,
1034
+ ssl : * mut SSL ,
1035
+ arg : * mut c_void ,
1036
+ ) ,
1037
+ > ;
1038
+
1039
+ // no NPN (obsolete precursor to ALPN)
1040
+
1041
+ entry_stub ! {
1042
+ pub fn _SSL_CTX_set_next_proto_select_cb(
1043
+ _ctx: * mut SSL_CTX ,
1044
+ _cb: SSL_CTX_npn_select_cb_func ,
1045
+ _arg: * mut c_void,
1046
+ ) ;
1047
+ }
1048
+
1049
+ pub type SSL_CTX_npn_select_cb_func = Option <
1050
+ unsafe extern "C" fn (
1051
+ s : * mut SSL ,
1052
+ out : * mut * mut c_uchar ,
1053
+ outlen : * mut c_uchar ,
1054
+ in_ : * const c_uchar ,
1055
+ inlen : c_uint ,
1056
+ arg : * mut c_void ,
1057
+ ) -> c_int ,
1058
+ > ;
1059
+
1060
+ // no password-protected key loading
1061
+
1062
+ entry_stub ! {
1063
+ pub fn _SSL_CTX_set_default_passwd_cb( _ctx: * mut SSL_CTX , _cb: pem_password_cb) ;
1064
+ }
1065
+
1066
+ pub type pem_password_cb = Option <
1067
+ unsafe extern "C" fn (
1068
+ buf : * mut c_char ,
1069
+ size : c_int ,
1070
+ rwflag : c_int ,
1071
+ userdata : * mut c_void ,
1072
+ ) -> c_int ,
1073
+ > ;
1074
+
1075
+ entry_stub ! {
1076
+ pub fn _SSL_CTX_set_default_passwd_cb_userdata( _ctx: * mut SSL_CTX , _u: * mut c_void) ;
1077
+ }
1078
+
1079
+ // no SRP
1080
+
1081
+ entry_stub ! {
1082
+ pub fn _SSL_CTX_set_srp_password( _ctx: * mut SSL_CTX , _password: * mut c_char) -> c_int;
1083
+ }
1084
+
1085
+ entry_stub ! {
1086
+ pub fn _SSL_CTX_set_srp_username( _ctx: * mut SSL_CTX , _name: * mut c_char) -> c_int;
1087
+ }
1088
+
1089
+ // no post-handshake auth
1090
+
1091
+ entry_stub ! {
1092
+ pub fn _SSL_CTX_set_post_handshake_auth( _ctx: * mut SSL_CTX , _val: c_int) ;
1093
+ }
1094
+
1095
+ entry_stub ! {
1096
+ pub fn _SSL_set_post_handshake_auth( _s: * mut SSL , _val: c_int) ;
1097
+ }
1098
+
1099
+ // ---------------------
1100
+
904
1101
#[ cfg( test) ]
905
1102
mod tests {
906
1103
use super :: * ;
0 commit comments