size_tification.
authorBen Laurie <ben@openssl.org>
Sat, 1 Nov 2008 14:37:00 +0000 (14:37 +0000)
committerBen Laurie <ben@openssl.org>
Sat, 1 Nov 2008 14:37:00 +0000 (14:37 +0000)
46 files changed:
apps/s_apps.h
apps/s_cb.c
apps/s_socket.c
crypto/asn1/a_bitstr.c
crypto/asn1/a_bool.c
crypto/asn1/a_bytes.c
crypto/asn1/a_int.c
crypto/asn1/a_mbstr.c
crypto/asn1/a_object.c
crypto/asn1/a_octet.c
crypto/asn1/a_print.c
crypto/asn1/a_set.c
crypto/asn1/a_strnid.c
crypto/asn1/a_time.c
crypto/asn1/a_utf8.c
crypto/asn1/asn1.h
crypto/asn1/asn1_gen.c
crypto/asn1/asn1_lib.c
crypto/asn1/asn1_mac.h
crypto/asn1/asn1_par.c
crypto/asn1/asn_pack.c
crypto/asn1/evp_asn1.c
crypto/asn1/tasn_dec.c
crypto/bio/bio.h
crypto/bio/bio_cb.c
crypto/bio/bio_lib.c
crypto/bn/asm/x86_64-gcc.c
crypto/bn/bn.h
crypto/bn/bn_add.c
crypto/bn/bn_div.c
crypto/bn/bn_exp.c
crypto/bn/bn_lcl.h
crypto/bn/bn_lib.c
crypto/bn/bn_mpi.c
crypto/bn/bn_mul.c
crypto/bn/bn_nist.c
crypto/bn/bn_print.c
crypto/bn/bn_rand.c
crypto/bn/bn_recp.c
crypto/bn/bn_word.c
crypto/crypto.h
crypto/mem.c
crypto/mem_dbg.c
crypto/objects/o_names.c
crypto/objects/obj_dat.c
crypto/objects/objects.h

index 08fbbc2229640f3eb6d4e15af90f7e64926a4970..a46d77b6d849966fd4a6093f9b8447a1a45c7c0d 100644 (file)
@@ -148,7 +148,9 @@ typedef fd_mask fd_set;
 #define PORT_STR        "4433"
 #define PROTOCOL        "tcp"
 
 #define PORT_STR        "4433"
 #define PROTOCOL        "tcp"
 
-int do_server(int port, int type, int *ret, int (*cb) (char *hostname, int s, unsigned char *context), unsigned char *context);
+int do_server(int port, int type, int *ret,
+             int (*cb) (char *hostname, int s, unsigned char *context),
+             unsigned char *context);
 #ifdef HEADER_X509_H
 int MS_CALLBACK verify_callback(int ok, X509_STORE_CTX *ctx);
 #endif
 #ifdef HEADER_X509_H
 int MS_CALLBACK verify_callback(int ok, X509_STORE_CTX *ctx);
 #endif
@@ -162,11 +164,12 @@ int extract_port(char *str, short *port_ptr);
 int extract_host_port(char *str,char **host_ptr,unsigned char *ip,short *p);
 
 long MS_CALLBACK bio_dump_callback(BIO *bio, int cmd, const char *argp,
 int extract_host_port(char *str,char **host_ptr,unsigned char *ip,short *p);
 
 long MS_CALLBACK bio_dump_callback(BIO *bio, int cmd, const char *argp,
-       int argi, long argl, long ret);
+                                  size_t argi, long argl, long ret);
 
 #ifdef HEADER_SSL_H
 void MS_CALLBACK apps_ssl_info_callback(const SSL *s, int where, int ret);
 
 #ifdef HEADER_SSL_H
 void MS_CALLBACK apps_ssl_info_callback(const SSL *s, int where, int ret);
-void MS_CALLBACK msg_cb(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg);
+void MS_CALLBACK msg_cb(int write_p, int version, int content_type,
+                       const void *buf, size_t len, SSL *ssl, void *arg);
 void MS_CALLBACK tlsext_cb(SSL *s, int client_server, int type,
                                        unsigned char *data, int len,
                                        void *arg);
 void MS_CALLBACK tlsext_cb(SSL *s, int client_server, int type,
                                        unsigned char *data, int len,
                                        void *arg);
index dc50ff5d3f4fa6130d6b1117b767861939c358be..95860d208f754377e634d8d9ad96b88c93be03e3 100644 (file)
@@ -260,7 +260,7 @@ int set_cert_key_stuff(SSL_CTX *ctx, X509 *cert, EVP_PKEY *key)
        }
 
 long MS_CALLBACK bio_dump_callback(BIO *bio, int cmd, const char *argp,
        }
 
 long MS_CALLBACK bio_dump_callback(BIO *bio, int cmd, const char *argp,
-       int argi, long argl, long ret)
+                                  size_t argi, long argl, long ret)
        {
        BIO *out;
 
        {
        BIO *out;
 
index b5f9db3062ea3a300c8a97bbfbf7eebe420471b6..f884f6d33e40785513fd9475fa8620cde7a44a57 100644 (file)
@@ -279,7 +279,9 @@ static int init_client_ip(int *sock, unsigned char ip[4], int port, int type)
        return(1);
        }
 
        return(1);
        }
 
-int do_server(int port, int type, int *ret, int (*cb)(char *hostname, int s, unsigned char *context), unsigned char *context)
+int do_server(int port, int type, int *ret,
+             int (*cb)(char *hostname, int s, unsigned char *context),
+             unsigned char *context)
        {
        int sock;
        char *name = NULL;
        {
        int sock;
        char *name = NULL;
index 34179960b87aed426902213ab2640ec6f4998d58..63331b2e1e97a53b7b101d376234eed54fb40ba5 100644 (file)
 #include "cryptlib.h"
 #include <openssl/asn1.h>
 
 #include "cryptlib.h"
 #include <openssl/asn1.h>
 
-int ASN1_BIT_STRING_set(ASN1_BIT_STRING *x, unsigned char *d, int len)
-{ return M_ASN1_BIT_STRING_set(x, d, len); }
+int ASN1_BIT_STRING_set(ASN1_BIT_STRING *x, unsigned char *d, size_t len)
+       { return M_ASN1_BIT_STRING_set(x, d, len); }
 
 int i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp)
        {
 
 int i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp)
        {
-       int ret,j,bits,len;
+       int ret,j,bits;
+       size_t len;
        unsigned char *p,*d;
 
        if (a == NULL) return(0);
        unsigned char *p,*d;
 
        if (a == NULL) return(0);
@@ -114,7 +115,7 @@ int i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp)
        }
 
 ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,
        }
 
 ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,
