summaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorBen Laurie <ben@openssl.org>2008-06-04 11:01:43 +0000
committerBen Laurie <ben@openssl.org>2008-06-04 11:01:43 +0000
commit5ce278a77bd7d23bcf965cfa37afb7b937c1a17d (patch)
treea69f3fe7e5a7e222cdd1e9314e671ffbcf79fc27 /crypto
parent37cf49a3df4b0094c5d335008705518e93b2dad2 (diff)
More type-checking.
Diffstat (limited to 'crypto')
-rw-r--r--crypto/asn1/a_set.c42
-rw-r--r--crypto/asn1/ameth_lib.c18
-rw-r--r--crypto/asn1/asn1.h18
-rw-r--r--crypto/asn1/asn_pack.c8
-rw-r--r--crypto/asn1/tasn_dec.c10
-rw-r--r--crypto/asn1/tasn_prn.c7
-rw-r--r--crypto/asn1/x_name.c71
-rw-r--r--crypto/conf/conf_api.c36
-rw-r--r--crypto/cryptlib.c11
-rw-r--r--crypto/crypto.h3
-rw-r--r--crypto/dh/Makefile20
-rw-r--r--crypto/dsa/Makefile11
-rw-r--r--crypto/dso/dso.h2
-rw-r--r--crypto/dso/dso_dlfcn.c16
-rw-r--r--crypto/dso/dso_lib.c4
-rw-r--r--crypto/ecdh/Makefile32
-rw-r--r--crypto/ecdsa/Makefile48
-rw-r--r--crypto/engine/Makefile404
-rw-r--r--crypto/engine/eng_dyn.c14
-rw-r--r--crypto/engine/engine.h3
-rw-r--r--crypto/evp/Makefile68
-rw-r--r--crypto/evp/evp_pbe.c34
-rw-r--r--crypto/evp/pmeth_lib.c15
-rw-r--r--crypto/ex_data.c16
-rw-r--r--crypto/lhash/lhash.h17
-rw-r--r--crypto/objects/obj_xref.c36
-rw-r--r--crypto/pem/pem.h7
-rw-r--r--crypto/rand/Makefile17
-rw-r--r--crypto/rsa/Makefile13
-rw-r--r--crypto/stack/safestack.h508
-rw-r--r--crypto/stack/stack.c69
-rw-r--r--crypto/stack/stack.h50
-rw-r--r--crypto/store/store.h3
-rw-r--r--crypto/store/str_lib.c10
-rw-r--r--crypto/store/str_mem.c56
-rw-r--r--crypto/txt_db/txt_db.c37
-rw-r--r--crypto/txt_db/txt_db.h5
-rw-r--r--crypto/x509v3/v3_utl.c41
-rw-r--r--crypto/x509v3/x509v3.h8
39 files changed, 1158 insertions, 630 deletions
diff --git a/crypto/asn1/a_set.c b/crypto/asn1/a_set.c
index 958558c204..2405ce1ec2 100644
--- a/crypto/asn1/a_set.c
+++ b/crypto/asn1/a_set.c
@@ -85,8 +85,9 @@ static int SetBlobCmp(const void *elem1, const void *elem2 )
}
/* int is_set: if TRUE, then sort the contents (i.e. it isn't a SEQUENCE) */
-int i2d_ASN1_SET(STACK *a, unsigned char **pp, i2d_of_void *i2d, int ex_tag,
- int ex_class, int is_set)
+int i2d_ASN1_SET(STACK_OF(BLOCK) *a, unsigned char **pp,
+ i2d_of_void *i2d, int ex_tag, int ex_class,
+ int is_set)
{
int ret=0,r;
int i;
@@ -96,8 +97,8 @@ int i2d_ASN1_SET(STACK *a, unsigned char **pp, i2d_of_void *i2d, int ex_tag,
int totSize;
if (a == NULL) return(0);
- for (i=sk_num(a)-1; i>=0; i--)
- ret+=i2d(sk_value(a,i),NULL);
+ for (i=sk_BLOCK_num(a)-1; i>=0; i--)
+ ret+=i2d(sk_BLOCK_value(a,i),NULL);
r=ASN1_object_size(1,ret,ex_tag);
if (pp == NULL) return(r);
@@ -108,10 +109,10 @@ int i2d_ASN1_SET(STACK *a, unsigned char **pp, i2d_of_void *i2d, int ex_tag,
/* And then again by Ben */
/* And again by Steve */
- if(!is_set || (sk_num(a) < 2))
+ if(!is_set || (sk_BLOCK_num(a) < 2))
{
- for (i=0; i<sk_num(a); i++)
- i2d(sk_value(a,i),&p);
+ for (i=0; i<sk_BLOCK_num(a); i++)
+ i2d(sk_BLOCK_value(a,i),&p);
*pp=p;
return(r);
@@ -119,17 +120,17 @@ int i2d_ASN1_SET(STACK *a, unsigned char **pp, i2d_of_void *i2d, int ex_tag,
pStart = p; /* Catch the beg of Setblobs*/
/* In this array we will store the SET blobs */
- rgSetBlob = (MYBLOB *)OPENSSL_malloc(sk_num(a) * sizeof(MYBLOB));
+ rgSetBlob = OPENSSL_malloc(sk_BLOCK_num(a) * sizeof(MYBLOB));
if (rgSetBlob == NULL)
{
ASN1err(ASN1_F_I2D_ASN1_SET,ERR_R_MALLOC_FAILURE);
return(0);
}
- for (i=0; i<sk_num(a); i++)
+ for (i=0; i<sk_BLOCK_num(a); i++)
{
rgSetBlob[i].pbData = p; /* catch each set encode blob */
- i2d(sk_value(a,i),&p);
+ i2d(sk_BLOCK_value(a,i),&p);
rgSetBlob[i].cbData = p - rgSetBlob[i].pbData; /* Length of this
SetBlob
*/
@@ -139,7 +140,7 @@ SetBlob
/* Now we have to sort the blobs. I am using a simple algo.
*Sort ptrs *Copy to temp-mem *Copy from temp-mem to user-mem*/
- qsort( rgSetBlob, sk_num(a), sizeof(MYBLOB), SetBlobCmp);
+ qsort( rgSetBlob, sk_BLOCK_num(a), sizeof(MYBLOB), SetBlobCmp);
if (!(pTempMem = OPENSSL_malloc(totSize)))
{
ASN1err(ASN1_F_I2D_ASN1_SET,ERR_R_MALLOC_FAILURE);
@@ -148,7 +149,7 @@ SetBlob
/* Copy to temp mem */
p = pTempMem;
- for(i=0; i<sk_num(a); ++i)
+ for(i=0; i<sk_BLOCK_num(a); ++i)
{
memcpy(p, rgSetBlob[i].pbData, rgSetBlob[i].cbData);
p += rgSetBlob[i].cbData;
@@ -162,16 +163,17 @@ SetBlob
return(r);
}
-STACK *d2i_ASN1_SET(STACK **a, const unsigned char **pp, long length,
- d2i_of_void *d2i, void (*free_func)(void *), int ex_tag,
- int ex_class)
+STACK_OF(BLOCK) *d2i_ASN1_SET(STACK_OF(BLOCK) **a, const unsigned char **pp,
+ long length, d2i_of_void *d2i,
+ void (*free_func)(BLOCK), int ex_tag,
+ int ex_class)
{
ASN1_const_CTX c;
- STACK *ret=NULL;
+ STACK_OF(BLOCK) *ret=NULL;
if ((a == NULL) || ((*a) == NULL))
{
- if ((ret=sk_new_null()) == NULL)
+ if ((ret=sk_BLOCK_new_null()) == NULL)
{
ASN1err(ASN1_F_D2I_ASN1_SET,ERR_R_MALLOC_FAILURE);
goto err;
@@ -219,7 +221,7 @@ STACK *d2i_ASN1_SET(STACK **a, const unsigned char **pp, long length,
asn1_add_error(*pp,(int)(c.q- *pp));
goto err;
}
- if (!sk_push(ret,s)) goto err;
+ if (!sk_BLOCK_push(ret,s)) goto err;
}
if (a != NULL) (*a)=ret;
*pp=c.p;
@@ -228,9 +230,9 @@ err:
if ((ret != NULL) && ((a == NULL) || (*a != ret)))
{
if (free_func != NULL)
- sk_pop_free(ret,free_func);
+ sk_BLOCK_pop_free(ret,free_func);
else
- sk_free(ret);
+ sk_BLOCK_free(ret);
}
return(NULL);
}
diff --git a/crypto/asn1/ameth_lib.c b/crypto/asn1/ameth_lib.c
index cfaef87555..d155791324 100644
--- a/crypto/asn1/ameth_lib.c
+++ b/crypto/asn1/ameth_lib.c
@@ -94,7 +94,8 @@ static const EVP_PKEY_ASN1_METHOD *standard_methods[] =
};
typedef int sk_cmp_fn_type(const char * const *a, const char * const *b);
-static STACK *app_methods = NULL;
+DECLARE_STACK_OF(EVP_PKEY_ASN1_METHOD);
+static STACK_OF(EVP_PKEY_ASN1_METHOD) *app_methods = NULL;
@@ -121,7 +122,7 @@ int EVP_PKEY_asn1_get_count(void)
{
int num = sizeof(standard_methods)/sizeof(EVP_PKEY_ASN1_METHOD *);
if (app_methods)
- num += sk_num(app_methods);
+ num += sk_EVP_PKEY_ASN1_METHOD_num(app_methods);
return num;
}
@@ -133,7 +134,7 @@ const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_get0(int idx)
if (idx < num)
return standard_methods[idx];
idx -= num;
- return (const EVP_PKEY_ASN1_METHOD *)sk_value(app_methods, idx);
+ return sk_EVP_PKEY_ASN1_METHOD_value(app_methods, idx);
}
static const EVP_PKEY_ASN1_METHOD *pkey_asn1_find(int type)
@@ -143,10 +144,9 @@ static const EVP_PKEY_ASN1_METHOD *pkey_asn1_find(int type)
if (app_methods)
{
int idx;
- idx = sk_find(app_methods, (char *)&tmp);
+ idx = sk_EVP_PKEY_ASN1_METHOD_find(app_methods, &tmp);
if (idx >= 0)
- return (EVP_PKEY_ASN1_METHOD *)
- sk_value(app_methods, idx);
+ return sk_EVP_PKEY_ASN1_METHOD_value(app_methods, idx);
}
ret = (EVP_PKEY_ASN1_METHOD **) OBJ_bsearch((char *)&t,
(char *)standard_methods,
@@ -234,13 +234,13 @@ int EVP_PKEY_asn1_add0(const EVP_PKEY_ASN1_METHOD *ameth)
{
if (app_methods == NULL)
{
- app_methods = sk_new((sk_cmp_fn_type *)ameth_cmp);
+ app_methods = sk_EVP_PKEY_ASN1_METHOD_new(ameth_cmp);
if (!app_methods)
return 0;
}
- if (!sk_push(app_methods, (char *)ameth))
+ if (!sk_EVP_PKEY_ASN1_METHOD_push(app_methods, ameth))
return 0;
- sk_sort(app_methods);
+ sk_EVP_PKEY_ASN1_METHOD_sort(app_methods);
return 1;
}
diff --git a/crypto/asn1/asn1.h b/crypto/asn1/asn1.h
index 2e7e9b6810..86c5933e98 100644
--- a/crypto/asn1/asn1.h
+++ b/crypto/asn1/asn1.h
@@ -879,11 +879,13 @@ ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s,time_t t);
int ASN1_TIME_check(ASN1_TIME *t);
ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(ASN1_TIME *t, ASN1_GENERALIZEDTIME **out);
-int i2d_ASN1_SET(STACK *a, unsigned char **pp,
- i2d_of_void *i2d, int ex_tag, int ex_class, int is_set);
-STACK * d2i_ASN1_SET(STACK **a, const unsigned char **pp, long length,
- d2i_of_void *d2i, void (*free_func)(void *),
- int ex_tag, int ex_class);
+int i2d_ASN1_SET(STACK_OF(BLOCK) *a, unsigned char **pp,
+ i2d_of_void *i2d, int ex_tag, int ex_class,
+ int is_set);
+STACK_OF(BLOCK) *d2i_ASN1_SET(STACK_OF(BLOCK) **a, const unsigned char **pp,
+ long length, d2i_of_void *d2i,
+ void (*free_func)(BLOCK), int ex_tag,
+ int ex_class);
#ifndef OPENSSL_NO_BIO
int i2a_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *a);
@@ -1035,9 +1037,9 @@ int ASN1_TYPE_set_int_octetstring(ASN1_TYPE *a, long num,
int ASN1_TYPE_get_int_octetstring(ASN1_TYPE *a,long *num,
unsigned char *data, int max_len);
-STACK *ASN1_seq_unpack(const unsigned char *buf, int len,
- d2i_of_void *d2i, void (*free_func)(void *));
-unsigned char *ASN1_seq_pack(STACK *safes, i2d_of_void *i2d,
+STACK_OF(BLOCK) *ASN1_seq_unpack(const unsigned char *buf, int len,
+ d2i_of_void *d2i, void (*free_func)(BLOCK));
+unsigned char *ASN1_seq_pack(STACK_OF(BLOCK) *safes, i2d_of_void *i2d,
unsigned char **buf, int *len );
void *ASN1_unpack_string(ASN1_STRING *oct, d2i_of_void *d2i);
void *ASN1_item_unpack(ASN1_STRING *oct, const ASN1_ITEM *it);
diff --git a/crypto/asn1/asn_pack.c b/crypto/asn1/asn_pack.c
index e8b671b7b5..1e268dee46 100644
--- a/crypto/asn1/asn_pack.c
+++ b/crypto/asn1/asn_pack.c
@@ -66,10 +66,10 @@
/* Turn an ASN1 encoded SEQUENCE OF into a STACK of structures */
-STACK *ASN1_seq_unpack(const unsigned char *buf, int len,
- d2i_of_void *d2i,void (*free_func)(void *))
+STACK_OF(BLOCK) *ASN1_seq_unpack(const unsigned char *buf, int len,
+ d2i_of_void *d2i, void (*free_func)(BLOCK))
{
- STACK *sk;
+ STACK_OF(BLOCK) *sk;
const unsigned char *pbuf;
pbuf = buf;
if (!(sk = d2i_ASN1_SET(NULL, &pbuf, len, d2i, free_func,
@@ -82,7 +82,7 @@ STACK *ASN1_seq_unpack(const unsigned char *buf, int len,
* OPENSSL_malloc'ed buffer
*/
-unsigned char *ASN1_seq_pack(STACK *safes, i2d_of_void *i2d,
+unsigned char *ASN1_seq_pack(STACK_OF(BLOCK) *safes, i2d_of_void *i2d,
unsigned char **buf, int *len)
{
int safelen;
diff --git a/crypto/asn1/tasn_dec.c b/crypto/asn1/tasn_dec.c
index f4831440fa..6f3ab00b36 100644
--- a/crypto/asn1/tasn_dec.c
+++ b/crypto/asn1/tasn_dec.c
@@ -668,11 +668,12 @@ static int asn1_template_noexp_d2i(ASN1_VALUE **val,
else
{
/* We've got a valid STACK: free up any items present */
- STACK *sktmp = (STACK *)*val;
+ STACK_OF(ASN1_VALUE) *sktmp
+ = (STACK_OF(ASN1_VALUE) *)*val;
ASN1_VALUE *vtmp;
- while(sk_num(sktmp) > 0)
+ while(sk_ASN1_VALUE_num(sktmp) > 0)
{
- vtmp = (ASN1_VALUE *)sk_pop(sktmp);
+ vtmp = sk_ASN1_VALUE_pop(sktmp);
ASN1_item_ex_free(&vtmp,
ASN1_ITEM_ptr(tt->item));
}
@@ -713,7 +714,8 @@ static int asn1_template_noexp_d2i(ASN1_VALUE **val,
goto err;
}
len -= p - q;
- if (!sk_push((STACK *)*val, (char *)skfield))
+ if (!sk_ASN1_VALUE_push((STACK_OF(ASN1_VALUE) *)*val,
+ skfield))
{
ASN1err(ASN1_F_ASN1_TEMPLATE_NOEXP_D2I,
ERR_R_MALLOC_FAILURE);
diff --git a/crypto/asn1/tasn_prn.c b/crypto/asn1/tasn_prn.c
index d2830a5ead..361e93c59f 100644
--- a/crypto/asn1/tasn_prn.c
+++ b/crypto/asn1/tasn_prn.c
@@ -354,6 +354,8 @@ int asn1_template_print_ctx(BIO *out, ASN1_VALUE **fld, int indent,
{
char *tname;
ASN1_VALUE *skitem;
+ STACK_OF(ASN1_VALUE) *stack;
+
/* SET OF, SEQUENCE OF */
if (fname)
{
@@ -371,12 +373,13 @@ int asn1_template_print_ctx(BIO *out, ASN1_VALUE **fld, int indent,
fname) <= 0)
return 0;
}
- for(i = 0; i < sk_num((STACK *)*fld); i++)
+ stack = (STACK_OF(ASN1_VALUE) *)*fld;
+ for(i = 0; i < sk_ASN1_VALUE_num(stack); i++)
{
if ((i > 0) && (BIO_puts(out, "\n") <= 0))
return 0;
- skitem = (ASN1_VALUE *)sk_value((STACK *)*fld, i);
+ skitem = sk_ASN1_VALUE_value(stack, i);
if (!asn1_item_print_ctx(out, &skitem, indent + 2,
ASN1_ITEM_ptr(tt->item), NULL, NULL, 1, pctx))
return 0;
diff --git a/crypto/asn1/x_name.c b/crypto/asn1/x_name.c
index 193f6d4403..3c9344c17f 100644
--- a/crypto/asn1/x_name.c
+++ b/crypto/asn1/x_name.c
@@ -63,6 +63,9 @@
#include <openssl/x509.h>
#include "asn1_locl.h"
+typedef STACK_OF(X509_NAME_ENTRY) STACK_OF_X509_NAME_ENTRY;
+DECLARE_STACK_OF(STACK_OF_X509_NAME_ENTRY);
+
static int x509_name_ex_d2i(ASN1_VALUE **val,
const unsigned char **in, long len,
const ASN1_ITEM *it,
@@ -76,7 +79,8 @@ static void x509_name_ex_free(ASN1_VALUE **val, const ASN1_ITEM *it);
static int x509_name_encode(X509_NAME *a);
static int x509_name_canon(X509_NAME *a);
static int asn1_string_canon(ASN1_STRING *out, ASN1_STRING *in);
-static int i2d_name_canon(STACK *intname, unsigned char **in);
+static int i2d_name_canon(STACK_OF(STACK_OF_X509_NAME_ENTRY) *intname,
+ unsigned char **in);
static int x509_name_ex_print(BIO *out, ASN1_VALUE **pval,
@@ -165,27 +169,13 @@ static void x509_name_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it)
*pval = NULL;
}
-/* Used with sk_pop_free() to free up the internal representation.
- * NB: we only free the STACK and not its contents because it is
- * already present in the X509_NAME structure.
- */
-
-static void sk_internal_free(void *a)
-{
- sk_free(a);
-}
-
-static void canon_free(void *a)
-{
- sk_X509_NAME_ENTRY_pop_free(a, X509_NAME_ENTRY_free);
-}
-
static int x509_name_ex_d2i(ASN1_VALUE **val,
const unsigned char **in, long len, const ASN1_ITEM *it,
int tag, int aclass, char opt, ASN1_TLC *ctx)
{
const unsigned char *p = *in, *q;
- union { STACK *s; ASN1_VALUE *a; } intname = {NULL};
+ union { STACK_OF(STACK_OF_X509_NAME_ENTRY) *s;
+ ASN1_VALUE *a; } intname = {NULL};
union { X509_NAME *x; ASN1_VALUE *a; } nm = {NULL};
int i, j, ret;
STACK_OF(X509_NAME_ENTRY) *entries;
@@ -206,8 +196,8 @@ static int x509_name_ex_d2i(ASN1_VALUE **val,
memcpy(nm.x->bytes->data, q, p - q);
/* Convert internal representation to X509_NAME structure */
- for(i = 0; i < sk_num(intname.s); i++) {
- entries = (STACK_OF(X509_NAME_ENTRY) *)sk_value(intname.s, i);
+ for(i = 0; i < sk_STACK_OF_X509_NAME_ENTRY_num(intname.s); i++) {
+ entries = sk_STACK_OF_X509_NAME_ENTRY_value(intname.s, i);
for(j = 0; j < sk_X509_NAME_ENTRY_num(entries); j++) {
entry = sk_X509_NAME_ENTRY_value(entries, j);
entry->set = i;
@@ -216,7 +206,7 @@ static int x509_name_ex_d2i(ASN1_VALUE **val,
}
sk_X509_NAME_ENTRY_free(entries);
}
- sk_free(intname.s);
+ sk_STACK_OF_X509_NAME_ENTRY_free(intname.s);
ret = x509_name_canon(nm.x);
if (!ret)
goto err;
@@ -249,22 +239,30 @@ static int x509_name_ex_i2d(ASN1_VALUE **val, unsigned char **out, const ASN1_IT
return ret;
}
+static void local_sk_X509_NAME_ENTRY_free(STACK_OF(X509_NAME_ENTRY) *ne)
+ {
+ sk_X509_NAME_ENTRY_free(ne);
+ }
+
static int x509_name_encode(X509_NAME *a)
{
- union { STACK *s; ASN1_VALUE *a; } intname = {NULL};
+ union { STACK_OF(STACK_OF_X509_NAME_ENTRY) *s;
+ ASN1_VALUE *a; } intname = {NULL};
int len;
unsigned char *p;
STACK_OF(X509_NAME_ENTRY) *entries = NULL;
X509_NAME_ENTRY *entry;
int i, set = -1;
- intname.s = sk_new_null();
+ intname.s = sk_STACK_OF_X509_NAME_ENTRY_new_null();
if(!intname.s) goto memerr;
for(i = 0; i < sk_X509_NAME_ENTRY_num(a->entries); i++) {
entry = sk_X509_NAME_ENTRY_value(a->entries, i);
if(entry->set != set) {
entries = sk_X509_NAME_ENTRY_new_null();
if(!entries) goto memerr;
- if(!sk_push(intname.s, (char *)entries)) goto memerr;
+ if(!sk_STACK_OF_X509_NAME_ENTRY_push(intname.s,
+ entries))
+ goto memerr;
set = entry->set;
}
if(!sk_X509_NAME_ENTRY_push(entries, entry)) goto memerr;
@@ -275,11 +273,13 @@ static int x509_name_encode(X509_NAME *a)
p=(unsigned char *)a->bytes->data;
ASN1_item_ex_i2d(&intname.a,
&p, ASN1_ITEM_rptr(X509_NAME_INTERNAL), -1, -1);
- sk_pop_free(intname.s, sk_internal_free);
+ sk_STACK_OF_X509_NAME_ENTRY_pop_free(intname.s,
+ local_sk_X509_NAME_ENTRY_free);
a->modified = 0;
return len;
- memerr:
- sk_pop_free(intname.s, sk_internal_free);
+memerr:
+ sk_STACK_OF_X509_NAME_ENTRY_pop_free(intname.s,
+ local_sk_X509_NAME_ENTRY_free);
ASN1err(ASN1_F_X509_NAME_ENCODE, ERR_R_MALLOC_FAILURE);
return -1;
}
@@ -311,10 +311,11 @@ static int x509_name_ex_print(BIO *out, ASN1_VALUE **pval,
static int x509_name_canon(X509_NAME *a)
{
unsigned char *p;
- STACK *intname = NULL;
+ STACK_OF(STACK_OF_X509_NAME_ENTRY) *intname = NULL;
STACK_OF(X509_NAME_ENTRY) *entries = NULL;
X509_NAME_ENTRY *entry, *tmpentry = NULL;
int i, set = -1, ret = 0;
+
if (a->canon_enc)
{
OPENSSL_free(a->canon_enc);
@@ -326,7 +327,7 @@ static int x509_name_canon(X509_NAME *a)
a->canon_enclen = 0;
return 1;
}
- intname = sk_new_null();
+ intname = sk_STACK_OF_X509_NAME_ENTRY_new_null();
if(!intname)
goto err;
for(i = 0; i < sk_X509_NAME_ENTRY_num(a->entries); i++)
@@ -337,7 +338,7 @@ static int x509_name_canon(X509_NAME *a)
entries = sk_X509_NAME_ENTRY_new_null();
if(!entries)
goto err;
- if(!sk_push(intname, (char *)entries))
+ if(!sk_STACK_OF_X509_NAME_ENTRY_push(intname, entries))
goto err;
set = entry->set;
}
@@ -370,7 +371,8 @@ static int x509_name_canon(X509_NAME *a)
if (tmpentry)
X509_NAME_ENTRY_free(tmpentry);
if (intname)
- sk_pop_free(intname, canon_free);
+ sk_STACK_OF_X509_NAME_ENTRY_pop_free(intname,
+ local_sk_X509_NAME_ENTRY_free);
return ret;
}
@@ -467,14 +469,17 @@ static int asn1_string_canon(ASN1_STRING *out, ASN1_STRING *in)
}
-static int i2d_name_canon(STACK *intname, unsigned char **in)
+static int i2d_name_canon(STACK_OF(STACK_OF_X509_NAME_ENTRY) *_intname,
+ unsigned char **in)
{
int i, len, ltmp;
ASN1_VALUE *v;
+ STACK_OF(ASN1_VALUE) *intname = (STACK_OF(ASN1_VALUE) *)_intname;
+
len = 0;
- for (i = 0; i < sk_num(intname); i++)
+ for (i = 0; i < sk_ASN1_VALUE_num(intname); i++)
{
- v = (ASN1_VALUE *)sk_value(intname, i);
+ v = sk_ASN1_VALUE_value(intname, i);
ltmp = ASN1_item_ex_i2d(&v, in,
ASN1_ITEM_rptr(X509_NAME_ENTRIES), -1, -1);
if (ltmp < 0)
diff --git a/crypto/conf/conf_api.c b/crypto/conf/conf_api.c
index 2438f8771e..53d7945da4 100644
--- a/crypto/conf/conf_api.c
+++ b/crypto/conf/conf_api.c
@@ -71,12 +71,10 @@
static void value_free_hash_doall_arg(CONF_VALUE *a,
LHASH_OF(CONF_VALUE) *conf);
-static void value_free_stack_doall_arg(CONF_VALUE *a,
- LHASH_OF(CONF_VALUE) *conf);
+static void value_free_stack_doall(CONF_VALUE *a);
static IMPLEMENT_LHASH_DOALL_ARG_FN(value_free_hash, CONF_VALUE,
LHASH_OF(CONF_VALUE))
-static IMPLEMENT_LHASH_DOALL_ARG_FN(value_free_stack, CONF_VALUE,
- LHASH_OF(CONF_VALUE))
+static IMPLEMENT_LHASH_DOALL_FN(value_free_stack, CONF_VALUE)
/* Up until OpenSSL 0.9.5a, this was get_section */
CONF_VALUE *_CONF_get_section(const CONF *conf, const char *section)
@@ -229,15 +227,14 @@ void _CONF_free_data(CONF *conf)
lh_CONF_VALUE_down_load(conf->data)=0; /* evil thing to make
* sure the 'OPENSSL_free()' works as
* expected */
- lh_CONF_VALUE_doall_arg(conf->data, LHASH_DOALL_ARG_FN(value_free_hash),
+ lh_CONF_VALUE_doall_arg(conf->data,
+ LHASH_DOALL_ARG_FN(value_free_hash),
LHASH_OF(CONF_VALUE), conf->data);
/* We now have only 'section' entries in the hash table.
* Due to problems with */
- lh_CONF_VALUE_doall_arg(conf->data,
- LHASH_DOALL_ARG_FN(value_free_stack),
- LHASH_OF(CONF_VALUE), conf->data);
+ lh_CONF_VALUE_doall(conf->data, LHASH_DOALL_FN(value_free_stack));
lh_CONF_VALUE_free(conf->data);
}
@@ -247,24 +244,23 @@ static void value_free_hash_doall_arg(CONF_VALUE *a, LHASH_OF(CONF_VALUE) *conf)
lh_CONF_VALUE_delete(conf,a);
}
-static void value_free_stack_doall_arg(CONF_VALUE *a,
- LHASH_OF(CONF_VALUE) *conf)
+static void value_free_stack_doall(CONF_VALUE *a)
{
CONF_VALUE *vv;
- STACK *sk;
+ STACK_OF(CONF_VALUE) *sk;
int i;
if (a->name != NULL) return;
- sk=(STACK *)a->value;
- for (i=sk_num(sk)-1; i>=0; i--)
+ sk=(STACK_OF(CONF_VALUE) *)a->value;
+ for (i=sk_CONF_VALUE_num(sk)-1; i>=0; i--)
{
- vv=(CONF_VALUE *)sk_value(sk,i);
+ vv=sk_CONF_VALUE_value(sk,i);
OPENSSL_free(vv->value);
OPENSSL_free(vv->name);
OPENSSL_free(vv);
}
- if (sk != NULL) sk_free(sk);
+ if (sk != NULL) sk_CONF_VALUE_free(sk);
OPENSSL_free(a->section);
OPENSSL_free(a);
}
@@ -272,16 +268,16 @@ static void value_free_stack_doall_arg(CONF_VALUE *a,
/* Up until OpenSSL 0.9.5a, this was new_section */
CONF_VALUE *_CONF_new_section(CONF *conf, const char *section)
{
- STACK *sk=NULL;
+ STACK_OF(CONF_VALUE) *sk=NULL;
int ok=0,i;
CONF_VALUE *v=NULL,*vv;
- if ((sk=sk_new_null()) == NULL)
+ if ((sk=sk_CONF_VALUE_new_null()) == NULL)
goto err;
- if ((v=(CONF_VALUE *)OPENSSL_malloc(sizeof(CONF_VALUE))) == NULL)
+ if ((v=OPENSSL_malloc(sizeof(CONF_VALUE))) == NULL)
goto err;
i=strlen(section)+1;
- if ((v->section=(char *)OPENSSL_malloc(i)) == NULL)
+ if ((v->section=OPENSSL_malloc(i)) == NULL)
goto err;
memcpy(v->section,section,i);
@@ -294,7 +290,7 @@ CONF_VALUE *_CONF_new_section(CONF *conf, const char *section)
err:
if (!ok)
{
- if (sk != NULL) sk_free(sk);
+ if (sk != NULL) sk_CONF_VALUE_free(sk);
if (v != NULL) OPENSSL_free(v);
v=NULL;
}
diff --git a/crypto/cryptlib.c b/crypto/cryptlib.c
index cb858d5519..b8c2ee80f6 100644
--- a/crypto/cryptlib.c
+++ b/crypto/cryptlib.c
@@ -122,7 +122,6 @@ static double SSLeay_MSVC5_hack=0.0; /* and for VC1.5 */
#endif
DECLARE_STACK_OF(CRYPTO_dynlock)
-IMPLEMENT_STACK_OF(CRYPTO_dynlock)
/* real #defines in crypto.h, keep these upto date */
static const char* const lock_names[CRYPTO_NUM_LOCKS] =
@@ -173,7 +172,7 @@ static const char* const lock_names[CRYPTO_NUM_LOCKS] =
/* This is for applications to allocate new type names in the non-dynamic
array of lock names. These are numbered with positive numbers. */
-static STACK *app_locks=NULL;
+static STACK_OF(STRING) *app_locks=NULL;
/* For applications that want a more dynamic way of handling threads, the
following stack is used. These are externally numbered with negative
@@ -207,7 +206,7 @@ int CRYPTO_get_new_lockid(char *name)
SSLeay_MSVC5_hack=(double)name[0]*(double)name[1];
#endif
- if ((app_locks == NULL) && ((app_locks=sk_new_null()) == NULL))
+ if ((app_locks == NULL) && ((app_locks=sk_STRING_new_null()) == NULL))
{
CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_LOCKID,ERR_R_MALLOC_FAILURE);
return(0);
@@ -217,7 +216,7 @@ int CRYPTO_get_new_lockid(char *name)
CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_LOCKID,ERR_R_MALLOC_FAILURE);
return(0);
}
- i=sk_push(app_locks,str);
+ i=sk_STRING_push(app_locks,str);
if (!i)
OPENSSL_free(str);
else
@@ -587,10 +586,10 @@ const char *CRYPTO_get_lock_name(int type)
return("dynamic");
else if (type < CRYPTO_NUM_LOCKS)
return(lock_names[type]);
- else if (type-CRYPTO_NUM_LOCKS > sk_num(app_locks))
+ else if (type-CRYPTO_NUM_LOCKS > sk_STRING_num(app_locks))
return("ERROR");
else
- return(sk_value(app_locks,type-CRYPTO_NUM_LOCKS));
+ return(sk_STRING_value(app_locks,type-CRYPTO_NUM_LOCKS));
}
#if defined(__i386) || defined(__i386__) || defined(_M_IX86) || \
diff --git a/crypto/crypto.h b/crypto/crypto.h
index 437ed63df1..4fa540527e 100644
--- a/crypto/crypto.h
+++ b/crypto/crypto.h
@@ -282,9 +282,10 @@ typedef struct bio_st BIO_dummy;
struct crypto_ex_data_st
{
- STACK *sk;
+ STACK_OF(void) *sk;
int dummy; /* gcc is screwing up this data structure :-( */
};
+DECLARE_STACK_OF(void)
/* This stuff is basically class callback functions
* The current classes are SSL_CTX, SSL, SSL_SESSION, and a few more */
diff --git a/crypto/dh/Makefile b/crypto/dh/Makefile
index a082a5e90a..eb1f0a12a9 100644
--- a/crypto/dh/Makefile
+++ b/crypto/dh/Makefile
@@ -140,14 +140,20 @@ dh_key.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
dh_key.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
dh_key.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
dh_key.o: ../../include/openssl/symhacks.h ../cryptlib.h dh_key.c
-dh_lib.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
-dh_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
-dh_lib.o: ../../include/openssl/dh.h ../../include/openssl/e_os2.h
+dh_lib.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
+dh_lib.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
+dh_lib.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
+dh_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
+dh_lib.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
dh_lib.o: ../../include/openssl/engine.h ../../include/openssl/err.h
-dh_lib.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
-dh_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h