1 ! Copyright (C) 2007 Elie CHAFTARI, 2009 Maxim Savchenko
2 ! See http://factorcode.org/license.txt for BSD license.
4 ! Tested with OpenSSL 0.9.8a_0 on Mac OS X 10.4.9 PowerPC
6 ! export LD_LIBRARY_PATH=/opt/local/lib
8 USING: alien alien.c-types alien.syntax combinators kernel system
9 alien.libraries classes.struct ;
15 { [ os openbsd? ] [ ] } ! VM is linked with it
16 { [ os netbsd? ] [ ] }
17 { [ os winnt? ] [ "libcrypto" "libeay32.dll" "cdecl" add-library ] }
18 { [ os macosx? ] [ "libcrypto" "libcrypto.dylib" "cdecl" add-library ] }
19 { [ os unix? ] [ "libcrypto" "libcrypto.so" "cdecl" add-library ] }
33 { callback-ctrl void* } ;
50 { crypto-ex-data-stack void* }
51 { crypto-ex-data-dummy int } ;
53 CONSTANT: BIO_NOCLOSE HEX: 00
54 CONSTANT: BIO_CLOSE HEX: 01
56 CONSTANT: RSA_3 HEX: 3
57 CONSTANT: RSA_F4 HEX: 10001
59 CONSTANT: BIO_C_SET_SSL 109
60 CONSTANT: BIO_C_GET_SSL 110
64 ! ===============================================
66 ! ===============================================
68 FUNCTION: bio* BIO_new_file ( char* filename, char* mode ) ;
70 FUNCTION: int BIO_printf ( bio* bio, char* format ) ;
72 FUNCTION: long BIO_ctrl ( void* bio, int cmd, long larg, void* parg ) ;
74 FUNCTION: void* BIO_new_socket ( int fd, int close-flag ) ;
76 FUNCTION: void* BIO_new ( void* method ) ;
78 FUNCTION: int BIO_set ( void* bio, void* method ) ;
80 FUNCTION: int BIO_free ( void* bio ) ;
82 FUNCTION: void* BIO_push ( void* bio, void* append ) ;
84 FUNCTION: int BIO_read ( void* b, void* buf, int len ) ;
86 FUNCTION: int BIO_gets ( void* b, char* buf, int size ) ;
88 FUNCTION: int BIO_write ( void* b, void* buf, int len ) ;
90 FUNCTION: int BIO_puts ( void* bp, char* buf ) ;
92 FUNCTION: ulong ERR_get_error ( ) ;
94 FUNCTION: void ERR_clear_error ( ) ;
96 FUNCTION: char* ERR_error_string ( ulong e, void* buf ) ;
98 FUNCTION: void* BIO_f_buffer ( ) ;
100 ! ===============================================
102 ! ===============================================
104 CONSTANT: EVP_MAX_MD_SIZE 64
115 ! Initialize ciphers and digest tables
116 FUNCTION: void OpenSSL_add_all_ciphers ( ) ;
118 FUNCTION: void OpenSSL_add_all_digests ( ) ;
120 ! Clean them up before exiting
121 FUNCTION: void EVP_cleanup ( ) ;
123 FUNCTION: EVP_MD* EVP_get_digestbyname ( char* name ) ;
125 FUNCTION: void EVP_MD_CTX_init ( EVP_MD* ctx ) ;
127 FUNCTION: int EVP_MD_CTX_cleanup ( EVP_MD_CTX* ctx ) ;
129 FUNCTION: EVP_MD_CTX* EVP_MD_CTX_create ( ) ;
131 FUNCTION: void EVP_MD_CTX_destroy ( EVP_MD_CTX* ctx ) ;
133 FUNCTION: int EVP_MD_CTX_copy_ex ( EVP_MD_CTX* out, EVP_MD_CTX* in ) ;
135 FUNCTION: int EVP_DigestInit_ex ( EVP_MD_CTX* ctx, EVP_MD* type, ENGINE* impl ) ;
137 FUNCTION: int EVP_DigestUpdate ( EVP_MD_CTX* ctx, void* d, uint cnt ) ;
139 FUNCTION: int EVP_DigestFinal_ex ( EVP_MD_CTX* ctx, void* md, uint* s ) ;
141 FUNCTION: int EVP_Digest ( void* data, uint count, void* md, uint* size, EVP_MD* type, ENGINE* impl ) ;
143 FUNCTION: int EVP_MD_CTX_copy ( EVP_MD_CTX* out, EVP_MD_CTX* in ) ;
145 FUNCTION: int EVP_DigestInit ( EVP_MD_CTX* ctx, EVP_MD* type ) ;
147 FUNCTION: int EVP_DigestFinal ( EVP_MD_CTX* ctx, void* md, uint* s ) ;
149 FUNCTION: void* PEM_read_bio_DHparams ( void* bp, void* x, void* cb,
152 ! ===============================================
154 ! ===============================================
156 FUNCTION: void* RSA_generate_key ( int num, ulong e, void* callback,
159 FUNCTION: int RSA_check_key ( void* rsa ) ;
161 FUNCTION: void RSA_free ( void* rsa ) ;
163 FUNCTION: int RSA_print_fp ( void* fp, void* x, int offset ) ;
165 ! ===============================================
167 ! ===============================================
169 FUNCTION: int OBJ_sn2nid ( char* s ) ;
171 ! ===============================================
173 ! ===============================================
175 FUNCTION: int BN_num_bits ( void* a ) ;
177 FUNCTION: void* BN_bin2bn ( void* s, int len, void* ret ) ;
179 FUNCTION: int BN_bn2bin ( void* a, void* to ) ;
181 FUNCTION: void BN_clear_free ( void* a ) ;
183 ! ===============================================
185 ! ===============================================
187 CONSTANT: POINT_CONVERSION_COMPRESSED 2
188 CONSTANT: POINT_CONVERSION_UNCOMPRESSED 4
189 CONSTANT: POINT_CONVERSION_HYBRID 6
191 FUNCTION: int EC_GROUP_get_degree ( void* group ) ;
193 FUNCTION: void* EC_POINT_new ( void* group ) ;
195 FUNCTION: void EC_POINT_clear_free ( void* point ) ;
197 FUNCTION: int EC_POINT_point2oct ( void* group, void* point, int form, void* buf, int len, void* ctx ) ;
199 FUNCTION: int EC_POINT_oct2point ( void* group, void* point, void* buf, int len, void* ctx ) ;
201 FUNCTION: void* EC_KEY_new_by_curve_name ( int nid ) ;
203 FUNCTION: void EC_KEY_free ( void* r ) ;
205 FUNCTION: int EC_KEY_set_private_key ( void* key, void* priv_key ) ;
207 FUNCTION: int EC_KEY_set_public_key ( void* key, void* pub_key ) ;
209 FUNCTION: int EC_KEY_generate_key ( void* eckey ) ;
211 FUNCTION: void* EC_KEY_get0_group ( void* key ) ;
213 FUNCTION: void* EC_KEY_get0_private_key ( void* key ) ;
215 FUNCTION: void* EC_KEY_get0_public_key ( void* key ) ;
217 ! ===============================================
219 ! ===============================================
221 FUNCTION: int ECDSA_size ( void* eckey ) ;
223 FUNCTION: int ECDSA_sign ( int type, void* dgst, int dgstlen, void* sig, void* siglen, void* eckey ) ;
225 FUNCTION: int ECDSA_verify ( int type, void* dgst, int dgstlen, void* sig, int siglen, void* eckey ) ;