-       const unsigned char **pp, long len)
+                                    const unsigned char **pp, size_t len)
        {
        ASN1_BIT_STRING *ret=NULL;
        const unsigned char *p;
        {
        ASN1_BIT_STRING *ret=NULL;
        const unsigned char *p;
@@ -144,13 +145,13 @@ ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,
 
        if (len-- > 1) /* using one because of the bits left byte */
                {
 
        if (len-- > 1) /* using one because of the bits left byte */
                {
-               s=(unsigned char *)OPENSSL_malloc((int)len);
+               s=OPENSSL_malloc(len);
                if (s == NULL)
                        {
                        i=ERR_R_MALLOC_FAILURE;
                        goto err;
                        }
                if (s == NULL)
                        {
                        i=ERR_R_MALLOC_FAILURE;
                        goto err;
                        }
-               memcpy(s,p,(int)len);
+               memcpy(s,p,len);
                s[len-1]&=(0xff<<i);
                p+=len;
                }
                s[len-1]&=(0xff<<i);
                p+=len;
                }
@@ -173,9 +174,10 @@ err:
 
 /* These next 2 functions from Goetz Babin-Ebell <babinebell@trustcenter.de>
  */
 
 /* These next 2 functions from Goetz Babin-Ebell <babinebell@trustcenter.de>
  */
-int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value)
+int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, size_t n, int value)
        {
        {
-       int w,v,iv;
+       int v,iv;
+       size_t w;
        unsigned char *c;
 
        w=n/8;
        unsigned char *c;
 
        w=n/8;
@@ -192,11 +194,9 @@ int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value)
                {
                if (!value) return(1); /* Don't need to set */
                if (a->data == NULL)
                {
                if (!value) return(1); /* Don't need to set */
                if (a->data == NULL)
-                       c=(unsigned char *)OPENSSL_malloc(w+1);
+                       c=OPENSSL_malloc(w+1);
                else
                else
-                       c=(unsigned char *)OPENSSL_realloc_clean(a->data,
-                                                                a->length,
-                                                                w+1);
+                       c=OPENSSL_realloc_clean(a->data, a->length, w+1);
                if (c == NULL)
                        {
                        ASN1err(ASN1_F_ASN1_BIT_STRING_SET_BIT,ERR_R_MALLOC_FAILURE);
                if (c == NULL)
                        {
                        ASN1err(ASN1_F_ASN1_BIT_STRING_SET_BIT,ERR_R_MALLOC_FAILURE);
@@ -212,7 +212,7 @@ int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value)
        return(1);
        }
 
        return(1);
        }
 
-int ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *a, int n)
+int ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *a, size_t n)
        {
        int w,v;
 
        {
        int w,v;
 
@@ -230,7 +230,7 @@ int ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *a, int n)
  * 'len' is the length of 'flags'.
  */
 int ASN1_BIT_STRING_check(ASN1_BIT_STRING *a,
  * 'len' is the length of 'flags'.
  */
 int ASN1_BIT_STRING_check(ASN1_BIT_STRING *a,
-                         unsigned char *flags, int flags_len)
+                         unsigned char *flags, size_t flags_len)
        {
        int i, ok;
        /* Check if there is one bit set at all. */
        {
        int i, ok;
        /* Check if there is one bit set at all. */
index 331acdf05350cff70cd90678d401fec1978b7b5d..bf5c079e9240256f57a5788ab26f23313f8ca23f 100644 (file)
@@ -75,11 +75,11 @@ int i2d_ASN1_BOOLEAN(int a, unsigned char **pp)
        return(r);
        }
 
        return(r);
        }
 
-int d2i_ASN1_BOOLEAN(int *a, const unsigned char **pp, long length)
+int d2i_ASN1_BOOLEAN(int *a, const unsigned char **pp, size_t length)
        {
        int ret= -1;
        const unsigned char *p;
        {
        int ret= -1;
        const unsigned char *p;
-       long len;
+       size_t len;
        int inf,tag,xclass;
        int i=0;
 
        int inf,tag,xclass;
        int i=0;
 
index 8d13f9c93113a80c116dc8b6b0a26438c95b7861..1bf9247d8ed336d00f2278ad777805514b29f659 100644 (file)
@@ -64,12 +64,12 @@ static int asn1_collate_primitive(ASN1_STRING *a, ASN1_const_CTX *c);
 /* type is a 'bitmap' of acceptable string types.
  */
 ASN1_STRING *d2i_ASN1_type_bytes(ASN1_STRING **a, const unsigned char **pp,
 /* type is a 'bitmap' of acceptable string types.
  */
 ASN1_STRING *d2i_ASN1_type_bytes(ASN1_STRING **a, const unsigned char **pp,
-            long length, int type)
+                                size_t length, int type)
        {
        ASN1_STRING *ret=NULL;
        const unsigned char *p;
        unsigned char *s;
        {
        ASN1_STRING *ret=NULL;
        const unsigned char *p;
        unsigned char *s;
-       long len;
+       size_t len;
        int inf,tag,xclass;
        int i=0;
 
        int inf,tag,xclass;
        int i=0;
 
@@ -155,12 +155,12 @@ int i2d_ASN1_bytes(ASN1_STRING *a, unsigned char **pp, int tag, int xclass)
        }
 
 ASN1_STRING *d2i_ASN1_bytes(ASN1_STRING **a, const unsigned char **pp,
        }
 
 ASN1_STRING *d2i_ASN1_bytes(ASN1_STRING **a, const unsigned char **pp,
-            long length, int Ptag, int Pclass)
+                           size_t length, int Ptag, int Pclass)
        {
        ASN1_STRING *ret=NULL;
        const unsigned char *p;
        unsigned char *s;
        {
        ASN1_STRING *ret=NULL;
        const unsigned char *p;
        unsigned char *s;
-       long len;
+       size_t len;
        int inf,tag,xclass;
        int i=0;
 
        int inf,tag,xclass;
        int i=0;
 
index c6fd204ae3b7221d5ab5323f68bc0c6b7fff4818..7691193c514089b4b4078730c1f19c3ce9afd0e3 100644 (file)
@@ -176,7 +176,7 @@ int i2c_ASN1_INTEGER(ASN1_INTEGER *a, unsigned char **pp)
 /* Convert just ASN1 INTEGER content octets to ASN1_INTEGER structure */
 
 ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **pp,
 /* Convert just ASN1 INTEGER content octets to ASN1_INTEGER structure */
 
 ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **pp,
-            long len)
+                              size_t len)
        {
        ASN1_INTEGER *ret=NULL;
        const unsigned char *p, *pend;
        {
        ASN1_INTEGER *ret=NULL;
        const unsigned char *p, *pend;
@@ -196,7 +196,7 @@ ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **pp,
 
        /* We must OPENSSL_malloc stuff, even for 0 bytes otherwise it
         * signifies a missing NULL parameter. */
 
        /* We must OPENSSL_malloc stuff, even for 0 bytes otherwise it
         * signifies a missing NULL parameter. */
-       s=(unsigned char *)OPENSSL_malloc((int)len+1);
+       s=OPENSSL_malloc(len+1);
        if (s == NULL)
                {
                i=ERR_R_MALLOC_FAILURE;
        if (s == NULL)
                {
                i=ERR_R_MALLOC_FAILURE;
@@ -246,7 +246,7 @@ ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **pp,
                        p++;
                        len--;
                        }
                        p++;
                        len--;
                        }
-               memcpy(s,p,(int)len);
+               memcpy(s,p,len);
        }
 
        if (ret->data != NULL) OPENSSL_free(ret->data);
        }
 
        if (ret->data != NULL) OPENSSL_free(ret->data);
@@ -269,12 +269,12 @@ err:
  */
 
 ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a, const unsigned char **pp,
  */
 
 ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a, const unsigned char **pp,
-            long length)
+                               size_t length)
        {
        ASN1_INTEGER *ret=NULL;
        const unsigned char *p;
        unsigned char *to,*s;
        {
        ASN1_INTEGER *ret=NULL;
        const unsigned char *p;
        unsigned char *to,*s;
-       long len;
+       size_t len;
        int inf,tag,xclass;
        int i;
 
        int inf,tag,xclass;
        int i;
 
@@ -302,7 +302,7 @@ ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a, const unsigned char **pp,
 
        /* We must OPENSSL_malloc stuff, even for 0 bytes otherwise it
         * signifies a missing NULL parameter. */
 
        /* We must OPENSSL_malloc stuff, even for 0 bytes otherwise it
         * signifies a missing NULL parameter. */
-       s=(unsigned char *)OPENSSL_malloc((int)len+1);
+       s=OPENSSL_malloc(len+1);
        if (s == NULL)
                {
                i=ERR_R_MALLOC_FAILURE;
        if (s == NULL)
                {
                i=ERR_R_MALLOC_FAILURE;
@@ -316,7 +316,7 @@ ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a, const unsigned char **pp,
                        p++;
                        len--;
                        }
                        p++;
                        len--;
                        }
-               memcpy(s,p,(int)len);
+               memcpy(s,p,len);
                p+=len;
        }
 
                p+=len;
        }
 
@@ -405,7 +405,7 @@ long ASN1_INTEGER_get(const ASN1_INTEGER *a)
 ASN1_INTEGER *BN_to_ASN1_INTEGER(const BIGNUM *bn, ASN1_INTEGER *ai)
        {
        ASN1_INTEGER *ret;
 ASN1_INTEGER *BN_to_ASN1_INTEGER(const BIGNUM *bn, ASN1_INTEGER *ai)
        {
        ASN1_INTEGER *ret;
-       int len,j;
+       size_t len,j;
 
        if (ai == NULL)
                ret=M_ASN1_INTEGER_new();
 
        if (ai == NULL)
                ret=M_ASN1_INTEGER_new();
@@ -423,7 +423,7 @@ ASN1_INTEGER *BN_to_ASN1_INTEGER(const BIGNUM *bn, ASN1_INTEGER *ai)
        len=((j == 0)?0:((j/8)+1));
        if (ret->length < len+4)
                {
        len=((j == 0)?0:((j/8)+1));
        if (ret->length < len+4)
                {
-               unsigned char *new_data=OPENSSL_realloc(ret->data, len+4);
+               unsigned char *new_data=OPENSSL_realloc(ret->data, len+4U);
                if (!new_data)
                        {
                        ASN1err(ASN1_F_BN_TO_ASN1_INTEGER,ERR_R_MALLOC_FAILURE);
                if (!new_data)
                        {
                        ASN1err(ASN1_F_BN_TO_ASN1_INTEGER,ERR_R_MALLOC_FAILURE);
index 2d4800a22a4c2c54f996969aa3100cfa0fd3d7c2..cc4b77478c3daf52fa8ae888f8b5a43b5c072455 100644 (file)
@@ -80,15 +80,15 @@ static int is_printable(unsigned long value);
  * The 'ncopy' form checks minimum and maximum size limits too.
  */
 
  * The 'ncopy' form checks minimum and maximum size limits too.
  */
 
-int ASN1_mbstring_copy(ASN1_STRING **out, const unsigned char *in, int len,
-                                       int inform, unsigned long mask)
+int ASN1_mbstring_copy(ASN1_STRING **out, const unsigned char *in, size_t len,
+                      int inform, unsigned long mask)
 {
        return ASN1_mbstring_ncopy(out, in, len, inform, mask, 0, 0);
 }
 
 {
        return ASN1_mbstring_ncopy(out, in, len, inform, mask, 0, 0);
 }
 
-int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,
-                                       int inform, unsigned long mask, 
-                                       long minsize, long maxsize)
+int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, size_t len,
+                       int inform, unsigned long mask, size_t minsize,
+                       size_t maxsize)
 {
        int str_type;
        int ret;
 {
        int str_type;
        int ret;
@@ -145,14 +145,14 @@ int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,
 
        if((minsize > 0) && (nchar < minsize)) {
                ASN1err(ASN1_F_ASN1_MBSTRING_NCOPY, ASN1_R_STRING_TOO_SHORT);
 
        if((minsize > 0) && (nchar < minsize)) {
                ASN1err(ASN1_F_ASN1_MBSTRING_NCOPY, ASN1_R_STRING_TOO_SHORT);
-               BIO_snprintf(strbuf, sizeof strbuf, "%ld", minsize);
+               BIO_snprintf(strbuf, sizeof strbuf, "%ld", (long)minsize);
                ERR_add_error_data(2, "minsize=", strbuf);
                return -1;
        }
 
        if((maxsize > 0) && (nchar > maxsize)) {
                ASN1err(ASN1_F_ASN1_MBSTRING_NCOPY, ASN1_R_STRING_TOO_LONG);
                ERR_add_error_data(2, "minsize=", strbuf);
                return -1;
        }
 
        if((maxsize > 0) && (nchar > maxsize)) {
                ASN1err(ASN1_F_ASN1_MBSTRING_NCOPY, ASN1_R_STRING_TOO_LONG);
-               BIO_snprintf(strbuf, sizeof strbuf, "%ld", maxsize);
+               BIO_snprintf(strbuf, sizeof strbuf, "%ld", (long)maxsize);
                ERR_add_error_data(2, "maxsize=", strbuf);
                return -1;
        }
                ERR_add_error_data(2, "maxsize=", strbuf);
                return -1;
        }
index f1a5a1e31e4a9367c0a657df1b9c782a44f5ed99..570aac71a742d254a6a4731bfe652b02674a9318 100644 (file)
@@ -83,11 +83,13 @@ int i2d_ASN1_OBJECT(ASN1_OBJECT *a, unsigned char **pp)
        return(objsize);
        }
 
        return(objsize);
        }
 
-int a2d_ASN1_OBJECT(unsigned char *out, int olen, const char *buf, int num)
+size_t a2d_ASN1_OBJECT(unsigned char *out, size_t olen, const char *buf,
+                      int num)
        {
        {
-       int i,first,len=0,c, use_bn;
+       int i,len=0,c, use_bn;
+       unsigned first;
        char ftmp[24], *tmp = ftmp;
        char ftmp[24], *tmp = ftmp;
-       int tmpsize = sizeof ftmp;
+       size_t tmpsize = sizeof ftmp;
        const char *p;
        unsigned long l;
        BIGNUM *bl = NULL;
        const char *p;
        unsigned long l;
        BIGNUM *bl = NULL;
@@ -150,11 +152,11 @@ int a2d_ASN1_OBJECT(unsigned char *out, int olen, const char *buf, int num)
                        if (use_bn)
                                {
                                if (!BN_mul_word(bl, 10L)
                        if (use_bn)
                                {
                                if (!BN_mul_word(bl, 10L)
-                                       || !BN_add_word(bl, c-'0'))
+                                   || !BN_add_signed_word(bl, c-'0'))
                                        goto err;
                                }
                        else
                                        goto err;
                                }
                        else
-                               l=l*10L+(long)(c-'0');
+                               l=l*10L+(c-'0');
                        }
                if (len == 0)
                        {
                        }
                if (len == 0)
                        {
@@ -227,7 +229,7 @@ err:
        return(0);
        }
 
        return(0);
        }
 
-int i2t_ASN1_OBJECT(char *buf, int buf_len, ASN1_OBJECT *a)
+int i2t_ASN1_OBJECT(char *buf, size_t buf_len, ASN1_OBJECT *a)
 {
        return OBJ_obj2txt(buf, buf_len, a, 0);
 }
 {
        return OBJ_obj2txt(buf, buf_len, a, 0);
 }
@@ -235,7 +237,7 @@ int i2t_ASN1_OBJECT(char *buf, int buf_len, ASN1_OBJECT *a)
 int i2a_ASN1_OBJECT(BIO *bp, ASN1_OBJECT *a)
        {
        char buf[80], *p = buf;
 int i2a_ASN1_OBJECT(BIO *bp, ASN1_OBJECT *a)
        {
        char buf[80], *p = buf;
-       int i;
+       size_t i;
 
        if ((a == NULL) || (a->data == NULL))
                return(BIO_write(bp,"NULL",4));
 
        if ((a == NULL) || (a->data == NULL))
                return(BIO_write(bp,"NULL",4));
@@ -256,13 +258,14 @@ int i2a_ASN1_OBJECT(BIO *bp, ASN1_OBJECT *a)
        }
 
 ASN1_OBJECT *d2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp,
        }
 
 ASN1_OBJECT *d2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp,
-            long length)
+                            size_t length)
 {
        const unsigned char *p;
 {
        const unsigned char *p;
-       long len;
+       size_t len;
        int tag,xclass;
        int inf,i;
        ASN1_OBJECT *ret = NULL;
        int tag,xclass;
        int inf,i;
        ASN1_OBJECT *ret = NULL;
+
        p= *pp;
        inf=ASN1_get_object(&p,&len,&tag,&xclass,length);
        if (inf & 0x80)
        p= *pp;
        inf=ASN1_get_object(&p,&len,&tag,&xclass,length);
        if (inf & 0x80)
@@ -284,7 +287,7 @@ err:
        return(NULL);
 }
 ASN1_OBJECT *c2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp,
        return(NULL);
 }
 ASN1_OBJECT *c2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp,
-            long len)
+                            size_t len)
        {
        ASN1_OBJECT *ret=NULL;
        const unsigned char *p;
        {
        ASN1_OBJECT *ret=NULL;
        const unsigned char *p;
@@ -309,15 +312,15 @@ ASN1_OBJECT *c2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp,
                {
                ret->length=0;
                if (data != NULL) OPENSSL_free(data);
                {
                ret->length=0;
                if (data != NULL) OPENSSL_free(data);
-               data=(unsigned char *)OPENSSL_malloc(len ? (int)len : 1);
+               data=OPENSSL_malloc(len ? len : 1);
                if (data == NULL)
                        { i=ERR_R_MALLOC_FAILURE; goto err; }
                ret->flags|=ASN1_OBJECT_FLAG_DYNAMIC_DATA;
                }
                if (data == NULL)
                        { i=ERR_R_MALLOC_FAILURE; goto err; }
                ret->flags|=ASN1_OBJECT_FLAG_DYNAMIC_DATA;
                }
-       memcpy(data,p,(int)len);
+       memcpy(data,p,len);
        /* reattach data to object, after which it remains const */
        /* reattach data to object, after which it remains const */
-       ret->data  =data;
-       ret->length=(int)len;
+       ret->data=data;
+       ret->length=len;
        ret->sn=NULL;
        ret->ln=NULL;
        /* ret->flags=ASN1_OBJECT_FLAG_DYNAMIC; we know it is dynamic */
        ret->sn=NULL;
        ret->ln=NULL;
        /* ret->flags=ASN1_OBJECT_FLAG_DYNAMIC; we know it is dynamic */
@@ -373,7 +376,7 @@ void ASN1_OBJECT_free(ASN1_OBJECT *a)
                OPENSSL_free(a);
        }
 
                OPENSSL_free(a);
        }
 
-ASN1_OBJECT *ASN1_OBJECT_create(int nid, unsigned char *data, int len,
+ASN1_OBJECT *ASN1_OBJECT_create(int nid, unsigned char *data, size_t len,
             const char *sn, const char *ln)
        {
        ASN1_OBJECT o;
             const char *sn, const char *ln)
        {
        ASN1_OBJECT o;
index e8725e44f1f50e8c5b54ed74f1133f3bf2de2ce0..edeccddf57a39c51521e102a23c8ba523abe1400 100644 (file)
 #include <openssl/asn1.h>
 
 ASN1_OCTET_STRING *ASN1_OCTET_STRING_dup(const ASN1_OCTET_STRING *x)
 #include <openssl/asn1.h>
 
 ASN1_OCTET_STRING *ASN1_OCTET_STRING_dup(const ASN1_OCTET_STRING *x)
-{ return M_ASN1_OCTET_STRING_dup(x); }
+       { return M_ASN1_OCTET_STRING_dup(x); }
 
 
-int ASN1_OCTET_STRING_cmp(const ASN1_OCTET_STRING *a, const ASN1_OCTET_STRING *b)
-{ return M_ASN1_OCTET_STRING_cmp(a, b); }
+int ASN1_OCTET_STRING_cmp(const ASN1_OCTET_STRING *a,
+                         const ASN1_OCTET_STRING *b)
+       { return M_ASN1_OCTET_STRING_cmp(a, b); }
 
 
-int ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *x, const unsigned char *d, int len)
-{ return M_ASN1_OCTET_STRING_set(x, d, len); }
+int ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *x, const unsigned char *d,
+                         size_t len)
+       { return M_ASN1_OCTET_STRING_set(x, d, len); }
 
 
index d18e772320441eda7cfda018c4adcd87eab7dcf4..4a20dca85cc2f6cf367a491339d2689be31598f6 100644 (file)
@@ -60,7 +60,7 @@
 #include "cryptlib.h"
 #include <openssl/asn1.h>
 
 #include "cryptlib.h"
 #include <openssl/asn1.h>
 
-int ASN1_PRINTABLE_type(const unsigned char *s, int len)
+int ASN1_PRINTABLE_type(const unsigned char *s, size_t len)
        {
        int c;
        int ia5=0;
        {
        int c;
        int ia5=0;
index 2405ce1ec2548ffb6f303d5736ca4e2e07098de8..02edaad9ae653fc49c219cb49f2317cd2aa184ba 100644 (file)
@@ -164,7 +164,7 @@ SetBlob
         }
 
 STACK_OF(BLOCK) *d2i_ASN1_SET(STACK_OF(BLOCK) **a, const unsigned char **pp,
         }
 
 STACK_OF(BLOCK) *d2i_ASN1_SET(STACK_OF(BLOCK) **a, const unsigned char **pp,
-                             long length, d2i_of_void *d2i,
+                             size_t length, d2i_of_void *d2i,
                              void (*free_func)(BLOCK), int ex_tag,
                              int ex_class)
        {
                              void (*free_func)(BLOCK), int ex_tag,
                              int ex_class)
        {
index cdba943737e71f1e73da3155496f8693b27bafe6..ac1a85fb433ea8a916ba69a797dc8baa65d2a025 100644 (file)
@@ -121,7 +121,7 @@ int ASN1_STRING_set_default_mask_asc(char *p)
  */
 
 ASN1_STRING *ASN1_STRING_set_by_NID(ASN1_STRING **out, const unsigned char *in,
  */
 
 ASN1_STRING *ASN1_STRING_set_by_NID(ASN1_STRING **out, const unsigned char *in,
-                                       int inlen, int inform, int nid)
+                                   size_t inlen, int inform, int nid)
 {
        ASN1_STRING_TABLE *tbl;
        ASN1_STRING *str = NULL;
 {
        ASN1_STRING_TABLE *tbl;
        ASN1_STRING *str = NULL;
index 577e2634022cdf007a072c839bee40480d9c87ee..0d618873c76ce5745b7c4210af6c4d9a70f3b6aa 100644 (file)
@@ -135,11 +135,12 @@ int ASN1_TIME_check(ASN1_TIME *t)
        }
 
 /* Convert an ASN1_TIME structure to GeneralizedTime */
        }
 
 /* Convert an ASN1_TIME structure to GeneralizedTime */
-ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(ASN1_TIME *t, ASN1_GENERALIZEDTIME **out)
+ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(ASN1_TIME *t,
+                                                  ASN1_GENERALIZEDTIME **out)
        {
        ASN1_GENERALIZEDTIME *ret;
        char *str;
        {
        ASN1_GENERALIZEDTIME *ret;
        char *str;
-       int newlen;
+       size_t newlen;
 
        if (!ASN1_TIME_check(t)) return NULL;
 
 
        if (!ASN1_TIME_check(t)) return NULL;
 
index 508e11e527c8c4b2b4bc84e872f453c58c179073..c677c99a5222020acb81dd93046598336eca7ade 100644 (file)
@@ -73,7 +73,7 @@
  * -4 = character encoded incorrectly (not minimal length).
  */
 
  * -4 = character encoded incorrectly (not minimal length).
  */
 
-int UTF8_getc(const unsigned char *str, int len, unsigned long *val)
+int UTF8_getc(const unsigned char *str, size_t len, unsigned long *val)
 {
        const unsigned char *p;
        unsigned long value;
 {
        const unsigned char *p;
        unsigned long value;
@@ -152,7 +152,7 @@ int UTF8_getc(const unsigned char *str, int len, unsigned long *val)
  * It will need at most 6 characters.
  */
 
  * It will need at most 6 characters.
  */
 
-int UTF8_putc(unsigned char *str, int len, unsigned long value)
+int UTF8_putc(unsigned char *str, size_t len, unsigned long value)
 {
        if(!str) len = 6;       /* Maximum we will need */
        else if(len <= 0) return -1;
 {
        if(!str) len = 6;       /* Maximum we will need */
        else if(len <= 0) return -1;
index a08ca334a01eb17a948484c1988eb777759d3796..f3189cc507f2543d0cbacd7bb73b0711c866cdb1 100644 (file)
@@ -180,7 +180,7 @@ typedef struct asn1_ctx_st
        int inf;        /* constructed if 0x20, indefinite is 0x21 */
        int tag;        /* tag from last 'get object' */
        int xclass;     /* class from last 'get object' */
        int inf;        /* constructed if 0x20, indefinite is 0x21 */
        int tag;        /* tag from last 'get object' */
        int xclass;     /* class from last 'get object' */
-       long slen;      /* length of last 'get object' */
+       size_t slen;    /* length of last 'get object' */
        unsigned char *max; /* largest value of p allowed */
        unsigned char *q;/* temporary variable */
        unsigned char **pp;/* variable */
        unsigned char *max; /* largest value of p allowed */
        unsigned char *q;/* temporary variable */
        unsigned char **pp;/* variable */
@@ -195,7 +195,7 @@ typedef struct asn1_const_ctx_st
        int inf;        /* constructed if 0x20, indefinite is 0x21 */
        int tag;        /* tag from last 'get object' */
        int xclass;     /* class from last 'get object' */
        int inf;        /* constructed if 0x20, indefinite is 0x21 */
        int tag;        /* tag from last 'get object' */
        int xclass;     /* class from last 'get object' */
-       long slen;      /* length of last 'get object' */
+       size_t slen;    /* length of last 'get object' */
        const unsigned char *max; /* largest value of p allowed */
        const unsigned char *q;/* temporary variable */
        const unsigned char **pp;/* variable */
        const unsigned char *max; /* largest value of p allowed */
        const unsigned char *q;/* temporary variable */
        const unsigned char **pp;/* variable */
@@ -212,7 +212,7 @@ typedef struct asn1_object_st
        {
        const char *sn,*ln;
        int nid;
        {
        const char *sn,*ln;
        int nid;
-       int length;
+       size_t length;
        const unsigned char *data;      /* data remains const after init */
        int flags;      /* Should we free this one */
        } ASN1_OBJECT;
        const unsigned char *data;      /* data remains const after init */
        int flags;      /* Should we free this one */
        } ASN1_OBJECT;
@@ -233,7 +233,7 @@ typedef struct asn1_object_st
 /* This is the base type that holds just about everything :-) */
 typedef struct asn1_string_st
        {
 /* This is the base type that holds just about everything :-) */
 typedef struct asn1_string_st
        {
-       int length;
+       size_t length;
        int type;
        unsigned char *data;
        /* The value of the following field depends on the type being
        int type;
        unsigned char *data;
        /* The value of the following field depends on the type being
@@ -251,7 +251,7 @@ typedef struct asn1_string_st
 typedef struct ASN1_ENCODING_st
        {
        unsigned char *enc;     /* DER encoding */
 typedef struct ASN1_ENCODING_st
        {
        unsigned char *enc;     /* DER encoding */
-       long len;               /* Length of encoding */
+       size_t len;             /* Length of encoding */
        int modified;            /* set to 1 if 'enc' is invalid */
        } ASN1_ENCODING;
 
        int modified;            /* set to 1 if 'enc' is invalid */
        } ASN1_ENCODING;
 
@@ -778,9 +778,9 @@ ASN1_OBJECT *       ASN1_OBJECT_new(void );
 void           ASN1_OBJECT_free(ASN1_OBJECT *a);
 int            i2d_ASN1_OBJECT(ASN1_OBJECT *a,unsigned char **pp);
 ASN1_OBJECT *  c2i_ASN1_OBJECT(ASN1_OBJECT **a,const unsigned char **pp,
 void           ASN1_OBJECT_free(ASN1_OBJECT *a);
 int            i2d_ASN1_OBJECT(ASN1_OBJECT *a,unsigned char **pp);
 ASN1_OBJECT *  c2i_ASN1_OBJECT(ASN1_OBJECT **a,const unsigned char **pp,
-                       long length);
+                               size_t length);
 ASN1_OBJECT *  d2i_ASN1_OBJECT(ASN1_OBJECT **a,const unsigned char **pp,
 ASN1_OBJECT *  d2i_ASN1_OBJECT(ASN1_OBJECT **a,const unsigned char **pp,
-                       long length);
+                               size_t length);
 
 DECLARE_ASN1_ITEM(ASN1_OBJECT)
 
 
 DECLARE_ASN1_ITEM(ASN1_OBJECT)
 
@@ -795,23 +795,24 @@ ASN1_STRING *     ASN1_STRING_type_new(int type );
 int            ASN1_STRING_cmp(const ASN1_STRING *a, const ASN1_STRING *b);
   /* Since this is used to store all sorts of things, via macros, for now, make
      its data void * */
 int            ASN1_STRING_cmp(const ASN1_STRING *a, const ASN1_STRING *b);
   /* Since this is used to store all sorts of things, via macros, for now, make
      its data void * */
-int            ASN1_STRING_set(ASN1_STRING *str, const void *data, int len);
-void           ASN1_STRING_set0(ASN1_STRING *str, void *data, int len);
-int ASN1_STRING_length(const ASN1_STRING *x);
-void ASN1_STRING_length_set(ASN1_STRING *x, int n);
+int            ASN1_STRING_set(ASN1_STRING *str, const void *data, size_t len);
+void           ASN1_STRING_set0(ASN1_STRING *str, void *data, size_t len);
+size_t ASN1_STRING_length(const ASN1_STRING *x);
+void ASN1_STRING_length_set(ASN1_STRING *x, size_t n);
 int ASN1_STRING_type(ASN1_STRING *x);
 unsigned char * ASN1_STRING_data(ASN1_STRING *x);
 
 DECLARE_ASN1_FUNCTIONS(ASN1_BIT_STRING)
 int            i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a,unsigned char **pp);
 int ASN1_STRING_type(ASN1_STRING *x);
 unsigned char * ASN1_STRING_data(ASN1_STRING *x);
 
 DECLARE_ASN1_FUNCTIONS(ASN1_BIT_STRING)
 int            i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a,unsigned char **pp);
-ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,const unsigned char **pp,
-                       long length);
+ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,
+                                    const unsigned char **pp, size_t length);
 int            ASN1_BIT_STRING_set(ASN1_BIT_STRING *a, unsigned char *d,
 int            ASN1_BIT_STRING_set(ASN1_BIT_STRING *a, unsigned char *d,
-                       int length );
-int            ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value);
-int            ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *a, int n);
-int            ASN1_BIT_STRING_check(ASN1_BIT_STRING *a,
-                                     unsigned char *flags, int flags_len);
+                                   size_t length);
+int            ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, size_t n,
+                                       int value);
+int            ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *a, size_t n);
+int             ASN1_BIT_STRING_check(ASN1_BIT_STRING *a,
+                                     unsigned char *flags, size_t flags_len);
 
 #ifndef OPENSSL_NO_BIO
 int ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs,
 
 #ifndef OPENSSL_NO_BIO
 int ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs,
@@ -821,15 +822,15 @@ int ASN1_BIT_STRING_num_asc(char *name, BIT_STRING_BITNAME *tbl);
 int ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, char *name, int value,
                                BIT_STRING_BITNAME *tbl);
 
 int ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, char *name, int value,
                                BIT_STRING_BITNAME *tbl);
 
