#include "cryptlib.h"
#include <openssl/asn1.h>
+ASN1_INTEGER *ASN1_INTEGER_new(void)
+{ return M_ASN1_INTEGER_new();}
+
+void ASN1_INTEGER_free(ASN1_INTEGER *x)
+{ M_ASN1_INTEGER_free(x);}
+
+ASN1_INTEGER *ASN1_INTEGER_dup(ASN1_INTEGER *x)
+{ return M_ASN1_INTEGER_dup(x);}
+
+int ASN1_INTEGER_cmp(ASN1_INTEGER *x, ASN1_INTEGER *y)
+{ return M_ASN1_INTEGER_cmp(x,y);}
+
/*
* This converts an ASN1 INTEGER into its DER encoding.
* The internal representation is an ASN1_STRING whose data is a big endian
ASN1_put_object(&p,0,ret,V_ASN1_INTEGER,V_ASN1_UNIVERSAL);
if (pad) *(p++)=pb;
- if (a->length == 0)
- *(p++)=0;
- else if (t == V_ASN1_INTEGER)
- {
- memcpy(p,a->data,(unsigned int)a->length);
- p+=a->length;
- }
+ if (a->length == 0) *(p++)=0;
+ else if (t == V_ASN1_INTEGER) memcpy(p,a->data,(unsigned int)a->length);
else {
/* Begin at the end of the encoding */
n=a->data + a->length - 1;
i--;
/* Complement any octets left */
for(;i > 0; i--) *(p--) = *(n--) ^ 0xff;
- p += a->length;
}
- *pp=p;
+ *pp+=r;
return(r);
}
long length)
{
ASN1_INTEGER *ret=NULL;
- unsigned char *p,*to,*s;
+ unsigned char *p,*to,*s, *pend;
long len;
int inf,tag,xclass;
int i;
if ((a == NULL) || ((*a) == NULL))
{
- if ((ret=ASN1_INTEGER_new()) == NULL) return(NULL);
+ if ((ret=M_ASN1_INTEGER_new()) == NULL) return(NULL);
ret->type=V_ASN1_INTEGER;
}
else
p= *pp;
inf=ASN1_get_object(&p,&len,&tag,&xclass,length);
+ pend = p + len;
if (inf & 0x80)
{
i=ASN1_R_BAD_OBJECT_HEADER;
if(!i) {
*s = 1;
s[len] = 0;
- p += len;
len++;
} else {
*(to--) = (*(p--) ^ 0xff) + 1;
i--;
for(;i > 0; i--) *(to--) = *(p--) ^ 0xff;
- p += len;
}
} else {
ret->type=V_ASN1_INTEGER;
len--;
}
memcpy(s,p,(int)len);
- p+=len;
}
if (ret->data != NULL) Free((char *)ret->data);
ret->data=s;
ret->length=(int)len;
if (a != NULL) (*a)=ret;
- *pp=p;
+ *pp=pend;
return(ret);
err:
ASN1err(ASN1_F_D2I_ASN1_INTEGER,i);
if ((ret != NULL) && ((a == NULL) || (*a != ret)))
- ASN1_INTEGER_free(ret);
+ M_ASN1_INTEGER_free(ret);
return(NULL);
}
if ((a == NULL) || ((*a) == NULL))
{
- if ((ret=ASN1_INTEGER_new()) == NULL) return(NULL);
+ if ((ret=M_ASN1_INTEGER_new()) == NULL) return(NULL);
ret->type=V_ASN1_INTEGER;
}
else
err:
ASN1err(ASN1_F_D2I_ASN1_UINTEGER,i);
if ((ret != NULL) && ((a == NULL) || (*a != ret)))
- ASN1_INTEGER_free(ret);
+ M_ASN1_INTEGER_free(ret);
return(NULL);
}
int len,j;
if (ai == NULL)
- ret=ASN1_INTEGER_new();
+ ret=M_ASN1_INTEGER_new();
else
ret=ai;
if (ret == NULL)
ret->length=BN_bn2bin(bn,ret->data);
return(ret);
err:
- if (ret != ai) ASN1_INTEGER_free(ret);
+ if (ret != ai) M_ASN1_INTEGER_free(ret);
return(NULL);
}