int pad=0,ret,i,neg;
unsigned char *p,*n,pb=0;
- if ((a == NULL) || (a->data == NULL)) return(0);
+ if (a == NULL) return(0);
neg=a->type & V_ASN1_NEG;
if (a->length == 0)
ret=1;
/* Convert just ASN1 INTEGER content octets to ASN1_INTEGER structure */
ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **pp,
- size_t len)
+ long len)
{
ASN1_INTEGER *ret=NULL;
const unsigned char *p, *pend;
/* We must OPENSSL_malloc stuff, even for 0 bytes otherwise it
* signifies a missing NULL parameter. */
- s=OPENSSL_malloc(len+1);
+ s=(unsigned char *)OPENSSL_malloc((int)len+1);
if (s == NULL)
{
i=ERR_R_MALLOC_FAILURE;
p++;
len--;
}
- memcpy(s,p,len);
+ memcpy(s,p,(int)len);
}
if (ret->data != NULL) OPENSSL_free(ret->data);
*/
ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a, const unsigned char **pp,
- size_t length)
+ long length)
{
ASN1_INTEGER *ret=NULL;
const unsigned char *p;
- unsigned char *to,*s;
- size_t len;
+ unsigned char *s;
+ long len;
int inf,tag,xclass;
int i;
/* We must OPENSSL_malloc stuff, even for 0 bytes otherwise it
* signifies a missing NULL parameter. */
- s=OPENSSL_malloc(len+1);
+ s=(unsigned char *)OPENSSL_malloc((int)len+1);
if (s == NULL)
{
i=ERR_R_MALLOC_FAILURE;
goto err;
}
- to=s;
ret->type=V_ASN1_INTEGER;
if(len) {
if ((*p == 0) && (len != 1))
p++;
len--;
}
- memcpy(s,p,len);
+ memcpy(s,p,(int)len);
p+=len;
}
int j,k;
unsigned int i;
unsigned char buf[sizeof(long)+1];
- long d;
- a->type=V_ASN1_INTEGER;
if (a->length < (int)(sizeof(long)+1))
{
if (a->data != NULL)
ASN1err(ASN1_F_ASN1_INTEGER_SET,ERR_R_MALLOC_FAILURE);
return(0);
}
- d=v;
- if (d < 0)
+ if (v < 0)
{
- d= -d;
+ v= -v;
a->type=V_ASN1_NEG_INTEGER;
}
+ else
+ a->type=V_ASN1_INTEGER;
for (i=0; i<sizeof(long); i++)
{
- if (d == 0) break;
- buf[i]=(int)d&0xff;
- d>>=8;
+ if (v == 0) break;
+ buf[i]=(int)v&0xff;
+ v>>=8;
}
j=0;
for (k=i-1; k >=0; k--)
if (a->length > (int)sizeof(long))
{
- /* hmm... a bit ugly */
- return(0xffffffffL);
+ /* hmm... a bit ugly, return all ones */
+ return -1;
}
if (a->data == NULL)
return 0;
ASN1_INTEGER *BN_to_ASN1_INTEGER(const BIGNUM *bn, ASN1_INTEGER *ai)
{
ASN1_INTEGER *ret;
- size_t len,j;
+ int len,j;
if (ai == NULL)
ret=M_ASN1_INTEGER_new();
len=((j == 0)?0:((j/8)+1));
if (ret->length < len+4)
{
- unsigned char *new_data=OPENSSL_realloc(ret->data, len+4U);
+ unsigned char *new_data=OPENSSL_realloc(ret->data, len+4);
if (!new_data)
{
ASN1err(ASN1_F_BN_TO_ASN1_INTEGER,ERR_R_MALLOC_FAILURE);