-int            i2d_ASN1_BOOLEAN(int a,unsigned char **pp);
-int            d2i_ASN1_BOOLEAN(int *a,const unsigned char **pp,long length);
+int i2d_ASN1_BOOLEAN(int a, unsigned char **pp);
+int d2i_ASN1_BOOLEAN(int *a, const unsigned char **pp, size_t length);
 
 DECLARE_ASN1_FUNCTIONS(ASN1_INTEGER)
 int            i2c_ASN1_INTEGER(ASN1_INTEGER *a,unsigned char **pp);
 ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a,const unsigned char **pp,
 
 DECLARE_ASN1_FUNCTIONS(ASN1_INTEGER)
 int            i2c_ASN1_INTEGER(ASN1_INTEGER *a,unsigned char **pp);
 ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a,const unsigned char **pp,
-                       long length);
+                              size_t length);
 ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a,const unsigned char **pp,
 ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a,const unsigned char **pp,
-                       long length);
+                               size_t length);
 ASN1_INTEGER * ASN1_INTEGER_dup(const ASN1_INTEGER *x);
 int ASN1_INTEGER_cmp(const ASN1_INTEGER *x, const ASN1_INTEGER *y);
 
 ASN1_INTEGER * ASN1_INTEGER_dup(const ASN1_INTEGER *x);
 int ASN1_INTEGER_cmp(const ASN1_INTEGER *x, const ASN1_INTEGER *y);
 
@@ -854,7 +855,8 @@ int ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, const char *str);
 DECLARE_ASN1_FUNCTIONS(ASN1_OCTET_STRING)
 ASN1_OCTET_STRING *    ASN1_OCTET_STRING_dup(const ASN1_OCTET_STRING *a);
 int    ASN1_OCTET_STRING_cmp(const ASN1_OCTET_STRING *a, const ASN1_OCTET_STRING *b);
 DECLARE_ASN1_FUNCTIONS(ASN1_OCTET_STRING)
 ASN1_OCTET_STRING *    ASN1_OCTET_STRING_dup(const ASN1_OCTET_STRING *a);
 int    ASN1_OCTET_STRING_cmp(const ASN1_OCTET_STRING *a, const ASN1_OCTET_STRING *b);
-int    ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *str, const unsigned char *data, int len);
+int    ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *str, const unsigned char *data,
+                             size_t len);
 
 DECLARE_ASN1_FUNCTIONS(ASN1_VISIBLESTRING)
 DECLARE_ASN1_FUNCTIONS(ASN1_UNIVERSALSTRING)
 
 DECLARE_ASN1_FUNCTIONS(ASN1_VISIBLESTRING)
 DECLARE_ASN1_FUNCTIONS(ASN1_UNIVERSALSTRING)
@@ -862,8 +864,8 @@ DECLARE_ASN1_FUNCTIONS(ASN1_UTF8STRING)
 DECLARE_ASN1_FUNCTIONS(ASN1_NULL)
 DECLARE_ASN1_FUNCTIONS(ASN1_BMPSTRING)
 
 DECLARE_ASN1_FUNCTIONS(ASN1_NULL)
 DECLARE_ASN1_FUNCTIONS(ASN1_BMPSTRING)
 
-int UTF8_getc(const unsigned char *str, int len, unsigned long *val);
-int UTF8_putc(unsigned char *str, int len, unsigned long value);
+int UTF8_getc(const unsigned char *str, size_t len, unsigned long *val);
+int UTF8_putc(unsigned char *str, size_t len, unsigned long value);
 
 DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, ASN1_PRINTABLE)
 
 
 DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, ASN1_PRINTABLE)
 
@@ -889,7 +891,7 @@ 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,
                 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,
+                             size_t length, d2i_of_void *d2i,
                              void (*free_func)(BLOCK), int ex_tag,
                              int ex_class);
 
                              void (*free_func)(BLOCK), int ex_tag,
                              int ex_class);
 
@@ -902,11 +904,12 @@ int i2a_ASN1_OBJECT(BIO *bp,ASN1_OBJECT *a);
 int a2i_ASN1_STRING(BIO *bp,ASN1_STRING *bs,char *buf,int size);
 int i2a_ASN1_STRING(BIO *bp, ASN1_STRING *a, int type);
 #endif
 int a2i_ASN1_STRING(BIO *bp,ASN1_STRING *bs,char *buf,int size);
 int i2a_ASN1_STRING(BIO *bp, ASN1_STRING *a, int type);
 #endif
-int i2t_ASN1_OBJECT(char *buf,int buf_len,ASN1_OBJECT *a);
+int i2t_ASN1_OBJECT(char *buf,size_t buf_len,ASN1_OBJECT *a);
 
 
-int a2d_ASN1_OBJECT(unsigned char *out,int olen, const char *buf, int num);
-ASN1_OBJECT *ASN1_OBJECT_create(int nid, unsigned char *data,int len,
-       const char *sn, const char *ln);
+size_t a2d_ASN1_OBJECT(unsigned char *out, size_t olen, const char *buf,
+                      int num);
+ASN1_OBJECT *ASN1_OBJECT_create(int nid, unsigned char *data, size_t len,
+                               const char *sn, const char *ln);
 
 int ASN1_INTEGER_set(ASN1_INTEGER *a, long v);
 long ASN1_INTEGER_get(const ASN1_INTEGER *a);
 
 int ASN1_INTEGER_set(ASN1_INTEGER *a, long v);
 long ASN1_INTEGER_get(const ASN1_INTEGER *a);
@@ -920,29 +923,29 @@ BIGNUM *ASN1_ENUMERATED_to_BN(ASN1_ENUMERATED *ai,BIGNUM *bn);
 
 /* General */
 /* given a string, return the correct type, max is the maximum length */
 
 /* General */
 /* given a string, return the correct type, max is the maximum length */
-int ASN1_PRINTABLE_type(const unsigned char *s, int max);
+int ASN1_PRINTABLE_type(const unsigned char *s, size_t max);
 
 int i2d_ASN1_bytes(ASN1_STRING *a, unsigned char **pp, int tag, int xclass);
 ASN1_STRING *d2i_ASN1_bytes(ASN1_STRING **a, const unsigned char **pp,
 
 int i2d_ASN1_bytes(ASN1_STRING *a, unsigned char **pp, int tag, int xclass);
 ASN1_STRING *d2i_ASN1_bytes(ASN1_STRING **a, const unsigned char **pp,
-       long length, int Ptag, int Pclass);
+                           size_t length, int Ptag, int Pclass);
 unsigned long ASN1_tag2bit(int tag);
 /* type is one or more of the B_ASN1_ values. */
 ASN1_STRING *d2i_ASN1_type_bytes(ASN1_STRING **a,const unsigned char **pp,
 unsigned long ASN1_tag2bit(int tag);
 /* type is one or more of the B_ASN1_ values. */
 ASN1_STRING *d2i_ASN1_type_bytes(ASN1_STRING **a,const unsigned char **pp,
-               long length,int type);
+                                size_t length,int type);
 
 /* PARSING */
 int asn1_Finish(ASN1_CTX *c);
 int asn1_const_Finish(ASN1_const_CTX *c);
 
 /* SPECIALS */
 
 /* PARSING */
 int asn1_Finish(ASN1_CTX *c);
 int asn1_const_Finish(ASN1_const_CTX *c);
 
 /* SPECIALS */
-int ASN1_get_object(const unsigned char **pp, long *plength, int *ptag,
-       int *pclass, long omax);
-int ASN1_check_infinite_end(unsigned char **p,long len);
-int ASN1_const_check_infinite_end(const unsigned char **p,long len);
-void ASN1_put_object(unsigned char **pp, int constructed, int length,
-       int tag, int xclass);
+int ASN1_get_object(const unsigned char **pp, size_t *plength, int *ptag,
+                   int *pclass, size_t omax);
+int ASN1_check_infinite_end(unsigned char **p, size_t len);
+int ASN1_const_check_infinite_end(const unsigned char **p, size_t len);
+void ASN1_put_object(unsigned char **pp, int constructed, size_t length,
+                    int tag, int xclass);
 int ASN1_put_eoc(unsigned char **pp);
 int ASN1_put_eoc(unsigned char **pp);
-int ASN1_object_size(int constructed, int length, int tag);
+size_t ASN1_object_size(int constructed, size_t length, int tag);
 
 /* Used to implement other functions */
 void *ASN1_dup(i2d_of_void *i2d, d2i_of_void *d2i, char *x);
 
 /* Used to implement other functions */
 void *ASN1_dup(i2d_of_void *i2d, d2i_of_void *d2i, char *x);
@@ -1023,8 +1026,9 @@ int ASN1_STRING_print(BIO *bp, const ASN1_STRING *v);
 int ASN1_STRING_print_ex(BIO *out, ASN1_STRING *str, unsigned long flags);
 int ASN1_bn_print(BIO *bp, const char *number, const BIGNUM *num,
                                unsigned char *buf, int off);
 int ASN1_STRING_print_ex(BIO *out, ASN1_STRING *str, unsigned long flags);
 int ASN1_bn_print(BIO *bp, const char *number, const BIGNUM *num,
                                unsigned char *buf, int off);
-int ASN1_parse(BIO *bp,const unsigned char *pp,long len,int indent);
-int ASN1_parse_dump(BIO *bp,const unsigned char *pp,long len,int indent,int dump);
+int ASN1_parse(BIO *bp, const unsigned char *pp, size_t len, int indent);
+int ASN1_parse_dump(BIO *bp, const unsigned char *pp, size_t len, int indent,
+                   int dump);
 #endif
 const char *ASN1_tag2str(int tag);
 
 #endif
 const char *ASN1_tag2str(int tag);
 
@@ -1035,24 +1039,24 @@ DECLARE_ASN1_FUNCTIONS(NETSCAPE_X509)
 int ASN1_UNIVERSALSTRING_to_string(ASN1_UNIVERSALSTRING *s);
 
 int ASN1_TYPE_set_octetstring(ASN1_TYPE *a,
 int ASN1_UNIVERSALSTRING_to_string(ASN1_UNIVERSALSTRING *s);
 
 int ASN1_TYPE_set_octetstring(ASN1_TYPE *a,
-       unsigned char *data, int len);
+       unsigned char *data, size_t len);
 int ASN1_TYPE_get_octetstring(ASN1_TYPE *a,
 int ASN1_TYPE_get_octetstring(ASN1_TYPE *a,
-       unsigned char *data, int max_len);
+       unsigned char *data, size_t max_len);
 int ASN1_TYPE_set_int_octetstring(ASN1_TYPE *a, long num,
 int ASN1_TYPE_set_int_octetstring(ASN1_TYPE *a, long num,
-       unsigned char *data, int len);
-int ASN1_TYPE_get_int_octetstring(ASN1_TYPE *a,long *num,
-       unsigned char *data, int max_len);
+       unsigned char *data, size_t len);
+int ASN1_TYPE_get_int_octetstring(ASN1_TYPE *a, long *num,
+       unsigned char *data, size_t max_len);
 
 
-STACK_OF(BLOCK) *ASN1_seq_unpack(const unsigned char *buf, int len,
+STACK_OF(BLOCK) *ASN1_seq_unpack(const unsigned char *buf, size_t len,
                                 d2i_of_void *d2i, void (*free_func)(BLOCK));
 unsigned char *ASN1_seq_pack(STACK_OF(BLOCK) *safes, i2d_of_void *i2d,
                                 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 );
+                            unsigned char **buf, size_t *len);
 void *ASN1_unpack_string(ASN1_STRING *oct, d2i_of_void *d2i);
 void *ASN1_item_unpack(ASN1_STRING *oct, const ASN1_ITEM *it);
 ASN1_STRING *ASN1_pack_string(void *obj, i2d_of_void *i2d,
                              ASN1_OCTET_STRING **oct);
 
 void *ASN1_unpack_string(ASN1_STRING *oct, d2i_of_void *d2i);
 void *ASN1_item_unpack(ASN1_STRING *oct, const ASN1_ITEM *it);
 ASN1_STRING *ASN1_pack_string(void *obj, i2d_of_void *i2d,
                              ASN1_OCTET_STRING **oct);
 
