Changes between 0.9.5a and 0.9.6 [xx XXX 2000]
+ *) Patches to make OpenSSL compile under Win32 again. Mostly
+ work arounds for the VC++ problem that it treats func() as
+ func(void). Also stripped out the parts of mkdef.pl that
+ added extra typesafe functions: these no longer exist.
+ [Steve Henson]
+
*) Reorganisation of the stack code. The macros are now all
collected in safestack.h . Each macro is defined in terms of
a "stack macro" of the form SKM_<name>(type, a, b). The
}
STACK *d2i_ASN1_SET(STACK **a, unsigned char **pp, long length,
- char *(*func)(), void (*free_func)(), int ex_tag, int ex_class)
+ char *(*func)(), void (*free_func)(void *), int ex_tag, int ex_class)
{
ASN1_CTX c;
STACK *ret=NULL;
static void st_free(ASN1_STRING_TABLE *tbl);
static int sk_table_cmp(const ASN1_STRING_TABLE * const *a,
const ASN1_STRING_TABLE * const *b);
-static int table_cmp(ASN1_STRING_TABLE *a, ASN1_STRING_TABLE *b);
+static int table_cmp(const void *a, const void *b);
/* This is the global mask for the mbstring functions: this is use to
return (*a)->nid - (*b)->nid;
}
-static int table_cmp(ASN1_STRING_TABLE *a, ASN1_STRING_TABLE *b)
+static int table_cmp(const void *a, const void *b)
{
- return a->nid - b->nid;
+ const ASN1_STRING_TABLE *sa = a, *sb = b;
+ return sa->nid - sb->nid;
}
ASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid)
ttmp = (ASN1_STRING_TABLE *) OBJ_bsearch((char *)&fnd,
(char *)tbl_standard,
sizeof(tbl_standard)/sizeof(ASN1_STRING_TABLE),
- sizeof(ASN1_STRING_TABLE), (int(*)())table_cmp);
+ sizeof(ASN1_STRING_TABLE), table_cmp);
if(ttmp) return ttmp;
if(!stable) return NULL;
idx = sk_ASN1_STRING_TABLE_find(stable, &fnd);
int i2d_ASN1_SET(STACK *a, unsigned char **pp,
int (*func)(), int ex_tag, int ex_class, int is_set);
STACK * d2i_ASN1_SET(STACK **a, unsigned char **pp, long length,
- char *(*func)(), void (*free_func)(),
+ char *(*func)(), void (*free_func)(void *),
int ex_tag, int ex_class);
#ifndef NO_BIO
unsigned char *data, int max_len);
STACK *ASN1_seq_unpack(unsigned char *buf, int len, char *(*d2i)(),
- void (*free_func)() );
+ void (*free_func)(void *) );
unsigned char *ASN1_seq_pack(STACK *safes, int (*i2d)(), unsigned char **buf,
int *len );
void *ASN1_unpack_string(ASN1_STRING *oct, char *(*d2i)());
/* Turn an ASN1 encoded SEQUENCE OF into a STACK of structures */
STACK *ASN1_seq_unpack(unsigned char *buf, int len, char *(*d2i)(),
- void (*free_func)())
+ void (*free_func)(void *))
{
STACK *sk;
unsigned char *pbuf;
static long buffer_ctrl(BIO *h, int cmd, long arg1, void *arg2);
static int buffer_new(BIO *h);
static int buffer_free(BIO *data);
-static long buffer_callback_ctrl(BIO *h, int cmd, void (*fp)());
+static long buffer_callback_ctrl(BIO *h, int cmd, bio_info_cb *fp);
#define DEFAULT_BUFFER_SIZE 1024
static BIO_METHOD methods_buffer=
return(0);
}
-static long buffer_callback_ctrl(BIO *b, int cmd, void (*fp)())
+static long buffer_callback_ctrl(BIO *b, int cmd, bio_info_cb *fp)
{
long ret=1;
static long nbiof_ctrl(BIO *h,int cmd,long arg1,void *arg2);
static int nbiof_new(BIO *h);
static int nbiof_free(BIO *data);
-static long nbiof_callback_ctrl(BIO *h,int cmd,void (*fp)());
+static long nbiof_callback_ctrl(BIO *h,int cmd,bio_info_cb *fp);
typedef struct nbio_test_st
{
/* only set if we sent a 'should retry' error */
return(ret);
}
-static long nbiof_callback_ctrl(BIO *b, int cmd, void (*fp)())
+static long nbiof_callback_ctrl(BIO *b, int cmd, bio_info_cb *fp)
{
long ret=1;
static long nullf_ctrl(BIO *h, int cmd, long arg1, void *arg2);
static int nullf_new(BIO *h);
static int nullf_free(BIO *data);
-static long nullf_callback_ctrl(BIO *h, int cmd, void (*fp)());
+static long nullf_callback_ctrl(BIO *h, int cmd, bio_info_cb *fp);
static BIO_METHOD methods_nullf=
{
BIO_TYPE_NULL_FILTER,
return(ret);
}
-static long nullf_callback_ctrl(BIO *b, int cmd, void (*fp)())
+static long nullf_callback_ctrl(BIO *b, int cmd, bio_info_cb *fp)
{
long ret=1;
typedef struct bio_st BIO;
+typedef void bio_info_cb(struct bio_st *, int, const char *, int, long, long);
+
#ifndef WIN16
typedef struct bio_method_st
{
long (*ctrl)(BIO *, int, long, void *);
int (*create)(BIO *);
int (*destroy)(BIO *);
- long (*callback_ctrl)(BIO *, int, void (*)(struct bio_st *, int, const char *, int, long, long));
+ long (*callback_ctrl)(BIO *, int, bio_info_cb *);
} BIO_METHOD;
#else
typedef struct bio_method_st
size_t BIO_ctrl_pending(BIO *b);
size_t BIO_ctrl_wpending(BIO *b);
#define BIO_flush(b) (int)BIO_ctrl(b,BIO_CTRL_FLUSH,0,NULL)
-#define BIO_get_info_callback(b,cbp) (int)BIO_ctrl(b,BIO_CTRL_GET_CALLBACK,0,(void (**)())(cbp))
-#define BIO_set_info_callback(b,cb) (int)BIO_callback_ctrl(b,BIO_CTRL_SET_CALLBACK,(void (*)())(cb))
+#define BIO_get_info_callback(b,cbp) (int)BIO_ctrl(b,BIO_CTRL_GET_CALLBACK,0,(bio_info_cb **)(cbp))
+#define BIO_set_info_callback(b,cb) (int)BIO_callback_ctrl(b,BIO_CTRL_SET_CALLBACK,(bio_info_cb *)(cb))
/* For the BIO_f_buffer() type */
#define BIO_buffer_get_num_lines(b) BIO_ctrl(b,BIO_CTRL_GET,0,NULL)
static long conn_ctrl(BIO *h, int cmd, long arg1, void *arg2);
static int conn_new(BIO *h);
static int conn_free(BIO *data);
-static long conn_callback_ctrl(BIO *h, int cmd, void (*fp)());
+static long conn_callback_ctrl(BIO *h, int cmd, bio_info_cb *);
static int conn_state(BIO *b, BIO_CONNECT *c);
static void conn_close_socket(BIO *data);
if (data->param_hostname)
BIO_set_conn_hostname(dbio,data->param_hostname);
BIO_set_nbio(dbio,data->nbio);
- (void)BIO_set_info_callback(dbio,(void *(*)())(data->info_callback));
+ (void)BIO_set_info_callback(dbio,data->info_callback);
}
break;
case BIO_CTRL_SET_CALLBACK:
return(ret);
}
-static long conn_callback_ctrl(BIO *b, int cmd, void (*fp)())
+static long conn_callback_ctrl(BIO *b, int cmd, bio_info_cb *fp)
{
long ret=1;
BIO_CONNECT *data;
if(p == NULL)
{
DSOerr(DSO_F_WIN32_LOAD,ERR_R_MALLOC_FAILURE);
- OPENSSL_freeLibrary(h);
+ FreeLibrary(h);
return(0);
}
*p = h;
if(!sk_push(dso->meth_data, (char *)p))
{
DSOerr(DSO_F_WIN32_LOAD,DSO_R_STACK_ERROR);
- OPENSSL_freeLibrary(h);
+ FreeLibrary(h);
OPENSSL_free(p);
return(0);
}
DSOerr(DSO_F_WIN32_UNLOAD,DSO_R_NULL_HANDLE);
return(0);
}
- if(!OPENSSL_freeLibrary(p))
+ if(!FreeLibrary(*p))
{
DSOerr(DSO_F_WIN32_UNLOAD,DSO_R_UNLOAD_FAILED);
/* We should push the value back onto the stack in
static long b64_ctrl(BIO *h, int cmd, long arg1, void *arg2);
static int b64_new(BIO *h);
static int b64_free(BIO *data);
-static long b64_callback_ctrl(BIO *h,int cmd,void (*fp)());
+static long b64_callback_ctrl(BIO *h,int cmd,bio_info_cb *fp);
#define B64_BLOCK_SIZE 1024
#define B64_BLOCK_SIZE2 768
#define B64_NONE 0
return(ret);
}
-static long b64_callback_ctrl(BIO *b, int cmd, void (*fp)())
+static long b64_callback_ctrl(BIO *b, int cmd, bio_info_cb *fp)
{
long ret=1;
static long enc_ctrl(BIO *h, int cmd, long arg1, void *arg2);
static int enc_new(BIO *h);
static int enc_free(BIO *data);
-static long enc_callback_ctrl(BIO *h, int cmd, void (*fp)());
+static long enc_callback_ctrl(BIO *h, int cmd, bio_info_cb *fps);
#define ENC_BLOCK_SIZE (1024*4)
typedef struct enc_struct
return(ret);
}
-static long enc_callback_ctrl(BIO *b, int cmd, void (*fp)())
+static long enc_callback_ctrl(BIO *b, int cmd, bio_info_cb *fp)
{
long ret=1;
static long md_ctrl(BIO *h, int cmd, long arg1, void *arg2);
static int md_new(BIO *h);
static int md_free(BIO *data);
-static long md_callback_ctrl(BIO *h,int cmd,void (*fp)());
+static long md_callback_ctrl(BIO *h,int cmd,bio_info_cb *fp);
static BIO_METHOD methods_md=
{
return(ret);
}
-static long md_callback_ctrl(BIO *b, int cmd, void (*fp)())
+static long md_callback_ctrl(BIO *b, int cmd, bio_info_cb *fp)
{
long ret=1;
static long ok_ctrl(BIO *h, int cmd, long arg1, void *arg2);
static int ok_new(BIO *h);
static int ok_free(BIO *data);
-static long ok_callback_ctrl(BIO *h, int cmd, void (*fp)());
+static long ok_callback_ctrl(BIO *h, int cmd, bio_info_cb *fp);
static void sig_out(BIO* b);
static void sig_in(BIO* b);
return(ret);
}
-static long ok_callback_ctrl(BIO *b, int cmd, void (*fp)())
+static long ok_callback_ctrl(BIO *b, int cmd, bio_info_cb *fp)
{
long ret=1;
return 1;
}
-static int pbe_cmp (EVP_PBE_CTL **pbe1, EVP_PBE_CTL **pbe2)
+static int pbe_cmp(const char * const *a, const char * const *b)
{
+ EVP_PBE_CTL **pbe1 = (EVP_PBE_CTL **) a, **pbe2 = (EVP_PBE_CTL **)b;
return ((*pbe1)->pbe_nid - (*pbe2)->pbe_nid);
}
EVP_PBE_KEYGEN *keygen)
{
EVP_PBE_CTL *pbe_tmp;
- if (!pbe_algs) pbe_algs = sk_new ((int (*)())pbe_cmp);
+ if (!pbe_algs) pbe_algs = sk_new(pbe_cmp);
if (!(pbe_tmp = (EVP_PBE_CTL*) OPENSSL_malloc (sizeof(EVP_PBE_CTL)))) {
EVPerr(EVP_F_EVP_PBE_ALG_ADD,ERR_R_MALLOC_FAILURE);
return 0;
return(names_lh != NULL);
}
-int OBJ_NAME_new_index(unsigned long (*hash_func)(), int (*cmp_func)(),
- void (*free_func)())
+int OBJ_NAME_new_index(unsigned long (*hash_func)(const char *),
+ int (*cmp_func)(const void *, const void *),
+ void (*free_func)(const char *, int, const char *))
{
int ret;
int i;
static ASN1_OBJECT *obj_objs[1];
#endif
-static int sn_cmp(ASN1_OBJECT **a, ASN1_OBJECT **b);
-static int ln_cmp(ASN1_OBJECT **a, ASN1_OBJECT **b);
-static int obj_cmp(ASN1_OBJECT **a, ASN1_OBJECT **b);
+static int sn_cmp(const void *a, const void *b);
+static int ln_cmp(const void *a, const void *b);
+static int obj_cmp(const void *a, const void *b);
#define ADDED_DATA 0
#define ADDED_SNAME 1
#define ADDED_LNAME 2
static int new_nid=NUM_NID;
static LHASH *added=NULL;
-static int sn_cmp(ASN1_OBJECT **ap, ASN1_OBJECT **bp)
- { return(strcmp((*ap)->sn,(*bp)->sn)); }
+static int sn_cmp(const void *a, const void *b)
+ {
+ const ASN1_OBJECT * const *ap = a, * const *bp = b;
+ return(strcmp((*ap)->sn,(*bp)->sn));
+ }
-static int ln_cmp(ASN1_OBJECT **ap, ASN1_OBJECT **bp)
- { return(strcmp((*ap)->ln,(*bp)->ln)); }
+static int ln_cmp(const void *a, const void *b)
+ {
+ const ASN1_OBJECT * const *ap = a, * const *bp = b;
+ return(strcmp((*ap)->ln,(*bp)->ln));
+ }
static unsigned long add_hash(ADDED_OBJ *ca)
{
if (adp != NULL) return (adp->obj->nid);
}
op=(ASN1_OBJECT **)OBJ_bsearch((char *)&a,(char *)obj_objs,NUM_OBJ,
- sizeof(ASN1_OBJECT *),(int (*)())obj_cmp);
+ sizeof(ASN1_OBJECT *),obj_cmp);
if (op == NULL)
return(NID_undef);
return((*op)->nid);
if (adp != NULL) return (adp->obj->nid);
}
op=(ASN1_OBJECT **)OBJ_bsearch((char *)&oo,(char *)ln_objs,NUM_LN,
- sizeof(ASN1_OBJECT *),(int (*)())ln_cmp);
+ sizeof(ASN1_OBJECT *),ln_cmp);
if (op == NULL) return(NID_undef);
return((*op)->nid);
}
if (adp != NULL) return (adp->obj->nid);
}
op=(ASN1_OBJECT **)OBJ_bsearch((char *)&oo,(char *)sn_objs,NUM_SN,
- sizeof(ASN1_OBJECT *),(int (*)())sn_cmp);
+ sizeof(ASN1_OBJECT *),sn_cmp);
if (op == NULL) return(NID_undef);
return((*op)->nid);
}
-static int obj_cmp(ASN1_OBJECT **ap, ASN1_OBJECT **bp)
+static int obj_cmp(const void *ap, const void *bp)
{
int j;
- ASN1_OBJECT *a= *ap;
- ASN1_OBJECT *b= *bp;
+ ASN1_OBJECT *a= *(ASN1_OBJECT **)ap;
+ ASN1_OBJECT *b= *(ASN1_OBJECT **)bp;
j=(a->length - b->length);
if (j) return(j);
return(memcmp(a->data,b->data,a->length));
}
-char *OBJ_bsearch(char *key, char *base, int num, int size, int (*cmp)())
+char *OBJ_bsearch(char *key, char *base, int num, int size, int (*cmp)(const void *, const void *))
{
int l,h,i,c;
char *p;
*/
char * PKCS12_decrypt_d2i (X509_ALGOR *algor, char * (*d2i)(),
- void (*free_func)(), const char *pass, int passlen,
+ void (*free_func)(void *), const char *pass, int passlen,
ASN1_OCTET_STRING *oct, int seq)
{
unsigned char *out, *p;
#define M_PKCS12_decrypt_skey(bag, pass, passlen) \
(PKCS8_PRIV_KEY_INFO *) PKCS12_decrypt_d2i((bag)->value.shkeybag->algor, \
-(char *(*)())d2i_PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO_free, \
+(char *(*)())d2i_PKCS8_PRIV_KEY_INFO, (void (*)(void *))PKCS8_PRIV_KEY_INFO_free, \
(pass), (passlen), \
(bag)->value.shkeybag->digest, 2)
#define M_PKCS8_decrypt(p8, pass, passlen) \
(PKCS8_PRIV_KEY_INFO *) PKCS12_decrypt_d2i((p8)->algor, \
-(char *(*)())d2i_PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO_free,\
+(char *(*)())d2i_PKCS8_PRIV_KEY_INFO, (void (*)(void *))PKCS8_PRIV_KEY_INFO_free,\
(pass), (passlen), (p8)->digest, 2)
#define PKCS12_get_attr(bag, attr_nid) \
int passlen, unsigned char *in, int inlen,
unsigned char **data, int *datalen, int en_de);
char *PKCS12_decrypt_d2i(X509_ALGOR *algor, char *(*d2i)(),
- void (*free_func)(), const char *pass, int passlen,
+ void (*free_func)(void *), const char *pass, int passlen,
ASN1_STRING *oct, int seq);
ASN1_STRING *PKCS12_i2d_encrypt(X509_ALGOR *algor, int (*i2d)(),
const char *pass, int passlen, char *obj,
*/
-#ifdef WINDOWS
+#if defined(WINDOWS) || defined(WIN32)
+#include "cryptlib.h"
#include <windows.h>
#include <openssl/rand.h>
/* XXX There are probably other includes missing here ... */
sk_sort(st)
#define SKM_ASN1_SET_OF_d2i(type, st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
- d2i_ASN1_SET(st,pp,length, (char *(*)())d2i_func, (void (*)())free_func, ex_tag,ex_class)
+ d2i_ASN1_SET(st,pp,length, (char *(*)())d2i_func, (void (*)(void *))free_func, ex_tag,ex_class)
#define SKM_ASN1_SET_OF_i2d(type, st, pp, i2d_func, ex_tag, ex_class, is_set) \
i2d_ASN1_SET(st,pp,i2d_func,ex_tag,ex_class,is_set)
static long ssl_ctrl(BIO *h, int cmd, long arg1, void *arg2);
static int ssl_new(BIO *h);
static int ssl_free(BIO *data);
-static long ssl_callback_ctrl(BIO *h, int cmd, void (*fp)());
+static long ssl_callback_ctrl(BIO *h, int cmd, bio_info_cb *fp);
typedef struct bio_ssl_st
{
SSL *ssl; /* The ssl handle :-) */
return(ret);
}
-static long ssl_callback_ctrl(BIO *b, int cmd, void (*fp)())
+static long ssl_callback_ctrl(BIO *b, int cmd, bio_info_cb *fp)
{
SSL *ssl;
BIO_SSL *bs;
cpp=(SSL_CIPHER **)OBJ_bsearch((char *)&cp,
(char *)sorted,
SSL2_NUM_CIPHERS,sizeof(SSL_CIPHER *),
- (int (*)())ssl_cipher_ptr_id_cmp);
+ FP_ICC ssl_cipher_ptr_id_cmp);
if ((cpp == NULL) || !(*cpp)->valid)
return(NULL);
else
cpp=(SSL_CIPHER **)OBJ_bsearch((char *)&cp,
(char *)sorted,
SSL3_NUM_CIPHERS,sizeof(SSL_CIPHER *),
- (int (*)())ssl_cipher_ptr_id_cmp);
+ FP_ICC ssl_cipher_ptr_id_cmp);
if ((cpp == NULL) || !(*cpp)->valid)
return(NULL);
else
} elsif (/^\#/) {
next;
}
- if (!$safe_stack_def &&
- /^\s*DECLARE_STACK_OF\s*\(\s*(\w*)\s*\)/) {
+ if (/^\s*DECLARE_STACK_OF\s*\(\s*(\w*)\s*\)/) {
next;
- } elsif ($safe_stack_def &&
- /^\s*DECLARE_STACK_OF\s*\(\s*(\w*)\s*\)/) {
- $funcs{"sk_${1}_new"} = 1;
- $funcs{"sk_${1}_new_null"} = 1;
- $funcs{"sk_${1}_free"} = 1;
- $funcs{"sk_${1}_num"} = 1;
- $funcs{"sk_${1}_value"} = 1;
- $funcs{"sk_${1}_set"} = 1;
- $funcs{"sk_${1}_zero"} = 1;
- $funcs{"sk_${1}_push"} = 1;
- $funcs{"sk_${1}_unshift"} = 1;
- $funcs{"sk_${1}_find"} = 1;
- $funcs{"sk_${1}_delete"} = 1;
- $funcs{"sk_${1}_delete_ptr"} = 1;
- $funcs{"sk_${1}_insert"} = 1;
- $funcs{"sk_${1}_set_cmp_func"} = 1;
- $funcs{"sk_${1}_dup"} = 1;
- $funcs{"sk_${1}_pop_free"} = 1;
- $funcs{"sk_${1}_shift"} = 1;
- $funcs{"sk_${1}_pop"} = 1;
- $funcs{"sk_${1}_sort"} = 1;
- } if (!$safe_stack_def &&
- /^\s*DECLARE_ASN1_SET_OF\s*\(\s*(\w*)\s*\)/) {
+ } elsif (/^\s*DECLARE_ASN1_SET_OF\s*\(\s*(\w*)\s*\)/) {
next;
- } elsif ($safe_stack_def &&
- /^\s*DECLARE_ASN1_SET_OF\s*\(\s*(\w*)\s*\)/) {
- $funcs{"d2i_ASN1_SET_OF_${1}"} = 1;
- $funcs{"i2d_ASN1_SET_OF_${1}"} = 1;
} elsif (/^DECLARE_PEM_rw\s*\(\s*(\w*)\s*,/ ||
/^DECLARE_PEM_rw_cb\s*\(\s*(\w*)\s*,/ ) {
if (!($no_rsa && ($1 eq "RSAPrivateKey" ||