提交 4d6e1e4f 编写于 作者: B Ben Laurie

size_tification.

上级 122396f2
...@@ -148,7 +148,9 @@ typedef fd_mask fd_set; ...@@ -148,7 +148,9 @@ typedef fd_mask fd_set;
#define PORT_STR "4433" #define PORT_STR "4433"
#define PROTOCOL "tcp" #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 #ifdef HEADER_X509_H
int MS_CALLBACK verify_callback(int ok, X509_STORE_CTX *ctx); int MS_CALLBACK verify_callback(int ok, X509_STORE_CTX *ctx);
#endif #endif
...@@ -162,11 +164,12 @@ int extract_port(char *str, short *port_ptr); ...@@ -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); 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, 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 #ifdef HEADER_SSL_H
void MS_CALLBACK apps_ssl_info_callback(const SSL *s, int where, int ret); 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, void MS_CALLBACK tlsext_cb(SSL *s, int client_server, int type,
unsigned char *data, int len, unsigned char *data, int len,
void *arg); void *arg);
......
...@@ -260,7 +260,7 @@ int set_cert_key_stuff(SSL_CTX *ctx, X509 *cert, EVP_PKEY *key) ...@@ -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;
......
...@@ -279,7 +279,9 @@ static int init_client_ip(int *sock, unsigned char ip[4], int port, int type) ...@@ -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; int sock;
char *name = NULL; char *name = NULL;
......
...@@ -60,12 +60,13 @@ ...@@ -60,12 +60,13 @@
#include "cryptlib.h" #include "cryptlib.h"
#include <openssl/asn1.h> #include <openssl/asn1.h>
int ASN1_BIT_STRING_set(ASN1_BIT_STRING *x, unsigned char *d, int 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); } { 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; unsigned char *p,*d;
if (a == NULL) return(0); if (a == NULL) return(0);
...@@ -114,7 +115,7 @@ int i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp) ...@@ -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; ASN1_BIT_STRING *ret=NULL;
const unsigned char *p; const unsigned char *p;
...@@ -144,13 +145,13 @@ ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a, ...@@ -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) if (s == NULL)
{ {
i=ERR_R_MALLOC_FAILURE; i=ERR_R_MALLOC_FAILURE;
goto err; goto err;
} }
memcpy(s,p,(int)len); memcpy(s,p,len);
s[len-1]&=(0xff<<i); s[len-1]&=(0xff<<i);
p+=len; p+=len;
} }
...@@ -173,9 +174,10 @@ err: ...@@ -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; unsigned char *c;
w=n/8; w=n/8;
...@@ -192,11 +194,9 @@ int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value) ...@@ -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 (!value) return(1); /* Don't need to set */
if (a->data == NULL) 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, c=OPENSSL_realloc_clean(a->data, a->length, w+1);
a->length,
w+1);
if (c == NULL) if (c == NULL)
{ {
ASN1err(ASN1_F_ASN1_BIT_STRING_SET_BIT,ERR_R_MALLOC_FAILURE); 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) ...@@ -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) ...@@ -230,7 +230,7 @@ int ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *a, int n)
* 'len' is the length of 'flags'. * 'len' is the length of 'flags'.
*/ */
int ASN1_BIT_STRING_check(ASN1_BIT_STRING *a, 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; int i, ok;
/* Check if there is one bit set at all. */ /* Check if there is one bit set at all. */
......
...@@ -75,11 +75,11 @@ int i2d_ASN1_BOOLEAN(int a, unsigned char **pp) ...@@ -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; int ret= -1;
const unsigned char *p; const unsigned char *p;
long len; size_t len;
int inf,tag,xclass; int inf,tag,xclass;
int i=0; int i=0;
......
...@@ -64,12 +64,12 @@ static int asn1_collate_primitive(ASN1_STRING *a, ASN1_const_CTX *c); ...@@ -64,12 +64,12 @@ static int asn1_collate_primitive(ASN1_STRING *a, ASN1_const_CTX *c);
/* type is a 'bitmap' of acceptable string types. /* type is a 'bitmap' of acceptable string types.
*/ */
ASN1_STRING *d2i_ASN1_type_bytes(ASN1_STRING **a, const unsigned char **pp, 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; ASN1_STRING *ret=NULL;
const unsigned char *p; const unsigned char *p;
unsigned char *s; unsigned char *s;
long len; size_t len;
int inf,tag,xclass; int inf,tag,xclass;
int i=0; int i=0;
...@@ -155,12 +155,12 @@ int i2d_ASN1_bytes(ASN1_STRING *a, unsigned char **pp, int tag, int xclass) ...@@ -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; ASN1_STRING *ret=NULL;
const unsigned char *p; const unsigned char *p;
unsigned char *s; unsigned char *s;
long len; size_t len;
int inf,tag,xclass; int inf,tag,xclass;
int i=0; int i=0;
......
...@@ -176,7 +176,7 @@ int i2c_ASN1_INTEGER(ASN1_INTEGER *a, unsigned char **pp) ...@@ -176,7 +176,7 @@ int i2c_ASN1_INTEGER(ASN1_INTEGER *a, unsigned char **pp)
/* Convert just ASN1 INTEGER content octets to ASN1_INTEGER structure */ /* Convert just ASN1 INTEGER content octets to ASN1_INTEGER structure */
ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **pp, ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **pp,
long len) size_t len)
{ {
ASN1_INTEGER *ret=NULL; ASN1_INTEGER *ret=NULL;
const unsigned char *p, *pend; const unsigned char *p, *pend;
...@@ -196,7 +196,7 @@ ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **pp, ...@@ -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 /* We must OPENSSL_malloc stuff, even for 0 bytes otherwise it
* signifies a missing NULL parameter. */ * signifies a missing NULL parameter. */
s=(unsigned char *)OPENSSL_malloc((int)len+1); s=OPENSSL_malloc(len+1);
if (s == NULL) if (s == NULL)
{ {
i=ERR_R_MALLOC_FAILURE; i=ERR_R_MALLOC_FAILURE;
...@@ -246,7 +246,7 @@ ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **pp, ...@@ -246,7 +246,7 @@ ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **pp,
p++; p++;
len--; 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: ...@@ -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; ASN1_INTEGER *ret=NULL;
const unsigned char *p; const unsigned char *p;
unsigned char *to,*s; unsigned char *to,*s;
long len; size_t len;
int inf,tag,xclass; int inf,tag,xclass;
int i; int i;
...@@ -302,7 +302,7 @@ ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a, const unsigned char **pp, ...@@ -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 /* We must OPENSSL_malloc stuff, even for 0 bytes otherwise it
* signifies a missing NULL parameter. */ * signifies a missing NULL parameter. */
s=(unsigned char *)OPENSSL_malloc((int)len+1); s=OPENSSL_malloc(len+1);
if (s == NULL) if (s == NULL)
{ {
i=ERR_R_MALLOC_FAILURE; i=ERR_R_MALLOC_FAILURE;
...@@ -316,7 +316,7 @@ ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a, const unsigned char **pp, ...@@ -316,7 +316,7 @@ ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a, const unsigned char **pp,
p++; p++;
len--; 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) ...@@ -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 *BN_to_ASN1_INTEGER(const BIGNUM *bn, ASN1_INTEGER *ai)
{ {
ASN1_INTEGER *ret; ASN1_INTEGER *ret;
int len,j; size_t len,j;
if (ai == NULL) if (ai == NULL)
ret=M_ASN1_INTEGER_new(); ret=M_ASN1_INTEGER_new();
...@@ -423,7 +423,7 @@ ASN1_INTEGER *BN_to_ASN1_INTEGER(const BIGNUM *bn, ASN1_INTEGER *ai) ...@@ -423,7 +423,7 @@ ASN1_INTEGER *BN_to_ASN1_INTEGER(const BIGNUM *bn, ASN1_INTEGER *ai)
len=((j == 0)?0:((j/8)+1)); len=((j == 0)?0:((j/8)+1));
if (ret->length < len+4) 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) if (!new_data)
{ {
ASN1err(ASN1_F_BN_TO_ASN1_INTEGER,ERR_R_MALLOC_FAILURE); ASN1err(ASN1_F_BN_TO_ASN1_INTEGER,ERR_R_MALLOC_FAILURE);
......
...@@ -80,15 +80,15 @@ static int is_printable(unsigned long value); ...@@ -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 ASN1_mbstring_copy(ASN1_STRING **out, const unsigned char *in, size_t len,
int inform, unsigned long mask) 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 ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, size_t len,
int inform, unsigned long mask, int inform, unsigned long mask, size_t minsize,
long minsize, long maxsize) size_t maxsize)
{ {
int str_type; int str_type;
int ret; int ret;
...@@ -145,14 +145,14 @@ int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len, ...@@ -145,14 +145,14 @@ int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,
if((minsize > 0) && (nchar < minsize)) { if((minsize > 0) && (nchar < minsize)) {
ASN1err(ASN1_F_ASN1_MBSTRING_NCOPY, ASN1_R_STRING_TOO_SHORT); 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); ERR_add_error_data(2, "minsize=", strbuf);
return -1; return -1;
} }
if((maxsize > 0) && (nchar > maxsize)) { if((maxsize > 0) && (nchar > maxsize)) {
ASN1err(ASN1_F_ASN1_MBSTRING_NCOPY, ASN1_R_STRING_TOO_LONG); 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); ERR_add_error_data(2, "maxsize=", strbuf);
return -1; return -1;
} }
......
...@@ -83,11 +83,13 @@ int i2d_ASN1_OBJECT(ASN1_OBJECT *a, unsigned char **pp) ...@@ -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; const char *p;
unsigned long l; unsigned long l;
BIGNUM *bl = NULL; BIGNUM *bl = NULL;
...@@ -150,11 +152,11 @@ int a2d_ASN1_OBJECT(unsigned char *out, int olen, const char *buf, int num) ...@@ -150,11 +152,11 @@ int a2d_ASN1_OBJECT(unsigned char *out, int olen, const char *buf, int num)
if (use_bn) if (use_bn)
{ {
if (!BN_mul_word(bl, 10L) if (!BN_mul_word(bl, 10L)
|| !BN_add_word(bl, c-'0')) || !BN_add_signed_word(bl, c-'0'))
goto err; goto err;
} }
else else
l=l*10L+(long)(c-'0'); l=l*10L+(c-'0');
} }
if (len == 0) if (len == 0)
{ {
...@@ -227,7 +229,7 @@ err: ...@@ -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) ...@@ -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) int i2a_ASN1_OBJECT(BIO *bp, ASN1_OBJECT *a)
{ {
char buf[80], *p = buf; char buf[80], *p = buf;
int i; size_t i;
if ((a == NULL) || (a->data == NULL)) if ((a == NULL) || (a->data == NULL))
return(BIO_write(bp,"NULL",4)); return(BIO_write(bp,"NULL",4));
...@@ -256,13 +258,14 @@ int i2a_ASN1_OBJECT(BIO *bp, ASN1_OBJECT *a) ...@@ -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 tag,xclass;
int inf,i; int inf,i;
ASN1_OBJECT *ret = NULL; ASN1_OBJECT *ret = NULL;
p= *pp; p= *pp;
inf=ASN1_get_object(&p,&len,&tag,&xclass,length); inf=ASN1_get_object(&p,&len,&tag,&xclass,length);
if (inf & 0x80) if (inf & 0x80)
...@@ -284,7 +287,7 @@ err: ...@@ -284,7 +287,7 @@ err:
return(NULL); return(NULL);
} }
ASN1_OBJECT *c2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp, ASN1_OBJECT *c2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp,
long len) size_t len)
{ {
ASN1_OBJECT *ret=NULL; ASN1_OBJECT *ret=NULL;
const unsigned char *p; const unsigned char *p;
...@@ -309,15 +312,15 @@ ASN1_OBJECT *c2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp, ...@@ -309,15 +312,15 @@ ASN1_OBJECT *c2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp,
{ {
ret->length=0; ret->length=0;
if (data != NULL) OPENSSL_free(data); if (data != NULL) OPENSSL_free(data);
data=(unsigned char *)OPENSSL_malloc(len ? (int)len : 1); data=OPENSSL_malloc(len ? len : 1);
if (data == NULL) if (data == NULL)
{ i=ERR_R_MALLOC_FAILURE; goto err; } { i=ERR_R_MALLOC_FAILURE; goto err; }
ret->flags|=ASN1_OBJECT_FLAG_DYNAMIC_DATA; 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->data=data;
ret->length=(int)len; ret->length=len;
ret->sn=NULL; ret->sn=NULL;
ret->ln=NULL; ret->ln=NULL;
/* ret->flags=ASN1_OBJECT_FLAG_DYNAMIC; we know it is dynamic */ /* ret->flags=ASN1_OBJECT_FLAG_DYNAMIC; we know it is dynamic */
...@@ -373,7 +376,7 @@ void ASN1_OBJECT_free(ASN1_OBJECT *a) ...@@ -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) const char *sn, const char *ln)
{ {
ASN1_OBJECT o; ASN1_OBJECT o;
......
...@@ -61,11 +61,13 @@ ...@@ -61,11 +61,13 @@
#include <openssl/asn1.h> #include <openssl/asn1.h>
ASN1_OCTET_STRING *ASN1_OCTET_STRING_dup(const ASN1_OCTET_STRING *x) 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) int ASN1_OCTET_STRING_cmp(const ASN1_OCTET_STRING *a,
{ return M_ASN1_OCTET_STRING_cmp(a, b); } 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) int ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *x, const unsigned char *d,
{ return M_ASN1_OCTET_STRING_set(x, d, len); } size_t len)
{ return M_ASN1_OCTET_STRING_set(x, d, len); }
...@@ -60,7 +60,7 @@ ...@@ -60,7 +60,7 @@
#include "cryptlib.h" #include "cryptlib.h"
#include <openssl/asn1.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 c;
int ia5=0; int ia5=0;
......
...@@ -164,7 +164,7 @@ SetBlob ...@@ -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, void (*free_func)(BLOCK), int ex_tag,
int ex_class) int ex_class)
{ {
......
...@@ -121,7 +121,7 @@ int ASN1_STRING_set_default_mask_asc(char *p) ...@@ -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_TABLE *tbl;
ASN1_STRING *str = NULL; ASN1_STRING *str = NULL;
......
...@@ -135,11 +135,12 @@ int ASN1_TIME_check(ASN1_TIME *t) ...@@ -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; ASN1_GENERALIZEDTIME *ret;
char *str; char *str;
int newlen; size_t newlen;
if (!ASN1_TIME_check(t)) return NULL; if (!ASN1_TIME_check(t)) return NULL;
......
...@@ -73,7 +73,7 @@ ...@@ -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; const unsigned char *p;
unsigned long value; unsigned long value;
...@@ -152,7 +152,7 @@ int UTF8_getc(const unsigned char *str, int len, unsigned long *val) ...@@ -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 */ if(!str) len = 6; /* Maximum we will need */
else if(len <= 0) return -1; else if(len <= 0) return -1;
......
...@@ -180,7 +180,7 @@ typedef struct asn1_ctx_st ...@@ -180,7 +180,7 @@ typedef struct asn1_ctx_st
int inf; /* constructed if 0x20, indefinite is 0x21 */ int inf; /* constructed if 0x20, indefinite is 0x21 */
int tag; /* tag from last 'get object' */ int tag; /* tag from last 'get object' */
int xclass; /* class 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 *max; /* largest value of p allowed */
unsigned char *q;/* temporary variable */ unsigned char *q;/* temporary variable */
unsigned char **pp;/* variable */ unsigned char **pp;/* variable */
...@@ -195,7 +195,7 @@ typedef struct asn1_const_ctx_st ...@@ -195,7 +195,7 @@ typedef struct asn1_const_ctx_st
int inf; /* constructed if 0x20, indefinite is 0x21 */ int inf; /* constructed if 0x20, indefinite is 0x21 */
int tag; /* tag from last 'get object' */ int tag; /* tag from last 'get object' */
int xclass; /* class 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 *max; /* largest value of p allowed */
const unsigned char *q;/* temporary variable */ const unsigned char *q;/* temporary variable */
const unsigned char **pp;/* variable */ const unsigned char **pp;/* variable */
...@@ -212,7 +212,7 @@ typedef struct asn1_object_st ...@@ -212,7 +212,7 @@ typedef struct asn1_object_st
{ {
const char *sn,*ln; const char *sn,*ln;
int nid; int nid;
int length; size_t length;
const unsigned char *data; /* data remains const after init */ const unsigned char *data; /* data remains const after init */
int flags; /* Should we free this one */ int flags; /* Should we free this one */
} ASN1_OBJECT; } ASN1_OBJECT;
...@@ -233,7 +233,7 @@ typedef struct asn1_object_st ...@@ -233,7 +233,7 @@ typedef struct asn1_object_st
/* This is the base type that holds just about everything :-) */ /* This is the base type that holds just about everything :-) */
typedef struct asn1_string_st typedef struct asn1_string_st
{ {
int length; size_t length;
int type; int type;
unsigned char *data; unsigned char *data;
/* The value of the following field depends on the type being /* The value of the following field depends on the type being
...@@ -251,7 +251,7 @@ typedef struct asn1_string_st ...@@ -251,7 +251,7 @@ typedef struct asn1_string_st
typedef struct ASN1_ENCODING_st typedef struct ASN1_ENCODING_st
{ {
unsigned char *enc; /* DER encoding */ 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 */ int modified; /* set to 1 if 'enc' is invalid */
} ASN1_ENCODING; } ASN1_ENCODING;
...@@ -778,9 +778,9 @@ ASN1_OBJECT * ASN1_OBJECT_new(void ); ...@@ -778,9 +778,9 @@ ASN1_OBJECT * ASN1_OBJECT_new(void );
void ASN1_OBJECT_free(ASN1_OBJECT *a); void ASN1_OBJECT_free(ASN1_OBJECT *a);
int i2d_ASN1_OBJECT(ASN1_OBJECT *a,unsigned char **pp); int i2d_ASN1_OBJECT(ASN1_OBJECT *a,unsigned char **pp);
ASN1_OBJECT * c2i_ASN1_OBJECT(ASN1_OBJECT **a,const 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 ); ...@@ -795,23 +795,24 @@ ASN1_STRING * ASN1_STRING_type_new(int type );
int ASN1_STRING_cmp(const ASN1_STRING *a, const ASN1_STRING *b); 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 /* Since this is used to store all sorts of things, via macros, for now, make
its data void * */ its data void * */
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);
void ASN1_STRING_set0(ASN1_STRING *str, void *data, int len); void ASN1_STRING_set0(ASN1_STRING *str, void *data, size_t len);
int ASN1_STRING_length(const ASN1_STRING *x); size_t ASN1_STRING_length(const ASN1_STRING *x);
void ASN1_STRING_length_set(ASN1_STRING *x, int n); void ASN1_STRING_length_set(ASN1_STRING *x, size_t n);
int ASN1_STRING_type(ASN1_STRING *x); int ASN1_STRING_type(ASN1_STRING *x);
unsigned char * ASN1_STRING_data(ASN1_STRING *x); unsigned char * ASN1_STRING_data(ASN1_STRING *x);
DECLARE_ASN1_FUNCTIONS(ASN1_BIT_STRING) DECLARE_ASN1_FUNCTIONS(ASN1_BIT_STRING)
int i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a,unsigned char **pp); 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, ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,
long length); 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 ); size_t length);
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 ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *a, int n); int value);
int ASN1_BIT_STRING_check(ASN1_BIT_STRING *a, int ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *a, size_t n);
unsigned char *flags, int flags_len); int ASN1_BIT_STRING_check(ASN1_BIT_STRING *a,
unsigned char *flags, size_t flags_len);
#ifndef OPENSSL_NO_BIO #ifndef OPENSSL_NO_BIO
int ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs, 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); ...@@ -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, int ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, char *name, int value,
BIT_STRING_BITNAME *tbl); BIT_STRING_BITNAME *tbl);
int i2d_ASN1_BOOLEAN(int a,unsigned char **pp); int i2d_ASN1_BOOLEAN(int a, unsigned char **pp);
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);
DECLARE_ASN1_FUNCTIONS(ASN1_INTEGER) DECLARE_ASN1_FUNCTIONS(ASN1_INTEGER)
int i2c_ASN1_INTEGER(ASN1_INTEGER *a,unsigned char **pp); int i2c_ASN1_INTEGER(ASN1_INTEGER *a,unsigned char **pp);
ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a,const 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); ASN1_INTEGER * ASN1_INTEGER_dup(const ASN1_INTEGER *x);
int ASN1_INTEGER_cmp(const ASN1_INTEGER *x, const ASN1_INTEGER *y); 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); ...@@ -854,7 +855,8 @@ int ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, const char *str);
DECLARE_ASN1_FUNCTIONS(ASN1_OCTET_STRING) DECLARE_ASN1_FUNCTIONS(ASN1_OCTET_STRING)
ASN1_OCTET_STRING * ASN1_OCTET_STRING_dup(const ASN1_OCTET_STRING *a); 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_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_VISIBLESTRING)
DECLARE_ASN1_FUNCTIONS(ASN1_UNIVERSALSTRING) DECLARE_ASN1_FUNCTIONS(ASN1_UNIVERSALSTRING)
...@@ -862,8 +864,8 @@ DECLARE_ASN1_FUNCTIONS(ASN1_UTF8STRING) ...@@ -862,8 +864,8 @@ DECLARE_ASN1_FUNCTIONS(ASN1_UTF8STRING)
DECLARE_ASN1_FUNCTIONS(ASN1_NULL) DECLARE_ASN1_FUNCTIONS(ASN1_NULL)
DECLARE_ASN1_FUNCTIONS(ASN1_BMPSTRING) DECLARE_ASN1_FUNCTIONS(ASN1_BMPSTRING)
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);
int UTF8_putc(unsigned char *str, int len, unsigned long value); 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, ...@@ -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, i2d_of_void *i2d, int ex_tag, int ex_class,
int is_set); int is_set);
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, void (*free_func)(BLOCK), int ex_tag,
int ex_class); int ex_class);
...@@ -902,11 +904,12 @@ int i2a_ASN1_OBJECT(BIO *bp,ASN1_OBJECT *a); ...@@ -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 a2i_ASN1_STRING(BIO *bp,ASN1_STRING *bs,char *buf,int size);
int i2a_ASN1_STRING(BIO *bp, ASN1_STRING *a, int type); int i2a_ASN1_STRING(BIO *bp, ASN1_STRING *a, int type);
#endif #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); size_t a2d_ASN1_OBJECT(unsigned char *out, size_t olen, const char *buf,
ASN1_OBJECT *ASN1_OBJECT_create(int nid, unsigned char *data,int len, int num);
const char *sn, const char *ln); 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); int ASN1_INTEGER_set(ASN1_INTEGER *a, long v);
long ASN1_INTEGER_get(const ASN1_INTEGER *a); long ASN1_INTEGER_get(const ASN1_INTEGER *a);
...@@ -920,29 +923,29 @@ BIGNUM *ASN1_ENUMERATED_to_BN(ASN1_ENUMERATED *ai,BIGNUM *bn); ...@@ -920,29 +923,29 @@ BIGNUM *ASN1_ENUMERATED_to_BN(ASN1_ENUMERATED *ai,BIGNUM *bn);
/* General */ /* General */
/* given a string, return the correct type, max is the maximum length */ /* 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); 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);
unsigned long ASN1_tag2bit(int tag); unsigned long ASN1_tag2bit(int tag);
/* type is one or more of the B_ASN1_ values. */ /* type is one or more of the B_ASN1_ values. */
ASN1_STRING *d2i_ASN1_type_bytes(ASN1_STRING **a,const unsigned char **pp, ASN1_STRING *d2i_ASN1_type_bytes(ASN1_STRING **a,const unsigned char **pp,
long length,int type); size_t length,int type);
/* PARSING */ /* PARSING */
int asn1_Finish(ASN1_CTX *c); int asn1_Finish(ASN1_CTX *c);
int asn1_const_Finish(ASN1_const_CTX *c); int asn1_const_Finish(ASN1_const_CTX *c);
/* SPECIALS */ /* SPECIALS */
int ASN1_get_object(const unsigned char **pp, long *plength, int *ptag, int ASN1_get_object(const unsigned char **pp, size_t *plength, int *ptag,
int *pclass, long omax); int *pclass, size_t omax);
int ASN1_check_infinite_end(unsigned char **p,long len); int ASN1_check_infinite_end(unsigned char **p, size_t 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);
void ASN1_put_object(unsigned char **pp, int constructed, int length, void ASN1_put_object(unsigned char **pp, int constructed, size_t length,
int tag, int xclass); 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 */ /* Used to implement other functions */
void *ASN1_dup(i2d_of_void *i2d, d2i_of_void *d2i, char *x); 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); ...@@ -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_STRING_print_ex(BIO *out, ASN1_STRING *str, unsigned long flags);
int ASN1_bn_print(BIO *bp, const char *number, const BIGNUM *num, int ASN1_bn_print(BIO *bp, const char *number, const BIGNUM *num,
unsigned char *buf, int off); unsigned char *buf, int off);
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);
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);
#endif #endif
const char *ASN1_tag2str(int tag); const char *ASN1_tag2str(int tag);
...@@ -1035,24 +1039,24 @@ DECLARE_ASN1_FUNCTIONS(NETSCAPE_X509) ...@@ -1035,24 +1039,24 @@ DECLARE_ASN1_FUNCTIONS(NETSCAPE_X509)
int ASN1_UNIVERSALSTRING_to_string(ASN1_UNIVERSALSTRING *s); int ASN1_UNIVERSALSTRING_to_string(ASN1_UNIVERSALSTRING *s);
int ASN1_TYPE_set_octetstring(ASN1_TYPE *a, 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); unsigned char *data, size_t len);
int ASN1_TYPE_get_int_octetstring(ASN1_TYPE *a,long *num, int ASN1_TYPE_get_int_octetstring(ASN1_TYPE *a, long *num,
unsigned char *data, int max_len); 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)); d2i_of_void *d2i, void (*free_func)(BLOCK));
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);
void *ASN1_unpack_string(ASN1_STRING *oct, d2i_of_void *d2i); void *ASN1_unpack_string(ASN1_STRING *oct, d2i_of_void *d2i);
void *ASN1_item_unpack(ASN1_STRING *oct, const ASN1_ITEM *it); void *ASN1_item_unpack(ASN1_STRING *oct, const ASN1_ITEM *it);
ASN1_STRING *ASN1_pack_string(void *obj, i2d_of_void *i2d, ASN1_STRING *ASN1_pack_string(void *obj, i2d_of_void *i2d,
ASN1_OCTET_STRING **oct); 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), \ (ASN1_pack_string(CHECKED_PTR_OF(type, obj), \
CHECKED_I2D_OF(type, i2d), \ CHECKED_I2D_OF(type, i2d), \
oct)) oct))
...@@ -1062,14 +1066,15 @@ ASN1_STRING *ASN1_item_pack(void *obj, const ASN1_ITEM *it, ASN1_OCTET_STRING ** ...@@ -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); void ASN1_STRING_set_default_mask(unsigned long mask);
int ASN1_STRING_set_default_mask_asc(char *p); int ASN1_STRING_set_default_mask_asc(char *p);
unsigned long ASN1_STRING_get_default_mask(void); 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); ASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid);
int ASN1_STRING_TABLE_add(int, long, long, unsigned long, unsigned long); int ASN1_STRING_TABLE_add(int, long, long, unsigned long, unsigned long);
void ASN1_STRING_TABLE_cleanup(void); void ASN1_STRING_TABLE_cleanup(void);
...@@ -1079,9 +1084,11 @@ void ASN1_STRING_TABLE_cleanup(void); ...@@ -1079,9 +1084,11 @@ void ASN1_STRING_TABLE_cleanup(void);
/* Old API compatible functions */ /* Old API compatible functions */
ASN1_VALUE *ASN1_item_new(const ASN1_ITEM *it); ASN1_VALUE *ASN1_item_new(const ASN1_ITEM *it);
void ASN1_item_free(ASN1_VALUE *val, 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);
......
...@@ -145,7 +145,7 @@ ASN1_TYPE *ASN1_generate_v3(char *str, X509V3_CTX *cnf) ...@@ -145,7 +145,7 @@ ASN1_TYPE *ASN1_generate_v3(char *str, X509V3_CTX *cnf)
unsigned char *p; unsigned char *p;
const unsigned char *cp; const unsigned char *cp;
int cpy_len; int cpy_len;
long hdr_len; size_t hdr_len;
int hdr_constructed = 0, hdr_tag, hdr_class; int hdr_constructed = 0, hdr_tag, hdr_class;
int r; int r;
......
...@@ -62,7 +62,8 @@ ...@@ -62,7 +62,8 @@
#include <openssl/asn1.h> #include <openssl/asn1.h>
#include <openssl/asn1_mac.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); static void asn1_put_length(unsigned char **pp, int length);
const char ASN1_version[]="ASN.1" OPENSSL_VERSION_PTEXT; 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) ...@@ -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 ASN1_get_object(const unsigned char **pp, size_t *plength, int *ptag,
int *pclass, long omax) int *pclass, size_t omax)
{ {
int i,ret; int i,ret;
long l; long l;
const unsigned char *p= *pp; const unsigned char *p= *pp;
int tag,xclass,inf; int tag,xclass,inf;
long max=omax; size_t max=omax;
if (!max)
goto err;
if (!max) goto err;
ret=(*p&V_ASN1_CONSTRUCTED); ret=(*p&V_ASN1_CONSTRUCTED);
xclass=(*p&V_ASN1_PRIVATE); xclass=(*p&V_ASN1_PRIVATE);
i= *p&V_ASN1_PRIMITIVE_TAG; i= *p&V_ASN1_PRIMITIVE_TAG;
...@@ -151,7 +154,8 @@ err: ...@@ -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; const unsigned char *p= *pp;
unsigned long ret=0; unsigned long ret=0;
...@@ -192,8 +196,8 @@ static int asn1_get_length(const unsigned char **pp, int *inf, long *rl, int max ...@@ -192,8 +196,8 @@ static int asn1_get_length(const unsigned char **pp, int *inf, long *rl, int max
/* class 0 is constructed /* class 0 is constructed
* constructed == 2 for indefinite length constructed */ * constructed == 2 for indefinite length constructed */
void ASN1_put_object(unsigned char **pp, int constructed, int length, int tag, void ASN1_put_object(unsigned char **pp, int constructed, size_t length,
int xclass) int tag, int xclass)
{ {
unsigned char *p= *pp; unsigned char *p= *pp;
int i, ttag; int i, ttag;
...@@ -254,7 +258,7 @@ static void asn1_put_length(unsigned char **pp, int length) ...@@ -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) ...@@ -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; unsigned char *c;
const char *data=_data; const char *data=_data;
...@@ -404,7 +408,7 @@ int ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len) ...@@ -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) if (str->data)
OPENSSL_free(str->data); OPENSSL_free(str->data);
...@@ -469,14 +473,14 @@ void asn1_add_error(const unsigned char *address, int offset) ...@@ -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) size_t ASN1_STRING_length(const ASN1_STRING *x)
{ return M_ASN1_STRING_length(x); } { return M_ASN1_STRING_length(x); }
void ASN1_STRING_length_set(ASN1_STRING *x, int len) void ASN1_STRING_length_set(ASN1_STRING *x, size_t len)
{ M_ASN1_STRING_length_set(x, len); return; } { 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); }
...@@ -279,7 +279,7 @@ err:\ ...@@ -279,7 +279,7 @@ err:\
(V_ASN1_CONSTRUCTED|V_ASN1_CONTEXT_SPECIFIC|tag))) \ (V_ASN1_CONSTRUCTED|V_ASN1_CONTEXT_SPECIFIC|tag))) \
{ \ { \
int Tinf,Ttag,Tclass; \ int Tinf,Ttag,Tclass; \
long Tlen; \ size_t Tlen; \
\ \
c.q=c.p; \ c.q=c.p; \
Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass,c.slen); \ Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass,c.slen); \
......
...@@ -63,11 +63,11 @@ ...@@ -63,11 +63,11 @@
#include <openssl/asn1.h> #include <openssl/asn1.h>
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 int asn1_parse2(BIO *bp, const unsigned char **pp, long length, static int asn1_parse2(BIO *bp, const unsigned char **pp, size_t length,
int offset, int depth, int indent, int dump); 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"; static const char fmt[]="%-18s";
char str[128]; char str[128];
...@@ -99,21 +99,22 @@ err: ...@@ -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, static int asn1_parse2(BIO *bp, const unsigned char **pp, size_t length,
int depth, int indent, int dump) 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 tag,xclass,ret=0;
int nl,hl,j,r; int nl,hl,j,r;
ASN1_OBJECT *o=NULL; ASN1_OBJECT *o=NULL;
...@@ -152,13 +153,13 @@ static int asn1_parse2(BIO *bp, const unsigned char **pp, long length, int offse ...@@ -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 (j != (V_ASN1_CONSTRUCTED | 1))
{ {
if (BIO_printf(bp,"d=%-2d hl=%ld l=%4ld ", if (BIO_printf(bp,"d=%-2d hl=%ld l=%4ld ",
depth,(long)hl,len) <= 0) depth,(long)hl,(long)len) <= 0)
goto end; goto end;
} }
else else
{ {
if (BIO_printf(bp,"d=%-2d hl=%ld l=inf ", if (BIO_printf(bp,"d=%-2d hl=%ld l=inf ",
depth,(long)hl) <= 0) depth,(long)hl) <= 0)
goto end; goto end;
} }
if (!asn1_print_info(bp,tag,xclass,j,(indent)?depth:0)) 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 ...@@ -170,7 +171,8 @@ static int asn1_parse2(BIO *bp, const unsigned char **pp, long length, int offse
if (len > length) if (len > length)
{ {
BIO_printf(bp, BIO_printf(bp,
"length is greater than %ld\n",length); "length is greater than %ld\n",
(long)length);
ret=0; ret=0;
goto end; goto end;
} }
......
...@@ -66,7 +66,7 @@ ...@@ -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)) d2i_of_void *d2i, void (*free_func)(BLOCK))
{ {
STACK_OF(BLOCK) *sk; STACK_OF(BLOCK) *sk;
...@@ -83,7 +83,7 @@ STACK_OF(BLOCK) *ASN1_seq_unpack(const unsigned char *buf, int len, ...@@ -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; int safelen;
unsigned char *safe, *p; unsigned char *safe, *p;
......
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
#include <openssl/asn1.h> #include <openssl/asn1.h>
#include <openssl/asn1_mac.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) ...@@ -73,7 +73,7 @@ int ASN1_TYPE_set_octetstring(ASN1_TYPE *a, unsigned char *data, int len)
/* int max_len: for returned value */ /* int max_len: for returned value */
int ASN1_TYPE_get_octetstring(ASN1_TYPE *a, unsigned char *data, int ASN1_TYPE_get_octetstring(ASN1_TYPE *a, unsigned char *data,
int max_len) size_t max_len)
{ {
int ret,num; int ret,num;
unsigned char *p; unsigned char *p;
...@@ -94,7 +94,7 @@ int ASN1_TYPE_get_octetstring(ASN1_TYPE *a, unsigned char *data, ...@@ -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; int n,size;
ASN1_OCTET_STRING os,*osp; ASN1_OCTET_STRING os,*osp;
...@@ -136,7 +136,7 @@ int ASN1_TYPE_set_int_octetstring(ASN1_TYPE *a, long num, unsigned char *data, ...@@ -136,7 +136,7 @@ int ASN1_TYPE_set_int_octetstring(ASN1_TYPE *a, long num, unsigned char *data,
* case, set it to zero */ * case, set it to zero */
/* int max_len: for returned value */ /* int max_len: for returned value */
int ASN1_TYPE_get_int_octetstring(ASN1_TYPE *a, long *num, unsigned char *data, 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; int ret= -1,n;
ASN1_INTEGER *ai=NULL; ASN1_INTEGER *ai=NULL;
......
...@@ -126,7 +126,8 @@ unsigned long ASN1_tag2bit(int tag) ...@@ -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_TLC c;
ASN1_VALUE *ptmpval = NULL; ASN1_VALUE *ptmpval = NULL;
...@@ -1243,7 +1244,7 @@ static int asn1_check_tlen(long *olen, int *otag, unsigned char *oclass, ...@@ -1243,7 +1244,7 @@ static int asn1_check_tlen(long *olen, int *otag, unsigned char *oclass,
{ {
int i; int i;
int ptag, pclass; int ptag, pclass;
long plen; size_t plen;
const unsigned char *p, *q; const unsigned char *p, *q;
p = *in; p = *in;
q = p; q = p;
......
...@@ -252,9 +252,11 @@ void BIO_clear_flags(BIO *b, int flags); ...@@ -252,9 +252,11 @@ void BIO_clear_flags(BIO *b, int flags);
#define BIO_cb_pre(a) (!((a)&BIO_CB_RETURN)) #define BIO_cb_pre(a) (!((a)&BIO_CB_RETURN))
#define BIO_cb_post(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); long (*BIO_get_callback(const BIO *b)) (struct bio_st *, int, const char *,
void BIO_set_callback(BIO *b, size_t, long, long);
long (*callback)(struct bio_st *,int,const char *,int, 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); char *BIO_get_callback_arg(const BIO *b);
void BIO_set_callback_arg(BIO *b, char *arg); void BIO_set_callback_arg(BIO *b, char *arg);
...@@ -281,7 +283,7 @@ struct bio_st ...@@ -281,7 +283,7 @@ struct bio_st
{ {
BIO_METHOD *method; BIO_METHOD *method;
/* bio, mode, argp, argi, argl, ret */ /* 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 */ char *cb_arg; /* first argument for the callback */
int init; int init;
...@@ -571,7 +573,7 @@ int BIO_free(BIO *a); ...@@ -571,7 +573,7 @@ int BIO_free(BIO *a);
void BIO_vfree(BIO *a); void BIO_vfree(BIO *a);
int BIO_read(BIO *b, void *data, int len); int BIO_read(BIO *b, void *data, int len);
int BIO_gets(BIO *bp,char *buf, int size); 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_puts(BIO *bp,const char *buf);
int BIO_indent(BIO *b,int indent,int max); int BIO_indent(BIO *b,int indent,int max);
long BIO_ctrl(BIO *bp,int cmd,long larg,void *parg); long BIO_ctrl(BIO *bp,int cmd,long larg,void *parg);
...@@ -592,8 +594,8 @@ int BIO_nread(BIO *bio, char **buf, int num); ...@@ -592,8 +594,8 @@ int BIO_nread(BIO *bio, char **buf, int num);
int BIO_nwrite0(BIO *bio, char **buf); int BIO_nwrite0(BIO *bio, char **buf);
int BIO_nwrite(BIO *bio, char **buf, int num); int BIO_nwrite(BIO *bio, char **buf, int num);
long BIO_debug_callback(BIO *bio,int cmd,const char *argp,int argi, long BIO_debug_callback(BIO *bio, int cmd, const char *argp, size_t argi,
long argl,long ret); long argl, long ret);
BIO_METHOD *BIO_s_mem(void); BIO_METHOD *BIO_s_mem(void);
BIO *BIO_new_mem_buf(void *buf, int len); BIO *BIO_new_mem_buf(void *buf, int len);
......
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
#include <openssl/err.h> #include <openssl/err.h>
long MS_CALLBACK BIO_debug_callback(BIO *bio, int cmd, const char *argp, 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; BIO *b;
MS_STATIC char buf[256]; MS_STATIC char buf[256];
......
...@@ -156,12 +156,14 @@ void BIO_set_flags(BIO *b, int flags) ...@@ -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) ...@@ -190,7 +192,7 @@ int BIO_method_type(const BIO *b)
int BIO_read(BIO *b, void *out, int outl) int BIO_read(BIO *b, void *out, int outl)
{ {
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) || (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) ...@@ -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) if (b == NULL)
return(0); return(0);
...@@ -235,7 +237,7 @@ int BIO_write(BIO *b, const void *in, int inl) ...@@ -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); return(i);
if (!b->init) if (!b->init)
...@@ -257,7 +259,7 @@ int BIO_write(BIO *b, const void *in, int inl) ...@@ -257,7 +259,7 @@ int BIO_write(BIO *b, const void *in, int inl)
int BIO_puts(BIO *b, const char *in) int BIO_puts(BIO *b, const char *in)
{ {
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) || (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) ...@@ -290,7 +292,7 @@ int BIO_puts(BIO *b, const char *in)
int BIO_gets(BIO *b, char *in, int inl) int BIO_gets(BIO *b, char *in, int 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) || (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) ...@@ -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 BIO_ctrl(BIO *b, int cmd, long larg, void *parg)
{ {
long ret; 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) ...@@ -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 BIO_callback_ctrl(BIO *b, int cmd, void (*fp)(struct bio_st *, int, const char *, int, long, long))
{ {
long ret; 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);
......
...@@ -175,7 +175,7 @@ BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d) ...@@ -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; { BN_ULONG ret=0,i=0;
if (n <= 0) return 0; if (n <= 0) return 0;
......
...@@ -300,9 +300,9 @@ typedef struct bn_gencb_st BN_GENCB; ...@@ -300,9 +300,9 @@ typedef struct bn_gencb_st BN_GENCB;
struct bignum_st struct bignum_st
{ {
BN_ULONG *d; /* Pointer to an array of 'BN_BITS2' bit chunks. */ 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 neg; /* one if the number is negative */
int flags; int flags;
}; };
...@@ -414,8 +414,8 @@ void BN_CTX_free(BN_CTX *c); ...@@ -414,8 +414,8 @@ void BN_CTX_free(BN_CTX *c);
void BN_CTX_start(BN_CTX *ctx); void BN_CTX_start(BN_CTX *ctx);
BIGNUM *BN_CTX_get(BN_CTX *ctx); BIGNUM *BN_CTX_get(BN_CTX *ctx);
void BN_CTX_end(BN_CTX *ctx); void BN_CTX_end(BN_CTX *ctx);
int BN_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, int 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_rand_range(BIGNUM *rnd, const BIGNUM *range);
int BN_pseudo_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_num_bits(const BIGNUM *a);
...@@ -425,9 +425,9 @@ void BN_init(BIGNUM *); ...@@ -425,9 +425,9 @@ void BN_init(BIGNUM *);
void BN_clear_free(BIGNUM *a); void BN_clear_free(BIGNUM *a);
BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b); BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b);
void BN_swap(BIGNUM *a, 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_bn2mpi(const BIGNUM *a, unsigned char *to);
int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
int BN_usub(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); ...@@ -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); BN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w);
int BN_mul_word(BIGNUM *a, BN_ULONG w); int BN_mul_word(BIGNUM *a, BN_ULONG w);
int BN_add_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_sub_word(BIGNUM *a, BN_ULONG w);
int BN_set_word(BIGNUM *a, BN_ULONG w); int BN_set_word(BIGNUM *a, BN_ULONG w);
BN_ULONG BN_get_word(const BIGNUM *a); BN_ULONG BN_get_word(const BIGNUM *a);
...@@ -500,7 +502,7 @@ int BN_print(BIO *fp, const BIGNUM *a); ...@@ -500,7 +502,7 @@ int BN_print(BIO *fp, const BIGNUM *a);
#else #else
int BN_print(void *fp, const BIGNUM *a); int BN_print(void *fp, const BIGNUM *a);
#endif #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_rshift(BIGNUM *r, const BIGNUM *a, int n);
int BN_rshift1(BIGNUM *r, const BIGNUM *a); int BN_rshift1(BIGNUM *r, const BIGNUM *a);
void BN_clear(BIGNUM *a); void BN_clear(BIGNUM *a);
...@@ -664,9 +666,9 @@ const BIGNUM *BN_get0_nist_prime_521(void); ...@@ -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)?\ #define bn_expand(a,bits) ((((((bits+BN_BITS2-1))/BN_BITS2)) <= (a)->dmax)?\
(a):bn_expand2((a),(bits+BN_BITS2-1)/BN_BITS2)) (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_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 #endif
/* Bignum consistency macros /* Bignum consistency macros
...@@ -762,12 +764,15 @@ int RAND_pseudo_bytes(unsigned char *buf,int num); ...@@ -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_add_words(BN_ULONG *rp, const BN_ULONG *ap, size_t num,
BN_ULONG bn_mul_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w); BN_ULONG w);
void bn_sqr_words(BN_ULONG *rp, const BN_ULONG *ap, int num); 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_add_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,
BN_ULONG bn_sub_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,int num); 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 */ /* Primes from RFC 2409 */
BIGNUM *get_rfc2409_prime_768(BIGNUM *bn); BIGNUM *get_rfc2409_prime_768(BIGNUM *bn);
...@@ -781,7 +786,7 @@ BIGNUM *get_rfc3526_prime_4096(BIGNUM *bn); ...@@ -781,7 +786,7 @@ BIGNUM *get_rfc3526_prime_4096(BIGNUM *bn);
BIGNUM *get_rfc3526_prime_6144(BIGNUM *bn); BIGNUM *get_rfc3526_prime_6144(BIGNUM *bn);
BIGNUM *get_rfc3526_prime_8192(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 */ /* BEGIN ERROR CODES */
/* The following lines are auto generated by the script mkerr.pl. Any changes /* The following lines are auto generated by the script mkerr.pl. Any changes
......
...@@ -104,7 +104,7 @@ int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b) ...@@ -104,7 +104,7 @@ int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)
/* unsigned add of b to a */ /* unsigned add of b to a */
int BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b) 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; BN_ULONG *ap,*bp,*rp,carry,t1,t2;
const BIGNUM *tmp; const BIGNUM *tmp;
...@@ -165,7 +165,7 @@ int BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b) ...@@ -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. */ /* unsigned subtraction of b from a, a must be larger than b. */
int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *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; register BN_ULONG t1,t2,*ap,*bp,*rp;
int i,carry; int i,carry;
#if defined(IRIX_CC_BUG) && !defined(LINT) #if defined(IRIX_CC_BUG) && !defined(LINT)
...@@ -262,7 +262,7 @@ int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b) ...@@ -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; int add=0,neg=0;
const BIGNUM *tmp; const BIGNUM *tmp;
......
...@@ -181,11 +181,12 @@ static int BN_div_no_branch(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, ...@@ -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, int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
BN_CTX *ctx) BN_CTX *ctx)
{ {
int norm_shift,i,loop; int norm_shift,i;
size_t loop;
BIGNUM *tmp,wnum,*snum,*sdiv,*res; BIGNUM *tmp,wnum,*snum,*sdiv,*res;
BN_ULONG *resp,*wnump; BN_ULONG *resp,*wnump;
BN_ULONG d0,d1; BN_ULONG d0,d1;
int num_n,div_n; size_t num_n,div_n;
/* Invalid zero-padding would have particularly bad consequences /* 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 * 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, ...@@ -265,7 +266,7 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
resp= &(res->d[loop-1]); resp= &(res->d[loop-1]);
/* space for temp */ /* 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, ...@@ -429,7 +430,7 @@ static int BN_div_no_branch(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num,
BIGNUM *tmp,wnum,*snum,*sdiv,*res; BIGNUM *tmp,wnum,*snum,*sdiv,*res;
BN_ULONG *resp,*wnump; BN_ULONG *resp,*wnump;
BN_ULONG d0,d1; BN_ULONG d0,d1;
int num_n,div_n; size_t num_n,div_n;
bn_check_top(dv); bn_check_top(dv);
bn_check_top(rm); bn_check_top(rm);
...@@ -498,12 +499,12 @@ static int BN_div_no_branch(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, ...@@ -498,12 +499,12 @@ static int BN_div_no_branch(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num,
/* Setup to 'res' */ /* Setup to 'res' */
res->neg= (num->neg^divisor->neg); 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; res->top=loop-1;
resp= &(res->d[loop-1]); resp= &(res->d[loop-1]);
/* space for temp */ /* 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 /* if res->top == 0 then clear the neg value otherwise decrease
* the resp pointer */ * the resp pointer */
......
...@@ -521,7 +521,8 @@ err: ...@@ -521,7 +521,8 @@ err:
* as cache lines are concerned. The following functions are used to transfer a BIGNUM * as cache lines are concerned. The following functions are used to transfer a BIGNUM
* from/to that table. */ * 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, ...@@ -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, ...@@ -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) const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont)
{ {
int i,bits,ret=0,idx,window,wvalue; int i,bits,ret=0,idx,window,wvalue;
int top; size_t top;
BIGNUM *r; BIGNUM *r;
const BIGNUM *aa; const BIGNUM *aa;
BN_MONT_CTX *mont=NULL; BN_MONT_CTX *mont=NULL;
int numPowers; int numPowers;
unsigned char *powerbufFree=NULL; unsigned char *powerbufFree=NULL;
int powerbufLen = 0; size_t powerbufLen = 0;
unsigned char *powerbuf=NULL; unsigned char *powerbuf=NULL;
BIGNUM *computeTemp=NULL, *am=NULL; BIGNUM *computeTemp=NULL, *am=NULL;
...@@ -625,7 +628,7 @@ int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, ...@@ -625,7 +628,7 @@ int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
*/ */
numPowers = 1 << window; numPowers = 1 << window;
powerbufLen = sizeof(m->d[0])*top*numPowers; 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; goto err;
powerbuf = MOD_EXP_CTIME_ALIGN(powerbufFree); powerbuf = MOD_EXP_CTIME_ALIGN(powerbufFree);
......
...@@ -113,6 +113,7 @@ ...@@ -113,6 +113,7 @@
#define HEADER_BN_LCL_H #define HEADER_BN_LCL_H
#include <openssl/bn.h> #include <openssl/bn.h>
#include <unistd.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
...@@ -468,21 +469,22 @@ void bn_sqr_comba4(BN_ULONG *r,const BN_ULONG *a); ...@@ -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_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 bn_cmp_part_words(const BN_ULONG *a, const BN_ULONG *b,
int cl, int dl); int cl, int dl);
void bn_mul_recursive(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b,int n2, void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, size_t n2,
int dna,int dnb,BN_ULONG *t); int dna, int dnb, BN_ULONG *t);
void bn_mul_part_recursive(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b, void bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b,
int n,int tna,int tnb,BN_ULONG *t); 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_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_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, void bn_mul_low_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
BN_ULONG *t); BN_ULONG *t);
void bn_mul_high(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b,BN_ULONG *l,int n2, void bn_mul_high(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, BN_ULONG *l, int n2,
BN_ULONG *t); 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 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 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
} }
......
...@@ -315,7 +315,7 @@ BIGNUM *BN_new(void) ...@@ -315,7 +315,7 @@ BIGNUM *BN_new(void)
/* This is used both by bn_expand2() and bn_dup_expand() */ /* This is used both by bn_expand2() and bn_dup_expand() */
/* The caller MUST check that words > b->dmax before calling this */ /* 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; BN_ULONG *A,*a = NULL;
const BN_ULONG *B; const BN_ULONG *B;
...@@ -391,7 +391,7 @@ static BN_ULONG *bn_expand_internal(const BIGNUM *b, int words) ...@@ -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) ...@@ -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, * It is mostly used by the various BIGNUM routines. If there is an error,
* NULL is returned. If not, 'b' is returned. */ * 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) ...@@ -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 i,m;
unsigned int n; unsigned int n;
...@@ -614,7 +614,7 @@ BIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret) ...@@ -614,7 +614,7 @@ BIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret)
} }
i=((n-1)/BN_BYTES)+1; i=((n-1)/BN_BYTES)+1;
m=((n-1)%(BN_BYTES)); m=((n-1)%(BN_BYTES));
if (bn_wexpand(ret, (int)i) == NULL) if (bn_wexpand(ret, i) == NULL)
{ {
if (bn) BN_free(bn); if (bn) BN_free(bn);
return NULL; return NULL;
...@@ -718,7 +718,7 @@ int BN_cmp(const BIGNUM *a, const BIGNUM *b) ...@@ -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) if (n < 0)
return 0; return 0;
......
...@@ -88,7 +88,7 @@ int BN_bn2mpi(const BIGNUM *a, unsigned char *d) ...@@ -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; long len;
int neg=0; int neg=0;
......
...@@ -78,8 +78,8 @@ ...@@ -78,8 +78,8 @@
assembler counterparts for the systems that use assembler files. */ assembler counterparts for the systems that use assembler files. */
BN_ULONG bn_sub_part_words(BN_ULONG *r, BN_ULONG bn_sub_part_words(BN_ULONG *r,
const BN_ULONG *a, const BN_ULONG *b, const BN_ULONG *a, const BN_ULONG *b,
int cl, int dl) 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, ...@@ -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 #ifdef BN_COUNT
fprintf(stderr, " bn_sub_part_words %d + %d (dl > 0, c = %d)\n", cl, dl, c); fprintf(stderr, " bn_sub_part_words %d + %d (dl > 0, c = %d)\n", cl, dl, c);
#endif #endif
...@@ -205,8 +205,8 @@ BN_ULONG bn_sub_part_words(BN_ULONG *r, ...@@ -205,8 +205,8 @@ BN_ULONG bn_sub_part_words(BN_ULONG *r,
#endif #endif
BN_ULONG bn_add_part_words(BN_ULONG *r, BN_ULONG bn_add_part_words(BN_ULONG *r,
const BN_ULONG *a, const BN_ULONG *b, const BN_ULONG *a, const BN_ULONG *b,
int cl, int dl) 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, ...@@ -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 #ifdef BN_COUNT
fprintf(stderr, " bn_add_part_words %d + %d (dl < 0, c = %d)\n", cl, dl, c); fprintf(stderr, " bn_add_part_words %d + %d (dl < 0, c = %d)\n", cl, dl, c);
#endif #endif
...@@ -390,8 +390,8 @@ BN_ULONG bn_add_part_words(BN_ULONG *r, ...@@ -390,8 +390,8 @@ BN_ULONG bn_add_part_words(BN_ULONG *r,
* a[1]*b[1] * a[1]*b[1]
*/ */
/* dnX may not be positive, but n2/2+dnX has to be */ /* 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, void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, size_t n2,
int dna, int dnb, BN_ULONG *t) int dna, int dnb, BN_ULONG *t)
{ {
int n=n2/2,c1,c2; int n=n2/2,c1,c2;
int tna=n+dna, tnb=n+dnb; 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, ...@@ -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 else
{ {
/* Might have a carry */ /* 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, ...@@ -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]) * r[32] holds (b[1]*b[1])
* c1 holds the carry bits * 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) if (c1)
{ {
p= &(r[n+n2]); p= &(r[n+n2]);
......
...@@ -415,7 +415,8 @@ int BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, ...@@ -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 ...@@ -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 top = a->top, i;
int carry; int carry;
......
...@@ -71,7 +71,7 @@ char *BN_bn2hex(const BIGNUM *a) ...@@ -71,7 +71,7 @@ char *BN_bn2hex(const BIGNUM *a)
char *buf; char *buf;
char *p; char *p;
buf=(char *)OPENSSL_malloc(a->top*BN_BYTES*2+2); buf=OPENSSL_malloc(a->top*BN_BYTES*2+2);
if (buf == NULL) if (buf == NULL)
{ {
BNerr(BN_F_BN_BN2HEX,ERR_R_MALLOC_FAILURE); BNerr(BN_F_BN_BN2HEX,ERR_R_MALLOC_FAILURE);
...@@ -116,7 +116,7 @@ char *BN_bn2dec(const BIGNUM *a) ...@@ -116,7 +116,7 @@ char *BN_bn2dec(const BIGNUM *a)
i=BN_num_bits(a)*3; i=BN_num_bits(a)*3;
num=(i/10+i/1000+1)+1; num=(i/10+i/1000+1)+1;
bn_data=(BN_ULONG *)OPENSSL_malloc((num/BN_DEC_NUM+1)*sizeof(BN_ULONG)); 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)) if ((buf == NULL) || (bn_data == NULL))
{ {
BNerr(BN_F_BN_BN2DEC,ERR_R_MALLOC_FAILURE); BNerr(BN_F_BN_BN2DEC,ERR_R_MALLOC_FAILURE);
......
...@@ -208,18 +208,18 @@ err: ...@@ -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); return bnrand(1, rnd, bits, top, bottom);
} }
#if 1 #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) ...@@ -229,7 +229,8 @@ int BN_bntest_rand(BIGNUM *rnd, int bits, int top, int bottom)
/* random number r: 0 <= r < range */ /* random number r: 0 <= r < range */
static int bn_rand_range(int pseudo, BIGNUM *r, const BIGNUM *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 n;
int count = 100; int count = 100;
......
...@@ -214,7 +214,7 @@ err: ...@@ -214,7 +214,7 @@ err:
* we can do faster division if the remainder is not required. * we can do faster division if the remainder is not required.
*/ */
/* r := 2^len / m */ /* 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; int ret= -1;
BIGNUM *t; BIGNUM *t;
......
...@@ -168,6 +168,13 @@ int BN_add_word(BIGNUM *a, BN_ULONG w) ...@@ -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 BN_sub_word(BIGNUM *a, BN_ULONG w)
{ {
int i; int i;
......
...@@ -365,7 +365,7 @@ int CRYPTO_is_mem_check_on(void); ...@@ -365,7 +365,7 @@ int CRYPTO_is_mem_check_on(void);
#define MemCheck_off() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE) #define MemCheck_off() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE)
#define is_MemCheck_on() CRYPTO_is_mem_check_on() #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_strdup(str) CRYPTO_strdup((str),__FILE__,__LINE__)
#define OPENSSL_realloc(addr,num) \ #define OPENSSL_realloc(addr,num) \
CRYPTO_realloc((char *)addr,(int)num,__FILE__,__LINE__) 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), ...@@ -469,8 +469,10 @@ int CRYPTO_set_mem_ex_functions(void *(*m)(size_t,const char *,int),
void (*f)(void *)); void (*f)(void *));
int CRYPTO_set_locked_mem_ex_functions(void *(*m)(size_t,const char *,int), int CRYPTO_set_locked_mem_ex_functions(void *(*m)(size_t,const char *,int),
void (*free_func)(void *)); void (*free_func)(void *));
int CRYPTO_set_mem_debug_functions(void (*m)(void *,int,const char *,int,int), int CRYPTO_set_mem_debug_functions(void (*m)(void *,size_t,const char *,int,
void (*r)(void *,void *,int,const char *,int,int), int),
void (*r)(void *,void *,size_t,const char *,
int,int),
void (*f)(void *,int), void (*f)(void *,int),
void (*so)(long), void (*so)(long),
long (*go)(void)); long (*go)(void));
...@@ -481,21 +483,23 @@ void CRYPTO_get_mem_ex_functions(void *(**m)(size_t,const char *,int), ...@@ -481,21 +483,23 @@ void CRYPTO_get_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 CRYPTO_get_locked_mem_ex_functions(void *(**m)(size_t,const char *,int),
void (**f)(void *)); void (**f)(void *));
void CRYPTO_get_mem_debug_functions(void (**m)(void *,int,const char *,int,int), void CRYPTO_get_mem_debug_functions(void (**m)(void *,size_t,const char *,int,
void (**r)(void *,void *,int,const char *,int,int), int),
void (**r)(void *,void *,size_t,
const char *,int,int),
void (**f)(void *,int), void (**f)(void *,int),
void (**so)(long), void (**so)(long),
long (**go)(void)); 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); char *CRYPTO_strdup(const char *str, const char *file, int line);
void CRYPTO_free(void *); void CRYPTO_free(void *);
void *CRYPTO_realloc(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,int old_num,int num,const char *file, void *CRYPTO_realloc_clean(void *addr, size_t old_num, size_t num,
int line); const char *file, int line);
void *CRYPTO_remalloc(void *addr,int 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); ...@@ -516,8 +520,10 @@ int CRYPTO_remove_all_info(void);
* 0: called before 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 * 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_malloc(void *addr,size_t num,const char *file,int line,
void CRYPTO_dbg_realloc(void *addr1,void *addr2,int num,const char *file,int line,int before_p); 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); void CRYPTO_dbg_free(void *addr,int before_p);
/* Tell the debugging code about options. By default, the following values /* Tell the debugging code about options. By default, the following values
* apply: * apply:
......
...@@ -103,9 +103,9 @@ static void (*free_locked_func)(void *) = free; ...@@ -103,9 +103,9 @@ static void (*free_locked_func)(void *) = free;
/* XXX use correct function pointer types */ /* XXX use correct function pointer types */
#ifdef CRYPTO_MDEBUG #ifdef CRYPTO_MDEBUG
/* use default functions from mem_dbg.c */ /* 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; = CRYPTO_dbg_realloc;
static void (*free_debug_func)(void *,int) = CRYPTO_dbg_free; static void (*free_debug_func)(void *,int) = CRYPTO_dbg_free;
static void (*set_debug_options_func)(long) = CRYPTO_dbg_set_options; static void (*set_debug_options_func)(long) = CRYPTO_dbg_set_options;
...@@ -178,8 +178,8 @@ int CRYPTO_set_locked_mem_ex_functions( ...@@ -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), int CRYPTO_set_mem_debug_functions(void (*m)(void *,size_t,const char *,int,int),
void (*r)(void *,void *,int,const char *,int,int), void (*r)(void *,void *,size_t,const char *,int,int),
void (*f)(void *,int), void (*f)(void *,int),
void (*so)(long), void (*so)(long),
long (*go)(void)) long (*go)(void))
...@@ -233,8 +233,8 @@ void CRYPTO_get_locked_mem_ex_functions( ...@@ -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 CRYPTO_get_mem_debug_functions(void (**m)(void *,size_t,const char *,int,int),
void (**r)(void *,void *,int,const char *,int,int), void (**r)(void *,void *,size_t,const char *,int,int),
void (**f)(void *,int), void (**f)(void *,int),
void (**so)(long), void (**so)(long),
long (**go)(void)) long (**go)(void))
...@@ -247,7 +247,7 @@ void CRYPTO_get_mem_debug_functions(void (**m)(void *,int,const char *,int,int), ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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, void *CRYPTO_realloc_clean(void *str, size_t old_len, size_t num,
int line) const char *file, int line)
{ {
void *ret = NULL; void *ret = NULL;
...@@ -393,10 +393,10 @@ void CRYPTO_free(void *str) ...@@ -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);
} }
......
...@@ -478,7 +478,7 @@ int CRYPTO_remove_all_info(void) ...@@ -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) int before_p)
{ {
MEM *m,*mm; MEM *m,*mm;
...@@ -602,8 +602,8 @@ void CRYPTO_dbg_free(void *addr, int before_p) ...@@ -602,8 +602,8 @@ void CRYPTO_dbg_free(void *addr, int before_p)
} }
} }
void CRYPTO_dbg_realloc(void *addr1, void *addr2, int num, void CRYPTO_dbg_realloc(void *addr1, void *addr2, size_t num,
const char *file, int line, int before_p) 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) ...@@ -666,7 +666,7 @@ static void print_leak_doall_arg(const MEM *m, MEM_LEAK *l)
char buf[1024]; char buf[1024];
char *bufp = buf; char *bufp = buf;
APP_INFO *amip; APP_INFO *amip;
int ami_cnt; size_t ami_cnt;
struct tm *lcl = NULL; struct tm *lcl = NULL;
CRYPTO_THREADID ti; CRYPTO_THREADID ti;
...@@ -712,7 +712,7 @@ static void print_leak_doall_arg(const MEM *m, MEM_LEAK *l) ...@@ -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; int info_len;
ami_cnt++; ami_cnt++;
......
...@@ -289,7 +289,7 @@ void OBJ_NAME_do_all(int type,void (*fn)(const OBJ_NAME *,void *arg),void *arg) ...@@ -289,7 +289,7 @@ void OBJ_NAME_do_all(int type,void (*fn)(const OBJ_NAME *,void *arg),void *arg)
struct doall_sorted struct doall_sorted
{ {
int type; 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), ...@@ -322,7 +322,7 @@ void OBJ_NAME_do_all_sorted(int type,void (*fn)(const OBJ_NAME *,void *arg),
d.n=0; d.n=0;
OBJ_NAME_do_all(type,do_all_sorted_fn,&d); 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) for(n=0 ; n < d.n ; ++n)
fn(d.names[n],arg); fn(d.names[n],arg);
......
...@@ -431,7 +431,8 @@ ASN1_OBJECT *OBJ_txt2obj(const char *s, int no_name) ...@@ -431,7 +431,8 @@ ASN1_OBJECT *OBJ_txt2obj(const char *s, int no_name)
unsigned char *buf; unsigned char *buf;
unsigned char *p; unsigned char *p;
const unsigned char *cp; const unsigned char *cp;
int i, j; size_t i;
size_t j;
if(!no_name) { if(!no_name) {
if( ((nid = OBJ_sn2nid(s)) != NID_undef) || if( ((nid = OBJ_sn2nid(s)) != NID_undef) ||
...@@ -441,7 +442,7 @@ ASN1_OBJECT *OBJ_txt2obj(const char *s, int no_name) ...@@ -441,7 +442,7 @@ ASN1_OBJECT *OBJ_txt2obj(const char *s, int no_name)
/* Work out size of content octets */ /* Work out size of content octets */
i=a2d_ASN1_OBJECT(NULL,0,s,-1); i=a2d_ASN1_OBJECT(NULL,0,s,-1);
if (i <= 0) { if (i == 0) {
/* Don't clear the error */ /* Don't clear the error */
/*ERR_clear_error();*/ /*ERR_clear_error();*/
return NULL; return NULL;
...@@ -449,7 +450,7 @@ ASN1_OBJECT *OBJ_txt2obj(const char *s, int no_name) ...@@ -449,7 +450,7 @@ ASN1_OBJECT *OBJ_txt2obj(const char *s, int no_name)
/* Work out total size */ /* Work out total size */
j = ASN1_object_size(0,i,V_ASN1_OBJECT); 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; p = buf;
/* Write out tag+length */ /* Write out tag+length */
...@@ -463,7 +464,7 @@ ASN1_OBJECT *OBJ_txt2obj(const char *s, int no_name) ...@@ -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; int i,n=0,len,nid, first, use_bn;
BIGNUM *bl; BIGNUM *bl;
...@@ -508,7 +509,7 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name) ...@@ -508,7 +509,7 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
goto err; goto err;
if (use_bn) if (use_bn)
{ {
if (!BN_add_word(bl, c & 0x7f)) if (!BN_add_word(bl, c & 0x7fU))
goto err; goto err;
} }
else else
...@@ -782,12 +783,13 @@ int OBJ_create(const char *oid, const char *sn, const char *ln) ...@@ -782,12 +783,13 @@ int OBJ_create(const char *oid, const char *sn, const char *ln)
int ok=0; int ok=0;
ASN1_OBJECT *op=NULL; ASN1_OBJECT *op=NULL;
unsigned char *buf; 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); OBJerr(OBJ_F_OBJ_CREATE,ERR_R_MALLOC_FAILURE);
return(0); return(0);
...@@ -795,7 +797,7 @@ int OBJ_create(const char *oid, const char *sn, const char *ln) ...@@ -795,7 +797,7 @@ int OBJ_create(const char *oid, const char *sn, const char *ln)
i=a2d_ASN1_OBJECT(buf,i,oid,-1); i=a2d_ASN1_OBJECT(buf,i,oid,-1);
if (i == 0) if (i == 0)
goto err; 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) if (op == NULL)
goto err; goto err;
ok=OBJ_add_object(op); ok=OBJ_add_object(op);
......
...@@ -1006,7 +1006,8 @@ const char * OBJ_nid2ln(int n); ...@@ -1006,7 +1006,8 @@ const char * OBJ_nid2ln(int n);
const char * OBJ_nid2sn(int n); const char * OBJ_nid2sn(int n);
int OBJ_obj2nid(const ASN1_OBJECT *o); int OBJ_obj2nid(const ASN1_OBJECT *o);
ASN1_OBJECT * OBJ_txt2obj(const char *s, int no_name); 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_txt2nid(const char *s);
int OBJ_ln2nid(const char *s); int OBJ_ln2nid(const char *s);
int OBJ_sn2nid(const char *s); int OBJ_sn2nid(const char *s);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册