-#define ASN1_pack_string_of(type,obj,i2d,oct) \
+#define ASN1_pack_string_of(type,obj,i2d,oct)   \
     (ASN1_pack_string(CHECKED_PTR_OF(type, obj), \
                      CHECKED_I2D_OF(type, i2d), \
                      oct))
     (ASN1_pack_string(CHECKED_PTR_OF(type, obj), \
                      CHECKED_I2D_OF(type, i2d), \
                      oct))
@@ -1062,14 +1066,15 @@ ASN1_STRING *ASN1_item_pack(void *obj, const ASN1_ITEM *it, ASN1_OCTET_STRING **
 void ASN1_STRING_set_default_mask(unsigned long mask);
 int ASN1_STRING_set_default_mask_asc(char *p);
 unsigned long ASN1_STRING_get_default_mask(void);
 void ASN1_STRING_set_default_mask(unsigned long mask);
 int ASN1_STRING_set_default_mask_asc(char *p);
 unsigned long ASN1_STRING_get_default_mask(void);
-int ASN1_mbstring_copy(ASN1_STRING **out, const unsigned char *in, int len,
+int ASN1_mbstring_copy(ASN1_STRING **out, const unsigned char *in, size_t len,
                                        int inform, unsigned long mask);
                                        int inform, unsigned long mask);
-int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,
+int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, size_t len,
                                        int inform, unsigned long mask, 
                                        int inform, unsigned long mask, 
-                                       long minsize, long maxsize);
+                                       size_t minsize, size_t maxsize);
 
 ASN1_STRING *ASN1_STRING_set_by_NID(ASN1_STRING **out, 
 
 ASN1_STRING *ASN1_STRING_set_by_NID(ASN1_STRING **out, 
-               const unsigned char *in, int inlen, int inform, int nid);
+                                   const unsigned char *in, size_t inlen,
+                                   int inform, int nid);
 ASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid);
 int ASN1_STRING_TABLE_add(int, long, long, unsigned long, unsigned long);
 void ASN1_STRING_TABLE_cleanup(void);
 ASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid);
 int ASN1_STRING_TABLE_add(int, long, long, unsigned long, unsigned long);
 void ASN1_STRING_TABLE_cleanup(void);
@@ -1079,9 +1084,11 @@ void ASN1_STRING_TABLE_cleanup(void);
 /* Old API compatible functions */
 ASN1_VALUE *ASN1_item_new(const ASN1_ITEM *it);
 void ASN1_item_free(ASN1_VALUE *val, const ASN1_ITEM *it);
 /* Old API compatible functions */
 ASN1_VALUE *ASN1_item_new(const ASN1_ITEM *it);
 void ASN1_item_free(ASN1_VALUE *val, const ASN1_ITEM *it);
-ASN1_VALUE * ASN1_item_d2i(ASN1_VALUE **val, const unsigned char **in, long len, const ASN1_ITEM *it);
+ASN1_VALUE * ASN1_item_d2i(ASN1_VALUE **val, const unsigned char **in,
+                          size_t len, const ASN1_ITEM *it);
 int ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it);
 int ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it);
-int ASN1_item_ndef_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it);
+int ASN1_item_ndef_i2d(ASN1_VALUE *val, unsigned char **out,
+                      const ASN1_ITEM *it);
 
 void ASN1_add_oid_module(void);
 
 
 void ASN1_add_oid_module(void);
 
index f73b65f9d59dc37919a114b3fc4f730e4b981781..5e7cd8fab9fd9d7c28d0be9a11c40b35769d561d 100644 (file)
@@ -145,7 +145,7 @@ ASN1_TYPE *ASN1_generate_v3(char *str, X509V3_CTX *cnf)
        unsigned char *p;
        const unsigned char *cp;
        int cpy_len;
        unsigned char *p;
        const unsigned char *cp;
        int cpy_len;
-       long hdr_len;
+       size_t hdr_len;
        int hdr_constructed = 0, hdr_tag, hdr_class;
        int r;
 
        int hdr_constructed = 0, hdr_tag, hdr_class;
        int r;
 
index 1bcb44aee203637ec70a60fe616588696bac32ac..61abef2ffc1393603c46b94a21869e25d1bebca6 100644 (file)
@@ -62,7 +62,8 @@
 #include <openssl/asn1.h>
 #include <openssl/asn1_mac.h>
 
 #include <openssl/asn1.h>
 #include <openssl/asn1_mac.h>
 
-static int asn1_get_length(const unsigned char **pp,int *inf,long *rl,int max);
+static int asn1_get_length(const unsigned char **pp, int *inf, size_t *rl,
+                          size_t max);
 static void asn1_put_length(unsigned char **pp, int length);
 const char ASN1_version[]="ASN.1" OPENSSL_VERSION_PTEXT;
 
 static void asn1_put_length(unsigned char **pp, int length);
 const char ASN1_version[]="ASN.1" OPENSSL_VERSION_PTEXT;
 
@@ -80,27 +81,29 @@ static int _asn1_check_infinite_end(const unsigned char **p, long len)
        return(0);
        }
 
        return(0);
        }
 
-int ASN1_check_infinite_end(unsigned char **p, long len)
+int ASN1_check_infinite_end(unsigned char **p, size_t len)
        {
        return _asn1_check_infinite_end((const unsigned char **)p, len);
        }
 
        {
        return _asn1_check_infinite_end((const unsigned char **)p, len);
        }
 
-int ASN1_const_check_infinite_end(const unsigned char **p, long len)
+int ASN1_const_check_infinite_end(const unsigned char **p, size_t len)
        {
        return _asn1_check_infinite_end(p, len);
        }
 
 
        {
        return _asn1_check_infinite_end(p, len);
        }
 
 
-int ASN1_get_object(const unsigned char **pp, long *plength, int *ptag,
-       int *pclass, long omax)
+int ASN1_get_object(const unsigned char **pp, size_t *plength, int *ptag,
+                   int *pclass, size_t omax)
        {
        int i,ret;
        long l;
        const unsigned char *p= *pp;
        int tag,xclass,inf;
        {
        int i,ret;
        long l;
        const unsigned char *p= *pp;
        int tag,xclass,inf;
-       long max=omax;
+       size_t max=omax;
+
+       if (!max)
+           goto err;
 
 
-       if (!max) goto err;
        ret=(*p&V_ASN1_CONSTRUCTED);
        xclass=(*p&V_ASN1_PRIVATE);
        i= *p&V_ASN1_PRIMITIVE_TAG;
        ret=(*p&V_ASN1_CONSTRUCTED);
        xclass=(*p&V_ASN1_PRIVATE);
        i= *p&V_ASN1_PRIMITIVE_TAG;
@@ -151,7 +154,8 @@ err:
        return(0x80);
        }
 
        return(0x80);
        }
 
-static int asn1_get_length(const unsigned char **pp, int *inf, long *rl, int max)
+static int asn1_get_length(const unsigned char **pp, int *inf, size_t *rl,
+                          size_t max)
        {
        const unsigned char *p= *pp;
        unsigned long ret=0;
        {
        const unsigned char *p= *pp;
        unsigned long ret=0;
@@ -192,8 +196,8 @@ static int asn1_get_length(const unsigned char **pp, int *inf, long *rl, int max
 
 /* class 0 is constructed
  * constructed == 2 for indefinite length constructed */
 
 /* class 0 is constructed
  * constructed == 2 for indefinite length constructed */
-void ASN1_put_object(unsigned char **pp, int constructed, int length, int tag,
-            int xclass)
+void ASN1_put_object(unsigned char **pp, int constructed, size_t length,
+                    int tag, int xclass)
        {
        unsigned char *p= *pp;
        int i, ttag;
        {
        unsigned char *p= *pp;
        int i, ttag;
@@ -254,7 +258,7 @@ static void asn1_put_length(unsigned char **pp, int length)
        *pp=p;
        }
 
        *pp=p;
        }
 
-int ASN1_object_size(int constructed, int length, int tag)
+size_t ASN1_object_size(int constructed, size_t length, int tag)
        {
        int ret;
 
        {
        int ret;
 
@@ -367,7 +371,7 @@ ASN1_STRING *ASN1_STRING_dup(const ASN1_STRING *str)
        return ret;
        }
 
        return ret;
        }
 
-int ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len)
+int ASN1_STRING_set(ASN1_STRING *str, const void *_data, size_t len)
        {
        unsigned char *c;
        const char *data=_data;
        {
        unsigned char *c;
        const char *data=_data;
@@ -404,7 +408,7 @@ int ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len)
        return(1);
        }
 
        return(1);
        }
 
-void ASN1_STRING_set0(ASN1_STRING *str, void *data, int len)
+void ASN1_STRING_set0(ASN1_STRING *str, void *data, size_t len)
        {
        if (str->data)
                OPENSSL_free(str->data);
        {
        if (str->data)
                OPENSSL_free(str->data);
@@ -469,14 +473,14 @@ void asn1_add_error(const unsigned char *address, int offset)
        ERR_add_error_data(4,"address=",buf1," offset=",buf2);
        }
 
        ERR_add_error_data(4,"address=",buf1," offset=",buf2);
        }
 
-int ASN1_STRING_length(const ASN1_STRING *x)
-{ return M_ASN1_STRING_length(x); }
+size_t ASN1_STRING_length(const ASN1_STRING *x)
+       { return M_ASN1_STRING_length(x); }
 
 
-void ASN1_STRING_length_set(ASN1_STRING *x, int len)
-{ M_ASN1_STRING_length_set(x, len); return; }
+void ASN1_STRING_length_set(ASN1_STRING *x, size_t len)
+       { M_ASN1_STRING_length_set(x, len); return; }
 
 int ASN1_STRING_type(ASN1_STRING *x)
 
 int ASN1_STRING_type(ASN1_STRING *x)
-{ return M_ASN1_STRING_type(x); }
+       { return M_ASN1_STRING_type(x); }
 
 unsigned char * ASN1_STRING_data(ASN1_STRING *x)
 
 unsigned char * ASN1_STRING_data(ASN1_STRING *x)
-{ return M_ASN1_STRING_data(x); }
+       { return M_ASN1_STRING_data(x); }
index 87bd0e9e1d81358b0631615269882ee4c88bb1a3..1383924574a257c901d1d5f3e5e77a629c9d5f5e 100644 (file)
@@ -279,7 +279,7 @@ err:\
                (V_ASN1_CONSTRUCTED|V_ASN1_CONTEXT_SPECIFIC|tag))) \
                { \
                int Tinf,Ttag,Tclass; \
                (V_ASN1_CONSTRUCTED|V_ASN1_CONTEXT_SPECIFIC|tag))) \
                { \
                int Tinf,Ttag,Tclass; \
-               long Tlen; \
+               size_t Tlen; \
                \
                c.q=c.p; \
                Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass,c.slen); \
                \
                c.q=c.p; \
                Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass,c.slen); \
index c322dec2b299a4f3c16fa2802379390bf65296e0..def7bcf2f1c76f5e026814a13288df75e36c312a 100644 (file)
 #include <openssl/asn1.h>
 
 static int asn1_print_info(BIO *bp, int tag, int xclass,int constructed,
 #include <openssl/asn1.h>
 
 static int asn1_print_info(BIO *bp, int tag, int xclass,int constructed,
-       int indent);
-static int asn1_parse2(BIO *bp, const unsigned char **pp, long length,
-       int offset, int depth, int indent, int dump);
+                          int indent);
+static int asn1_parse2(BIO *bp, const unsigned char **pp, size_t length,
+                      int offset, int depth, int indent, int dump);
 static int asn1_print_info(BIO *bp, int tag, int xclass, int constructed,
 static int asn1_print_info(BIO *bp, int tag, int xclass, int constructed,
-            int indent)
+                          int indent)
        {
        static const char fmt[]="%-18s";
        char str[128];
        {
        static const char fmt[]="%-18s";
        char str[128];
@@ -99,21 +99,22 @@ err:
        return(0);
        }
 
        return(0);
        }
 
-int ASN1_parse(BIO *bp, const unsigned char *pp, long len, int indent)
+int ASN1_parse(BIO *bp, const unsigned char *pp, size_t len, int indent)
        {
        return(asn1_parse2(bp,&pp,len,0,0,indent,0));
        }
 
        {
        return(asn1_parse2(bp,&pp,len,0,0,indent,0));
        }
 
-int ASN1_parse_dump(BIO *bp, const unsigned char *pp, long len, int indent, int dump)
+int ASN1_parse_dump(BIO *bp, const unsigned char *pp, size_t len, int indent,
+                   int dump)
        {
        return(asn1_parse2(bp,&pp,len,0,0,indent,dump));
        }
 
        {
        return(asn1_parse2(bp,&pp,len,0,0,indent,dump));
        }
 
