65 static int asn1_get_length(
const unsigned char **
pp,
int *inf,
long *rl,
int max);
66 static void asn1_put_length(
unsigned char **
pp,
int length);
69 static int _asn1_check_infinite_end(
const unsigned char **
p,
long len)
75 else if ((len >= 2) && ((*p)[0] == 0) && ((*p)[1] == 0))
85 return _asn1_check_infinite_end((
const unsigned char **)p, len);
90 return _asn1_check_infinite_end(p, len);
95 int *pclass,
long omax)
99 const unsigned char *
p= *
pp;
107 if (i == V_ASN1_PRIMITIVE_TAG)
110 if (--max == 0)
goto err;
116 if (--max == 0)
goto err;
117 if (l > (INT_MAX >> 7L))
goto err;
122 if (--max == 0)
goto err;
128 if (--max == 0)
goto err;
132 if (!asn1_get_length(&p,&inf,plength,(
int)
max))
goto err;
135 fprintf(stderr,
"p=%d + *plength=%ld > omax=%ld + *pp=%d (%d > %d)\n",
136 (
int)p,*plength,omax,(
int)*pp,(
int)(p+ *plength),
140 if (*plength > (omax - (p - *pp)))
154 static int asn1_get_length(
const unsigned char **
pp,
int *inf,
long *rl,
int max)
156 const unsigned char *
p= *
pp;
160 if (max-- < 1)
return(0);
173 if (i >
sizeof(
long))
175 if (max-- == 0)
return(0);
180 if (max-- == 0)
return(0);
198 unsigned char *p= *
pp;
207 *(p++)=i|V_ASN1_PRIMITIVE_TAG;
208 for(i = 0, ttag = tag; ttag > 0; i++) ttag >>=7;
213 if(i != (ttag - 1)) p[i] |= 0x80;
218 if (constructed == 2)
221 asn1_put_length(&p,length);
227 unsigned char *p = *
pp;
234 static void asn1_put_length(
unsigned char **pp,
int length)
236 unsigned char *p= *
pp;
239 *(p++)=(
unsigned char)
length;
243 for (i=0; l > 0; i++)
271 if (constructed == 2)
295 if ( ((c->
slen != 0) && !(c->
inf & 1)) ||
296 ((c->
slen < 0) && (c->
inf & 1)))
311 return _asn1_Finish(c);
316 const unsigned char *
q;
332 if (c->
max && (*length < 0))
338 c->
slen= *length+ *(c->
pp)-c->
p;
373 const char *
data=_data;
382 if ((str->
length < len) || (str->
data == NULL))
390 if (str->
data == NULL)
400 memcpy(str->
data,data,len);
440 if (a == NULL)
return;
467 BIO_snprintf(buf1,
sizeof buf1,
"%lu",(
unsigned long)address);