]> gitweb.factorcode.org Git - factor.git/blob - extra/openssl/libssl/libssl.factor
Initial import
[factor.git] / extra / openssl / libssl / libssl.factor
1 ! Copyright (C) 2007 Elie CHAFTARI
2 ! See http://factorcode.org/license.txt for BSD license.
3 !
4 ! Tested with OpenSSL 0.9.8a_0 on Mac OS X 10.4.9 PowerPC
5 !
6 ! export LD_LIBRARY_PATH=/opt/local/lib
7
8 USING: alien alien.syntax combinators kernel system ;
9
10 IN: openssl.libssl
11
12 "libssl" {
13     { [ win32? ] [ "ssleay32.dll" "stdcall" ] }
14     { [ macosx? ] [ "libssl.dylib" "cdecl" ] }
15     { [ unix? ] [ "$LD_LIBRARY_PATH/libssl.so" "cdecl" ] }
16 } cond add-library
17
18 : X509_FILETYPE_PEM       1 ; inline
19 : X509_FILETYPE_ASN1      2 ; inline
20 : X509_FILETYPE_DEFAULT   3 ; inline
21
22 : SSL_FILETYPE_ASN1  X509_FILETYPE_ASN1 ; inline
23 : SSL_FILETYPE_PEM   X509_FILETYPE_PEM ; inline
24
25 : SSL_CTRL_NEED_TMP_RSA      1 ; inline
26 : SSL_CTRL_SET_TMP_RSA       2 ; inline
27 : SSL_CTRL_SET_TMP_DH        3 ; inline
28 : SSL_CTRL_SET_TMP_RSA_CB    4 ; inline
29 : SSL_CTRL_SET_TMP_DH_CB     5 ; inline
30
31 : SSL_ERROR_NONE             0 ; inline
32 : SSL_ERROR_SSL              1 ; inline
33 : SSL_ERROR_WANT_READ        2 ; inline
34 : SSL_ERROR_WANT_WRITE       3 ; inline
35 : SSL_ERROR_WANT_X509_LOOKUP 4 ; inline
36 : SSL_ERROR_SYSCALL          5 ; inline ! consult errno for details
37 : SSL_ERROR_ZERO_RETURN      6 ; inline
38 : SSL_ERROR_WANT_CONNECT     7 ; inline
39 : SSL_ERROR_WANT_ACCEPT      8 ; inline
40
41 ! Error messages table
42 : error-messages ( -- hash )
43     H{
44         { 0  "SSL_ERROR_NONE" }
45         { 1  "SSL_ERROR_SSL" }
46         { 2  "SSL_ERROR_WANT_READ" }
47         { 3  "SSL_ERROR_WANT_WRITE" }
48         { 4  "SSL_ERROR_WANT_X509_LOOKUP" }
49         { 5  "SSL_ERROR_SYSCALL" }
50         { 6  "SSL_ERROR_ZERO_RETURN" }
51         { 7  "SSL_ERROR_WANT_CONNECT" }
52         { 8  "SSL_ERROR_WANT_ACCEPT" }
53     } ;
54
55 TYPEDEF: void* ssl-method
56 TYPEDEF: void* ssl-ctx
57 TYPEDEF: void* ssl-pointer
58
59 LIBRARY: libssl
60
61 ! ===============================================
62 ! ssl.h
63 ! ===============================================
64
65 FUNCTION: char* SSL_get_version ( ssl-pointer ssl ) ;
66
67 ! Maps OpenSSL errors to strings
68 FUNCTION: void SSL_load_error_strings (  ) ;
69
70 ! Must be called before any other action takes place
71 FUNCTION: int SSL_library_init (  ) ;
72
73 ! Sets the default SSL version
74 FUNCTION: ssl-method SSLv2_client_method (  ) ;
75
76 FUNCTION: ssl-method SSLv23_client_method (  ) ;
77
78 FUNCTION: ssl-method SSLv23_server_method (  ) ;
79
80 FUNCTION: ssl-method SSLv23_method (  ) ; ! SSLv3 but can rollback to v2
81
82 FUNCTION: ssl-method SSLv3_client_method (  ) ;
83
84 FUNCTION: ssl-method SSLv3_server_method (  ) ;
85
86 FUNCTION: ssl-method SSLv3_method (  ) ;
87
88 FUNCTION: ssl-method TLSv1_client_method (  ) ;
89
90 FUNCTION: ssl-method TLSv1_server_method (  ) ;
91
92 FUNCTION: ssl-method TLSv1_method (  ) ;
93
94 ! Creates the context
95 FUNCTION: ssl-ctx SSL_CTX_new ( ssl-method method ) ;
96
97 ! Load the certificates and private keys into the SSL_CTX
98 FUNCTION: int SSL_CTX_use_certificate_chain_file ( ssl-ctx ctx,
99                                                    char* file ) ; ! PEM type
100 FUNCTION: ssl-pointer SSL_new ( ssl-ctx ctx ) ;
101
102 FUNCTION: int SSL_set_fd ( ssl-pointer ssl, int fd ) ;
103
104 FUNCTION: void SSL_set_bio ( ssl-pointer ssl, void* rbio, void* wbio ) ;
105
106 FUNCTION: int SSL_get_error ( ssl-pointer ssl, int ret ) ;
107
108 FUNCTION: void SSL_set_connect_state ( ssl-pointer ssl ) ;
109
110 FUNCTION: void SSL_set_accept_state ( ssl-pointer ssl ) ;
111
112 FUNCTION: int SSL_connect ( ssl-pointer ssl ) ;
113
114 FUNCTION: int SSL_accept ( ssl-pointer ssl ) ;
115
116 FUNCTION: int SSL_write ( ssl-pointer ssl, void* buf, int num ) ;
117
118 FUNCTION: int SSL_read ( ssl-pointer ssl, void* buf, int num ) ;
119
120 FUNCTION: void SSL_shutdown ( ssl-pointer ssl ) ;
121
122 FUNCTION: void SSL_free ( ssl-pointer ssl ) ;
123
124 FUNCTION: void SSL_CTX_free ( ssl-ctx ctx ) ;
125
126 FUNCTION: void RAND_seed ( void* buf, int num ) ;
127
128 FUNCTION: int SSL_set_cipher_list ( ssl-pointer ssl, char* str ) ;
129
130 FUNCTION: int SSL_use_RSAPrivateKey_file ( ssl-pointer ssl, char* str ) ;
131
132 FUNCTION: int SSL_CTX_use_RSAPrivateKey_file ( ssl-ctx ctx, int type ) ;
133
134 FUNCTION: int SSL_use_certificate_file ( ssl-pointer ssl,
135                                          char* str, int type ) ;
136
137 FUNCTION: int SSL_CTX_load_verify_locations ( ssl-ctx ctx, char* CAfile,
138                                               char* CApath ) ;
139
140 FUNCTION: void SSL_CTX_set_client_CA_list ( ssl-ctx ctx, ssl-pointer list ) ;
141
142 FUNCTION: ssl-pointer SSL_load_client_CA_file ( char* file ) ;
143
144 ! Used to manipulate settings of the SSL_CTX and SSL objects.
145 ! This function should never be called directly
146 FUNCTION: long SSL_CTX_ctrl ( ssl-ctx ctx, int cmd, long larg, void* parg ) ;
147
148 FUNCTION: void SSL_CTX_set_default_passwd_cb ( ssl-ctx ctx, void* cb ) ;
149
150 FUNCTION: void SSL_CTX_set_default_passwd_cb_userdata ( ssl-ctx ctx,
151                                                         void* u ) ;
152
153 FUNCTION: int SSL_CTX_use_PrivateKey_file ( ssl-ctx ctx, char* file,
154                                             int type ) ;
155
156 ! Sets the maximum depth for the allowed ctx certificate chain verification 
157 FUNCTION: void SSL_CTX_set_verify_depth ( ssl-ctx ctx, int depth ) ;
158
159 ! Sets DH parameters to be used to be dh.
160 ! The key is inherited by all ssl objects created from ctx
161 FUNCTION: void SSL_CTX_set_tmp_dh_callback ( ssl-ctx ctx, void* dh ) ;
162
163 FUNCTION: void SSL_CTX_set_tmp_rsa_callback ( ssl-ctx ctx, void* rsa ) ;
164
165 FUNCTION: void* BIO_f_ssl (  ) ;
166
167 ! ===============================================
168 ! sha.h
169 ! ===============================================
170
171 ! For a high level interface to message digests
172 ! use the EVP digest routines in libcrypto.factor
173
174 FUNCTION: uchar* SHA1 ( uchar* d, ulong n, uchar* md ) ;