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 windows? ] [ "libcrypto" "libeay32.dll" cdecl add-library ] }
16 { [ os macosx? ] [ "libcrypto" "libcrypto.dylib" cdecl add-library ] }
17 { [ os unix? ] [ "libcrypto" "libcrypto.so" cdecl add-library ] }
31 { callback-ctrl void* } ;
48 { crypto-ex-data-stack void* }
49 { crypto-ex-data-dummy int } ;
51 CONSTANT: BIO_NOCLOSE HEX: 00
52 CONSTANT: BIO_CLOSE HEX: 01
54 CONSTANT: RSA_3 HEX: 3
55 CONSTANT: RSA_F4 HEX: 10001
57 CONSTANT: BIO_C_SET_SSL 109
58 CONSTANT: BIO_C_GET_SSL 110
62 ! ===============================================
64 ! ===============================================
66 FUNCTION: bio* BIO_new_file ( c-string filename, c-string mode ) ;
68 FUNCTION: int BIO_printf ( bio* bio, c-string format ) ;
70 FUNCTION: long BIO_ctrl ( void* bio, int cmd, long larg, void* parg ) ;
72 FUNCTION: void* BIO_new_socket ( int fd, int close-flag ) ;
74 FUNCTION: void* BIO_new ( void* method ) ;
76 FUNCTION: int BIO_set ( void* bio, void* method ) ;
78 FUNCTION: int BIO_free ( void* bio ) ;
80 FUNCTION: void* BIO_push ( void* bio, void* append ) ;
82 FUNCTION: int BIO_read ( void* b, void* buf, int len ) ;
84 FUNCTION: int BIO_gets ( void* b, c-string buf, int size ) ;
86 FUNCTION: int BIO_write ( void* b, void* buf, int len ) ;
88 FUNCTION: int BIO_puts ( void* bp, c-string buf ) ;
90 FUNCTION: ulong ERR_get_error ( ) ;
92 FUNCTION: void ERR_clear_error ( ) ;
94 FUNCTION: c-string ERR_error_string ( ulong e, void* buf ) ;
96 FUNCTION: void* BIO_f_buffer ( ) ;
98 ! ===============================================
100 ! ===============================================
102 CONSTANT: EVP_MAX_MD_SIZE 64
113 ! Initialize ciphers and digest tables
114 FUNCTION: void OpenSSL_add_all_ciphers ( ) ;
116 FUNCTION: void OpenSSL_add_all_digests ( ) ;
118 ! Clean them up before exiting
119 FUNCTION: void EVP_cleanup ( ) ;
121 FUNCTION: EVP_MD* EVP_get_digestbyname ( c-string name ) ;
123 FUNCTION: void EVP_MD_CTX_init ( EVP_MD* ctx ) ;
125 FUNCTION: int EVP_MD_CTX_cleanup ( EVP_MD_CTX* ctx ) ;
127 FUNCTION: EVP_MD_CTX* EVP_MD_CTX_create ( ) ;
129 FUNCTION: void EVP_MD_CTX_destroy ( EVP_MD_CTX* ctx ) ;
131 FUNCTION: int EVP_MD_CTX_copy_ex ( EVP_MD_CTX* out, EVP_MD_CTX* in ) ;
133 FUNCTION: int EVP_DigestInit_ex ( EVP_MD_CTX* ctx, EVP_MD* type, ENGINE* impl ) ;
135 FUNCTION: int EVP_DigestUpdate ( EVP_MD_CTX* ctx, void* d, uint cnt ) ;
137 FUNCTION: int EVP_DigestFinal_ex ( EVP_MD_CTX* ctx, void* md, uint* s ) ;
139 FUNCTION: int EVP_Digest ( void* data, uint count, void* md, uint* size, EVP_MD* type, ENGINE* impl ) ;
141 FUNCTION: int EVP_MD_CTX_copy ( EVP_MD_CTX* out, EVP_MD_CTX* in ) ;
143 FUNCTION: int EVP_DigestInit ( EVP_MD_CTX* ctx, EVP_MD* type ) ;
145 FUNCTION: int EVP_DigestFinal ( EVP_MD_CTX* ctx, void* md, uint* s ) ;
147 FUNCTION: void* PEM_read_bio_DHparams ( void* bp, void* x, void* cb,
150 ! ===============================================
152 ! ===============================================
154 FUNCTION: void* RSA_generate_key ( int num, ulong e, void* callback,
157 FUNCTION: int RSA_check_key ( void* rsa ) ;
159 FUNCTION: void RSA_free ( void* rsa ) ;
161 FUNCTION: int RSA_print_fp ( void* fp, void* x, int offset ) ;
163 ! ===============================================
165 ! ===============================================
167 FUNCTION: int OBJ_sn2nid ( c-string s ) ;
169 ! ===============================================
171 ! ===============================================
173 FUNCTION: int BN_num_bits ( void* a ) ;
175 FUNCTION: void* BN_bin2bn ( void* s, int len, void* ret ) ;
177 FUNCTION: int BN_bn2bin ( void* a, void* to ) ;
179 FUNCTION: void BN_clear_free ( void* a ) ;
181 ! ===============================================
183 ! ===============================================
185 CONSTANT: POINT_CONVERSION_COMPRESSED 2
186 CONSTANT: POINT_CONVERSION_UNCOMPRESSED 4
187 CONSTANT: POINT_CONVERSION_HYBRID 6
189 FUNCTION: int EC_GROUP_get_degree ( void* group ) ;
191 FUNCTION: void* EC_POINT_new ( void* group ) ;
193 FUNCTION: void EC_POINT_clear_free ( void* point ) ;
195 FUNCTION: int EC_POINT_point2oct ( void* group, void* point, int form, void* buf, int len, void* ctx ) ;
197 FUNCTION: int EC_POINT_oct2point ( void* group, void* point, void* buf, int len, void* ctx ) ;
199 FUNCTION: void* EC_KEY_new_by_curve_name ( int nid ) ;
201 FUNCTION: void EC_KEY_free ( void* r ) ;
203 FUNCTION: int EC_KEY_set_private_key ( void* key, void* priv_key ) ;
205 FUNCTION: int EC_KEY_set_public_key ( void* key, void* pub_key ) ;
207 FUNCTION: int EC_KEY_generate_key ( void* eckey ) ;
209 FUNCTION: void* EC_KEY_get0_group ( void* key ) ;
211 FUNCTION: void* EC_KEY_get0_private_key ( void* key ) ;
213 FUNCTION: void* EC_KEY_get0_public_key ( void* key ) ;
215 ! ===============================================
217 ! ===============================================
219 FUNCTION: int ECDSA_size ( void* eckey ) ;
221 FUNCTION: int ECDSA_sign ( int type, void* dgst, int dgstlen, void* sig, void* siglen, void* eckey ) ;
223 FUNCTION: int ECDSA_verify ( int type, void* dgst, int dgstlen, void* sig, int siglen, void* eckey ) ;