-static int asn1_parse2(BIO *bp, const unsigned char **pp, long length, int offset,
-            int depth, int indent, int dump)
+static int asn1_parse2(BIO *bp, const unsigned char **pp, size_t length,
+                      int offset, int depth, int indent, int dump)
        {
        const unsigned char *p,*ep,*tot,*op,*opp;
        {
        const unsigned char *p,*ep,*tot,*op,*opp;
-       long len;
+       size_t len;
        int tag,xclass,ret=0;
        int nl,hl,j,r;
        ASN1_OBJECT *o=NULL;
        int tag,xclass,ret=0;
        int nl,hl,j,r;
        ASN1_OBJECT *o=NULL;
@@ -152,13 +153,13 @@ static int asn1_parse2(BIO *bp, const unsigned char **pp, long length, int offse
                if (j != (V_ASN1_CONSTRUCTED | 1))
                        {
                        if (BIO_printf(bp,"d=%-2d hl=%ld l=%4ld ",
                if (j != (V_ASN1_CONSTRUCTED | 1))
                        {
                        if (BIO_printf(bp,"d=%-2d hl=%ld l=%4ld ",
-                               depth,(long)hl,len) <= 0)
+                                      depth,(long)hl,(long)len) <= 0)
                                goto end;
                        }
                else
                        {
                        if (BIO_printf(bp,"d=%-2d hl=%ld l=inf  ",
                                goto end;
                        }
                else
                        {
                        if (BIO_printf(bp,"d=%-2d hl=%ld l=inf  ",
-                               depth,(long)hl) <= 0)
+                                      depth,(long)hl) <= 0)
                                goto end;
                        }
                if (!asn1_print_info(bp,tag,xclass,j,(indent)?depth:0))
                                goto end;
                        }
                if (!asn1_print_info(bp,tag,xclass,j,(indent)?depth:0))
@@ -170,7 +171,8 @@ static int asn1_parse2(BIO *bp, const unsigned char **pp, long length, int offse
                        if (len > length)
                                {
                                BIO_printf(bp,
                        if (len > length)
                                {
                                BIO_printf(bp,
-                                       "length is greater than %ld\n",length);
+                                          "length is greater than %ld\n",
+                                          (long)length);
                                ret=0;
                                goto end;
                                }
                                ret=0;
                                goto end;
                                }
index 1e268dee467b5ba5f204f317238f37195550a77f..751025e5d11fe1775abb760c7c84ce06dc0f62c6 100644 (file)
@@ -66,7 +66,7 @@
 
 /* Turn an ASN1 encoded SEQUENCE OF into a STACK of structures */
 
 
 /* Turn an ASN1 encoded SEQUENCE OF into a STACK of structures */
 
-STACK_OF(BLOCK) *ASN1_seq_unpack(const unsigned char *buf, int len,
+STACK_OF(BLOCK) *ASN1_seq_unpack(const unsigned char *buf, size_t len,
                                 d2i_of_void *d2i, void (*free_func)(BLOCK))
 {
     STACK_OF(BLOCK) *sk;
                                 d2i_of_void *d2i, void (*free_func)(BLOCK))
 {
     STACK_OF(BLOCK) *sk;
@@ -83,7 +83,7 @@ STACK_OF(BLOCK) *ASN1_seq_unpack(const unsigned char *buf, int len,
  */
 
 unsigned char *ASN1_seq_pack(STACK_OF(BLOCK) *safes, i2d_of_void *i2d,
  */
 
 unsigned char *ASN1_seq_pack(STACK_OF(BLOCK) *safes, i2d_of_void *i2d,
-                            unsigned char **buf, int *len)
+                            unsigned char **buf, size_t *len)
 {
        int safelen;
        unsigned char *safe, *p;
 {
        int safelen;
        unsigned char *safe, *p;
index f3d9804860ec31fc09d885f18f3c6e3e47ad00da..b7bb7eb127c76034a3528136810b553310c1397c 100644 (file)
@@ -61,7 +61,7 @@
 #include <openssl/asn1.h>
 #include <openssl/asn1_mac.h>
 
 #include <openssl/asn1.h>
 #include <openssl/asn1_mac.h>
 
-int ASN1_TYPE_set_octetstring(ASN1_TYPE *a, unsigned char *data, int len)
+int ASN1_TYPE_set_octetstring(ASN1_TYPE *a, unsigned char *data, size_t len)
        {
        ASN1_STRING *os;
 
        {
        ASN1_STRING *os;
 
@@ -73,7 +73,7 @@ int ASN1_TYPE_set_octetstring(ASN1_TYPE *a, unsigned char *data, int len)
 
 /* int max_len:  for returned value    */
 int ASN1_TYPE_get_octetstring(ASN1_TYPE *a, unsigned char *data,
 
 /* int max_len:  for returned value    */
 int ASN1_TYPE_get_octetstring(ASN1_TYPE *a, unsigned char *data,
-            int max_len)
+                             size_t max_len)
        {
        int ret,num;
        unsigned char *p;
        {
        int ret,num;
        unsigned char *p;
@@ -94,7 +94,7 @@ int ASN1_TYPE_get_octetstring(ASN1_TYPE *a, unsigned char *data,
        }
 
 int ASN1_TYPE_set_int_octetstring(ASN1_TYPE *a, long num, unsigned char *data,
        }
 
 int ASN1_TYPE_set_int_octetstring(ASN1_TYPE *a, long num, unsigned char *data,
-            int len)
+                                 size_t len)
        {
        int n,size;
        ASN1_OCTET_STRING os,*osp;
        {
        int n,size;
        ASN1_OCTET_STRING os,*osp;
@@ -136,7 +136,7 @@ int ASN1_TYPE_set_int_octetstring(ASN1_TYPE *a, long num, unsigned char *data,
  * case, set it to zero */
 /* int max_len:  for returned value    */
 int ASN1_TYPE_get_int_octetstring(ASN1_TYPE *a, long *num, unsigned char *data,
  * case, set it to zero */
 /* int max_len:  for returned value    */
 int ASN1_TYPE_get_int_octetstring(ASN1_TYPE *a, long *num, unsigned char *data,
-            int max_len)
+                                 size_t max_len)
        {
        int ret= -1,n;
        ASN1_INTEGER *ai=NULL;
        {
        int ret= -1,n;
        ASN1_INTEGER *ai=NULL;
index 6f3ab00b3637adcb90c50cfe42f7105ce71ac3d3..0604c51eca38bde9f912d7217d79b447cdb80253 100644 (file)
@@ -126,7 +126,8 @@ unsigned long ASN1_tag2bit(int tag)
  */
 
 ASN1_VALUE *ASN1_item_d2i(ASN1_VALUE **pval,
  */
 
 ASN1_VALUE *ASN1_item_d2i(ASN1_VALUE **pval,
-               const unsigned char **in, long len, const ASN1_ITEM *it)
+                         const unsigned char **in, size_t len,
+                         const ASN1_ITEM *it)
        {
        ASN1_TLC c;
        ASN1_VALUE *ptmpval = NULL;
        {
        ASN1_TLC c;
        ASN1_VALUE *ptmpval = NULL;
@@ -1243,7 +1244,7 @@ static int asn1_check_tlen(long *olen, int *otag, unsigned char *oclass,
        {
        int i;
        int ptag, pclass;
        {
        int i;
        int ptag, pclass;
-       long plen;
+       size_t plen;
        const unsigned char *p, *q;
        p = *in;
        q = p;
        const unsigned char *p, *q;
        p = *in;
        q = p;
index ea5323d20fe91997604eaaebe38f3e0bdc84dd21..299dadfb3f46ef77774e4082b3cd831f0e1827e7 100644 (file)
@@ -252,9 +252,11 @@ void BIO_clear_flags(BIO *b, int flags);
 #define BIO_cb_pre(a)  (!((a)&BIO_CB_RETURN))
 #define BIO_cb_post(a) ((a)&BIO_CB_RETURN)
 
 #define BIO_cb_pre(a)  (!((a)&BIO_CB_RETURN))
 #define BIO_cb_post(a) ((a)&BIO_CB_RETURN)
 
-long (*BIO_get_callback(const BIO *b)) (struct bio_st *,int,const char *,int, long,long);
-void BIO_set_callback(BIO *b, 
-       long (*callback)(struct bio_st *,int,const char *,int, long,long));
+long (*BIO_get_callback(const BIO *b)) (struct bio_st *, int, const char *,
+                                       size_t, long, long);
+void BIO_set_callback(BIO *b, long (*callback)(struct bio_st *, int,
+                                              const char *, size_t, long,
+                                              long));
 char *BIO_get_callback_arg(const BIO *b);
 void BIO_set_callback_arg(BIO *b, char *arg);
 
 char *BIO_get_callback_arg(const BIO *b);
 void BIO_set_callback_arg(BIO *b, char *arg);
 
@@ -281,7 +283,7 @@ struct bio_st
        {
        BIO_METHOD *method;
        /* bio, mode, argp, argi, argl, ret */
        {
        BIO_METHOD *method;
        /* bio, mode, argp, argi, argl, ret */
-       long (*callback)(struct bio_st *,int,const char *,int, long,long);
+       long (*callback)(struct bio_st *,int,const char *,size_t, long,long);
        char *cb_arg; /* first argument for the callback */
 
        int init;
        char *cb_arg; /* first argument for the callback */
 
        int init;
@@ -571,7 +573,7 @@ int BIO_free(BIO *a);
 void   BIO_vfree(BIO *a);
 int    BIO_read(BIO *b, void *data, int len);
 int    BIO_gets(BIO *bp,char *buf, int size);
 void   BIO_vfree(BIO *a);
 int    BIO_read(BIO *b, void *data, int len);
 int    BIO_gets(BIO *bp,char *buf, int size);
-int    BIO_write(BIO *b, const void *data, int len);
+int    BIO_write(BIO *b, const void *data, size_t len);
 int    BIO_puts(BIO *bp,const char *buf);
 int    BIO_indent(BIO *b,int indent,int max);
 long   BIO_ctrl(BIO *bp,int cmd,long larg,void *parg);
 int    BIO_puts(BIO *bp,const char *buf);
 int    BIO_indent(BIO *b,int indent,int max);
 long   BIO_ctrl(BIO *bp,int cmd,long larg,void *parg);
@@ -592,8 +594,8 @@ int BIO_nread(BIO *bio, char **buf, int num);
 int BIO_nwrite0(BIO *bio, char **buf);
 int BIO_nwrite(BIO *bio, char **buf, int num);
 
 int BIO_nwrite0(BIO *bio, char **buf);
 int BIO_nwrite(BIO *bio, char **buf, int num);
 
-long BIO_debug_callback(BIO *bio,int cmd,const char *argp,int argi,
-       long argl,long ret);
+long BIO_debug_callback(BIO *bio, int cmd, const char *argp, size_t argi,
+                       long argl, long ret);
 
 BIO_METHOD *BIO_s_mem(void);
 BIO *BIO_new_mem_buf(void *buf, int len);
 
 BIO_METHOD *BIO_s_mem(void);
 BIO *BIO_new_mem_buf(void *buf, int len);
index 6f4254a1141a03a400d85ac4b8f5cd1e96d8ae0c..4a72cc98964760b38cc8a83f86b73b5213f97d18 100644 (file)
@@ -64,7 +64,7 @@
 #include <openssl/err.h>
 
 long MS_CALLBACK BIO_debug_callback(BIO *bio, int cmd, const char *argp,
 #include <openssl/err.h>
 
 long MS_CALLBACK BIO_debug_callback(BIO *bio, int cmd, const char *argp,
-            int argi, long argl, long ret)
+                                   size_t argi, long argl, long ret)
        {
        BIO *b;
        MS_STATIC char buf[256];
        {
        BIO *b;
        MS_STATIC char buf[256];
index 3f52ae953c2946b88e6d04c360aa52a4c2b631f7..ea7f22a8ce18bbc76cb0489283c4f6609455c7a4 100644 (file)
@@ -156,12 +156,14 @@ void      BIO_set_flags(BIO *b, int flags)
        b->flags |= flags;
        }
 
        b->flags |= flags;
        }
 
-long (*BIO_get_callback(const BIO *b))(struct bio_st *,int,const char *,int, long,long)
+long (*BIO_get_callback(const BIO *b))(struct bio_st *, int, const char *,
+                                      size_t, long, long)
        {
        return b->callback;
        }
 
        {
        return b->callback;
        }
 
-void BIO_set_callback(BIO *b, long (*cb)(struct bio_st *,int,const char *,int, long,long))
+void BIO_set_callback(BIO *b, long (*cb)(struct bio_st *, int, const char *,
+                                        size_t, long, long))
        {
        b->callback = cb;
        }
        {
        b->callback = cb;
        }
@@ -190,7 +192,7 @@ int BIO_method_type(const BIO *b)
 int BIO_read(BIO *b, void *out, int outl)
        {
        int i;
 int BIO_read(BIO *b, void *out, int outl)
        {
        int i;
-       long (*cb)(BIO *,int,const char *,int,long,long);
+       long (*cb)(BIO *, int, const char *, size_t, long, long);
 
        if ((b == NULL) || (b->method == NULL) || (b->method->bread == NULL))
                {
 
        if ((b == NULL) || (b->method == NULL) || (b->method->bread == NULL))
                {
@@ -219,10 +221,10 @@ int BIO_read(BIO *b, void *out, int outl)
        return(i);
        }
 
        return(i);
        }
 
-int BIO_write(BIO *b, const void *in, int inl)
+int BIO_write(BIO *b, const void *in, size_t inl)
        {
        int i;
        {
        int i;
-       long (*cb)(BIO *,int,const char *,int,long,long);
+       long (*cb)(BIO *,int,const char *,size_t,long,long);
 
        if (b == NULL)
                return(0);
 
        if (b == NULL)
                return(0);
@@ -235,7 +237,7 @@ int BIO_write(BIO *b, const void *in, int inl)
                }
 
        if ((cb != NULL) &&
                }
 
        if ((cb != NULL) &&
-               ((i=(int)cb(b,BIO_CB_WRITE,in,inl,0L,1L)) <= 0))
+               ((i=cb(b,BIO_CB_WRITE,in,inl,0L,1L)) <= 0))
                        return(i);
 
        if (!b->init)
                        return(i);
 
        if (!b->init)
@@ -257,7 +259,7 @@ int BIO_write(BIO *b, const void *in, int inl)
 int BIO_puts(BIO *b, const char *in)
        {
        int i;
 int BIO_puts(BIO *b, const char *in)
        {
        int i;
-       long (*cb)(BIO *,int,const char *,int,long,long);
+       long (*cb)(BIO *, int, const char *, size_t, long, long);
 
        if ((b == NULL) || (b->method == NULL) || (b->method->bputs == NULL))
                {
 
        if ((b == NULL) || (b->method == NULL) || (b->method->bputs == NULL))
                {
@@ -290,7 +292,7 @@ int BIO_puts(BIO *b, const char *in)
 int BIO_gets(BIO *b, char *in, int inl)
        {
        int i;
 int BIO_gets(BIO *b, char *in, int inl)
        {
        int i;
-       long (*cb)(BIO *,int,const char *,int,long,long);
+       long (*cb)(BIO *, int, const char *, size_t, long, long);
 
        if ((b == NULL) || (b->method == NULL) || (b->method->bgets == NULL))
                {
 
        if ((b == NULL) || (b->method == NULL) || (b->method->bgets == NULL))
                {
@@ -351,7 +353,7 @@ char *BIO_ptr_ctrl(BIO *b, int cmd, long larg)
 long BIO_ctrl(BIO *b, int cmd, long larg, void *parg)
        {
        long ret;
 long BIO_ctrl(BIO *b, int cmd, long larg, void *parg)
        {
        long ret;
-       long (*cb)(BIO *,int,const char *,int,long,long);
+       long (*cb)(BIO *, int, const char *, size_t, long, long);
 
        if (b == NULL) return(0);
 
 
        if (b == NULL) return(0);
 
@@ -378,7 +380,7 @@ long BIO_ctrl(BIO *b, int cmd, long larg, void *parg)
 long BIO_callback_ctrl(BIO *b, int cmd, void (*fp)(struct bio_st *, int, const char *, int, long, long))
        {
        long ret;
 long BIO_callback_ctrl(BIO *b, int cmd, void (*fp)(struct bio_st *, int, const char *, int, long, long))
        {
        long ret;
-       long (*cb)(BIO *,int,const char *,int,long,long);
+       long (*cb)(BIO *, int, const char *, size_t, long, long);
 
        if (b == NULL) return(0);
 
 
        if (b == NULL) return(0);
 
index f13f52dd853e2f8bdb795b5226d4137f105652ab..1509864574815a991827b5ac5ec7e4185cd790b0 100644 (file)
@@ -175,7 +175,7 @@ BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d)
        return ret;
 }
 
        return ret;
 }
 
-BN_ULONG bn_add_words (BN_ULONG *rp, BN_ULONG *ap, BN_ULONG *bp,int n)
+BN_ULONG bn_add_words (BN_ULONG *rp, BN_ULONG *ap, BN_ULONG *bp, size_t n)
 { BN_ULONG ret=0,i=0;
 
        if (n <= 0) return 0;
 { BN_ULONG ret=0,i=0;
 
        if (n <= 0) return 0;
index 2333682a1738364be61cc5874dc05f2576a0d657..3a8d694bb6c2b701c01e824526de2e41a1c6a7ca 100644 (file)
@@ -300,9 +300,9 @@ typedef struct bn_gencb_st BN_GENCB;
 struct bignum_st
        {
        BN_ULONG *d;    /* Pointer to an array of 'BN_BITS2' bit chunks. */
 struct bignum_st
        {
        BN_ULONG *d;    /* Pointer to an array of 'BN_BITS2' bit chunks. */
-       int top;        /* Index of last used d +1. */
+       size_t top;     /* Index of last used d +1. */
        /* The next are internal book keeping for bn_expand. */
        /* The next are internal book keeping for bn_expand. */
-       int dmax;       /* Size of the d array. */
+       size_t dmax;    /* Size of the d array. */
        int neg;        /* one if the number is negative */
        int flags;
        };
        int neg;        /* one if the number is negative */
        int flags;
        };
@@ -414,8 +414,8 @@ void        BN_CTX_free(BN_CTX *c);
 void   BN_CTX_start(BN_CTX *ctx);
 BIGNUM *BN_CTX_get(BN_CTX *ctx);
 void   BN_CTX_end(BN_CTX *ctx);
 void   BN_CTX_start(BN_CTX *ctx);
 BIGNUM *BN_CTX_get(BN_CTX *ctx);
 void   BN_CTX_end(BN_CTX *ctx);
-int     BN_rand(BIGNUM *rnd, int bits, int top,int bottom);
-int     BN_pseudo_rand(BIGNUM *rnd, int bits, int top,int bottom);
+int     BN_rand(BIGNUM *rnd, size_t bits, int top,int bottom);
+int     BN_pseudo_rand(BIGNUM *rnd, size_t bits, int top,int bottom);
 int    BN_rand_range(BIGNUM *rnd, const BIGNUM *range);
 int    BN_pseudo_rand_range(BIGNUM *rnd, const BIGNUM *range);
 int    BN_num_bits(const BIGNUM *a);
 int    BN_rand_range(BIGNUM *rnd, const BIGNUM *range);
 int    BN_pseudo_rand_range(BIGNUM *rnd, const BIGNUM *range);
 int    BN_num_bits(const BIGNUM *a);
@@ -425,9 +425,9 @@ void        BN_init(BIGNUM *);
 void   BN_clear_free(BIGNUM *a);
 BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b);
 void   BN_swap(BIGNUM *a, BIGNUM *b);
 void   BN_clear_free(BIGNUM *a);
 BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b);
 void   BN_swap(BIGNUM *a, BIGNUM *b);
-BIGNUM *BN_bin2bn(const unsigned char *s,int len,BIGNUM *ret);
+BIGNUM *BN_bin2bn(const unsigned char *s, size_t len, BIGNUM *ret);
 int    BN_bn2bin(const BIGNUM *a, unsigned char *to);
 int    BN_bn2bin(const BIGNUM *a, unsigned char *to);
-BIGNUM *BN_mpi2bn(const unsigned char *s,int len,BIGNUM *ret);
+BIGNUM *BN_mpi2bn(const unsigned char *s, size_t len, BIGNUM *ret);
 int    BN_bn2mpi(const BIGNUM *a, unsigned char *to);
 int    BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
 int    BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
 int    BN_bn2mpi(const BIGNUM *a, unsigned char *to);
 int    BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
 int    BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
@@ -466,6 +466,8 @@ BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w);
 BN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w);
 int    BN_mul_word(BIGNUM *a, BN_ULONG w);
 int    BN_add_word(BIGNUM *a, BN_ULONG w);
 BN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w);
 int    BN_mul_word(BIGNUM *a, BN_ULONG w);
 int    BN_add_word(BIGNUM *a, BN_ULONG w);
+/* Note that this will give an error if w is negative */
+int    BN_add_signed_word(BIGNUM *a, BN_LONG w);
 int    BN_sub_word(BIGNUM *a, BN_ULONG w);
 int    BN_set_word(BIGNUM *a, BN_ULONG w);
 BN_ULONG BN_get_word(const BIGNUM *a);
 int    BN_sub_word(BIGNUM *a, BN_ULONG w);
 int    BN_set_word(BIGNUM *a, BN_ULONG w);
 BN_ULONG BN_get_word(const BIGNUM *a);
@@ -500,7 +502,7 @@ int BN_print(BIO *fp, const BIGNUM *a);
 #else
 int    BN_print(void *fp, const BIGNUM *a);
 #endif
 #else
 int    BN_print(void *fp, const BIGNUM *a);
 #endif
-int    BN_reciprocal(BIGNUM *r, const BIGNUM *m, int len, BN_CTX *ctx);
+int    BN_reciprocal(BIGNUM *r, const BIGNUM *m, size_t len, BN_CTX *ctx);
 int    BN_rshift(BIGNUM *r, const BIGNUM *a, int n);
 int    BN_rshift1(BIGNUM *r, const BIGNUM *a);
 void   BN_clear(BIGNUM *a);
 int    BN_rshift(BIGNUM *r, const BIGNUM *a, int n);
 int    BN_rshift1(BIGNUM *r, const BIGNUM *a);
 void   BN_clear(BIGNUM *a);
@@ -664,9 +666,9 @@ const BIGNUM *BN_get0_nist_prime_521(void);
 #define bn_expand(a,bits) ((((((bits+BN_BITS2-1))/BN_BITS2)) <= (a)->dmax)?\
        (a):bn_expand2((a),(bits+BN_BITS2-1)/BN_BITS2))
 #define bn_wexpand(a,words) (((words) <= (a)->dmax)?(a):bn_expand2((a),(words)))
 #define bn_expand(a,bits) ((((((bits+BN_BITS2-1))/BN_BITS2)) <= (a)->dmax)?\
        (a):bn_expand2((a),(bits+BN_BITS2-1)/BN_BITS2))
 #define bn_wexpand(a,words) (((words) <= (a)->dmax)?(a):bn_expand2((a),(words)))
-BIGNUM *bn_expand2(BIGNUM *a, int words);
+BIGNUM *bn_expand2(BIGNUM *a, size_t words);
 #ifndef OPENSSL_NO_DEPRECATED
 #ifndef OPENSSL_NO_DEPRECATED
-BIGNUM *bn_dup_expand(const BIGNUM *a, int words); /* unused */
+BIGNUM *bn_dup_expand(const BIGNUM *a, size_t words); /* unused */
 #endif
 
 /* Bignum consistency macros
 #endif
 
 /* Bignum consistency macros
@@ -762,12 +764,15 @@ int RAND_pseudo_bytes(unsigned char *buf,int num);
        bn_pollute(a); \
        }
 
        bn_pollute(a); \
        }
 
-BN_ULONG bn_mul_add_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w);
-BN_ULONG bn_mul_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w);
-void     bn_sqr_words(BN_ULONG *rp, const BN_ULONG *ap, int num);
+BN_ULONG bn_mul_add_words(BN_ULONG *rp, const BN_ULONG *ap, size_t num,
+                         BN_ULONG w);
+BN_ULONG bn_mul_words(BN_ULONG *rp, const BN_ULONG *ap, size_t num, BN_ULONG w);
+void     bn_sqr_words(BN_ULONG *rp, const BN_ULONG *ap, size_t num);
 BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d);
 BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d);
-BN_ULONG bn_add_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,int num);
-BN_ULONG bn_sub_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,int num);
+BN_ULONG bn_add_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,
+                     size_t num);
+BN_ULONG bn_sub_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,
+                     size_t num);
 
 /* Primes from RFC 2409 */
 BIGNUM *get_rfc2409_prime_768(BIGNUM *bn);
 
 /* Primes from RFC 2409 */
 BIGNUM *get_rfc2409_prime_768(BIGNUM *bn);
@@ -781,7 +786,7 @@ BIGNUM *get_rfc3526_prime_4096(BIGNUM *bn);
 BIGNUM *get_rfc3526_prime_6144(BIGNUM *bn);
 BIGNUM *get_rfc3526_prime_8192(BIGNUM *bn);
 
 BIGNUM *get_rfc3526_prime_6144(BIGNUM *bn);
 BIGNUM *get_rfc3526_prime_8192(BIGNUM *bn);
 
-int BN_bntest_rand(BIGNUM *rnd, int bits, int top,int bottom);
+int BN_bntest_rand(BIGNUM *rnd, size_t bits, int top, int bottom);
 
 /* BEGIN ERROR CODES */
 /* The following lines are auto generated by the script mkerr.pl. Any changes
 
 /* BEGIN ERROR CODES */
 /* The following lines are auto generated by the script mkerr.pl. Any changes
index 9405163706aae5dc8064780a2ce879fece80ccdf..fa27ff77b77f2cdaa7fed7366ee489c4f1130af4 100644 (file)
@@ -104,7 +104,7 @@ int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)
 /* unsigned add of b to a */
 int BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)
        {
 /* unsigned add of b to a */
 int BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)
        {
-       int max,min,dif;
+       size_t max,min,dif;
        BN_ULONG *ap,*bp,*rp,carry,t1,t2;
        const BIGNUM *tmp;
 
        BN_ULONG *ap,*bp,*rp,carry,t1,t2;
        const BIGNUM *tmp;
 
@@ -165,7 +165,7 @@ int BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)
 /* unsigned subtraction of b from a, a must be larger than b. */
 int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)
        {
 /* unsigned subtraction of b from a, a must be larger than b. */
 int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)
        {
-       int max,min,dif;
+       size_t max,min,dif;
        register BN_ULONG t1,t2,*ap,*bp,*rp;
        int i,carry;
 #if defined(IRIX_CC_BUG) && !defined(LINT)
        register BN_ULONG t1,t2,*ap,*bp,*rp;
        int i,carry;
 #if defined(IRIX_CC_BUG) && !defined(LINT)
@@ -262,7 +262,7 @@ int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)
 
 int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)
        {
 
 int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)
        {
-       int max;
+       size_t max;
        int add=0,neg=0;
        const BIGNUM *tmp;
 
        int add=0,neg=0;
        const BIGNUM *tmp;
 
index 6db472f8c321ec162433577540ad73e084be2d3f..68ff960aef551bd3b2e56d80646e41034518b2dc 100644 (file)
@@ -181,11 +181,12 @@ static int BN_div_no_branch(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num,
 int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
           BN_CTX *ctx)
        {
 int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
           BN_CTX *ctx)
        {
-       int norm_shift,i,loop;
+       int norm_shift,i;
+       size_t loop;
        BIGNUM *tmp,wnum,*snum,*sdiv,*res;
        BN_ULONG *resp,*wnump;
        BN_ULONG d0,d1;
        BIGNUM *tmp,wnum,*snum,*sdiv,*res;
        BN_ULONG *resp,*wnump;
        BN_ULONG d0,d1;
-       int num_n,div_n;
+       size_t num_n,div_n;
 
        /* Invalid zero-padding would have particularly bad consequences
         * in the case of 'num', so don't just rely on bn_check_top() for this one
 
        /* Invalid zero-padding would have particularly bad consequences
         * in the case of 'num', so don't just rely on bn_check_top() for this one
@@ -265,7 +266,7 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
        resp= &(res->d[loop-1]);
 
        /* space for temp */
        resp= &(res->d[loop-1]);
 
        /* space for temp */
-       if (!bn_wexpand(tmp,(div_n+1))) goto err;
+       if (!bn_wexpand(tmp, div_n+1)) goto err;
 
        if (BN_ucmp(&wnum,sdiv) >= 0)
                {
 
        if (BN_ucmp(&wnum,sdiv) >= 0)
                {
@@ -429,7 +430,7 @@ static int BN_div_no_branch(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num,
        BIGNUM *tmp,wnum,*snum,*sdiv,*res;
        BN_ULONG *resp,*wnump;
        BN_ULONG d0,d1;
        BIGNUM *tmp,wnum,*snum,*sdiv,*res;
        BN_ULONG *resp,*wnump;
        BN_ULONG d0,d1;
-       int num_n,div_n;
+       size_t num_n,div_n;
 
        bn_check_top(dv);
        bn_check_top(rm);
 
        bn_check_top(dv);
        bn_check_top(rm);
@@ -498,12 +499,12 @@ static int BN_div_no_branch(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num,
 
        /* Setup to 'res' */
        res->neg= (num->neg^divisor->neg);
 
        /* Setup to 'res' */
        res->neg= (num->neg^divisor->neg);
-       if (!bn_wexpand(res,(loop+1))) goto err;
+       if (!bn_wexpand(res,loop+1U)) goto err;
        res->top=loop-1;
        resp= &(res->d[loop-1]);
 
        /* space for temp */
        res->top=loop-1;
        resp= &(res->d[loop-1]);
 
        /* space for temp */
-       if (!bn_wexpand(tmp,(div_n+1))) goto err;
+       if (!bn_wexpand(tmp,div_n+1U)) goto err;
 
        /* if res->top == 0 then clear the neg value otherwise decrease
         * the resp pointer */
 
        /* if res->top == 0 then clear the neg value otherwise decrease
         * the resp pointer */
index 70a33f0d936c81fab3f6a77e411f7e354c652edc..ac590e0f9deb8ba238d5c13bee6fade5c579a8ab 100644 (file)
@@ -521,7 +521,8 @@ err:
  * as cache lines are concerned.  The following functions are used to transfer a BIGNUM
  * from/to that table. */
 
  * as cache lines are concerned.  The following functions are used to transfer a BIGNUM
  * from/to that table. */
 
-static int MOD_EXP_CTIME_COPY_TO_PREBUF(BIGNUM *b, int top, unsigned char *buf, int idx, int width)
+static int MOD_EXP_CTIME_COPY_TO_PREBUF(BIGNUM *b, size_t top,
+                                       unsigned char *buf, int idx, int width)
        {
        size_t i, j;
 
        {
        size_t i, j;
 
@@ -541,7 +542,9 @@ static int MOD_EXP_CTIME_COPY_TO_PREBUF(BIGNUM *b, int top, unsigned char *buf,
        return 1;
        }
 
        return 1;
        }
 
-static int MOD_EXP_CTIME_COPY_FROM_PREBUF(BIGNUM *b, int top, unsigned char *buf, int idx, int width)
+static int MOD_EXP_CTIME_COPY_FROM_PREBUF(BIGNUM *b, size_t top,
+                                         unsigned char *buf, int idx,
+                                         int width)
        {
        size_t i, j;
 
        {
        size_t i, j;
 
@@ -572,14 +575,14 @@ int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
                    const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont)
        {
        int i,bits,ret=0,idx,window,wvalue;
                    const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont)
        {
        int i,bits,ret=0,idx,window,wvalue;
-       int top;
+       size_t top;
        BIGNUM *r;
        const BIGNUM *aa;
        BN_MONT_CTX *mont=NULL;
 
        int numPowers;
        unsigned char *powerbufFree=NULL;
        BIGNUM *r;
        const BIGNUM *aa;
        BN_MONT_CTX *mont=NULL;
 
        int numPowers;
        unsigned char *powerbufFree=NULL;
-       int powerbufLen = 0;
+       size_t powerbufLen = 0;
        unsigned char *powerbuf=NULL;
        BIGNUM *computeTemp=NULL, *am=NULL;
 
        unsigned char *powerbuf=NULL;
        BIGNUM *computeTemp=NULL, *am=NULL;
 
@@ -625,7 +628,7 @@ int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
         */
        numPowers = 1 << window;
        powerbufLen = sizeof(m->d[0])*top*numPowers;
         */
        numPowers = 1 << window;
        powerbufLen = sizeof(m->d[0])*top*numPowers;
-       if ((powerbufFree=(unsigned char*)OPENSSL_malloc(powerbufLen+MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH)) == NULL)
+       if ((powerbufFree=OPENSSL_malloc(powerbufLen+MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH)) == NULL)
                goto err;
                
        powerbuf = MOD_EXP_CTIME_ALIGN(powerbufFree);
                goto err;
                
        powerbuf = MOD_EXP_CTIME_ALIGN(powerbufFree);
index 8e5e98e3f2b87fd80a1d33511df3ba495e60414a..857616d53b32dd9684c2a67b43451bcde5be493e 100644 (file)
 #define HEADER_BN_LCL_H
 
 #include <openssl/bn.h>
 #define HEADER_BN_LCL_H
 
 #include <openssl/bn.h>
+#include <unistd.h>
 
 #ifdef  __cplusplus
 extern "C" {
 
 #ifdef  __cplusplus
 extern "C" {
@@ -468,21 +469,22 @@ void bn_sqr_comba4(BN_ULONG *r,const BN_ULONG *a);
 int bn_cmp_words(const BN_ULONG *a,const BN_ULONG *b,int n);
 int bn_cmp_part_words(const BN_ULONG *a, const BN_ULONG *b,
        int cl, int dl);
 int bn_cmp_words(const BN_ULONG *a,const BN_ULONG *b,int n);
 int bn_cmp_part_words(const BN_ULONG *a, const BN_ULONG *b,
        int cl, int dl);
-void bn_mul_recursive(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b,int n2,
-       int dna,int dnb,BN_ULONG *t);
-void bn_mul_part_recursive(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b,
-       int n,int tna,int tnb,BN_ULONG *t);
-void bn_sqr_recursive(BN_ULONG *r,const BN_ULONG *a, int n2, BN_ULONG *t);
-void bn_mul_low_normal(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b, int n);
-void bn_mul_low_recursive(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b,int n2,
-       BN_ULONG *t);
-void bn_mul_high(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b,BN_ULONG *l,int n2,
-       BN_ULONG *t);
+void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, size_t n2,
+                     int dna, int dnb, BN_ULONG *t);
+void bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b,
+                          int n, int tna, int tnb, BN_ULONG *t);
+void bn_sqr_recursive(BN_ULONG *r, const BN_ULONG *a, int n2, BN_ULONG *t);
+void bn_mul_low_normal(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n);
+void bn_mul_low_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
+                         BN_ULONG *t);
+void bn_mul_high(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, BN_ULONG *l, int n2,
+                BN_ULONG *t);
 BN_ULONG bn_add_part_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
 BN_ULONG bn_add_part_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
-       int cl, int dl);
+                          size_t cl, ssize_t dl);
 BN_ULONG bn_sub_part_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
 BN_ULONG bn_sub_part_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
-       int cl, int dl);
-int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, const BN_ULONG *np,const BN_ULONG *n0, int num);
+                          int cl, int dl);
+int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,
+               const BN_ULONG *np,const BN_ULONG *n0, int num);
 
 #ifdef  __cplusplus
 }
 
 #ifdef  __cplusplus
 }
index 0c6e7e59644c6cd17f5d65263fd0c91940ac1938..f22d358ce5267acd4aa09a9338bd42eb31dacdbf 100644 (file)
@@ -315,7 +315,7 @@ BIGNUM *BN_new(void)
 
 /* This is used both by bn_expand2() and bn_dup_expand() */
 /* The caller MUST check that words > b->dmax before calling this */
 
 /* This is used both by bn_expand2() and bn_dup_expand() */
 /* The caller MUST check that words > b->dmax before calling this */
-static BN_ULONG *bn_expand_internal(const BIGNUM *b, int words)
+static BN_ULONG *bn_expand_internal(const BIGNUM *b, size_t words)
        {
        BN_ULONG *A,*a = NULL;
        const BN_ULONG *B;
        {
        BN_ULONG *A,*a = NULL;
        const BN_ULONG *B;
@@ -391,7 +391,7 @@ static BN_ULONG *bn_expand_internal(const BIGNUM *b, int words)
  */
 
 #ifndef OPENSSL_NO_DEPRECATED
  */
 
 #ifndef OPENSSL_NO_DEPRECATED
-BIGNUM *bn_dup_expand(const BIGNUM *b, int words)
+BIGNUM *bn_dup_expand(const BIGNUM *b, size_t words)
        {
        BIGNUM *r = NULL;
 
        {
        BIGNUM *r = NULL;
 
@@ -442,7 +442,7 @@ BIGNUM *bn_dup_expand(const BIGNUM *b, int words)
  * It is mostly used by the various BIGNUM routines. If there is an error,
  * NULL is returned. If not, 'b' is returned. */
 
  * It is mostly used by the various BIGNUM routines. If there is an error,
  * NULL is returned. If not, 'b' is returned. */
 
-BIGNUM *bn_expand2(BIGNUM *b, int words)
+BIGNUM *bn_expand2(BIGNUM *b, size_t words)
        {
        bn_check_top(b);
 
        {
        bn_check_top(b);
 
@@ -594,7 +594,7 @@ int BN_set_word(BIGNUM *a, BN_ULONG w)
        return(1);
        }
 
        return(1);
        }
 
-BIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret)
+BIGNUM *BN_bin2bn(const unsigned char *s, size_t len, BIGNUM *ret)
        {
        unsigned int i,m;
        unsigned int n;
        {
        unsigned int i,m;
        unsigned int n;
@@ -614,7 +614,7 @@ BIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret)
                }
        i=((n-1)/BN_BYTES)+1;
        m=((n-1)%(BN_BYTES));
                }
        i=((n-1)/BN_BYTES)+1;
        m=((n-1)%(BN_BYTES));
-       if (bn_wexpand(ret, (int)i) == NULL)
+       if (bn_wexpand(ret, i) == NULL)
                {
                if (bn) BN_free(bn);
                return NULL;
                {
                if (bn) BN_free(bn);
                return NULL;
@@ -718,7 +718,7 @@ int BN_cmp(const BIGNUM *a, const BIGNUM *b)
 
 int BN_set_bit(BIGNUM *a, int n)
        {
 
 int BN_set_bit(BIGNUM *a, int n)
        {
-       int i,j,k;
+       size_t i,j,k;
 
        if (n < 0)
                return 0;
 
        if (n < 0)
                return 0;
index a054d21aed6b9a0cb04b384320ddd2fc6d6bfcbf..da2d2c479e27fb6e7a6a090b03c3ce7b2d87b910 100644 (file)
@@ -88,7 +88,7 @@ int BN_bn2mpi(const BIGNUM *a, unsigned char *d)
        return(num+4+ext);
        }
 
        return(num+4+ext);
        }
 
-BIGNUM *BN_mpi2bn(const unsigned char *d, int n, BIGNUM *a)
+BIGNUM *BN_mpi2bn(const unsigned char *d, size_t n, BIGNUM *a)
        {
        long len;
        int neg=0;
        {
        long len;
        int neg=0;
index b848c8cc60f4d69ab60468c3090385318930a40a..6938c88cb229b5f9b5670f1e3e7d152ee132de92 100644 (file)
@@ -78,8 +78,8 @@
    assembler counterparts for the systems that use assembler files.  */
 
 BN_ULONG bn_sub_part_words(BN_ULONG *r,
    assembler counterparts for the systems that use assembler files.  */
 
 BN_ULONG bn_sub_part_words(BN_ULONG *r,
-       const BN_ULONG *a, const BN_ULONG *b,
-       int cl, int dl)
+                          const BN_ULONG *a, const BN_ULONG *b,
+                          size_t cl, ssize_t dl)
        {
        BN_ULONG c, t;
 
        {
        BN_ULONG c, t;
 
@@ -126,7 +126,7 @@ BN_ULONG bn_sub_part_words(BN_ULONG *r,
                }
        else
                {
                }
        else
                {
-               int save_dl = dl;
+               ssize_t save_dl = dl;
 #ifdef BN_COUNT
                fprintf(stderr, "  bn_sub_part_words %d + %d (dl > 0, c = %d)\n", cl, dl, c);
 #endif
 #ifdef BN_COUNT
                fprintf(stderr, "  bn_sub_part_words %d + %d (dl > 0, c = %d)\n", cl, dl, c);
 #endif
@@ -205,8 +205,8 @@ BN_ULONG bn_sub_part_words(BN_ULONG *r,
 #endif
 
 BN_ULONG bn_add_part_words(BN_ULONG *r,
 #endif
 
 BN_ULONG bn_add_part_words(BN_ULONG *r,
-       const BN_ULONG *a, const BN_ULONG *b,
-       int cl, int dl)
+                          const BN_ULONG *a, const BN_ULONG *b,
+                          size_t cl, ssize_t dl)
        {
        BN_ULONG c, l, t;
 
        {
        BN_ULONG c, l, t;
 
@@ -222,7 +222,7 @@ BN_ULONG bn_add_part_words(BN_ULONG *r,
 
        if (dl < 0)
                {
 
        if (dl < 0)
                {
-               int save_dl = dl;
+               ssize_t save_dl = dl;
 #ifdef BN_COUNT
                fprintf(stderr, "  bn_add_part_words %d + %d (dl < 0, c = %d)\n", cl, dl, c);
 #endif
 #ifdef BN_COUNT
                fprintf(stderr, "  bn_add_part_words %d + %d (dl < 0, c = %d)\n", cl, dl, c);
 #endif
@@ -390,8 +390,8 @@ BN_ULONG bn_add_part_words(BN_ULONG *r,
  * a[1]*b[1]
  */
 /* dnX may not be positive, but n2/2+dnX has to be */
  * a[1]*b[1]
  */
 /* dnX may not be positive, but n2/2+dnX has to be */
-void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
-       int dna, int dnb, BN_ULONG *t)
+void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, size_t n2,
+                     int dna, int dnb, BN_ULONG *t)
        {
        int n=n2/2,c1,c2;
        int tna=n+dna, tnb=n+dnb;
        {
        int n=n2/2,c1,c2;
        int tna=n+dna, tnb=n+dnb;
@@ -505,16 +505,16 @@ void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
         * r[32] holds (b[1]*b[1])
         */
 
         * r[32] holds (b[1]*b[1])
         */
 
-       c1=(int)(bn_add_words(t,r,&(r[n2]),n2));
+       c1=bn_add_words(t,r,&(r[n2]),n2);
 
        if (neg) /* if t[32] is negative */
                {
 
        if (neg) /* if t[32] is negative */
                {
-               c1-=(int)(bn_sub_words(&(t[n2]),t,&(t[n2]),n2));
+               c1-=bn_sub_words(&(t[n2]),t,&(t[n2]),n2);
                }
        else
                {
                /* Might have a carry */
                }
        else
                {
                /* Might have a carry */
-               c1+=(int)(bn_add_words(&(t[n2]),&(t[n2]),t,n2));
+               c1+=bn_add_words(&(t[n2]),&(t[n2]),t,n2);
                }
 
        /* t[32] holds (a[0]-a[1])*(b[1]-b[0])+(a[0]*b[0])+(a[1]*b[1])
                }
 
        /* t[32] holds (a[0]-a[1])*(b[1]-b[0])+(a[0]*b[0])+(a[1]*b[1])
@@ -522,7 +522,7 @@ void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
         * r[32] holds (b[1]*b[1])
         * c1 holds the carry bits
         */
         * r[32] holds (b[1]*b[1])
         * c1 holds the carry bits
         */
-       c1+=(int)(bn_add_words(&(r[n]),&(r[n]),&(t[n2]),n2));
+       c1+=bn_add_words(&(r[n]),&(r[n]),&(t[n2]),n2);
        if (c1)
                {
                p= &(r[n+n2]);
        if (c1)
                {
                p= &(r[n+n2]);
index ea991c95b1ceb37249ddd3c3b336d2fc1cba3018..4d07a0d94e19436f110c176d97e85561a67d0884 100644 (file)
@@ -415,7 +415,8 @@ int BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,
        return 1;
        }
 
        return 1;
        }
 
-typedef BN_ULONG (*bn_addsub_f)(BN_ULONG *,const BN_ULONG *,const BN_ULONG *,int);
+typedef BN_ULONG (*bn_addsub_f)(BN_ULONG *, const BN_ULONG *, const BN_ULONG *,
+                               size_t);
 
 #define nist_set_224(to, from, a1, a2, a3, a4, a5, a6, a7) \
        { \
 
 #define nist_set_224(to, from, a1, a2, a3, a4, a5, a6, a7) \
        { \
@@ -429,7 +430,7 @@ typedef BN_ULONG (*bn_addsub_f)(BN_ULONG *,const BN_ULONG *,const BN_ULONG *,int
        }
 
 int BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,
        }
 
 int BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,
-       BN_CTX *ctx)
+                   BN_CTX *ctx)
        {
        int     top = a->top, i;
        int     carry;
        {
        int     top = a->top, i;
        int     carry;
index bebb466d088a27c60b9440d08aee478564771d80..521e8a383165082be46b5657068c27701452a992 100644 (file)
@@ -71,7 +71,7 @@ char *BN_bn2hex(const BIGNUM *a)
        char *buf;
        char *p;
 
        char *buf;
        char *p;
 
-       buf=(char *)OPENSSL_malloc(a->top*BN_BYTES*2+2);
+       buf=OPENSSL_malloc(a->top*BN_BYTES*2+2);
        if (buf == NULL)
                {
                BNerr(BN_F_BN_BN2HEX,ERR_R_MALLOC_FAILURE);
        if (buf == NULL)
                {
                BNerr(BN_F_BN_BN2HEX,ERR_R_MALLOC_FAILURE);
@@ -116,7 +116,7 @@ char *BN_bn2dec(const BIGNUM *a)
        i=BN_num_bits(a)*3;
        num=(i/10+i/1000+1)+1;
        bn_data=(BN_ULONG *)OPENSSL_malloc((num/BN_DEC_NUM+1)*sizeof(BN_ULONG));
        i=BN_num_bits(a)*3;
        num=(i/10+i/1000+1)+1;
        bn_data=(BN_ULONG *)OPENSSL_malloc((num/BN_DEC_NUM+1)*sizeof(BN_ULONG));
-       buf=(char *)OPENSSL_malloc(num+3);
+       buf=OPENSSL_malloc(num+3);
        if ((buf == NULL) || (bn_data == NULL))
                {
                BNerr(BN_F_BN_BN2DEC,ERR_R_MALLOC_FAILURE);
        if ((buf == NULL) || (bn_data == NULL))
                {
                BNerr(BN_F_BN_BN2DEC,ERR_R_MALLOC_FAILURE);
index b376c28ff3ff25b027922964af6ca26b4995250a..a58a77988c1d7667b64583f98f15d8048e12560d 100644 (file)
@@ -208,18 +208,18 @@ err:
        return(ret);
        }
 
        return(ret);
        }
 
-int     BN_rand(BIGNUM *rnd, int bits, int top, int bottom)
+int     BN_rand(BIGNUM *rnd, size_t bits, int top, int bottom)
        {
        return bnrand(0, rnd, bits, top, bottom);
        }
 
        {
        return bnrand(0, rnd, bits, top, bottom);
        }
 
-int     BN_pseudo_rand(BIGNUM *rnd, int bits, int top, int bottom)
+int     BN_pseudo_rand(BIGNUM *rnd, size_t bits, int top, int bottom)
        {
        return bnrand(1, rnd, bits, top, bottom);
        }
 
 #if 1
        {
        return bnrand(1, rnd, bits, top, bottom);
        }
 
 #if 1
-int     BN_bntest_rand(BIGNUM *rnd, int bits, int top, int bottom)
+int     BN_bntest_rand(BIGNUM *rnd, size_t bits, int top, int bottom)
        {
        return bnrand(2, rnd, bits, top, bottom);
        }
        {
        return bnrand(2, rnd, bits, top, bottom);
        }
@@ -229,7 +229,8 @@ int     BN_bntest_rand(BIGNUM *rnd, int bits, int top, int bottom)
 /* random number r:  0 <= r < range */
 static int bn_rand_range(int pseudo, BIGNUM *r, const BIGNUM *range)
        {
 /* random number r:  0 <= r < range */
 static int bn_rand_range(int pseudo, BIGNUM *r, const BIGNUM *range)
        {
-       int (*bn_rand)(BIGNUM *, int, int, int) = pseudo ? BN_pseudo_rand : BN_rand;
+       int (*bn_rand)(BIGNUM *, size_t, int, int)
+           = pseudo ? BN_pseudo_rand : BN_rand;
        int n;
        int count = 100;
 
        int n;
        int count = 100;
 
index 2e8efb8dae29ac2f5473299ae2bcb9e4752c1f5c..20ee319fe51bc86154a6ec0b95c51d8c30d7b3b5 100644 (file)
@@ -214,7 +214,7 @@ err:
  * we can do faster division if the remainder is not required.
  */
 /* r := 2^len / m */
  * we can do faster division if the remainder is not required.
  */
 /* r := 2^len / m */
-int BN_reciprocal(BIGNUM *r, const BIGNUM *m, int len, BN_CTX *ctx)
+int BN_reciprocal(BIGNUM *r, const BIGNUM *m, size_t len, BN_CTX *ctx)
        {
        int ret= -1;
        BIGNUM *t;
        {
        int ret= -1;
        BIGNUM *t;
index ee7b87c45ccd38839db6261ed81c2d87b9e881b5..d83032c66ca01438e8f35d0b21d4d19d4e429eaf 100644 (file)
@@ -168,6 +168,13 @@ int BN_add_word(BIGNUM *a, BN_ULONG w)
        return(1);
        }
 
        return(1);
        }
 
+int BN_add_signed_word(BIGNUM *a, BN_LONG w)
+       {
+       if(w < 0)
+               return 0;
+       return BN_add_word(a, (BN_ULONG)w);
+       }
+
 int BN_sub_word(BIGNUM *a, BN_ULONG w)
        {
        int i;
 int BN_sub_word(BIGNUM *a, BN_ULONG w)
        {
        int i;
index ff09bc5fb44fa1e4fde58b0bc9c617b18e38077d..1df5926efd3d87105ebd3c09bc23e477821fec59 100644 (file)
@@ -365,7 +365,7 @@ int CRYPTO_is_mem_check_on(void);
 #define MemCheck_off() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE)
 #define is_MemCheck_on() CRYPTO_is_mem_check_on()
 
 #define MemCheck_off() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE)
 #define is_MemCheck_on() CRYPTO_is_mem_check_on()
 
-#define OPENSSL_malloc(num)    CRYPTO_malloc((int)num,__FILE__,__LINE__)
+#define OPENSSL_malloc(num)    CRYPTO_malloc(num,__FILE__,__LINE__)
 #define OPENSSL_strdup(str)    CRYPTO_strdup((str),__FILE__,__LINE__)
 #define OPENSSL_realloc(addr,num) \
        CRYPTO_realloc((char *)addr,(int)num,__FILE__,__LINE__)
 #define OPENSSL_strdup(str)    CRYPTO_strdup((str),__FILE__,__LINE__)
 #define OPENSSL_realloc(addr,num) \
        CRYPTO_realloc((char *)addr,(int)num,__FILE__,__LINE__)
@@ -469,8 +469,10 @@ int CRYPTO_set_mem_ex_functions(void *(*m)(size_t,const char *,int),
                                 void (*f)(void *));
 int CRYPTO_set_locked_mem_ex_functions(void *(*m)(size_t,const char *,int),
                                        void (*free_func)(void *));
                                 void (*f)(void *));
 int CRYPTO_set_locked_mem_ex_functions(void *(*m)(size_t,const char *,int),
                                        void (*free_func)(void *));
-int CRYPTO_set_mem_debug_functions(void (*m)(void *,int,const char *,int,int),
-                                  void (*r)(void *,void *,int,const char *,int,int),
+int CRYPTO_set_mem_debug_functions(void (*m)(void *,size_t,const char *,int,
+                                            int),
+                                  void (*r)(void *,void *,size_t,const char *,
+                                            int,int),
                                   void (*f)(void *,int),
                                   void (*so)(long),
                                   long (*go)(void));
                                   void (*f)(void *,int),
                                   void (*so)(long),
                                   long (*go)(void));
@@ -481,21 +483,23 @@ void CRYPTO_get_mem_ex_functions(void *(**m)(size_t,const char *,int),
                                  void (**f)(void *));
 void CRYPTO_get_locked_mem_ex_functions(void *(**m)(size_t,const char *,int),
                                         void (**f)(void *));
                                  void (**f)(void *));
 void CRYPTO_get_locked_mem_ex_functions(void *(**m)(size_t,const char *,int),
                                         void (**f)(void *));
-void CRYPTO_get_mem_debug_functions(void (**m)(void *,int,const char *,int,int),
-                                   void (**r)(void *,void *,int,const char *,int,int),
+void CRYPTO_get_mem_debug_functions(void (**m)(void *,size_t,const char *,int,
+                                              int),
+                                   void (**r)(void *,void *,size_t,
+                                              const char *,int,int),
                                    void (**f)(void *,int),
                                    void (**so)(long),
                                    long (**go)(void));
 
                                    void (**f)(void *,int),
                                    void (**so)(long),
                                    long (**go)(void));
 
-void *CRYPTO_malloc_locked(int num, const char *file, int line);
+void *CRYPTO_malloc_locked(size_t num, const char *file, int line);
 void CRYPTO_free_locked(void *);
 void CRYPTO_free_locked(void *);
-void *CRYPTO_malloc(int num, const char *file, int line);
+void *CRYPTO_malloc(size_t num, const char *file, int line);
 char *CRYPTO_strdup(const char *str, const char *file, int line);
 void CRYPTO_free(void *);
 char *CRYPTO_strdup(const char *str, const char *file, int line);
 void CRYPTO_free(void *);
-void *CRYPTO_realloc(void *addr,int num, const char *file, int line);
-void *CRYPTO_realloc_clean(void *addr,int old_num,int num,const char *file,
-                          int line);
-void *CRYPTO_remalloc(void *addr,int num, const char *file, int line);
+void *CRYPTO_realloc(void *addr, size_t num, const char *file, int line);
+void *CRYPTO_realloc_clean(void *addr, size_t old_num, size_t num,
+                          const char *file, int line);
+void *CRYPTO_remalloc(void *addr, size_t num, const char *file, int line);
 
 void OPENSSL_cleanse(void *ptr, size_t len);
 
 
 void OPENSSL_cleanse(void *ptr, size_t len);
 
@@ -516,8 +520,10 @@ int CRYPTO_remove_all_info(void);
  * 0:  called before the actual memory allocation has taken place
  * 1:  called after the actual memory allocation has taken place
  */
  * 0:  called before the actual memory allocation has taken place
  * 1:  called after the actual memory allocation has taken place
  */
-void CRYPTO_dbg_malloc(void *addr,int num,const char *file,int line,int before_p);
-void CRYPTO_dbg_realloc(void *addr1,void *addr2,int num,const char *file,int line,int before_p);
+void CRYPTO_dbg_malloc(void *addr,size_t num,const char *file,int line,
+                      int before_p);
+void CRYPTO_dbg_realloc(void *addr1,void *addr2,size_t num,const char *file,
+                       int line,int before_p);
 void CRYPTO_dbg_free(void *addr,int before_p);
 /* Tell the debugging code about options.  By default, the following values
  * apply:
 void CRYPTO_dbg_free(void *addr,int before_p);
 /* Tell the debugging code about options.  By default, the following values
  * apply:
index 6f80dd33eb740a3822390bae39a40fa7d40d1e80..e868d645be13538a8893ca8365badd968c5048fe 100644 (file)
@@ -103,9 +103,9 @@ static void (*free_locked_func)(void *)     = free;
 /* XXX use correct function pointer types */
 #ifdef CRYPTO_MDEBUG
 /* use default functions from mem_dbg.c */
 /* XXX use correct function pointer types */
 #ifdef CRYPTO_MDEBUG
 /* use default functions from mem_dbg.c */
-static void (*malloc_debug_func)(void *,int,const char *,int,int)
+static void (*malloc_debug_func)(void *,size_t,const char *,int,int)
        = CRYPTO_dbg_malloc;
        = CRYPTO_dbg_malloc;
-static void (*realloc_debug_func)(void *,void *,int,const char *,int,int)
+static void (*realloc_debug_func)(void *,void *,size_t,const char *,int,int)
        = CRYPTO_dbg_realloc;
 static void (*free_debug_func)(void *,int) = CRYPTO_dbg_free;
 static void (*set_debug_options_func)(long) = CRYPTO_dbg_set_options;
        = CRYPTO_dbg_realloc;
 static void (*free_debug_func)(void *,int) = CRYPTO_dbg_free;
 static void (*set_debug_options_func)(long) = CRYPTO_dbg_set_options;
@@ -178,8 +178,8 @@ int CRYPTO_set_locked_mem_ex_functions(
        return 1;
        }
 
        return 1;
        }
 
-int CRYPTO_set_mem_debug_functions(void (*m)(void *,int,const char *,int,int),
-                                  void (*r)(void *,void *,int,const char *,int,int),
+int CRYPTO_set_mem_debug_functions(void (*m)(void *,size_t,const char *,int,int),
+                                  void (*r)(void *,void *,size_t,const char *,int,int),
                                   void (*f)(void *,int),
                                   void (*so)(long),
                                   long (*go)(void))
                                   void (*f)(void *,int),
                                   void (*so)(long),
                                   long (*go)(void))
@@ -233,8 +233,8 @@ void CRYPTO_get_locked_mem_ex_functions(
        if (f != NULL) *f=free_locked_func;
        }
 
        if (f != NULL) *f=free_locked_func;
        }
 
-void CRYPTO_get_mem_debug_functions(void (**m)(void *,int,const char *,int,int),
-                                   void (**r)(void *,void *,int,const char *,int,int),
+void CRYPTO_get_mem_debug_functions(void (**m)(void *,size_t,const char *,int,int),
+                                   void (**r)(void *,void *,size_t,const char *,int,int),
                                    void (**f)(void *,int),
                                    void (**so)(long),
                                    long (**go)(void))
                                    void (**f)(void *,int),
                                    void (**so)(long),
                                    long (**go)(void))
@@ -247,7 +247,7 @@ void CRYPTO_get_mem_debug_functions(void (**m)(void *,int,const char *,int,int),
        }
 
 
        }
 
 
-void *CRYPTO_malloc_locked(int num, const char *file, int line)
+void *CRYPTO_malloc_locked(size_t num, const char *file, int line)
        {
        void *ret = NULL;
 
        {
        void *ret = NULL;
 
@@ -291,7 +291,7 @@ void CRYPTO_free_locked(void *str)
                free_debug_func(NULL, 1);
        }
 
                free_debug_func(NULL, 1);
        }
 
-void *CRYPTO_malloc(int num, const char *file, int line)
+void *CRYPTO_malloc(size_t num, const char *file, int line)
        {
        void *ret = NULL;
 
        {
        void *ret = NULL;
 
@@ -330,7 +330,7 @@ char *CRYPTO_strdup(const char *str, const char *file, int line)
        return ret;
        }
 
        return ret;
        }
 
-void *CRYPTO_realloc(void *str, int num, const char *file, int line)
+void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)
        {
        void *ret = NULL;
 
        {
        void *ret = NULL;
 
@@ -351,8 +351,8 @@ void *CRYPTO_realloc(void *str, int num, const char *file, int line)
        return ret;
        }
 
        return ret;
        }
 
-void *CRYPTO_realloc_clean(void *str, int old_len, int num, const char *file,
-                          int line)
+void *CRYPTO_realloc_clean(void *str, size_t old_len, size_t num,
+                          const char *file, int line)
        {
        void *ret = NULL;
 
        {
        void *ret = NULL;
 
@@ -393,10 +393,10 @@ void CRYPTO_free(void *str)
                free_debug_func(NULL, 1);
        }
 
                free_debug_func(NULL, 1);
        }
 
-void *CRYPTO_remalloc(void *a, int num, const char *file, int line)
+void *CRYPTO_remalloc(void *a, size_t num, const char *file, int line)
        {
        if (a != NULL) OPENSSL_free(a);
        {
        if (a != NULL) OPENSSL_free(a);
-       a=(char *)OPENSSL_malloc(num);
+       a=OPENSSL_malloc(num);
        return(a);
        }
 
        return(a);
        }
 
index 131669a23b2fb4a30e310a73e63d9d7acef9dc34..f80060d9471a0bf71d798e730951d2319821351c 100644 (file)
@@ -478,7 +478,7 @@ int CRYPTO_remove_all_info(void)
 
 
 static unsigned long break_order_num=0;
 
 
 static unsigned long break_order_num=0;
-void CRYPTO_dbg_malloc(void *addr, int num, const char *file, int line,
+void CRYPTO_dbg_malloc(void *addr, size_t num, const char *file, int line,
        int before_p)
        {
        MEM *m,*mm;
        int before_p)
        {
        MEM *m,*mm;
@@ -602,8 +602,8 @@ void CRYPTO_dbg_free(void *addr, int before_p)
                }
        }
 
                }
        }
 
-void CRYPTO_dbg_realloc(void *addr1, void *addr2, int num,
-       const char *file, int line, int before_p)
+void CRYPTO_dbg_realloc(void *addr1, void *addr2, size_t num,
+                       const char *file, int line, int before_p)
        {
        MEM m,*mp;
 
        {
        MEM m,*mp;
 
@@ -666,7 +666,7 @@ static void print_leak_doall_arg(const MEM *m, MEM_LEAK *l)
        char buf[1024];
        char *bufp = buf;
        APP_INFO *amip;
        char buf[1024];
        char *bufp = buf;
        APP_INFO *amip;
-       int ami_cnt;
+       size_t ami_cnt;
        struct tm *lcl = NULL;
        CRYPTO_THREADID ti;
 
        struct tm *lcl = NULL;
        CRYPTO_THREADID ti;
 
@@ -712,7 +712,7 @@ static void print_leak_doall_arg(const MEM *m, MEM_LEAK *l)
 
        do
                {
 
        do
                {
-               int buf_len;
+               size_t buf_len;
                int info_len;
 
                ami_cnt++;
                int info_len;
 
                ami_cnt++;
index 84380a96a98c71109ed821c522f4c500363f1a18..992a6ee983a5d7014d60bd1f7c891d69d7e85102 100644 (file)
@@ -289,7 +289,7 @@ void OBJ_NAME_do_all(int type,void (*fn)(const OBJ_NAME *,void *arg),void *arg)
 struct doall_sorted
        {
        int type;
 struct doall_sorted
        {
        int type;
-       int n;
+       size_t n;
        const OBJ_NAME **names;
        };
 
        const OBJ_NAME **names;
        };
 
@@ -322,7 +322,7 @@ void OBJ_NAME_do_all_sorted(int type,void (*fn)(const OBJ_NAME *,void *arg),
        d.n=0;
        OBJ_NAME_do_all(type,do_all_sorted_fn,&d);
 
        d.n=0;
        OBJ_NAME_do_all(type,do_all_sorted_fn,&d);
 
-       qsort((void *)d.names,d.n,sizeof *d.names,do_all_sorted_cmp);
+       qsort(d.names,d.n,sizeof *d.names,do_all_sorted_cmp);
 
        for(n=0 ; n < d.n ; ++n)
                fn(d.names[n],arg);
 
        for(n=0 ; n < d.n ; ++n)
                fn(d.names[n],arg);
index e999ef7831a231b426c486608432f3ba6173ba56..1582d61492280798b4429ce041948f8e9e0f74dd 100644 (file)
@@ -431,7 +431,8 @@ ASN1_OBJECT *OBJ_txt2obj(const char *s, int no_name)
        unsigned char *buf;
        unsigned char *p;
        const unsigned char *cp;
        unsigned char *buf;
        unsigned char *p;
        const unsigned char *cp;
-       int i, j;
+       size_t i;
+       size_t j;
 
        if(!no_name) {
                if( ((nid = OBJ_sn2nid(s)) != NID_undef) ||
 
        if(!no_name) {
                if( ((nid = OBJ_sn2nid(s)) != NID_undef) ||
@@ -441,7 +442,7 @@ ASN1_OBJECT *OBJ_txt2obj(const char *s, int no_name)
 
        /* Work out size of content octets */
        i=a2d_ASN1_OBJECT(NULL,0,s,-1);
 
        /* Work out size of content octets */
        i=a2d_ASN1_OBJECT(NULL,0,s,-1);
-       if (i <= 0) {
+       if (i == 0) {
                /* Don't clear the error */
                /*ERR_clear_error();*/
                return NULL;
                /* Don't clear the error */
                /*ERR_clear_error();*/
                return NULL;
@@ -449,7 +450,7 @@ ASN1_OBJECT *OBJ_txt2obj(const char *s, int no_name)
        /* Work out total size */
        j = ASN1_object_size(0,i,V_ASN1_OBJECT);
 
        /* Work out total size */
        j = ASN1_object_size(0,i,V_ASN1_OBJECT);
 
-       if((buf=(unsigned char *)OPENSSL_malloc(j)) == NULL) return NULL;
+       if((buf=OPENSSL_malloc(j)) == NULL) return NULL;
 
        p = buf;
        /* Write out tag+length */
 
        p = buf;
        /* Write out tag+length */
@@ -463,7 +464,7 @@ ASN1_OBJECT *OBJ_txt2obj(const char *s, int no_name)
        return op;
        }
 
        return op;
        }
 
-int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
+int OBJ_obj2txt(char *buf, size_t buf_len, const ASN1_OBJECT *a, int no_name)
 {
        int i,n=0,len,nid, first, use_bn;
        BIGNUM *bl;
 {
        int i,n=0,len,nid, first, use_bn;
        BIGNUM *bl;
@@ -508,7 +509,7 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
                                goto err;
                        if (use_bn)
                                {
                                goto err;
                        if (use_bn)
                                {
-                               if (!BN_add_word(bl, c & 0x7f))
+                               if (!BN_add_word(bl, c & 0x7fU))
                                        goto err;
                                }
                        else
                                        goto err;
                                }
                        else
@@ -782,12 +783,13 @@ int OBJ_create(const char *oid, const char *sn, const char *ln)
        int ok=0;
        ASN1_OBJECT *op=NULL;
        unsigned char *buf;
        int ok=0;
        ASN1_OBJECT *op=NULL;
        unsigned char *buf;
-       int i;
+       size_t i;
 
        i=a2d_ASN1_OBJECT(NULL,0,oid,-1);
 
        i=a2d_ASN1_OBJECT(NULL,0,oid,-1);
-       if (i <= 0) return(0);
+       if (i == 0)
+           return 0;
 
 
-       if ((buf=(unsigned char *)OPENSSL_malloc(i)) == NULL)
+       if ((buf=OPENSSL_malloc(i)) == NULL)
                {
                OBJerr(OBJ_F_OBJ_CREATE,ERR_R_MALLOC_FAILURE);
                return(0);
                {
                OBJerr(OBJ_F_OBJ_CREATE,ERR_R_MALLOC_FAILURE);
                return(0);
@@ -795,7 +797,7 @@ int OBJ_create(const char *oid, const char *sn, const char *ln)
        i=a2d_ASN1_OBJECT(buf,i,oid,-1);
        if (i == 0)
                goto err;
        i=a2d_ASN1_OBJECT(buf,i,oid,-1);
        if (i == 0)
                goto err;
-       op=(ASN1_OBJECT *)ASN1_OBJECT_create(OBJ_new_nid(1),buf,i,sn,ln);
+       op=ASN1_OBJECT_create(OBJ_new_nid(1),buf,i,sn,ln);
        if (op == NULL) 
                goto err;
        ok=OBJ_add_object(op);
        if (op == NULL) 
                goto err;
        ok=OBJ_add_object(op);
index 65b6f013588cddf53b2453a1fdcfd9b52d0ca9b2..10c198ad4728bc6a247add7dca171e1e6c8a4046 100644 (file)
@@ -1006,7 +1006,8 @@ const char *      OBJ_nid2ln(int n);
 const char *   OBJ_nid2sn(int n);
 int            OBJ_obj2nid(const ASN1_OBJECT *o);
 ASN1_OBJECT *  OBJ_txt2obj(const char *s, int no_name);
 const char *   OBJ_nid2sn(int n);
 int            OBJ_obj2nid(const ASN1_OBJECT *o);
 ASN1_OBJECT *  OBJ_txt2obj(const char *s, int no_name);
-int    OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name);
+int             OBJ_obj2txt(char *buf, size_t buf_len, const ASN1_OBJECT *a,
+                           int no_name);
 int            OBJ_txt2nid(const char *s);
 int            OBJ_ln2nid(const char *s);
 int            OBJ_sn2nid(const char *s);
 int            OBJ_txt2nid(const char *s);
 int            OBJ_ln2nid(const char *s);
 int            OBJ_sn2nid(const char *s);