mirror of
https://github.com/openbsd/src.git
synced 2025-01-10 06:47:55 -08:00
openssl-engine-0.9.6 merge
This commit is contained in:
parent
8737778657
commit
c109e39817
@ -27,7 +27,7 @@ LIBS=
|
||||
|
||||
SDIRS= md2 md5 sha mdc2 hmac ripemd \
|
||||
des rc2 rc4 rc5 idea bf cast \
|
||||
bn rsa dsa dh \
|
||||
bn rsa dsa dh dso engine \
|
||||
buffer bio stack lhash rand err objects \
|
||||
evp asn1 pem x509 x509v3 conf txt_db pkcs7 pkcs12 comp
|
||||
|
||||
@ -39,7 +39,7 @@ LIBOBJ= cryptlib.o mem.o mem_dbg.o cversion.o ex_data.o tmdiff.o cpt_err.o ebcdi
|
||||
|
||||
SRC= $(LIBSRC)
|
||||
|
||||
EXHEADER= crypto.h tmdiff.h opensslv.h opensslconf.h ebcdic.h
|
||||
EXHEADER= crypto.h tmdiff.h opensslv.h opensslconf.h ebcdic.h symhacks.h
|
||||
HEADER= cryptlib.h buildinf.h md32_common.h $(EXHEADER)
|
||||
|
||||
ALL= $(GENERAL) $(SRC) $(HEADER)
|
||||
@ -155,41 +155,45 @@ dclean:
|
||||
|
||||
# DO NOT DELETE THIS LINE -- make depend depends on it.
|
||||
|
||||
cpt_err.o: ../include/openssl/crypto.h ../include/openssl/err.h
|
||||
cpt_err.o: ../include/openssl/bio.h ../include/openssl/crypto.h
|
||||
cpt_err.o: ../include/openssl/err.h ../include/openssl/lhash.h
|
||||
cpt_err.o: ../include/openssl/opensslv.h ../include/openssl/safestack.h
|
||||
cpt_err.o: ../include/openssl/stack.h
|
||||
cpt_err.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
|
||||
cryptlib.o: ../include/openssl/bio.h ../include/openssl/buffer.h
|
||||
cryptlib.o: ../include/openssl/crypto.h ../include/openssl/e_os.h
|
||||
cryptlib.o: ../include/openssl/e_os2.h ../include/openssl/err.h
|
||||
cryptlib.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
|
||||
cryptlib.o: ../include/openssl/safestack.h ../include/openssl/stack.h
|
||||
cryptlib.o: cryptlib.h
|
||||
cryptlib.o: ../include/openssl/lhash.h ../include/openssl/opensslconf.h
|
||||
cryptlib.o: ../include/openssl/opensslv.h ../include/openssl/safestack.h
|
||||
cryptlib.o: ../include/openssl/stack.h ../include/openssl/symhacks.h cryptlib.h
|
||||
cversion.o: ../include/openssl/bio.h ../include/openssl/buffer.h
|
||||
cversion.o: ../include/openssl/crypto.h ../include/openssl/e_os.h
|
||||
cversion.o: ../include/openssl/e_os2.h ../include/openssl/err.h
|
||||
cversion.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
|
||||
cversion.o: ../include/openssl/safestack.h ../include/openssl/stack.h
|
||||
cversion.o: buildinf.h cryptlib.h
|
||||
cversion.o: ../include/openssl/lhash.h ../include/openssl/opensslconf.h
|
||||
cversion.o: ../include/openssl/opensslv.h ../include/openssl/safestack.h
|
||||
cversion.o: ../include/openssl/stack.h ../include/openssl/symhacks.h buildinf.h
|
||||
cversion.o: cryptlib.h
|
||||
ex_data.o: ../include/openssl/bio.h ../include/openssl/buffer.h
|
||||
ex_data.o: ../include/openssl/crypto.h ../include/openssl/e_os.h
|
||||
ex_data.o: ../include/openssl/e_os2.h ../include/openssl/err.h
|
||||
ex_data.o: ../include/openssl/lhash.h ../include/openssl/opensslconf.h
|
||||
ex_data.o: ../include/openssl/opensslv.h ../include/openssl/safestack.h
|
||||
ex_data.o: ../include/openssl/stack.h cryptlib.h
|
||||
ex_data.o: ../include/openssl/stack.h ../include/openssl/symhacks.h cryptlib.h
|
||||
mem.o: ../include/openssl/bio.h ../include/openssl/buffer.h
|
||||
mem.o: ../include/openssl/crypto.h ../include/openssl/e_os.h
|
||||
mem.o: ../include/openssl/e_os2.h ../include/openssl/err.h
|
||||
mem.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
|
||||
mem.o: ../include/openssl/safestack.h ../include/openssl/stack.h cryptlib.h
|
||||
mem.o: ../include/openssl/lhash.h ../include/openssl/opensslconf.h
|
||||
mem.o: ../include/openssl/opensslv.h ../include/openssl/safestack.h
|
||||
mem.o: ../include/openssl/stack.h ../include/openssl/symhacks.h cryptlib.h
|
||||
mem_dbg.o: ../include/openssl/bio.h ../include/openssl/buffer.h
|
||||
mem_dbg.o: ../include/openssl/crypto.h ../include/openssl/e_os.h
|
||||
mem_dbg.o: ../include/openssl/e_os2.h ../include/openssl/err.h
|
||||
mem_dbg.o: ../include/openssl/lhash.h ../include/openssl/opensslconf.h
|
||||
mem_dbg.o: ../include/openssl/opensslv.h ../include/openssl/safestack.h
|
||||
mem_dbg.o: ../include/openssl/stack.h cryptlib.h
|
||||
mem_dbg.o: ../include/openssl/stack.h ../include/openssl/symhacks.h cryptlib.h
|
||||
tmdiff.o: ../include/openssl/bio.h ../include/openssl/buffer.h
|
||||
tmdiff.o: ../include/openssl/crypto.h ../include/openssl/e_os.h
|
||||
tmdiff.o: ../include/openssl/e_os2.h ../include/openssl/err.h
|
||||
tmdiff.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
|
||||
tmdiff.o: ../include/openssl/safestack.h ../include/openssl/stack.h
|
||||
tmdiff.o: ../include/openssl/lhash.h ../include/openssl/opensslconf.h
|
||||
tmdiff.o: ../include/openssl/opensslv.h ../include/openssl/safestack.h
|
||||
tmdiff.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
|
||||
tmdiff.o: ../include/openssl/tmdiff.h cryptlib.h
|
||||
|
@ -27,7 +27,7 @@ LIBS=
|
||||
|
||||
SDIRS= md2 md5 sha mdc2 hmac ripemd \
|
||||
des rc2 rc4 rc5 idea bf cast \
|
||||
bn rsa dsa dh \
|
||||
bn rsa dsa dh dso engine \
|
||||
buffer bio stack lhash rand err objects \
|
||||
evp asn1 pem x509 x509v3 conf txt_db pkcs7 pkcs12 comp
|
||||
|
||||
@ -39,7 +39,7 @@ LIBOBJ= cryptlib.o mem.o mem_dbg.o cversion.o ex_data.o tmdiff.o cpt_err.o ebcdi
|
||||
|
||||
SRC= $(LIBSRC)
|
||||
|
||||
EXHEADER= crypto.h tmdiff.h opensslv.h opensslconf.h ebcdic.h
|
||||
EXHEADER= crypto.h tmdiff.h opensslv.h opensslconf.h ebcdic.h symhacks.h
|
||||
HEADER= cryptlib.h buildinf.h md32_common.h $(EXHEADER)
|
||||
|
||||
ALL= $(GENERAL) $(SRC) $(HEADER)
|
||||
@ -155,41 +155,45 @@ dclean:
|
||||
|
||||
# DO NOT DELETE THIS LINE -- make depend depends on it.
|
||||
|
||||
cpt_err.o: ../include/openssl/crypto.h ../include/openssl/err.h
|
||||
cpt_err.o: ../include/openssl/bio.h ../include/openssl/crypto.h
|
||||
cpt_err.o: ../include/openssl/err.h ../include/openssl/lhash.h
|
||||
cpt_err.o: ../include/openssl/opensslv.h ../include/openssl/safestack.h
|
||||
cpt_err.o: ../include/openssl/stack.h
|
||||
cpt_err.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
|
||||
cryptlib.o: ../include/openssl/bio.h ../include/openssl/buffer.h
|
||||
cryptlib.o: ../include/openssl/crypto.h ../include/openssl/e_os.h
|
||||
cryptlib.o: ../include/openssl/e_os2.h ../include/openssl/err.h
|
||||
cryptlib.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
|
||||
cryptlib.o: ../include/openssl/safestack.h ../include/openssl/stack.h
|
||||
cryptlib.o: cryptlib.h
|
||||
cryptlib.o: ../include/openssl/lhash.h ../include/openssl/opensslconf.h
|
||||
cryptlib.o: ../include/openssl/opensslv.h ../include/openssl/safestack.h
|
||||
cryptlib.o: ../include/openssl/stack.h ../include/openssl/symhacks.h cryptlib.h
|
||||
cversion.o: ../include/openssl/bio.h ../include/openssl/buffer.h
|
||||
cversion.o: ../include/openssl/crypto.h ../include/openssl/e_os.h
|
||||
cversion.o: ../include/openssl/e_os2.h ../include/openssl/err.h
|
||||
cversion.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
|
||||
cversion.o: ../include/openssl/safestack.h ../include/openssl/stack.h
|
||||
cversion.o: buildinf.h cryptlib.h
|
||||
cversion.o: ../include/openssl/lhash.h ../include/openssl/opensslconf.h
|
||||
cversion.o: ../include/openssl/opensslv.h ../include/openssl/safestack.h
|
||||
cversion.o: ../include/openssl/stack.h ../include/openssl/symhacks.h buildinf.h
|
||||
cversion.o: cryptlib.h
|
||||
ex_data.o: ../include/openssl/bio.h ../include/openssl/buffer.h
|
||||
ex_data.o: ../include/openssl/crypto.h ../include/openssl/e_os.h
|
||||
ex_data.o: ../include/openssl/e_os2.h ../include/openssl/err.h
|
||||
ex_data.o: ../include/openssl/lhash.h ../include/openssl/opensslconf.h
|
||||
ex_data.o: ../include/openssl/opensslv.h ../include/openssl/safestack.h
|
||||
ex_data.o: ../include/openssl/stack.h cryptlib.h
|
||||
ex_data.o: ../include/openssl/stack.h ../include/openssl/symhacks.h cryptlib.h
|
||||
mem.o: ../include/openssl/bio.h ../include/openssl/buffer.h
|
||||
mem.o: ../include/openssl/crypto.h ../include/openssl/e_os.h
|
||||
mem.o: ../include/openssl/e_os2.h ../include/openssl/err.h
|
||||
mem.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
|
||||
mem.o: ../include/openssl/safestack.h ../include/openssl/stack.h cryptlib.h
|
||||
mem.o: ../include/openssl/lhash.h ../include/openssl/opensslconf.h
|
||||
mem.o: ../include/openssl/opensslv.h ../include/openssl/safestack.h
|
||||
mem.o: ../include/openssl/stack.h ../include/openssl/symhacks.h cryptlib.h
|
||||
mem_dbg.o: ../include/openssl/bio.h ../include/openssl/buffer.h
|
||||
mem_dbg.o: ../include/openssl/crypto.h ../include/openssl/e_os.h
|
||||
mem_dbg.o: ../include/openssl/e_os2.h ../include/openssl/err.h
|
||||
mem_dbg.o: ../include/openssl/lhash.h ../include/openssl/opensslconf.h
|
||||
mem_dbg.o: ../include/openssl/opensslv.h ../include/openssl/safestack.h
|
||||
mem_dbg.o: ../include/openssl/stack.h cryptlib.h
|
||||
mem_dbg.o: ../include/openssl/stack.h ../include/openssl/symhacks.h cryptlib.h
|
||||
tmdiff.o: ../include/openssl/bio.h ../include/openssl/buffer.h
|
||||
tmdiff.o: ../include/openssl/crypto.h ../include/openssl/e_os.h
|
||||
tmdiff.o: ../include/openssl/e_os2.h ../include/openssl/err.h
|
||||
tmdiff.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
|
||||
tmdiff.o: ../include/openssl/safestack.h ../include/openssl/stack.h
|
||||
tmdiff.o: ../include/openssl/lhash.h ../include/openssl/opensslconf.h
|
||||
tmdiff.o: ../include/openssl/opensslv.h ../include/openssl/safestack.h
|
||||
tmdiff.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
|
||||
tmdiff.o: ../include/openssl/tmdiff.h cryptlib.h
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -70,13 +70,27 @@ int ASN1_BIT_STRING_set(ASN1_BIT_STRING *x, unsigned char *d, int len)
|
||||
{ return M_ASN1_BIT_STRING_set(x, d, len); }
|
||||
|
||||
int i2d_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp)
|
||||
{
|
||||
int len, ret;
|
||||
len = i2c_ASN1_BIT_STRING(a, NULL);
|
||||
ret=ASN1_object_size(0,len,V_ASN1_BIT_STRING);
|
||||
if(pp) {
|
||||
ASN1_put_object(pp,0,len,V_ASN1_BIT_STRING,V_ASN1_UNIVERSAL);
|
||||
i2c_ASN1_BIT_STRING(a, pp);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp)
|
||||
{
|
||||
int ret,j,r,bits,len;
|
||||
int ret,j,bits,len;
|
||||
unsigned char *p,*d;
|
||||
|
||||
if (a == NULL) return(0);
|
||||
|
||||
len=a->length;
|
||||
ret=1+len;
|
||||
if (pp == NULL) return(ret);
|
||||
|
||||
if (len > 0)
|
||||
{
|
||||
@ -104,36 +118,27 @@ int i2d_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp)
|
||||
}
|
||||
else
|
||||
bits=0;
|
||||
ret=1+len;
|
||||
r=ASN1_object_size(0,ret,V_ASN1_BIT_STRING);
|
||||
if (pp == NULL) return(r);
|
||||
p= *pp;
|
||||
|
||||
ASN1_put_object(&p,0,ret,V_ASN1_BIT_STRING,V_ASN1_UNIVERSAL);
|
||||
*(p++)=(unsigned char)bits;
|
||||
d=a->data;
|
||||
memcpy(p,d,len);
|
||||
p+=len;
|
||||
if (len > 0) p[-1]&=(0xff<<bits);
|
||||
*pp=p;
|
||||
return(r);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
|
||||
/* Convert DER encoded ASN1 BIT_STRING to ASN1_BIT_STRING structure */
|
||||
ASN1_BIT_STRING *d2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a, unsigned char **pp,
|
||||
long length)
|
||||
{
|
||||
ASN1_BIT_STRING *ret=NULL;
|
||||
unsigned char *p,*s;
|
||||
{
|
||||
unsigned char *p;
|
||||
long len;
|
||||
int inf,tag,xclass;
|
||||
int i;
|
||||
|
||||
if ((a == NULL) || ((*a) == NULL))
|
||||
{
|
||||
if ((ret=M_ASN1_BIT_STRING_new()) == NULL) return(NULL);
|
||||
}
|
||||
else
|
||||
ret=(*a);
|
||||
int inf,tag,xclass;
|
||||
ASN1_BIT_STRING *ret;
|
||||
|
||||
p= *pp;
|
||||
inf=ASN1_get_object(&p,&len,&tag,&xclass,length);
|
||||
@ -149,7 +154,30 @@ ASN1_BIT_STRING *d2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a, unsigned char **pp,
|
||||
goto err;
|
||||
}
|
||||
if (len < 1) { i=ASN1_R_STRING_TOO_SHORT; goto err; }
|
||||
ret = c2i_ASN1_BIT_STRING(a, &p, len);
|
||||
if(ret) *pp = p;
|
||||
return ret;
|
||||
err:
|
||||
ASN1err(ASN1_F_D2I_ASN1_BIT_STRING,i);
|
||||
return(NULL);
|
||||
|
||||
}
|
||||
|
||||
ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a, unsigned char **pp,
|
||||
long len)
|
||||
{
|
||||
ASN1_BIT_STRING *ret=NULL;
|
||||
unsigned char *p,*s;
|
||||
int i;
|
||||
|
||||
if ((a == NULL) || ((*a) == NULL))
|
||||
{
|
||||
if ((ret=M_ASN1_BIT_STRING_new()) == NULL) return(NULL);
|
||||
}
|
||||
else
|
||||
ret=(*a);
|
||||
|
||||
p= *pp;
|
||||
i= *(p++);
|
||||
/* We do this to preserve the settings. If we modify
|
||||
* the settings, via the _set_bit function, we will recalculate
|
||||
@ -159,7 +187,7 @@ ASN1_BIT_STRING *d2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a, unsigned char **pp,
|
||||
|
||||
if (len-- > 1) /* using one because of the bits left byte */
|
||||
{
|
||||
s=(unsigned char *)Malloc((int)len);
|
||||
s=(unsigned char *)OPENSSL_malloc((int)len);
|
||||
if (s == NULL)
|
||||
{
|
||||
i=ERR_R_MALLOC_FAILURE;
|
||||
@ -173,7 +201,7 @@ ASN1_BIT_STRING *d2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a, unsigned char **pp,
|
||||
s=NULL;
|
||||
|
||||
ret->length=(int)len;
|
||||
if (ret->data != NULL) Free(ret->data);
|
||||
if (ret->data != NULL) OPENSSL_free(ret->data);
|
||||
ret->data=s;
|
||||
ret->type=V_ASN1_BIT_STRING;
|
||||
if (a != NULL) (*a)=ret;
|
||||
@ -204,14 +232,14 @@ int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value)
|
||||
{
|
||||
if (!value) return(1); /* Don't need to set */
|
||||
if (a->data == NULL)
|
||||
c=(unsigned char *)Malloc(w+1);
|
||||
c=(unsigned char *)OPENSSL_malloc(w+1);
|
||||
else
|
||||
c=(unsigned char *)Realloc(a->data,w+1);
|
||||
c=(unsigned char *)OPENSSL_realloc(a->data,w+1);
|
||||
if (c == NULL) return(0);
|
||||
if (w+1-a->length > 0) memset(c+a->length, 0, w+1-a->length);
|
||||
a->data=c;
|
||||
a->length=w+1;
|
||||
c[w]=0;
|
||||
}
|
||||
}
|
||||
a->data[w]=((a->data[w])&iv)|v;
|
||||
while ((a->length > 0) && (a->data[a->length-1] == 0))
|
||||
a->length--;
|
||||
|
@ -111,7 +111,7 @@ ASN1_STRING *d2i_ASN1_type_bytes(ASN1_STRING **a, unsigned char **pp,
|
||||
|
||||
if (len != 0)
|
||||
{
|
||||
s=(unsigned char *)Malloc((int)len+1);
|
||||
s=(unsigned char *)OPENSSL_malloc((int)len+1);
|
||||
if (s == NULL)
|
||||
{
|
||||
i=ERR_R_MALLOC_FAILURE;
|
||||
@ -124,7 +124,7 @@ ASN1_STRING *d2i_ASN1_type_bytes(ASN1_STRING **a, unsigned char **pp,
|
||||
else
|
||||
s=NULL;
|
||||
|
||||
if (ret->data != NULL) Free(ret->data);
|
||||
if (ret->data != NULL) OPENSSL_free(ret->data);
|
||||
ret->length=(int)len;
|
||||
ret->data=s;
|
||||
ret->type=tag;
|
||||
@ -218,8 +218,8 @@ ASN1_STRING *d2i_ASN1_bytes(ASN1_STRING **a, unsigned char **pp, long length,
|
||||
{
|
||||
if ((ret->length < len) || (ret->data == NULL))
|
||||
{
|
||||
if (ret->data != NULL) Free(ret->data);
|
||||
s=(unsigned char *)Malloc((int)len + 1);
|
||||
if (ret->data != NULL) OPENSSL_free(ret->data);
|
||||
s=(unsigned char *)OPENSSL_malloc((int)len + 1);
|
||||
if (s == NULL)
|
||||
{
|
||||
i=ERR_R_MALLOC_FAILURE;
|
||||
@ -235,7 +235,7 @@ ASN1_STRING *d2i_ASN1_bytes(ASN1_STRING **a, unsigned char **pp, long length,
|
||||
else
|
||||
{
|
||||
s=NULL;
|
||||
if (ret->data != NULL) Free(ret->data);
|
||||
if (ret->data != NULL) OPENSSL_free(ret->data);
|
||||
}
|
||||
|
||||
ret->length=(int)len;
|
||||
@ -310,14 +310,14 @@ static int asn1_collate_primitive(ASN1_STRING *a, ASN1_CTX *c)
|
||||
if (!asn1_Finish(c)) goto err;
|
||||
|
||||
a->length=num;
|
||||
if (a->data != NULL) Free(a->data);
|
||||
if (a->data != NULL) OPENSSL_free(a->data);
|
||||
a->data=(unsigned char *)b.data;
|
||||
if (os != NULL) ASN1_STRING_free(os);
|
||||
return(1);
|
||||
err:
|
||||
ASN1err(ASN1_F_ASN1_COLLATE_PRIMITIVE,c->error);
|
||||
if (os != NULL) ASN1_STRING_free(os);
|
||||
if (b.data != NULL) Free(b.data);
|
||||
if (b.data != NULL) OPENSSL_free(b.data);
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
@ -77,14 +77,14 @@ int ASN1_digest(int (*i2d)(), const EVP_MD *type, char *data,
|
||||
unsigned char *str,*p;
|
||||
|
||||
i=i2d(data,NULL);
|
||||
if ((str=(unsigned char *)Malloc(i)) == NULL) return(0);
|
||||
if ((str=(unsigned char *)OPENSSL_malloc(i)) == NULL) return(0);
|
||||
p=str;
|
||||
i2d(data,&p);
|
||||
|
||||
EVP_DigestInit(&ctx,type);
|
||||
EVP_DigestUpdate(&ctx,str,i);
|
||||
EVP_DigestFinal(&ctx,md,len);
|
||||
Free(str);
|
||||
OPENSSL_free(str);
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
@ -71,13 +71,13 @@ char *ASN1_dup(int (*i2d)(), char *(*d2i)(), char *x)
|
||||
if (x == NULL) return(NULL);
|
||||
|
||||
i=(long)i2d(x,NULL);
|
||||
b=(unsigned char *)Malloc((unsigned int)i+10);
|
||||
b=(unsigned char *)OPENSSL_malloc((unsigned int)i+10);
|
||||
if (b == NULL)
|
||||
{ ASN1err(ASN1_F_ASN1_DUP,ERR_R_MALLOC_FAILURE); return(NULL); }
|
||||
p= b;
|
||||
i=i2d(x,&p);
|
||||
p= b;
|
||||
ret=d2i(NULL,&p,i);
|
||||
Free(b);
|
||||
OPENSSL_free(b);
|
||||
return(ret);
|
||||
}
|
||||
|
@ -71,88 +71,28 @@ ASN1_ENUMERATED *ASN1_ENUMERATED_new(void)
|
||||
void ASN1_ENUMERATED_free(ASN1_ENUMERATED *x)
|
||||
{ M_ASN1_ENUMERATED_free(x); }
|
||||
|
||||
|
||||
int i2d_ASN1_ENUMERATED(ASN1_ENUMERATED *a, unsigned char **pp)
|
||||
{
|
||||
int pad=0,ret,r,i,t;
|
||||
unsigned char *p,*n,pb=0;
|
||||
|
||||
if ((a == NULL) || (a->data == NULL)) return(0);
|
||||
t=a->type;
|
||||
if (a->length == 0)
|
||||
ret=1;
|
||||
else
|
||||
{
|
||||
ret=a->length;
|
||||
i=a->data[0];
|
||||
if ((t == V_ASN1_ENUMERATED) && (i > 127)) {
|
||||
pad=1;
|
||||
pb=0;
|
||||
} else if(t == V_ASN1_NEG_ENUMERATED) {
|
||||
if(i>128) {
|
||||
pad=1;
|
||||
pb=0xFF;
|
||||
} else if(i == 128) {
|
||||
for(i = 1; i < a->length; i++) if(a->data[i]) {
|
||||
pad=1;
|
||||
pb=0xFF;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
ret+=pad;
|
||||
}
|
||||
r=ASN1_object_size(0,ret,V_ASN1_ENUMERATED);
|
||||
if (pp == NULL) return(r);
|
||||
p= *pp;
|
||||
|
||||
ASN1_put_object(&p,0,ret,V_ASN1_ENUMERATED,V_ASN1_UNIVERSAL);
|
||||
if (pad) *(p++)=pb;
|
||||
if (a->length == 0)
|
||||
*(p++)=0;
|
||||
else if (t == V_ASN1_ENUMERATED)
|
||||
{
|
||||
memcpy(p,a->data,(unsigned int)a->length);
|
||||
p+=a->length;
|
||||
}
|
||||
else {
|
||||
/* Begin at the end of the encoding */
|
||||
n=a->data + a->length - 1;
|
||||
p += a->length - 1;
|
||||
i = a->length;
|
||||
/* Copy zeros to destination as long as source is zero */
|
||||
while(!*n) {
|
||||
*(p--) = 0;
|
||||
n--;
|
||||
i--;
|
||||
}
|
||||
/* Complement and increment next octet */
|
||||
*(p--) = ((*(n--)) ^ 0xff) + 1;
|
||||
i--;
|
||||
/* Complement any octets left */
|
||||
for(;i > 0; i--) *(p--) = *(n--) ^ 0xff;
|
||||
p += a->length;
|
||||
}
|
||||
|
||||
*pp=p;
|
||||
return(r);
|
||||
{
|
||||
int len, ret;
|
||||
if(!a) return 0;
|
||||
len = i2c_ASN1_INTEGER(a, NULL);
|
||||
ret=ASN1_object_size(0,len,V_ASN1_ENUMERATED);
|
||||
if(pp) {
|
||||
ASN1_put_object(pp,0,len,V_ASN1_ENUMERATED,V_ASN1_UNIVERSAL);
|
||||
i2c_ASN1_INTEGER(a, pp);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
ASN1_ENUMERATED *d2i_ASN1_ENUMERATED(ASN1_ENUMERATED **a, unsigned char **pp,
|
||||
long length)
|
||||
{
|
||||
ASN1_ENUMERATED *ret=NULL;
|
||||
unsigned char *p,*to,*s;
|
||||
{
|
||||
unsigned char *p;
|
||||
long len;
|
||||
int inf,tag,xclass;
|
||||
int i;
|
||||
|
||||
if ((a == NULL) || ((*a) == NULL))
|
||||
{
|
||||
if ((ret=M_ASN1_ENUMERATED_new()) == NULL) return(NULL);
|
||||
ret->type=V_ASN1_ENUMERATED;
|
||||
}
|
||||
else
|
||||
ret=(*a);
|
||||
int inf,tag,xclass;
|
||||
ASN1_ENUMERATED *ret;
|
||||
|
||||
p= *pp;
|
||||
inf=ASN1_get_object(&p,&len,&tag,&xclass,length);
|
||||
@ -167,70 +107,17 @@ ASN1_ENUMERATED *d2i_ASN1_ENUMERATED(ASN1_ENUMERATED **a, unsigned char **pp,
|
||||
i=ASN1_R_EXPECTING_AN_ENUMERATED;
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* We must Malloc stuff, even for 0 bytes otherwise it
|
||||
* signifies a missing NULL parameter. */
|
||||
s=(unsigned char *)Malloc((int)len+1);
|
||||
if (s == NULL)
|
||||
{
|
||||
i=ERR_R_MALLOC_FAILURE;
|
||||
goto err;
|
||||
}
|
||||
to=s;
|
||||
if(!len) {
|
||||
/* Strictly speaking this is an illegal ENUMERATED but we
|
||||
* tolerate it.
|
||||
*/
|
||||
ret->type=V_ASN1_ENUMERATED;
|
||||
} else if (*p & 0x80) /* a negative number */
|
||||
{
|
||||
ret->type=V_ASN1_NEG_ENUMERATED;
|
||||
if ((*p == 0xff) && (len != 1)) {
|
||||
p++;
|
||||
len--;
|
||||
}
|
||||
i = len;
|
||||
p += i - 1;
|
||||
to += i - 1;
|
||||
while((!*p) && i) {
|
||||
*(to--) = 0;
|
||||
i--;
|
||||
p--;
|
||||
}
|
||||
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_ENUMERATED;
|
||||
if ((*p == 0) && (len != 1))
|
||||
{
|
||||
p++;
|
||||
len--;
|
||||
}
|
||||
memcpy(s,p,(int)len);
|
||||
p+=len;
|
||||
ret = c2i_ASN1_INTEGER(a, &p, len);
|
||||
if(ret) {
|
||||
ret->type = (V_ASN1_NEG & ret->type) | V_ASN1_ENUMERATED;
|
||||
*pp = p;
|
||||
}
|
||||
|
||||
if (ret->data != NULL) Free(ret->data);
|
||||
ret->data=s;
|
||||
ret->length=(int)len;
|
||||
if (a != NULL) (*a)=ret;
|
||||
*pp=p;
|
||||
return(ret);
|
||||
return ret;
|
||||
err:
|
||||
ASN1err(ASN1_F_D2I_ASN1_ENUMERATED,i);
|
||||
if ((ret != NULL) && ((a == NULL) || (*a != ret)))
|
||||
M_ASN1_ENUMERATED_free(ret);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v)
|
||||
{
|
||||
@ -242,8 +129,8 @@ int ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v)
|
||||
if (a->length < (sizeof(long)+1))
|
||||
{
|
||||
if (a->data != NULL)
|
||||
Free(a->data);
|
||||
if ((a->data=(unsigned char *)Malloc(sizeof(long)+1)) != NULL)
|
||||
OPENSSL_free(a->data);
|
||||
if ((a->data=(unsigned char *)OPENSSL_malloc(sizeof(long)+1)) != NULL)
|
||||
memset((char *)a->data,0,sizeof(long)+1);
|
||||
}
|
||||
if (a->data == NULL)
|
||||
@ -318,7 +205,7 @@ ASN1_ENUMERATED *BN_to_ASN1_ENUMERATED(BIGNUM *bn, ASN1_ENUMERATED *ai)
|
||||
else ret->type=V_ASN1_ENUMERATED;
|
||||
j=BN_num_bits(bn);
|
||||
len=((j == 0)?0:((j/8)+1));
|
||||
ret->data=(unsigned char *)Malloc(len+4);
|
||||
ret->data=(unsigned char *)OPENSSL_malloc(len+4);
|
||||
ret->length=BN_bn2bin(bn,ret->data);
|
||||
return(ret);
|
||||
err:
|
||||
@ -332,6 +219,6 @@ BIGNUM *ASN1_ENUMERATED_to_BN(ASN1_ENUMERATED *ai, BIGNUM *bn)
|
||||
|
||||
if ((ret=BN_bin2bn(ai->data,ai->length,bn)) == NULL)
|
||||
ASN1err(ASN1_F_ASN1_ENUMERATED_TO_BN,ASN1_R_BN_LIB);
|
||||
if(ai->type == V_ASN1_NEG_ENUMERATED) bn->neg = 1;
|
||||
else if(ai->type == V_ASN1_NEG_ENUMERATED) ret->neg = 1;
|
||||
return(ret);
|
||||
}
|
||||
|
@ -212,10 +212,10 @@ ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s,
|
||||
p=(char *)s->data;
|
||||
if ((p == NULL) || (s->length < 16))
|
||||
{
|
||||
p=Malloc(20);
|
||||
p=OPENSSL_malloc(20);
|
||||
if (p == NULL) return(NULL);
|
||||
if (s->data != NULL)
|
||||
Free(s->data);
|
||||
OPENSSL_free(s->data);
|
||||
s->data=(unsigned char *)p;
|
||||
}
|
||||
|
||||
|
@ -115,5 +115,5 @@ void ASN1_HEADER_free(ASN1_HEADER *a)
|
||||
M_ASN1_OCTET_STRING_free(a->header);
|
||||
if (a->meth != NULL)
|
||||
a->meth->destroy(a->data);
|
||||
Free(a);
|
||||
OPENSSL_free(a);
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ int ASN1_i2d_bio(int (*i2d)(), BIO *out, unsigned char *x)
|
||||
int i,j=0,n,ret=1;
|
||||
|
||||
n=i2d(x,NULL);
|
||||
b=(char *)Malloc(n);
|
||||
b=(char *)OPENSSL_malloc(n);
|
||||
if (b == NULL)
|
||||
{
|
||||
ASN1err(ASN1_F_ASN1_I2D_BIO,ERR_R_MALLOC_FAILURE);
|
||||
@ -108,6 +108,6 @@ int ASN1_i2d_bio(int (*i2d)(), BIO *out, unsigned char *x)
|
||||
j+=i;
|
||||
n-=i;
|
||||
}
|
||||
Free(b);
|
||||
OPENSSL_free(b);
|
||||
return(ret);
|
||||
}
|
||||
|
@ -72,8 +72,23 @@ ASN1_INTEGER *ASN1_INTEGER_dup(ASN1_INTEGER *x)
|
||||
int ASN1_INTEGER_cmp(ASN1_INTEGER *x, ASN1_INTEGER *y)
|
||||
{ return M_ASN1_INTEGER_cmp(x,y);}
|
||||
|
||||
/* Output ASN1 INTEGER including tag+length */
|
||||
|
||||
int i2d_ASN1_INTEGER(ASN1_INTEGER *a, unsigned char **pp)
|
||||
{
|
||||
int len, ret;
|
||||
if(!a) return 0;
|
||||
len = i2c_ASN1_INTEGER(a, NULL);
|
||||
ret=ASN1_object_size(0,len,V_ASN1_INTEGER);
|
||||
if(pp) {
|
||||
ASN1_put_object(pp,0,len,V_ASN1_INTEGER,V_ASN1_UNIVERSAL);
|
||||
i2c_ASN1_INTEGER(a, pp);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* This converts an ASN1 INTEGER into its DER encoding.
|
||||
* This converts an ASN1 INTEGER into its content encoding.
|
||||
* The internal representation is an ASN1_STRING whose data is a big endian
|
||||
* representation of the value, ignoring the sign. The sign is determined by
|
||||
* the type: V_ASN1_INTEGER for positive and V_ASN1_NEG_INTEGER for negative.
|
||||
@ -97,23 +112,23 @@ int ASN1_INTEGER_cmp(ASN1_INTEGER *x, ASN1_INTEGER *y)
|
||||
* followed by optional zeros isn't padded.
|
||||
*/
|
||||
|
||||
int i2d_ASN1_INTEGER(ASN1_INTEGER *a, unsigned char **pp)
|
||||
int i2c_ASN1_INTEGER(ASN1_INTEGER *a, unsigned char **pp)
|
||||
{
|
||||
int pad=0,ret,r,i,t;
|
||||
int pad=0,ret,i,neg;
|
||||
unsigned char *p,*n,pb=0;
|
||||
|
||||
if ((a == NULL) || (a->data == NULL)) return(0);
|
||||
t=a->type;
|
||||
neg=a->type & V_ASN1_NEG;
|
||||
if (a->length == 0)
|
||||
ret=1;
|
||||
else
|
||||
{
|
||||
ret=a->length;
|
||||
i=a->data[0];
|
||||
if ((t == V_ASN1_INTEGER) && (i > 127)) {
|
||||
if (!neg && (i > 127)) {
|
||||
pad=1;
|
||||
pb=0;
|
||||
} else if(t == V_ASN1_NEG_INTEGER) {
|
||||
} else if(neg) {
|
||||
if(i>128) {
|
||||
pad=1;
|
||||
pb=0xFF;
|
||||
@ -131,14 +146,12 @@ int i2d_ASN1_INTEGER(ASN1_INTEGER *a, unsigned char **pp)
|
||||
}
|
||||
ret+=pad;
|
||||
}
|
||||
r=ASN1_object_size(0,ret,V_ASN1_INTEGER);
|
||||
if (pp == NULL) return(r);
|
||||
if (pp == NULL) return(ret);
|
||||
p= *pp;
|
||||
|
||||
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);
|
||||
else if (!neg) memcpy(p,a->data,(unsigned int)a->length);
|
||||
else {
|
||||
/* Begin at the end of the encoding */
|
||||
n=a->data + a->length - 1;
|
||||
@ -157,30 +170,22 @@ int i2d_ASN1_INTEGER(ASN1_INTEGER *a, unsigned char **pp)
|
||||
for(;i > 0; i--) *(p--) = *(n--) ^ 0xff;
|
||||
}
|
||||
|
||||
*pp+=r;
|
||||
return(r);
|
||||
*pp+=ret;
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/* Convert DER encoded ASN1 INTEGER to ASN1_INTEGER structure */
|
||||
ASN1_INTEGER *d2i_ASN1_INTEGER(ASN1_INTEGER **a, unsigned char **pp,
|
||||
long length)
|
||||
{
|
||||
ASN1_INTEGER *ret=NULL;
|
||||
unsigned char *p,*to,*s, *pend;
|
||||
{
|
||||
unsigned char *p;
|
||||
long len;
|
||||
int inf,tag,xclass;
|
||||
int i;
|
||||
|
||||
if ((a == NULL) || ((*a) == NULL))
|
||||
{
|
||||
if ((ret=M_ASN1_INTEGER_new()) == NULL) return(NULL);
|
||||
ret->type=V_ASN1_INTEGER;
|
||||
}
|
||||
else
|
||||
ret=(*a);
|
||||
int inf,tag,xclass;
|
||||
ASN1_INTEGER *ret;
|
||||
|
||||
p= *pp;
|
||||
inf=ASN1_get_object(&p,&len,&tag,&xclass,length);
|
||||
pend = p + len;
|
||||
if (inf & 0x80)
|
||||
{
|
||||
i=ASN1_R_BAD_OBJECT_HEADER;
|
||||
@ -192,10 +197,39 @@ ASN1_INTEGER *d2i_ASN1_INTEGER(ASN1_INTEGER **a, unsigned char **pp,
|
||||
i=ASN1_R_EXPECTING_AN_INTEGER;
|
||||
goto err;
|
||||
}
|
||||
ret = c2i_ASN1_INTEGER(a, &p, len);
|
||||
if(ret) *pp = p;
|
||||
return ret;
|
||||
err:
|
||||
ASN1err(ASN1_F_D2I_ASN1_INTEGER,i);
|
||||
return(NULL);
|
||||
|
||||
/* We must Malloc stuff, even for 0 bytes otherwise it
|
||||
}
|
||||
|
||||
|
||||
/* Convert just ASN1 INTEGER content octets to ASN1_INTEGER structure */
|
||||
|
||||
ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a, unsigned char **pp,
|
||||
long len)
|
||||
{
|
||||
ASN1_INTEGER *ret=NULL;
|
||||
unsigned char *p,*to,*s, *pend;
|
||||
int i;
|
||||
|
||||
if ((a == NULL) || ((*a) == NULL))
|
||||
{
|
||||
if ((ret=M_ASN1_INTEGER_new()) == NULL) return(NULL);
|
||||
ret->type=V_ASN1_INTEGER;
|
||||
}
|
||||
else
|
||||
ret=(*a);
|
||||
|
||||
p= *pp;
|
||||
pend = p + len;
|
||||
|
||||
/* We must OPENSSL_malloc stuff, even for 0 bytes otherwise it
|
||||
* signifies a missing NULL parameter. */
|
||||
s=(unsigned char *)Malloc((int)len+1);
|
||||
s=(unsigned char *)OPENSSL_malloc((int)len+1);
|
||||
if (s == NULL)
|
||||
{
|
||||
i=ERR_R_MALLOC_FAILURE;
|
||||
@ -248,7 +282,7 @@ ASN1_INTEGER *d2i_ASN1_INTEGER(ASN1_INTEGER **a, unsigned char **pp,
|
||||
memcpy(s,p,(int)len);
|
||||
}
|
||||
|
||||
if (ret->data != NULL) Free(ret->data);
|
||||
if (ret->data != NULL) OPENSSL_free(ret->data);
|
||||
ret->data=s;
|
||||
ret->length=(int)len;
|
||||
if (a != NULL) (*a)=ret;
|
||||
@ -261,6 +295,7 @@ err:
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
||||
/* This is a version of d2i_ASN1_INTEGER that ignores the sign bit of
|
||||
* ASN1 integers: some broken software can encode a positive INTEGER
|
||||
* with its MSB set as negative (it doesn't add a padding zero).
|
||||
@ -297,9 +332,9 @@ ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a, unsigned char **pp,
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* We must Malloc stuff, even for 0 bytes otherwise it
|
||||
/* We must OPENSSL_malloc stuff, even for 0 bytes otherwise it
|
||||
* signifies a missing NULL parameter. */
|
||||
s=(unsigned char *)Malloc((int)len+1);
|
||||
s=(unsigned char *)OPENSSL_malloc((int)len+1);
|
||||
if (s == NULL)
|
||||
{
|
||||
i=ERR_R_MALLOC_FAILURE;
|
||||
@ -317,7 +352,7 @@ ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a, unsigned char **pp,
|
||||
p+=len;
|
||||
}
|
||||
|
||||
if (ret->data != NULL) Free(ret->data);
|
||||
if (ret->data != NULL) OPENSSL_free(ret->data);
|
||||
ret->data=s;
|
||||
ret->length=(int)len;
|
||||
if (a != NULL) (*a)=ret;
|
||||
@ -340,8 +375,8 @@ int ASN1_INTEGER_set(ASN1_INTEGER *a, long v)
|
||||
if (a->length < (sizeof(long)+1))
|
||||
{
|
||||
if (a->data != NULL)
|
||||
Free(a->data);
|
||||
if ((a->data=(unsigned char *)Malloc(sizeof(long)+1)) != NULL)
|
||||
OPENSSL_free(a->data);
|
||||
if ((a->data=(unsigned char *)OPENSSL_malloc(sizeof(long)+1)) != NULL)
|
||||
memset((char *)a->data,0,sizeof(long)+1);
|
||||
}
|
||||
if (a->data == NULL)
|
||||
@ -416,7 +451,7 @@ ASN1_INTEGER *BN_to_ASN1_INTEGER(BIGNUM *bn, ASN1_INTEGER *ai)
|
||||
else ret->type=V_ASN1_INTEGER;
|
||||
j=BN_num_bits(bn);
|
||||
len=((j == 0)?0:((j/8)+1));
|
||||
ret->data=(unsigned char *)Malloc(len+4);
|
||||
ret->data=(unsigned char *)OPENSSL_malloc(len+4);
|
||||
ret->length=BN_bn2bin(bn,ret->data);
|
||||
return(ret);
|
||||
err:
|
||||
@ -430,6 +465,9 @@ BIGNUM *ASN1_INTEGER_to_BN(ASN1_INTEGER *ai, BIGNUM *bn)
|
||||
|
||||
if ((ret=BN_bin2bn(ai->data,ai->length,bn)) == NULL)
|
||||
ASN1err(ASN1_F_ASN1_INTEGER_TO_BN,ASN1_R_BN_LIB);
|
||||
if(ai->type == V_ASN1_NEG_INTEGER) bn->neg = 1;
|
||||
else if(ai->type == V_ASN1_NEG_INTEGER) ret->neg = 1;
|
||||
return(ret);
|
||||
}
|
||||
|
||||
IMPLEMENT_STACK_OF(ASN1_INTEGER)
|
||||
IMPLEMENT_ASN1_SET_OF(ASN1_INTEGER)
|
||||
|
@ -92,6 +92,7 @@ int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,
|
||||
{
|
||||
int str_type;
|
||||
int ret;
|
||||
char free_out;
|
||||
int outform, outlen;
|
||||
ASN1_STRING *dest;
|
||||
unsigned char *p;
|
||||
@ -180,14 +181,16 @@ int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,
|
||||
}
|
||||
if(!out) return str_type;
|
||||
if(*out) {
|
||||
free_out = 0;
|
||||
dest = *out;
|
||||
if(dest->data) {
|
||||
dest->length = 0;
|
||||
Free(dest->data);
|
||||
OPENSSL_free(dest->data);
|
||||
dest->data = NULL;
|
||||
}
|
||||
dest->type = str_type;
|
||||
} else {
|
||||
free_out = 1;
|
||||
dest = ASN1_STRING_type_new(str_type);
|
||||
if(!dest) {
|
||||
ASN1err(ASN1_F_ASN1_MBSTRING_COPY,
|
||||
@ -228,8 +231,8 @@ int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,
|
||||
cpyfunc = cpy_utf8;
|
||||
break;
|
||||
}
|
||||
if(!(p = Malloc(outlen + 1))) {
|
||||
ASN1_STRING_free(dest);
|
||||
if(!(p = OPENSSL_malloc(outlen + 1))) {
|
||||
if(free_out) ASN1_STRING_free(dest);
|
||||
ASN1err(ASN1_F_ASN1_MBSTRING_COPY,ERR_R_MALLOC_FAILURE);
|
||||
return -1;
|
||||
}
|
||||
@ -258,8 +261,8 @@ static int traverse_string(const unsigned char *p, int len, int inform,
|
||||
value |= *p++;
|
||||
len -= 2;
|
||||
} else if(inform == MBSTRING_UNIV) {
|
||||
value = *p++ << 24;
|
||||
value |= *p++ << 16;
|
||||
value = ((unsigned long)*p++) << 24;
|
||||
value |= ((unsigned long)*p++) << 16;
|
||||
value |= *p++ << 8;
|
||||
value |= *p++;
|
||||
len -= 4;
|
||||
@ -382,9 +385,16 @@ static int is_printable(unsigned long value)
|
||||
/* Note: we can't use 'isalnum' because certain accented
|
||||
* characters may count as alphanumeric in some environments.
|
||||
*/
|
||||
#ifndef CHARSET_EBCDIC
|
||||
if((ch >= 'a') && (ch <= 'z')) return 1;
|
||||
if((ch >= 'A') && (ch <= 'Z')) return 1;
|
||||
if((ch >= '0') && (ch <= '9')) return 1;
|
||||
if ((ch == ' ') || strchr("'()+,-./:=?", ch)) return 1;
|
||||
#else /*CHARSET_EBCDIC*/
|
||||
if((ch >= os_toascii['a']) && (ch <= os_toascii['z'])) return 1;
|
||||
if((ch >= os_toascii['A']) && (ch <= os_toascii['Z'])) return 1;
|
||||
if((ch >= os_toascii['0']) && (ch <= os_toascii['9'])) return 1;
|
||||
if ((ch == os_toascii[' ']) || strchr("'()+,-./:=?", os_toebcdic[ch])) return 1;
|
||||
#endif /*CHARSET_EBCDIC*/
|
||||
return 0;
|
||||
}
|
||||
|
@ -65,11 +65,12 @@
|
||||
int i2d_ASN1_OBJECT(ASN1_OBJECT *a, unsigned char **pp)
|
||||
{
|
||||
unsigned char *p;
|
||||
int objsize;
|
||||
|
||||
if ((a == NULL) || (a->data == NULL)) return(0);
|
||||
|
||||
if (pp == NULL)
|
||||
return(ASN1_object_size(0,a->length,V_ASN1_OBJECT));
|
||||
objsize = ASN1_object_size(0,a->length,V_ASN1_OBJECT);
|
||||
if (pp == NULL) return objsize;
|
||||
|
||||
p= *pp;
|
||||
ASN1_put_object(&p,0,a->length,V_ASN1_OBJECT,V_ASN1_UNIVERSAL);
|
||||
@ -77,7 +78,7 @@ int i2d_ASN1_OBJECT(ASN1_OBJECT *a, unsigned char **pp)
|
||||
p+=a->length;
|
||||
|
||||
*pp=p;
|
||||
return(a->length);
|
||||
return(objsize);
|
||||
}
|
||||
|
||||
int a2d_ASN1_OBJECT(unsigned char *out, int olen, const char *buf, int num)
|
||||
@ -190,24 +191,13 @@ int i2a_ASN1_OBJECT(BIO *bp, ASN1_OBJECT *a)
|
||||
|
||||
ASN1_OBJECT *d2i_ASN1_OBJECT(ASN1_OBJECT **a, unsigned char **pp,
|
||||
long length)
|
||||
{
|
||||
ASN1_OBJECT *ret=NULL;
|
||||
{
|
||||
unsigned char *p;
|
||||
long len;
|
||||
int tag,xclass;
|
||||
int inf,i;
|
||||
|
||||
/* only the ASN1_OBJECTs from the 'table' will have values
|
||||
* for ->sn or ->ln */
|
||||
if ((a == NULL) || ((*a) == NULL) ||
|
||||
!((*a)->flags & ASN1_OBJECT_FLAG_DYNAMIC))
|
||||
{
|
||||
if ((ret=ASN1_OBJECT_new()) == NULL) return(NULL);
|
||||
}
|
||||
else ret=(*a);
|
||||
|
||||
ASN1_OBJECT *ret = NULL;
|
||||
p= *pp;
|
||||
|
||||
inf=ASN1_get_object(&p,&len,&tag,&xclass,length);
|
||||
if (inf & 0x80)
|
||||
{
|
||||
@ -220,10 +210,36 @@ ASN1_OBJECT *d2i_ASN1_OBJECT(ASN1_OBJECT **a, unsigned char **pp,
|
||||
i=ASN1_R_EXPECTING_AN_OBJECT;
|
||||
goto err;
|
||||
}
|
||||
ret = c2i_ASN1_OBJECT(a, &p, len);
|
||||
if(ret) *pp = p;
|
||||
return ret;
|
||||
err:
|
||||
ASN1err(ASN1_F_D2I_ASN1_OBJECT,i);
|
||||
if ((ret != NULL) && ((a == NULL) || (*a != ret)))
|
||||
ASN1_OBJECT_free(ret);
|
||||
return(NULL);
|
||||
}
|
||||
ASN1_OBJECT *c2i_ASN1_OBJECT(ASN1_OBJECT **a, unsigned char **pp,
|
||||
long len)
|
||||
{
|
||||
ASN1_OBJECT *ret=NULL;
|
||||
unsigned char *p;
|
||||
int i;
|
||||
|
||||
/* only the ASN1_OBJECTs from the 'table' will have values
|
||||
* for ->sn or ->ln */
|
||||
if ((a == NULL) || ((*a) == NULL) ||
|
||||
!((*a)->flags & ASN1_OBJECT_FLAG_DYNAMIC))
|
||||
{
|
||||
if ((ret=ASN1_OBJECT_new()) == NULL) return(NULL);
|
||||
}
|
||||
else ret=(*a);
|
||||
|
||||
p= *pp;
|
||||
if ((ret->data == NULL) || (ret->length < len))
|
||||
{
|
||||
if (ret->data != NULL) Free(ret->data);
|
||||
ret->data=(unsigned char *)Malloc(len ? (int)len : 1);
|
||||
if (ret->data != NULL) OPENSSL_free(ret->data);
|
||||
ret->data=(unsigned char *)OPENSSL_malloc(len ? (int)len : 1);
|
||||
ret->flags|=ASN1_OBJECT_FLAG_DYNAMIC_DATA;
|
||||
if (ret->data == NULL)
|
||||
{ i=ERR_R_MALLOC_FAILURE; goto err; }
|
||||
@ -249,7 +265,7 @@ ASN1_OBJECT *ASN1_OBJECT_new(void)
|
||||
{
|
||||
ASN1_OBJECT *ret;
|
||||
|
||||
ret=(ASN1_OBJECT *)Malloc(sizeof(ASN1_OBJECT));
|
||||
ret=(ASN1_OBJECT *)OPENSSL_malloc(sizeof(ASN1_OBJECT));
|
||||
if (ret == NULL)
|
||||
{
|
||||
ASN1err(ASN1_F_ASN1_OBJECT_NEW,ERR_R_MALLOC_FAILURE);
|
||||
@ -270,19 +286,19 @@ void ASN1_OBJECT_free(ASN1_OBJECT *a)
|
||||
if (a->flags & ASN1_OBJECT_FLAG_DYNAMIC_STRINGS)
|
||||
{
|
||||
#ifndef CONST_STRICT /* disable purely for compile-time strict const checking. Doing this on a "real" compile will cause memory leaks */
|
||||
if (a->sn != NULL) Free((void *)a->sn);
|
||||
if (a->ln != NULL) Free((void *)a->ln);
|
||||
if (a->sn != NULL) OPENSSL_free((void *)a->sn);
|
||||
if (a->ln != NULL) OPENSSL_free((void *)a->ln);
|
||||
#endif
|
||||
a->sn=a->ln=NULL;
|
||||
}
|
||||
if (a->flags & ASN1_OBJECT_FLAG_DYNAMIC_DATA)
|
||||
{
|
||||
if (a->data != NULL) Free(a->data);
|
||||
if (a->data != NULL) OPENSSL_free(a->data);
|
||||
a->data=NULL;
|
||||
a->length=0;
|
||||
}
|
||||
if (a->flags & ASN1_OBJECT_FLAG_DYNAMIC)
|
||||
Free(a);
|
||||
OPENSSL_free(a);
|
||||
}
|
||||
|
||||
ASN1_OBJECT *ASN1_OBJECT_create(int nid, unsigned char *data, int len,
|
||||
|
@ -116,7 +116,7 @@ int i2d_ASN1_SET(STACK *a, unsigned char **pp, int (*func)(), int ex_tag,
|
||||
}
|
||||
|
||||
pStart = p; /* Catch the beg of Setblobs*/
|
||||
rgSetBlob = (MYBLOB *)Malloc( sk_num(a) * sizeof(MYBLOB)); /* In this array
|
||||
rgSetBlob = (MYBLOB *)OPENSSL_malloc( sk_num(a) * sizeof(MYBLOB)); /* In this array
|
||||
we will store the SET blobs */
|
||||
|
||||
for (i=0; i<sk_num(a); i++)
|
||||
@ -133,7 +133,7 @@ SetBlob
|
||||
/* Now we have to sort the blobs. I am using a simple algo.
|
||||
*Sort ptrs *Copy to temp-mem *Copy from temp-mem to user-mem*/
|
||||
qsort( rgSetBlob, sk_num(a), sizeof(MYBLOB), SetBlobCmp);
|
||||
pTempMem = Malloc(totSize);
|
||||
pTempMem = OPENSSL_malloc(totSize);
|
||||
|
||||
/* Copy to temp mem */
|
||||
p = pTempMem;
|
||||
@ -145,20 +145,20 @@ SetBlob
|
||||
|
||||
/* Copy back to user mem*/
|
||||
memcpy(pStart, pTempMem, totSize);
|
||||
Free(pTempMem);
|
||||
Free(rgSetBlob);
|
||||
OPENSSL_free(pTempMem);
|
||||
OPENSSL_free(rgSetBlob);
|
||||
|
||||
return(r);
|
||||
}
|
||||
|
||||
STACK *d2i_ASN1_SET(STACK **a, unsigned char **pp, long length,
|
||||
char *(*func)(), void (*free_func)(), int ex_tag, int ex_class)
|
||||
char *(*func)(), void (*free_func)(void *), int ex_tag, int ex_class)
|
||||
{
|
||||
ASN1_CTX c;
|
||||
STACK *ret=NULL;
|
||||
|
||||
if ((a == NULL) || ((*a) == NULL))
|
||||
{ if ((ret=sk_new(NULL)) == NULL) goto err; }
|
||||
{ if ((ret=sk_new_null()) == NULL) goto err; }
|
||||
else
|
||||
ret=(*a);
|
||||
|
||||
|
@ -108,9 +108,9 @@ int ASN1_sign(int (*i2d)(), X509_ALGOR *algor1, X509_ALGOR *algor2,
|
||||
}
|
||||
}
|
||||
inl=i2d(data,NULL);
|
||||
buf_in=(unsigned char *)Malloc((unsigned int)inl);
|
||||
buf_in=(unsigned char *)OPENSSL_malloc((unsigned int)inl);
|
||||
outll=outl=EVP_PKEY_size(pkey);
|
||||
buf_out=(unsigned char *)Malloc((unsigned int)outl);
|
||||
buf_out=(unsigned char *)OPENSSL_malloc((unsigned int)outl);
|
||||
if ((buf_in == NULL) || (buf_out == NULL))
|
||||
{
|
||||
outl=0;
|
||||
@ -129,7 +129,7 @@ int ASN1_sign(int (*i2d)(), X509_ALGOR *algor1, X509_ALGOR *algor2,
|
||||
ASN1err(ASN1_F_ASN1_SIGN,ERR_R_EVP_LIB);
|
||||
goto err;
|
||||
}
|
||||
if (signature->data != NULL) Free(signature->data);
|
||||
if (signature->data != NULL) OPENSSL_free(signature->data);
|
||||
signature->data=buf_out;
|
||||
buf_out=NULL;
|
||||
signature->length=outl;
|
||||
@ -141,8 +141,8 @@ int ASN1_sign(int (*i2d)(), X509_ALGOR *algor1, X509_ALGOR *algor2,
|
||||
err:
|
||||
memset(&ctx,0,sizeof(ctx));
|
||||
if (buf_in != NULL)
|
||||
{ memset((char *)buf_in,0,(unsigned int)inl); Free(buf_in); }
|
||||
{ memset((char *)buf_in,0,(unsigned int)inl); OPENSSL_free(buf_in); }
|
||||
if (buf_out != NULL)
|
||||
{ memset((char *)buf_out,0,outll); Free(buf_out); }
|
||||
{ memset((char *)buf_out,0,outll); OPENSSL_free(buf_out); }
|
||||
return(outl);
|
||||
}
|
||||
|
533
lib/libcrypto/asn1/a_strex.c
Normal file
533
lib/libcrypto/asn1/a_strex.c
Normal file
@ -0,0 +1,533 @@
|
||||
/* a_strex.c */
|
||||
/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL
|
||||
* project 2000.
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2000 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* licensing@OpenSSL.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <openssl/crypto.h>
|
||||
#include <openssl/x509.h>
|
||||
#include <openssl/asn1.h>
|
||||
|
||||
#include "charmap.h"
|
||||
|
||||
/* ASN1_STRING_print_ex() and X509_NAME_print_ex().
|
||||
* Enhanced string and name printing routines handling
|
||||
* multibyte characters, RFC2253 and a host of other
|
||||
* options.
|
||||
*/
|
||||
|
||||
|
||||
#define CHARTYPE_BS_ESC (ASN1_STRFLGS_ESC_2253 | CHARTYPE_FIRST_ESC_2253 | CHARTYPE_LAST_ESC_2253)
|
||||
|
||||
|
||||
/* Three IO functions for sending data to memory, a BIO and
|
||||
* and a FILE pointer.
|
||||
*/
|
||||
|
||||
int send_mem_chars(void *arg, const void *buf, int len)
|
||||
{
|
||||
unsigned char **out = arg;
|
||||
if(!out) return 1;
|
||||
memcpy(*out, buf, len);
|
||||
*out += len;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int send_bio_chars(void *arg, const void *buf, int len)
|
||||
{
|
||||
if(!arg) return 1;
|
||||
if(BIO_write(arg, buf, len) != len) return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int send_fp_chars(void *arg, const void *buf, int len)
|
||||
{
|
||||
if(!arg) return 1;
|
||||
if(fwrite(buf, 1, len, arg) != (unsigned int)len) return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
typedef int char_io(void *arg, const void *buf, int len);
|
||||
|
||||
/* This function handles display of
|
||||
* strings, one character at a time.
|
||||
* It is passed an unsigned long for each
|
||||
* character because it could come from 2 or even
|
||||
* 4 byte forms.
|
||||
*/
|
||||
|
||||
static int do_esc_char(unsigned long c, unsigned char flags, char *do_quotes, char_io *io_ch, void *arg)
|
||||
{
|
||||
unsigned char chflgs, chtmp;
|
||||
char tmphex[11];
|
||||
if(c > 0xffff) {
|
||||
BIO_snprintf(tmphex, 11, "\\W%08lX", c);
|
||||
if(!io_ch(arg, tmphex, 10)) return -1;
|
||||
return 10;
|
||||
}
|
||||
if(c > 0xff) {
|
||||
BIO_snprintf(tmphex, 11, "\\U%04lX", c);
|
||||
if(!io_ch(arg, tmphex, 6)) return -1;
|
||||
return 6;
|
||||
}
|
||||
chtmp = (unsigned char)c;
|
||||
if(chtmp > 0x7f) chflgs = flags & ASN1_STRFLGS_ESC_MSB;
|
||||
else chflgs = char_type[chtmp] & flags;
|
||||
if(chflgs & CHARTYPE_BS_ESC) {
|
||||
/* If we don't escape with quotes, signal we need quotes */
|
||||
if(chflgs & ASN1_STRFLGS_ESC_QUOTE) {
|
||||
if(do_quotes) *do_quotes = 1;
|
||||
if(!io_ch(arg, &chtmp, 1)) return -1;
|
||||
return 1;
|
||||
}
|
||||
if(!io_ch(arg, "\\", 1)) return -1;
|
||||
if(!io_ch(arg, &chtmp, 1)) return -1;
|
||||
return 2;
|
||||
}
|
||||
if(chflgs & (ASN1_STRFLGS_ESC_CTRL|ASN1_STRFLGS_ESC_MSB)) {
|
||||
BIO_snprintf(tmphex, 11, "\\%02X", chtmp);
|
||||
if(!io_ch(arg, tmphex, 3)) return -1;
|
||||
return 3;
|
||||
}
|
||||
if(!io_ch(arg, &chtmp, 1)) return -1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
#define BUF_TYPE_WIDTH_MASK 0x7
|
||||
#define BUF_TYPE_CONVUTF8 0x8
|
||||
|
||||
/* This function sends each character in a buffer to
|
||||
* do_esc_char(). It interprets the content formats
|
||||
* and converts to or from UTF8 as appropriate.
|
||||
*/
|
||||
|
||||
static int do_buf(unsigned char *buf, int buflen,
|
||||
int type, unsigned char flags, char *quotes, char_io *io_ch, void *arg)
|
||||
{
|
||||
int i, outlen, len;
|
||||
unsigned char orflags, *p, *q;
|
||||
unsigned long c;
|
||||
p = buf;
|
||||
q = buf + buflen;
|
||||
outlen = 0;
|
||||
while(p != q) {
|
||||
if(p == buf) orflags = CHARTYPE_FIRST_ESC_2253;
|
||||
else orflags = 0;
|
||||
switch(type & BUF_TYPE_WIDTH_MASK) {
|
||||
case 4:
|
||||
c = ((unsigned long)*p++) << 24;
|
||||
c |= ((unsigned long)*p++) << 16;
|
||||
c |= ((unsigned long)*p++) << 8;
|
||||
c |= *p++;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
c = ((unsigned long)*p++) << 8;
|
||||
c |= *p++;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
c = *p++;
|
||||
break;
|
||||
|
||||
case 0:
|
||||
i = UTF8_getc(p, buflen, &c);
|
||||
if(i < 0) return -1; /* Invalid UTF8String */
|
||||
p += i;
|
||||
break;
|
||||
}
|
||||
if (p == q) orflags = CHARTYPE_LAST_ESC_2253;
|
||||
if(type & BUF_TYPE_CONVUTF8) {
|
||||
unsigned char utfbuf[6];
|
||||
int utflen;
|
||||
utflen = UTF8_putc(utfbuf, 6, c);
|
||||
for(i = 0; i < utflen; i++) {
|
||||
/* We don't need to worry about setting orflags correctly
|
||||
* because if utflen==1 its value will be correct anyway
|
||||
* otherwise each character will be > 0x7f and so the
|
||||
* character will never be escaped on first and last.
|
||||
*/
|
||||
len = do_esc_char(utfbuf[i], (unsigned char)(flags | orflags), quotes, io_ch, arg);
|
||||
if(len < 0) return -1;
|
||||
outlen += len;
|
||||
}
|
||||
} else {
|
||||
len = do_esc_char(c, (unsigned char)(flags | orflags), quotes, io_ch, arg);
|
||||
if(len < 0) return -1;
|
||||
outlen += len;
|
||||
}
|
||||
}
|
||||
return outlen;
|
||||
}
|
||||
|
||||
/* This function hex dumps a buffer of characters */
|
||||
|
||||
static int do_hex_dump(char_io *io_ch, void *arg, unsigned char *buf, int buflen)
|
||||
{
|
||||
const static char hexdig[] = "0123456789ABCDEF";
|
||||
unsigned char *p, *q;
|
||||
char hextmp[2];
|
||||
if(arg) {
|
||||
p = buf;
|
||||
q = buf + buflen;
|
||||
while(p != q) {
|
||||
hextmp[0] = hexdig[*p >> 4];
|
||||
hextmp[1] = hexdig[*p & 0xf];
|
||||
if(!io_ch(arg, hextmp, 2)) return -1;
|
||||
p++;
|
||||
}
|
||||
}
|
||||
return buflen << 1;
|
||||
}
|
||||
|
||||
/* "dump" a string. This is done when the type is unknown,
|
||||
* or the flags request it. We can either dump the content
|
||||
* octets or the entire DER encoding. This uses the RFC2253
|
||||
* #01234 format.
|
||||
*/
|
||||
|
||||
int do_dump(unsigned long lflags, char_io *io_ch, void *arg, ASN1_STRING *str)
|
||||
{
|
||||
/* Placing the ASN1_STRING in a temp ASN1_TYPE allows
|
||||
* the DER encoding to readily obtained
|
||||
*/
|
||||
ASN1_TYPE t;
|
||||
unsigned char *der_buf, *p;
|
||||
int outlen, der_len;
|
||||
|
||||
if(!io_ch(arg, "#", 1)) return -1;
|
||||
/* If we don't dump DER encoding just dump content octets */
|
||||
if(!(lflags & ASN1_STRFLGS_DUMP_DER)) {
|
||||
outlen = do_hex_dump(io_ch, arg, str->data, str->length);
|
||||
if(outlen < 0) return -1;
|
||||
return outlen + 1;
|
||||
}
|
||||
t.type = str->type;
|
||||
t.value.ptr = (char *)str;
|
||||
der_len = i2d_ASN1_TYPE(&t, NULL);
|
||||
der_buf = OPENSSL_malloc(der_len);
|
||||
if(!der_buf) return -1;
|
||||
p = der_buf;
|
||||
i2d_ASN1_TYPE(&t, &p);
|
||||
outlen = do_hex_dump(io_ch, arg, der_buf, der_len);
|
||||
OPENSSL_free(der_buf);
|
||||
if(outlen < 0) return -1;
|
||||
return outlen + 1;
|
||||
}
|
||||
|
||||
/* Lookup table to convert tags to character widths,
|
||||
* 0 = UTF8 encoded, -1 is used for non string types
|
||||
* otherwise it is the number of bytes per character
|
||||
*/
|
||||
|
||||
const static char tag2nbyte[] = {
|
||||
-1, -1, -1, -1, -1, /* 0-4 */
|
||||
-1, -1, -1, -1, -1, /* 5-9 */
|
||||
-1, -1, 0, -1, /* 10-13 */
|
||||
-1, -1, -1, -1, /* 15-17 */
|
||||
-1, 1, 1, /* 18-20 */
|
||||
-1, 1, -1,-1, /* 21-24 */
|
||||
-1, 1, -1, /* 25-27 */
|
||||
4, -1, 2 /* 28-30 */
|
||||
};
|
||||
|
||||
#define ESC_FLAGS (ASN1_STRFLGS_ESC_2253 | \
|
||||
ASN1_STRFLGS_ESC_QUOTE | \
|
||||
ASN1_STRFLGS_ESC_CTRL | \
|
||||
ASN1_STRFLGS_ESC_MSB)
|
||||
|
||||
/* This is the main function, print out an
|
||||
* ASN1_STRING taking note of various escape
|
||||
* and display options. Returns number of
|
||||
* characters written or -1 if an error
|
||||
* occurred.
|
||||
*/
|
||||
|
||||
static int do_print_ex(char_io *io_ch, void *arg, unsigned long lflags, ASN1_STRING *str)
|
||||
{
|
||||
int outlen, len;
|
||||
int type;
|
||||
char quotes;
|
||||
unsigned char flags;
|
||||
quotes = 0;
|
||||
/* Keep a copy of escape flags */
|
||||
flags = (unsigned char)(lflags & ESC_FLAGS);
|
||||
|
||||
type = str->type;
|
||||
|
||||
outlen = 0;
|
||||
|
||||
|
||||
if(lflags & ASN1_STRFLGS_SHOW_TYPE) {
|
||||
const char *tagname;
|
||||
tagname = ASN1_tag2str(type);
|
||||
outlen += strlen(tagname);
|
||||
if(!io_ch(arg, tagname, outlen) || !io_ch(arg, ":", 1)) return -1;
|
||||
outlen++;
|
||||
}
|
||||
|
||||
/* Decide what to do with type, either dump content or display it */
|
||||
|
||||
/* Dump everything */
|
||||
if(lflags & ASN1_STRFLGS_DUMP_ALL) type = -1;
|
||||
/* Ignore the string type */
|
||||
else if(lflags & ASN1_STRFLGS_IGNORE_TYPE) type = 1;
|
||||
else {
|
||||
/* Else determine width based on type */
|
||||
if((type > 0) && (type < 31)) type = tag2nbyte[type];
|
||||
else type = -1;
|
||||
if((type == -1) && !(lflags & ASN1_STRFLGS_DUMP_UNKNOWN)) type = 1;
|
||||
}
|
||||
|
||||
if(type == -1) {
|
||||
len = do_dump(lflags, io_ch, arg, str);
|
||||
if(len < 0) return -1;
|
||||
outlen += len;
|
||||
return outlen;
|
||||
}
|
||||
|
||||
if(lflags & ASN1_STRFLGS_UTF8_CONVERT) {
|
||||
/* Note: if string is UTF8 and we want
|
||||
* to convert to UTF8 then we just interpret
|
||||
* it as 1 byte per character to avoid converting
|
||||
* twice.
|
||||
*/
|
||||
if(!type) type = 1;
|
||||
else type |= BUF_TYPE_CONVUTF8;
|
||||
}
|
||||
|
||||
len = do_buf(str->data, str->length, type, flags, "es, io_ch, NULL);
|
||||
if(outlen < 0) return -1;
|
||||
outlen += len;
|
||||
if(quotes) outlen += 2;
|
||||
if(!arg) return outlen;
|
||||
if(quotes && !io_ch(arg, "\"", 1)) return -1;
|
||||
do_buf(str->data, str->length, type, flags, NULL, io_ch, arg);
|
||||
if(quotes && !io_ch(arg, "\"", 1)) return -1;
|
||||
return outlen;
|
||||
}
|
||||
|
||||
/* Used for line indenting: print 'indent' spaces */
|
||||
|
||||
static int do_indent(char_io *io_ch, void *arg, int indent)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < indent; i++)
|
||||
if(!io_ch(arg, " ", 1)) return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static int do_name_ex(char_io *io_ch, void *arg, X509_NAME *n,
|
||||
int indent, unsigned long flags)
|
||||
{
|
||||
int i, prev = -1, orflags, cnt;
|
||||
int fn_opt, fn_nid;
|
||||
ASN1_OBJECT *fn;
|
||||
ASN1_STRING *val;
|
||||
X509_NAME_ENTRY *ent;
|
||||
char objtmp[80];
|
||||
const char *objbuf;
|
||||
int outlen, len;
|
||||
char *sep_dn, *sep_mv, *sep_eq;
|
||||
int sep_dn_len, sep_mv_len, sep_eq_len;
|
||||
if(indent < 0) indent = 0;
|
||||
outlen = indent;
|
||||
if(!do_indent(io_ch, arg, indent)) return -1;
|
||||
switch (flags & XN_FLAG_SEP_MASK)
|
||||
{
|
||||
case XN_FLAG_SEP_MULTILINE:
|
||||
sep_dn = "\n";
|
||||
sep_dn_len = 1;
|
||||
sep_mv = " + ";
|
||||
sep_mv_len = 3;
|
||||
break;
|
||||
|
||||
case XN_FLAG_SEP_COMMA_PLUS:
|
||||
sep_dn = ",";
|
||||
sep_dn_len = 1;
|
||||
sep_mv = "+";
|
||||
sep_mv_len = 1;
|
||||
indent = 0;
|
||||
break;
|
||||
|
||||
case XN_FLAG_SEP_CPLUS_SPC:
|
||||
sep_dn = ", ";
|
||||
sep_dn_len = 2;
|
||||
sep_mv = " + ";
|
||||
sep_mv_len = 3;
|
||||
indent = 0;
|
||||
break;
|
||||
|
||||
case XN_FLAG_SEP_SPLUS_SPC:
|
||||
sep_dn = "; ";
|
||||
sep_dn_len = 2;
|
||||
sep_mv = " + ";
|
||||
sep_mv_len = 3;
|
||||
indent = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(flags & XN_FLAG_SPC_EQ) {
|
||||
sep_eq = " = ";
|
||||
sep_eq_len = 3;
|
||||
} else {
|
||||
sep_eq = "=";
|
||||
sep_eq_len = 1;
|
||||
}
|
||||
|
||||
fn_opt = flags & XN_FLAG_FN_MASK;
|
||||
|
||||
cnt = X509_NAME_entry_count(n);
|
||||
for(i = 0; i < cnt; i++) {
|
||||
if(flags & XN_FLAG_DN_REV)
|
||||
ent = X509_NAME_get_entry(n, cnt - i - 1);
|
||||
else ent = X509_NAME_get_entry(n, i);
|
||||
if(prev != -1) {
|
||||
if(prev == ent->set) {
|
||||
if(!io_ch(arg, sep_mv, sep_mv_len)) return -1;
|
||||
outlen += sep_mv_len;
|
||||
} else {
|
||||
if(!io_ch(arg, sep_dn, sep_dn_len)) return -1;
|
||||
outlen += sep_dn_len;
|
||||
if(!do_indent(io_ch, arg, indent)) return -1;
|
||||
outlen += indent;
|
||||
}
|
||||
}
|
||||
prev = ent->set;
|
||||
fn = X509_NAME_ENTRY_get_object(ent);
|
||||
val = X509_NAME_ENTRY_get_data(ent);
|
||||
fn_nid = OBJ_obj2nid(fn);
|
||||
if(fn_opt != XN_FLAG_FN_NONE) {
|
||||
int objlen;
|
||||
if((fn_opt == XN_FLAG_FN_OID) || (fn_nid==NID_undef) ) {
|
||||
OBJ_obj2txt(objtmp, 80, fn, 1);
|
||||
objbuf = objtmp;
|
||||
} else {
|
||||
if(fn_opt == XN_FLAG_FN_SN)
|
||||
objbuf = OBJ_nid2sn(fn_nid);
|
||||
else if(fn_opt == XN_FLAG_FN_LN)
|
||||
objbuf = OBJ_nid2ln(fn_nid);
|
||||
else objbuf = "";
|
||||
}
|
||||
objlen = strlen(objbuf);
|
||||
if(!io_ch(arg, objbuf, objlen)) return -1;
|
||||
if(!io_ch(arg, sep_eq, sep_eq_len)) return -1;
|
||||
outlen += objlen + sep_eq_len;
|
||||
}
|
||||
/* If the field name is unknown then fix up the DER dump
|
||||
* flag. We might want to limit this further so it will
|
||||
* DER dump on anything other than a few 'standard' fields.
|
||||
*/
|
||||
if((fn_nid == NID_undef) && (flags & XN_FLAG_DUMP_UNKNOWN_FIELDS))
|
||||
orflags = ASN1_STRFLGS_DUMP_ALL;
|
||||
else orflags = 0;
|
||||
|
||||
len = do_print_ex(io_ch, arg, flags | orflags, val);
|
||||
if(len < 0) return -1;
|
||||
outlen += len;
|
||||
}
|
||||
return outlen;
|
||||
}
|
||||
|
||||
/* Wrappers round the main functions */
|
||||
|
||||
int X509_NAME_print_ex(BIO *out, X509_NAME *nm, int indent, unsigned long flags)
|
||||
{
|
||||
return do_name_ex(send_bio_chars, out, nm, indent, flags);
|
||||
}
|
||||
|
||||
|
||||
int X509_NAME_print_ex_fp(FILE *fp, X509_NAME *nm, int indent, unsigned long flags)
|
||||
{
|
||||
return do_name_ex(send_fp_chars, fp, nm, indent, flags);
|
||||
}
|
||||
|
||||
int ASN1_STRING_print_ex(BIO *out, ASN1_STRING *str, unsigned long flags)
|
||||
{
|
||||
return do_print_ex(send_bio_chars, out, flags, str);
|
||||
}
|
||||
|
||||
|
||||
int ASN1_STRING_print_ex_fp(FILE *fp, ASN1_STRING *str, unsigned long flags)
|
||||
{
|
||||
return do_print_ex(send_fp_chars, fp, flags, str);
|
||||
}
|
||||
|
||||
/* Utility function: convert any string type to UTF8, returns number of bytes
|
||||
* in output string or a negative error code
|
||||
*/
|
||||
|
||||
int ASN1_STRING_to_UTF8(unsigned char **out, ASN1_STRING *in)
|
||||
{
|
||||
ASN1_STRING stmp, *str = &stmp;
|
||||
int mbflag, type, ret;
|
||||
if(!*out || !in) return -1;
|
||||
type = in->type;
|
||||
if((type < 0) || (type > 30)) return -1;
|
||||
mbflag = tag2nbyte[type];
|
||||
if(mbflag == -1) return -1;
|
||||
mbflag |= MBSTRING_FLAG;
|
||||
stmp.data = NULL;
|
||||
ret = ASN1_mbstring_copy(&str, in->data, in->length, mbflag, B_ASN1_UTF8STRING);
|
||||
if(ret < 0) return ret;
|
||||
if(out) *out = stmp.data;
|
||||
return stmp.length;
|
||||
}
|
@ -65,8 +65,9 @@
|
||||
|
||||
static STACK_OF(ASN1_STRING_TABLE) *stable = NULL;
|
||||
static void st_free(ASN1_STRING_TABLE *tbl);
|
||||
static int sk_table_cmp(ASN1_STRING_TABLE **a, ASN1_STRING_TABLE **b);
|
||||
static int table_cmp(ASN1_STRING_TABLE *a, ASN1_STRING_TABLE *b);
|
||||
static int sk_table_cmp(const ASN1_STRING_TABLE * const *a,
|
||||
const ASN1_STRING_TABLE * const *b);
|
||||
static int table_cmp(const void *a, const void *b);
|
||||
|
||||
|
||||
/* This is the global mask for the mbstring functions: this is use to
|
||||
@ -173,14 +174,16 @@ static ASN1_STRING_TABLE tbl_standard[] = {
|
||||
{NID_dnQualifier, -1, -1, B_ASN1_PRINTABLESTRING, STABLE_NO_MASK}
|
||||
};
|
||||
|
||||
static int sk_table_cmp(ASN1_STRING_TABLE **a, ASN1_STRING_TABLE **b)
|
||||
static int sk_table_cmp(const ASN1_STRING_TABLE * const *a,
|
||||
const ASN1_STRING_TABLE * const *b)
|
||||
{
|
||||
return (*a)->nid - (*b)->nid;
|
||||
}
|
||||
|
||||
static int table_cmp(ASN1_STRING_TABLE *a, ASN1_STRING_TABLE *b)
|
||||
static int table_cmp(const void *a, const void *b)
|
||||
{
|
||||
return a->nid - b->nid;
|
||||
const ASN1_STRING_TABLE *sa = a, *sb = b;
|
||||
return sa->nid - sb->nid;
|
||||
}
|
||||
|
||||
ASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid)
|
||||
@ -192,7 +195,7 @@ ASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid)
|
||||
ttmp = (ASN1_STRING_TABLE *) OBJ_bsearch((char *)&fnd,
|
||||
(char *)tbl_standard,
|
||||
sizeof(tbl_standard)/sizeof(ASN1_STRING_TABLE),
|
||||
sizeof(ASN1_STRING_TABLE), (int(*)())table_cmp);
|
||||
sizeof(ASN1_STRING_TABLE), table_cmp);
|
||||
if(ttmp) return ttmp;
|
||||
if(!stable) return NULL;
|
||||
idx = sk_ASN1_STRING_TABLE_find(stable, &fnd);
|
||||
@ -213,7 +216,7 @@ int ASN1_STRING_TABLE_add(int nid,
|
||||
return 0;
|
||||
}
|
||||
if(!(tmp = ASN1_STRING_TABLE_get(nid))) {
|
||||
tmp = Malloc(sizeof(ASN1_STRING_TABLE));
|
||||
tmp = OPENSSL_malloc(sizeof(ASN1_STRING_TABLE));
|
||||
if(!tmp) {
|
||||
ASN1err(ASN1_F_ASN1_STRING_TABLE_ADD,
|
||||
ERR_R_MALLOC_FAILURE);
|
||||
@ -241,7 +244,7 @@ void ASN1_STRING_TABLE_cleanup(void)
|
||||
|
||||
static void st_free(ASN1_STRING_TABLE *tbl)
|
||||
{
|
||||
if(tbl->flags & STABLE_FLAGS_MALLOC) Free(tbl);
|
||||
if(tbl->flags & STABLE_FLAGS_MALLOC) OPENSSL_free(tbl);
|
||||
}
|
||||
|
||||
IMPLEMENT_STACK_OF(ASN1_STRING_TABLE)
|
||||
|
@ -113,11 +113,9 @@ ASN1_TIME *d2i_ASN1_TIME(ASN1_TIME **a, unsigned char **pp, long length)
|
||||
ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s, time_t t)
|
||||
{
|
||||
struct tm *ts;
|
||||
#if defined(THREADS) && !defined(WIN32)
|
||||
#if defined(THREADS) && !defined(WIN32) && !defined(__CYGWIN32__)
|
||||
struct tm data;
|
||||
#endif
|
||||
|
||||
#if defined(THREADS) && !defined(WIN32)
|
||||
gmtime_r(&t,&data);
|
||||
ts=&data; /* should return &data, but doesn't on some systems, so we don't even look at the return value */
|
||||
#else
|
||||
|
@ -123,6 +123,8 @@ int i2d_ASN1_TYPE(ASN1_TYPE *a, unsigned char **pp)
|
||||
break;
|
||||
case V_ASN1_SET:
|
||||
case V_ASN1_SEQUENCE:
|
||||
case V_ASN1_OTHER:
|
||||
default:
|
||||
if (a->value.set == NULL)
|
||||
r=0;
|
||||
else
|
||||
@ -159,6 +161,8 @@ ASN1_TYPE *d2i_ASN1_TYPE(ASN1_TYPE **a, unsigned char **pp, long length)
|
||||
|
||||
inf=ASN1_get_object(&q,&len,&tag,&xclass,length);
|
||||
if (inf & 0x80) goto err;
|
||||
/* If not universal tag we've no idea what it is */
|
||||
if(xclass != V_ASN1_UNIVERSAL) tag = V_ASN1_OTHER;
|
||||
|
||||
ASN1_TYPE_component_free(ret);
|
||||
|
||||
@ -245,6 +249,8 @@ ASN1_TYPE *d2i_ASN1_TYPE(ASN1_TYPE **a, unsigned char **pp, long length)
|
||||
break;
|
||||
case V_ASN1_SET:
|
||||
case V_ASN1_SEQUENCE:
|
||||
case V_ASN1_OTHER:
|
||||
default:
|
||||
/* Sets and sequences are left complete */
|
||||
if ((ret->value.set=ASN1_STRING_new()) == NULL) goto err;
|
||||
ret->value.set->type=tag;
|
||||
@ -252,9 +258,6 @@ ASN1_TYPE *d2i_ASN1_TYPE(ASN1_TYPE **a, unsigned char **pp, long length)
|
||||
if (!ASN1_STRING_set(ret->value.set,p,(int)len)) goto err;
|
||||
p+=len;
|
||||
break;
|
||||
default:
|
||||
ASN1err(ASN1_F_D2I_ASN1_TYPE,ASN1_R_BAD_TYPE);
|
||||
goto err;
|
||||
}
|
||||
|
||||
ret->type=tag;
|
||||
@ -282,7 +285,7 @@ void ASN1_TYPE_free(ASN1_TYPE *a)
|
||||
{
|
||||
if (a == NULL) return;
|
||||
ASN1_TYPE_component_free(a);
|
||||
Free(a);
|
||||
OPENSSL_free(a);
|
||||
}
|
||||
|
||||
int ASN1_TYPE_get(ASN1_TYPE *a)
|
||||
@ -312,6 +315,8 @@ static void ASN1_TYPE_component_free(ASN1_TYPE *a)
|
||||
case V_ASN1_OBJECT:
|
||||
ASN1_OBJECT_free(a->value.object);
|
||||
break;
|
||||
case V_ASN1_NULL:
|
||||
break;
|
||||
case V_ASN1_INTEGER:
|
||||
case V_ASN1_NEG_INTEGER:
|
||||
case V_ASN1_ENUMERATED:
|
||||
@ -333,10 +338,9 @@ static void ASN1_TYPE_component_free(ASN1_TYPE *a)
|
||||
case V_ASN1_UNIVERSALSTRING:
|
||||
case V_ASN1_BMPSTRING:
|
||||
case V_ASN1_UTF8STRING:
|
||||
ASN1_STRING_free((ASN1_STRING *)a->value.ptr);
|
||||
break;
|
||||
case V_ASN1_OTHER:
|
||||
default:
|
||||
/* MEMORY LEAK */
|
||||
ASN1_STRING_free((ASN1_STRING *)a->value.ptr);
|
||||
break;
|
||||
}
|
||||
a->type=0;
|
||||
|
@ -193,7 +193,8 @@ ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s, time_t t)
|
||||
{
|
||||
char *p;
|
||||
struct tm *ts;
|
||||
#if defined(THREADS) && !defined(WIN32)
|
||||
#if defined(THREADS) && !defined(WIN32) && !defined(__CYGWIN32__)
|
||||
|
||||
struct tm data;
|
||||
#endif
|
||||
|
||||
@ -202,7 +203,7 @@ ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s, time_t t)
|
||||
if (s == NULL)
|
||||
return(NULL);
|
||||
|
||||
#if defined(THREADS) && !defined(WIN32)
|
||||
#if defined(THREADS) && !defined(WIN32) && !defined(__CYGWIN32__)
|
||||
gmtime_r(&t,&data); /* should return &data, but doesn't on some systems, so we don't even look at the return value */
|
||||
ts=&data;
|
||||
#else
|
||||
@ -248,10 +249,10 @@ ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s, time_t t)
|
||||
p=(char *)s->data;
|
||||
if ((p == NULL) || (s->length < 14))
|
||||
{
|
||||
p=Malloc(20);
|
||||
p=OPENSSL_malloc(20);
|
||||
if (p == NULL) return(NULL);
|
||||
if (s->data != NULL)
|
||||
Free(s->data);
|
||||
OPENSSL_free(s->data);
|
||||
s->data=(unsigned char *)p;
|
||||
}
|
||||
|
||||
@ -264,3 +265,84 @@ ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s, time_t t)
|
||||
#endif
|
||||
return(s);
|
||||
}
|
||||
|
||||
|
||||
int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t)
|
||||
{
|
||||
struct tm *tm;
|
||||
int offset;
|
||||
int year;
|
||||
|
||||
#define g2(p) (((p)[0]-'0')*10+(p)[1]-'0')
|
||||
|
||||
if (s->data[12] == 'Z')
|
||||
offset=0;
|
||||
else
|
||||
{
|
||||
offset = g2(s->data+13)*60+g2(s->data+15);
|
||||
if (s->data[12] == '-')
|
||||
offset = -offset;
|
||||
}
|
||||
|
||||
t -= offset*60; /* FIXME: may overflow in extreme cases */
|
||||
|
||||
#if defined(THREADS) && !defined(WIN32) && !defined(__CYGWIN32__)
|
||||
{ struct tm data; gmtime_r(&t, &data); tm = &data; }
|
||||
#else
|
||||
tm = gmtime(&t);
|
||||
#endif
|
||||
|
||||
#define return_cmp(a,b) if ((a)<(b)) return -1; else if ((a)>(b)) return 1
|
||||
year = g2(s->data);
|
||||
if (year < 50)
|
||||
year += 100;
|
||||
return_cmp(year, tm->tm_year);
|
||||
return_cmp(g2(s->data+2) - 1, tm->tm_mon);
|
||||
return_cmp(g2(s->data+4), tm->tm_mday);
|
||||
return_cmp(g2(s->data+6), tm->tm_hour);
|
||||
return_cmp(g2(s->data+8), tm->tm_min);
|
||||
return_cmp(g2(s->data+10), tm->tm_sec);
|
||||
#undef g2
|
||||
#undef return_cmp
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
time_t ASN1_UTCTIME_get(const ASN1_UTCTIME *s)
|
||||
{
|
||||
struct tm tm;
|
||||
int offset;
|
||||
|
||||
memset(&tm,'\0',sizeof tm);
|
||||
|
||||
#define g2(p) (((p)[0]-'0')*10+(p)[1]-'0')
|
||||
tm.tm_year=g2(s->data);
|
||||
if(tm.tm_year < 50)
|
||||
tm.tm_year+=100;
|
||||
tm.tm_mon=g2(s->data+2)-1;
|
||||
tm.tm_mday=g2(s->data+4);
|
||||
tm.tm_hour=g2(s->data+6);
|
||||
tm.tm_min=g2(s->data+8);
|
||||
tm.tm_sec=g2(s->data+10);
|
||||
if(s->data[12] == 'Z')
|
||||
offset=0;
|
||||
else
|
||||
{
|
||||
offset=g2(s->data+13)*60+g2(s->data+15);
|
||||
if(s->data[12] == '-')
|
||||
offset= -offset;
|
||||
}
|
||||
#undef g2
|
||||
|
||||
return mktime(&tm)-offset*60; /* FIXME: mktime assumes the current timezone
|
||||
* instead of UTC, and unless we rewrite OpenSSL
|
||||
* in Lisp we cannot locally change the timezone
|
||||
* without possibly interfering with other parts
|
||||
* of the program. timegm, which uses UTC, is
|
||||
* non-standard.
|
||||
* Also time_t is inappropriate for general
|
||||
* UTC times because it may a 32 bit type. */
|
||||
}
|
||||
#endif
|
||||
|
@ -133,7 +133,7 @@ int UTF8_getc(const unsigned char *str, int len, unsigned long *val)
|
||||
if( ((p[1] & 0xc0) != 0x80)
|
||||
|| ((p[2] & 0xc0) != 0x80)
|
||||
|| ((p[3] & 0xc0) != 0x80) ) return -3;
|
||||
value = (*p++ & 0x7) << 18;
|
||||
value = ((unsigned long)(*p++ & 0x7)) << 18;
|
||||
value |= (*p++ & 0x3f) << 12;
|
||||
value |= (*p++ & 0x3f) << 6;
|
||||
value |= *p++ & 0x3f;
|
||||
@ -145,9 +145,9 @@ int UTF8_getc(const unsigned char *str, int len, unsigned long *val)
|
||||
|| ((p[2] & 0xc0) != 0x80)
|
||||
|| ((p[3] & 0xc0) != 0x80)
|
||||
|| ((p[4] & 0xc0) != 0x80) ) return -3;
|
||||
value = (*p++ & 0x3) << 24;
|
||||
value |= (*p++ & 0x3f) << 18;
|
||||
value |= (*p++ & 0x3f) << 12;
|
||||
value = ((unsigned long)(*p++ & 0x3)) << 24;
|
||||
value |= ((unsigned long)(*p++ & 0x3f)) << 18;
|
||||
value |= ((unsigned long)(*p++ & 0x3f)) << 12;
|
||||
value |= (*p++ & 0x3f) << 6;
|
||||
value |= *p++ & 0x3f;
|
||||
if(value < 0x200000) return -4;
|
||||
@ -159,10 +159,10 @@ int UTF8_getc(const unsigned char *str, int len, unsigned long *val)
|
||||
|| ((p[3] & 0xc0) != 0x80)
|
||||
|| ((p[4] & 0xc0) != 0x80)
|
||||
|| ((p[5] & 0xc0) != 0x80) ) return -3;
|
||||
value = (*p++ & 0x1) << 30;
|
||||
value |= (*p++ & 0x3f) << 24;
|
||||
value |= (*p++ & 0x3f) << 18;
|
||||
value |= (*p++ & 0x3f) << 12;
|
||||
value = ((unsigned long)(*p++ & 0x1)) << 30;
|
||||
value |= ((unsigned long)(*p++ & 0x3f)) << 24;
|
||||
value |= ((unsigned long)(*p++ & 0x3f)) << 18;
|
||||
value |= ((unsigned long)(*p++ & 0x3f)) << 12;
|
||||
value |= (*p++ & 0x3f) << 6;
|
||||
value |= *p++ & 0x3f;
|
||||
if(value < 0x4000000) return -4;
|
||||
|
@ -88,7 +88,7 @@ int ASN1_verify(int (*i2d)(), X509_ALGOR *a, ASN1_BIT_STRING *signature,
|
||||
}
|
||||
|
||||
inl=i2d(data,NULL);
|
||||
buf_in=Malloc((unsigned int)inl);
|
||||
buf_in=OPENSSL_malloc((unsigned int)inl);
|
||||
if (buf_in == NULL)
|
||||
{
|
||||
ASN1err(ASN1_F_ASN1_VERIFY,ERR_R_MALLOC_FAILURE);
|
||||
@ -101,7 +101,7 @@ int ASN1_verify(int (*i2d)(), X509_ALGOR *a, ASN1_BIT_STRING *signature,
|
||||
EVP_VerifyUpdate(&ctx,(unsigned char *)buf_in,inl);
|
||||
|
||||
memset(buf_in,0,(unsigned int)inl);
|
||||
Free(buf_in);
|
||||
OPENSSL_free(buf_in);
|
||||
|
||||
if (EVP_VerifyFinal(&ctx,(unsigned char *)signature->data,
|
||||
(unsigned int)signature->length,pkey) <= 0)
|
||||
|
@ -59,17 +59,18 @@
|
||||
#ifndef HEADER_ASN1_H
|
||||
#define HEADER_ASN1_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <time.h>
|
||||
#ifndef NO_BIO
|
||||
#include <openssl/bio.h>
|
||||
#endif
|
||||
#include <openssl/bn.h>
|
||||
#include <openssl/stack.h>
|
||||
#include <openssl/safestack.h>
|
||||
|
||||
#ifdef VMS
|
||||
#include <openssl/vms_idhacks.h>
|
||||
#include <openssl/symhacks.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define V_ASN1_UNIVERSAL 0x00
|
||||
@ -82,12 +83,15 @@ extern "C" {
|
||||
#define V_ASN1_PRIMATIVE_TAG 0x1f
|
||||
|
||||
#define V_ASN1_APP_CHOOSE -2 /* let the recipient choose */
|
||||
#define V_ASN1_OTHER -3 /* used in ASN1_TYPE */
|
||||
|
||||
#define V_ASN1_NEG 0x100 /* negative flag */
|
||||
|
||||
#define V_ASN1_UNDEF -1
|
||||
#define V_ASN1_EOC 0
|
||||
#define V_ASN1_BOOLEAN 1 /**/
|
||||
#define V_ASN1_INTEGER 2
|
||||
#define V_ASN1_NEG_INTEGER (2+0x100)
|
||||
#define V_ASN1_NEG_INTEGER (2 | V_ASN1_NEG)
|
||||
#define V_ASN1_BIT_STRING 3
|
||||
#define V_ASN1_OCTET_STRING 4
|
||||
#define V_ASN1_NULL 5
|
||||
@ -96,7 +100,7 @@ extern "C" {
|
||||
#define V_ASN1_EXTERNAL 8
|
||||
#define V_ASN1_REAL 9
|
||||
#define V_ASN1_ENUMERATED 10
|
||||
#define V_ASN1_NEG_ENUMERATED (10+0x100)
|
||||
#define V_ASN1_NEG_ENUMERATED (10 | V_ASN1_NEG)
|
||||
#define V_ASN1_UTF8STRING 12
|
||||
#define V_ASN1_SEQUENCE 16
|
||||
#define V_ASN1_SET 17
|
||||
@ -140,32 +144,10 @@ extern "C" {
|
||||
#define MBSTRING_UNIV (MBSTRING_FLAG|3)
|
||||
#define MBSTRING_UTF8 (MBSTRING_FLAG|4)
|
||||
|
||||
#define DECLARE_ASN1_SET_OF(type) \
|
||||
int i2d_ASN1_SET_OF_##type(STACK_OF(type) *a,unsigned char **pp, \
|
||||
int (*func)(type *,unsigned char **), int ex_tag, \
|
||||
int ex_class, int is_set); \
|
||||
STACK_OF(type) *d2i_ASN1_SET_OF_##type(STACK_OF(type) **a,unsigned char **pp, \
|
||||
long length, \
|
||||
type *(*func)(type **, \
|
||||
unsigned char **,long), \
|
||||
void (*free_func)(type *), \
|
||||
int ex_tag,int ex_class);
|
||||
struct X509_algor_st;
|
||||
|
||||
#define IMPLEMENT_ASN1_SET_OF(type) \
|
||||
int i2d_ASN1_SET_OF_##type(STACK_OF(type) *a,unsigned char **pp, \
|
||||
int (*func)(type *,unsigned char **), int ex_tag, \
|
||||
int ex_class, int is_set) \
|
||||
{ return i2d_ASN1_SET((STACK *)a,pp,func,ex_tag,ex_class,is_set); } \
|
||||
STACK_OF(type) *d2i_ASN1_SET_OF_##type(STACK_OF(type) **a,unsigned char **pp, \
|
||||
long length, \
|
||||
type *(*func)(type **, \
|
||||
unsigned char **,long), \
|
||||
void (*free_func)(type *), \
|
||||
int ex_tag,int ex_class) \
|
||||
{ return (STACK_OF(type) *)d2i_ASN1_SET((STACK **)a,pp,length, \
|
||||
(char *(*)())func, \
|
||||
(void (*)())free_func, \
|
||||
ex_tag,ex_class); }
|
||||
#define DECLARE_ASN1_SET_OF(type) /* filled in by mkstack.pl */
|
||||
#define IMPLEMENT_ASN1_SET_OF(type) /* nothing, no longer needed */
|
||||
|
||||
typedef struct asn1_ctx_st
|
||||
{
|
||||
@ -254,6 +236,7 @@ DECLARE_STACK_OF(ASN1_STRING_TABLE)
|
||||
#define ASN1_BMPSTRING ASN1_STRING
|
||||
#define ASN1_VISIBLESTRING ASN1_STRING
|
||||
#define ASN1_UTF8STRING ASN1_STRING
|
||||
#define ASN1_BOOLEAN int
|
||||
#else
|
||||
typedef struct asn1_string_st ASN1_INTEGER;
|
||||
typedef struct asn1_string_st ASN1_ENUMERATED;
|
||||
@ -270,15 +253,99 @@ typedef struct asn1_string_st ASN1_TIME;
|
||||
typedef struct asn1_string_st ASN1_GENERALIZEDTIME;
|
||||
typedef struct asn1_string_st ASN1_VISIBLESTRING;
|
||||
typedef struct asn1_string_st ASN1_UTF8STRING;
|
||||
typedef int ASN1_BOOLEAN;
|
||||
#endif
|
||||
|
||||
typedef int ASN1_NULL;
|
||||
|
||||
/* Parameters used by ASN1_STRING_print_ex() */
|
||||
|
||||
/* These determine which characters to escape:
|
||||
* RFC2253 special characters, control characters and
|
||||
* MSB set characters
|
||||
*/
|
||||
|
||||
#define ASN1_STRFLGS_ESC_2253 1
|
||||
#define ASN1_STRFLGS_ESC_CTRL 2
|
||||
#define ASN1_STRFLGS_ESC_MSB 4
|
||||
|
||||
|
||||
/* This flag determines how we do escaping: normally
|
||||
* RC2253 backslash only, set this to use backslash and
|
||||
* quote.
|
||||
*/
|
||||
|
||||
#define ASN1_STRFLGS_ESC_QUOTE 8
|
||||
|
||||
|
||||
/* These three flags are internal use only. */
|
||||
|
||||
/* Character is a valid PrintableString character */
|
||||
#define CHARTYPE_PRINTABLESTRING 0x10
|
||||
/* Character needs escaping if it is the first character */
|
||||
#define CHARTYPE_FIRST_ESC_2253 0x20
|
||||
/* Character needs escaping if it is the last character */
|
||||
#define CHARTYPE_LAST_ESC_2253 0x40
|
||||
|
||||
/* NB the internal flags are safely reused below by flags
|
||||
* handled at the top level.
|
||||
*/
|
||||
|
||||
/* If this is set we convert all character strings
|
||||
* to UTF8 first
|
||||
*/
|
||||
|
||||
#define ASN1_STRFLGS_UTF8_CONVERT 0x10
|
||||
|
||||
/* If this is set we don't attempt to interpret content:
|
||||
* just assume all strings are 1 byte per character. This
|
||||
* will produce some pretty odd looking output!
|
||||
*/
|
||||
|
||||
#define ASN1_STRFLGS_IGNORE_TYPE 0x20
|
||||
|
||||
/* If this is set we include the string type in the output */
|
||||
#define ASN1_STRFLGS_SHOW_TYPE 0x40
|
||||
|
||||
/* This determines which strings to display and which to
|
||||
* 'dump' (hex dump of content octets or DER encoding). We can
|
||||
* only dump non character strings or everything. If we
|
||||
* don't dump 'unknown' they are interpreted as character
|
||||
* strings with 1 octet per character and are subject to
|
||||
* the usual escaping options.
|
||||
*/
|
||||
|
||||
#define ASN1_STRFLGS_DUMP_ALL 0x80
|
||||
#define ASN1_STRFLGS_DUMP_UNKNOWN 0x100
|
||||
|
||||
/* These determine what 'dumping' does, we can dump the
|
||||
* content octets or the DER encoding: both use the
|
||||
* RFC2253 #XXXXX notation.
|
||||
*/
|
||||
|
||||
#define ASN1_STRFLGS_DUMP_DER 0x200
|
||||
|
||||
/* All the string flags consistent with RFC2253,
|
||||
* escaping control characters isn't essential in
|
||||
* RFC2253 but it is advisable anyway.
|
||||
*/
|
||||
|
||||
#define ASN1_STRFLGS_RFC2253 (ASN1_STRFLGS_ESC_2253 | \
|
||||
ASN1_STRFLGS_ESC_CTRL | \
|
||||
ASN1_STRFLGS_ESC_MSB | \
|
||||
ASN1_STRFLGS_UTF8_CONVERT | \
|
||||
ASN1_STRFLGS_DUMP_UNKNOWN | \
|
||||
ASN1_STRFLGS_DUMP_DER)
|
||||
|
||||
DECLARE_STACK_OF(ASN1_INTEGER)
|
||||
DECLARE_ASN1_SET_OF(ASN1_INTEGER)
|
||||
|
||||
typedef struct asn1_type_st
|
||||
{
|
||||
int type;
|
||||
union {
|
||||
char *ptr;
|
||||
ASN1_BOOLEAN boolean;
|
||||
ASN1_STRING * asn1_string;
|
||||
ASN1_OBJECT * object;
|
||||
ASN1_INTEGER * integer;
|
||||
@ -520,6 +587,8 @@ void ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value);
|
||||
ASN1_OBJECT * ASN1_OBJECT_new(void );
|
||||
void ASN1_OBJECT_free(ASN1_OBJECT *a);
|
||||
int i2d_ASN1_OBJECT(ASN1_OBJECT *a,unsigned char **pp);
|
||||
ASN1_OBJECT * c2i_ASN1_OBJECT(ASN1_OBJECT **a,unsigned char **pp,
|
||||
long length);
|
||||
ASN1_OBJECT * d2i_ASN1_OBJECT(ASN1_OBJECT **a,unsigned char **pp,
|
||||
long length);
|
||||
|
||||
@ -542,14 +611,17 @@ unsigned char * ASN1_STRING_data(ASN1_STRING *x);
|
||||
ASN1_BIT_STRING * ASN1_BIT_STRING_new(void);
|
||||
void ASN1_BIT_STRING_free(ASN1_BIT_STRING *a);
|
||||
int i2d_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 *d2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,unsigned char **pp,
|
||||
long length);
|
||||
ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,unsigned char **pp,
|
||||
long length);
|
||||
int ASN1_BIT_STRING_set(ASN1_BIT_STRING *a, unsigned char *d,
|
||||
int length );
|
||||
int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value);
|
||||
int ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *a, int n);
|
||||
|
||||
#ifdef HEADER_BIO_H
|
||||
#ifndef NO_BIO
|
||||
int ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs,
|
||||
BIT_STRING_BITNAME *tbl, int indent);
|
||||
#endif
|
||||
@ -563,8 +635,11 @@ int d2i_ASN1_BOOLEAN(int *a,unsigned char **pp,long length);
|
||||
ASN1_INTEGER * ASN1_INTEGER_new(void);
|
||||
void ASN1_INTEGER_free(ASN1_INTEGER *a);
|
||||
int i2d_ASN1_INTEGER(ASN1_INTEGER *a,unsigned char **pp);
|
||||
int i2c_ASN1_INTEGER(ASN1_INTEGER *a,unsigned char **pp);
|
||||
ASN1_INTEGER *d2i_ASN1_INTEGER(ASN1_INTEGER **a,unsigned char **pp,
|
||||
long length);
|
||||
ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a,unsigned char **pp,
|
||||
long length);
|
||||
ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a,unsigned char **pp,
|
||||
long length);
|
||||
ASN1_INTEGER * ASN1_INTEGER_dup(ASN1_INTEGER *x);
|
||||
@ -579,6 +654,10 @@ ASN1_ENUMERATED *d2i_ASN1_ENUMERATED(ASN1_ENUMERATED **a,unsigned char **pp,
|
||||
int ASN1_UTCTIME_check(ASN1_UTCTIME *a);
|
||||
ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s,time_t t);
|
||||
int ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, char *str);
|
||||
int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t);
|
||||
#if 0
|
||||
time_t ASN1_UTCTIME_get(const ASN1_UTCTIME *s);
|
||||
#endif
|
||||
|
||||
int ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME *a);
|
||||
ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s,time_t t);
|
||||
@ -673,10 +752,10 @@ ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s,time_t t);
|
||||
int i2d_ASN1_SET(STACK *a, unsigned char **pp,
|
||||
int (*func)(), int ex_tag, int ex_class, int is_set);
|
||||
STACK * d2i_ASN1_SET(STACK **a, unsigned char **pp, long length,
|
||||
char *(*func)(), void (*free_func)(),
|
||||
char *(*func)(), void (*free_func)(void *),
|
||||
int ex_tag, int ex_class);
|
||||
|
||||
#ifdef HEADER_BIO_H
|
||||
#ifndef NO_BIO
|
||||
int i2a_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *a);
|
||||
int a2i_ASN1_INTEGER(BIO *bp,ASN1_INTEGER *bs,char *buf,int size);
|
||||
int i2a_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *a);
|
||||
@ -729,16 +808,21 @@ char *ASN1_dup(int (*i2d)(),char *(*d2i)(),char *x);
|
||||
#ifndef NO_FP_API
|
||||
char *ASN1_d2i_fp(char *(*xnew)(),char *(*d2i)(),FILE *fp,unsigned char **x);
|
||||
int ASN1_i2d_fp(int (*i2d)(),FILE *out,unsigned char *x);
|
||||
int ASN1_STRING_print_ex_fp(FILE *fp, ASN1_STRING *str, unsigned long flags);
|
||||
#endif
|
||||
|
||||
#ifdef HEADER_BIO_H
|
||||
int ASN1_STRING_to_UTF8(unsigned char **out, ASN1_STRING *in);
|
||||
|
||||
#ifndef NO_BIO
|
||||
char *ASN1_d2i_bio(char *(*xnew)(),char *(*d2i)(),BIO *bp,unsigned char **x);
|
||||
int ASN1_i2d_bio(int (*i2d)(),BIO *out,unsigned char *x);
|
||||
int ASN1_UTCTIME_print(BIO *fp,ASN1_UTCTIME *a);
|
||||
int ASN1_GENERALIZEDTIME_print(BIO *fp,ASN1_GENERALIZEDTIME *a);
|
||||
int ASN1_TIME_print(BIO *fp,ASN1_TIME *a);
|
||||
int ASN1_STRING_print(BIO *bp,ASN1_STRING *v);
|
||||
int ASN1_STRING_print_ex(BIO *out, ASN1_STRING *str, unsigned long flags);
|
||||
int ASN1_parse(BIO *bp,unsigned char *pp,long len,int indent);
|
||||
int ASN1_parse_dump(BIO *bp,unsigned char *pp,long len,int indent,int dump);
|
||||
#endif
|
||||
const char *ASN1_tag2str(int tag);
|
||||
|
||||
@ -768,9 +852,9 @@ int ASN1_TYPE_get_int_octetstring(ASN1_TYPE *a,long *num,
|
||||
unsigned char *data, int max_len);
|
||||
|
||||
STACK *ASN1_seq_unpack(unsigned char *buf, int len, char *(*d2i)(),
|
||||
void (*free_func)() );
|
||||
void (*free_func)(void *) );
|
||||
unsigned char *ASN1_seq_pack(STACK *safes, int (*i2d)(), unsigned char **buf,
|
||||
int *len );
|
||||
int *len );
|
||||
void *ASN1_unpack_string(ASN1_STRING *oct, char *(*d2i)());
|
||||
ASN1_STRING *ASN1_pack_string(void *obj, int (*i2d)(), ASN1_OCTET_STRING **oct);
|
||||
|
||||
|
@ -181,7 +181,7 @@ void ASN1_put_object(unsigned char **pp, int constructed, int length, int tag,
|
||||
int xclass)
|
||||
{
|
||||
unsigned char *p= *pp;
|
||||
int i;
|
||||
int i, ttag;
|
||||
|
||||
i=(constructed)?V_ASN1_CONSTRUCTED:0;
|
||||
i|=(xclass&V_ASN1_PRIVATE);
|
||||
@ -190,12 +190,15 @@ void ASN1_put_object(unsigned char **pp, int constructed, int length, int tag,
|
||||
else
|
||||
{
|
||||
*(p++)=i|V_ASN1_PRIMITIVE_TAG;
|
||||
while (tag > 0x7f)
|
||||
for(i = 0, ttag = tag; ttag > 0; i++) ttag >>=7;
|
||||
ttag = i;
|
||||
while(i-- > 0)
|
||||
{
|
||||
*(p++)=(tag&0x7f)|0x80;
|
||||
tag>>=7;
|
||||
p[i] = tag & 0x7f;
|
||||
if(i != (ttag - 1)) p[i] |= 0x80;
|
||||
tag >>= 7;
|
||||
}
|
||||
*(p++)=(tag&0x7f);
|
||||
p += ttag;
|
||||
}
|
||||
if ((constructed == 2) && (length == 0))
|
||||
*(p++)=0x80; /* der_put_length would output 0 instead */
|
||||
@ -335,9 +338,9 @@ int ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len)
|
||||
{
|
||||
c=str->data;
|
||||
if (c == NULL)
|
||||
str->data=Malloc(len+1);
|
||||
str->data=OPENSSL_malloc(len+1);
|
||||
else
|
||||
str->data=Realloc(c,len+1);
|
||||
str->data=OPENSSL_realloc(c,len+1);
|
||||
|
||||
if (str->data == NULL)
|
||||
{
|
||||
@ -365,7 +368,7 @@ ASN1_STRING *ASN1_STRING_type_new(int type)
|
||||
{
|
||||
ASN1_STRING *ret;
|
||||
|
||||
ret=(ASN1_STRING *)Malloc(sizeof(ASN1_STRING));
|
||||
ret=(ASN1_STRING *)OPENSSL_malloc(sizeof(ASN1_STRING));
|
||||
if (ret == NULL)
|
||||
{
|
||||
ASN1err(ASN1_F_ASN1_STRING_TYPE_NEW,ERR_R_MALLOC_FAILURE);
|
||||
@ -381,8 +384,8 @@ ASN1_STRING *ASN1_STRING_type_new(int type)
|
||||
void ASN1_STRING_free(ASN1_STRING *a)
|
||||
{
|
||||
if (a == NULL) return;
|
||||
if (a->data != NULL) Free(a->data);
|
||||
Free(a);
|
||||
if (a->data != NULL) OPENSSL_free(a->data);
|
||||
OPENSSL_free(a);
|
||||
}
|
||||
|
||||
int ASN1_STRING_cmp(ASN1_STRING *a, ASN1_STRING *b)
|
||||
|
@ -59,12 +59,12 @@
|
||||
#ifndef HEADER_ASN1_MAC_H
|
||||
#define HEADER_ASN1_MAC_H
|
||||
|
||||
#include <openssl/asn1.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <openssl/asn1.h>
|
||||
|
||||
#ifndef ASN1_MAC_ERR_LIB
|
||||
#define ASN1_MAC_ERR_LIB ERR_LIB_ASN1
|
||||
#endif
|
||||
@ -340,7 +340,7 @@ err:\
|
||||
|
||||
/* New macros */
|
||||
#define M_ASN1_New_Malloc(ret,type) \
|
||||
if ((ret=(type *)Malloc(sizeof(type))) == NULL) \
|
||||
if ((ret=(type *)OPENSSL_malloc(sizeof(type))) == NULL) \
|
||||
{ c.line=__LINE__; goto err2; }
|
||||
|
||||
#define M_ASN1_New(arg,func) \
|
||||
|
@ -65,7 +65,7 @@
|
||||
static int asn1_print_info(BIO *bp, int tag, int xclass,int constructed,
|
||||
int indent);
|
||||
static int asn1_parse2(BIO *bp, unsigned char **pp, long length,
|
||||
int offset, int depth, int indent);
|
||||
int offset, int depth, int indent, int dump);
|
||||
static int asn1_print_info(BIO *bp, int tag, int xclass, int constructed,
|
||||
int indent)
|
||||
{
|
||||
@ -110,11 +110,16 @@ err:
|
||||
|
||||
int ASN1_parse(BIO *bp, unsigned char *pp, long len, int indent)
|
||||
{
|
||||
return(asn1_parse2(bp,&pp,len,0,0,indent));
|
||||
return(asn1_parse2(bp,&pp,len,0,0,indent,0));
|
||||
}
|
||||
|
||||
int ASN1_parse_dump(BIO *bp, unsigned char *pp, long len, int indent, int dump)
|
||||
{
|
||||
return(asn1_parse2(bp,&pp,len,0,0,indent,dump));
|
||||
}
|
||||
|
||||
static int asn1_parse2(BIO *bp, unsigned char **pp, long length, int offset,
|
||||
int depth, int indent)
|
||||
int depth, int indent, int dump)
|
||||
{
|
||||
unsigned char *p,*ep,*tot,*op,*opp;
|
||||
long len;
|
||||
@ -123,7 +128,13 @@ static int asn1_parse2(BIO *bp, unsigned char **pp, long length, int offset,
|
||||
ASN1_OBJECT *o=NULL;
|
||||
ASN1_OCTET_STRING *os=NULL;
|
||||
/* ASN1_BMPSTRING *bmp=NULL;*/
|
||||
int dump_indent;
|
||||
|
||||
#if 0
|
||||
dump_indent = indent;
|
||||
#else
|
||||
dump_indent = 6; /* Because we know BIO_dump_indent() */
|
||||
#endif
|
||||
p= *pp;
|
||||
tot=p+length;
|
||||
op=p-1;
|
||||
@ -178,7 +189,7 @@ static int asn1_parse2(BIO *bp, unsigned char **pp, long length, int offset,
|
||||
{
|
||||
r=asn1_parse2(bp,&p,(long)(tot-p),
|
||||
offset+(p - *pp),depth+1,
|
||||
indent);
|
||||
indent,dump);
|
||||
if (r == 0) { ret=0; goto end; }
|
||||
if ((r == 2) || (p >= tot)) break;
|
||||
}
|
||||
@ -188,7 +199,7 @@ static int asn1_parse2(BIO *bp, unsigned char **pp, long length, int offset,
|
||||
{
|
||||
r=asn1_parse2(bp,&p,(long)len,
|
||||
offset+(p - *pp),depth+1,
|
||||
indent);
|
||||
indent,dump);
|
||||
if (r == 0) { ret=0; goto end; }
|
||||
}
|
||||
}
|
||||
@ -273,6 +284,20 @@ static int asn1_parse2(BIO *bp, unsigned char **pp, long length, int offset,
|
||||
os->length) <= 0)
|
||||
goto end;
|
||||
}
|
||||
if (!printable && (os->length > 0)
|
||||
&& dump)
|
||||
{
|
||||
if (!nl)
|
||||
{
|
||||
if (BIO_write(bp,"\n",1) <= 0)
|
||||
goto end;
|
||||
}
|
||||
if (BIO_dump_indent(bp,(char *)opp,
|
||||
((dump == -1 || dump > os->length)?os->length:dump),
|
||||
dump_indent) <= 0)
|
||||
goto end;
|
||||
nl=1;
|
||||
}
|
||||
M_ASN1_OCTET_STRING_free(os);
|
||||
os=NULL;
|
||||
}
|
||||
@ -341,6 +366,19 @@ static int asn1_parse2(BIO *bp, unsigned char **pp, long length, int offset,
|
||||
}
|
||||
M_ASN1_ENUMERATED_free(bs);
|
||||
}
|
||||
else if (len > 0 && dump)
|
||||
{
|
||||
if (!nl)
|
||||
{
|
||||
if (BIO_write(bp,"\n",1) <= 0)
|
||||
goto end;
|
||||
}
|
||||
if (BIO_dump_indent(bp,(char *)p,
|
||||
((dump == -1 || dump > len)?len:dump),
|
||||
dump_indent) <= 0)
|
||||
goto end;
|
||||
nl=1;
|
||||
}
|
||||
|
||||
if (!nl)
|
||||
{
|
||||
|
@ -65,7 +65,7 @@
|
||||
/* Turn an ASN1 encoded SEQUENCE OF into a STACK of structures */
|
||||
|
||||
STACK *ASN1_seq_unpack(unsigned char *buf, int len, char *(*d2i)(),
|
||||
void (*free_func)())
|
||||
void (*free_func)(void *))
|
||||
{
|
||||
STACK *sk;
|
||||
unsigned char *pbuf;
|
||||
@ -77,7 +77,7 @@ STACK *ASN1_seq_unpack(unsigned char *buf, int len, char *(*d2i)(),
|
||||
}
|
||||
|
||||
/* Turn a STACK structures into an ASN1 encoded SEQUENCE OF structure in a
|
||||
* Malloc'ed buffer
|
||||
* OPENSSL_malloc'ed buffer
|
||||
*/
|
||||
|
||||
unsigned char *ASN1_seq_pack(STACK *safes, int (*i2d)(), unsigned char **buf,
|
||||
@ -90,7 +90,7 @@ unsigned char *ASN1_seq_pack(STACK *safes, int (*i2d)(), unsigned char **buf,
|
||||
ASN1err(ASN1_F_ASN1_SEQ_PACK,ASN1_R_ENCODE_ERROR);
|
||||
return NULL;
|
||||
}
|
||||
if (!(safe = Malloc (safelen))) {
|
||||
if (!(safe = OPENSSL_malloc (safelen))) {
|
||||
ASN1err(ASN1_F_ASN1_SEQ_PACK,ERR_R_MALLOC_FAILURE);
|
||||
return NULL;
|
||||
}
|
||||
@ -134,7 +134,7 @@ ASN1_STRING *ASN1_pack_string (void *obj, int (*i2d)(), ASN1_STRING **oct)
|
||||
ASN1err(ASN1_F_ASN1_PACK_STRING,ASN1_R_ENCODE_ERROR);
|
||||
return NULL;
|
||||
}
|
||||
if (!(p = Malloc (octmp->length))) {
|
||||
if (!(p = OPENSSL_malloc (octmp->length))) {
|
||||
ASN1err(ASN1_F_ASN1_PACK_STRING,ERR_R_MALLOC_FAILURE);
|
||||
return NULL;
|
||||
}
|
||||
|
15
lib/libcrypto/asn1/charmap.h
Normal file
15
lib/libcrypto/asn1/charmap.h
Normal file
@ -0,0 +1,15 @@
|
||||
/* Auto generated with chartype.pl script.
|
||||
* Mask of various character properties
|
||||
*/
|
||||
|
||||
static unsigned char char_type[] = {
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
||||
120, 0, 1,40, 0, 0, 0,16,16,16, 0,25,25,16,16,16,
|
||||
16,16,16,16,16,16,16,16,16,16,16, 9, 9,16, 9,16,
|
||||
0,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
||||
16,16,16,16,16,16,16,16,16,16,16, 0, 1, 0, 0, 0,
|
||||
0,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
||||
16,16,16,16,16,16,16,16,16,16,16, 0, 0, 0, 0, 2
|
||||
};
|
||||
|
80
lib/libcrypto/asn1/charmap.pl
Normal file
80
lib/libcrypto/asn1/charmap.pl
Normal file
@ -0,0 +1,80 @@
|
||||
#!/usr/local/bin/perl -w
|
||||
|
||||
use strict;
|
||||
|
||||
my ($i, @arr);
|
||||
|
||||
# Set up an array with the type of ASCII characters
|
||||
# Each set bit represents a character property.
|
||||
|
||||
# RFC2253 character properties
|
||||
my $RFC2253_ESC = 1; # Character escaped with \
|
||||
my $ESC_CTRL = 2; # Escaped control character
|
||||
# These are used with RFC1779 quoting using "
|
||||
my $NOESC_QUOTE = 8; # Not escaped if quoted
|
||||
my $PSTRING_CHAR = 0x10; # Valid PrintableString character
|
||||
my $RFC2253_FIRST_ESC = 0x20; # Escaped with \ if first character
|
||||
my $RFC2253_LAST_ESC = 0x40; # Escaped with \ if last character
|
||||
|
||||
for($i = 0; $i < 128; $i++) {
|
||||
# Set the RFC2253 escape characters (control)
|
||||
$arr[$i] = 0;
|
||||
if(($i < 32) || ($i > 126)) {
|
||||
$arr[$i] |= $ESC_CTRL;
|
||||
}
|
||||
|
||||
# Some PrintableString characters
|
||||
if( ( ( $i >= ord("a")) && ( $i <= ord("z")) )
|
||||
|| ( ( $i >= ord("A")) && ( $i <= ord("Z")) )
|
||||
|| ( ( $i >= ord("0")) && ( $i <= ord("9")) ) ) {
|
||||
$arr[$i] |= $PSTRING_CHAR;
|
||||
}
|
||||
}
|
||||
|
||||
# Now setup the rest
|
||||
|
||||
# Remaining RFC2253 escaped characters
|
||||
|
||||
$arr[ord(" ")] |= $NOESC_QUOTE | $RFC2253_FIRST_ESC | $RFC2253_LAST_ESC;
|
||||
$arr[ord("#")] |= $NOESC_QUOTE | $RFC2253_FIRST_ESC;
|
||||
|
||||
$arr[ord(",")] |= $NOESC_QUOTE | $RFC2253_ESC;
|
||||
$arr[ord("+")] |= $NOESC_QUOTE | $RFC2253_ESC;
|
||||
$arr[ord("\"")] |= $RFC2253_ESC;
|
||||
$arr[ord("\\")] |= $RFC2253_ESC;
|
||||
$arr[ord("<")] |= $NOESC_QUOTE | $RFC2253_ESC;
|
||||
$arr[ord(">")] |= $NOESC_QUOTE | $RFC2253_ESC;
|
||||
$arr[ord(";")] |= $NOESC_QUOTE | $RFC2253_ESC;
|
||||
|
||||
# Remaining PrintableString characters
|
||||
|
||||
$arr[ord(" ")] |= $PSTRING_CHAR;
|
||||
$arr[ord("'")] |= $PSTRING_CHAR;
|
||||
$arr[ord("(")] |= $PSTRING_CHAR;
|
||||
$arr[ord(")")] |= $PSTRING_CHAR;
|
||||
$arr[ord("+")] |= $PSTRING_CHAR;
|
||||
$arr[ord(",")] |= $PSTRING_CHAR;
|
||||
$arr[ord("-")] |= $PSTRING_CHAR;
|
||||
$arr[ord(".")] |= $PSTRING_CHAR;
|
||||
$arr[ord("/")] |= $PSTRING_CHAR;
|
||||
$arr[ord(":")] |= $PSTRING_CHAR;
|
||||
$arr[ord("=")] |= $PSTRING_CHAR;
|
||||
$arr[ord("?")] |= $PSTRING_CHAR;
|
||||
|
||||
# Now generate the C code
|
||||
|
||||
print <<EOF;
|
||||
/* Auto generated with chartype.pl script.
|
||||
* Mask of various character properties
|
||||
*/
|
||||
|
||||
static unsigned char char_type[] = {
|
||||
EOF
|
||||
|
||||
for($i = 0; $i < 128; $i++) {
|
||||
print("\n") if($i && (($i % 16) == 0));
|
||||
printf("%2d", $arr[$i]);
|
||||
print(",") if ($i != 127);
|
||||
}
|
||||
print("\n};\n\n");
|
||||
|
@ -64,7 +64,7 @@
|
||||
#include <openssl/objects.h>
|
||||
#include <openssl/asn1_mac.h>
|
||||
|
||||
#ifdef NEG_PUBKEY_BUG
|
||||
#ifndef NO_NEG_PUBKEY_BUG
|
||||
#define d2i_ASN1_INTEGER d2i_ASN1_UINTEGER
|
||||
#endif
|
||||
|
||||
|
@ -64,7 +64,7 @@
|
||||
#include <openssl/objects.h>
|
||||
#include <openssl/asn1_mac.h>
|
||||
|
||||
#ifdef NEG_PUBKEY_BUG
|
||||
#ifndef NO_NEG_PUBKEY_BUG
|
||||
#define d2i_ASN1_INTEGER d2i_ASN1_UINTEGER
|
||||
#endif
|
||||
|
||||
|
@ -92,6 +92,7 @@ DSA *d2i_DSAPrivateKey(DSA **a, unsigned char **pp, long length)
|
||||
== NULL) goto err_bn;
|
||||
|
||||
M_ASN1_INTEGER_free(bs);
|
||||
bs = NULL;
|
||||
|
||||
M_ASN1_D2I_Finish_2(a);
|
||||
err_bn:
|
||||
|
@ -66,7 +66,7 @@
|
||||
#include <openssl/objects.h>
|
||||
#include <openssl/asn1_mac.h>
|
||||
|
||||
#ifdef NEG_PUBKEY_BUG
|
||||
#ifndef NO_NEG_PUBKEY_BUG
|
||||
#define d2i_ASN1_INTEGER d2i_ASN1_UINTEGER
|
||||
#endif
|
||||
|
||||
|
@ -153,15 +153,15 @@ int a2i_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *bs, char *buf, int size)
|
||||
if (num+i > slen)
|
||||
{
|
||||
if (s == NULL)
|
||||
sp=(unsigned char *)Malloc(
|
||||
sp=(unsigned char *)OPENSSL_malloc(
|
||||
(unsigned int)num+i*2);
|
||||
else
|
||||
sp=(unsigned char *)Realloc(s,
|
||||
sp=(unsigned char *)OPENSSL_realloc(s,
|
||||
(unsigned int)num+i*2);
|
||||
if (sp == NULL)
|
||||
{
|
||||
ASN1err(ASN1_F_A2I_ASN1_ENUMERATED,ERR_R_MALLOC_FAILURE);
|
||||
if (s != NULL) Free(s);
|
||||
if (s != NULL) OPENSSL_free(s);
|
||||
goto err;
|
||||
}
|
||||
s=sp;
|
||||
|
@ -160,15 +160,15 @@ int a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size)
|
||||
if (num+i > slen)
|
||||
{
|
||||
if (s == NULL)
|
||||
sp=(unsigned char *)Malloc(
|
||||
sp=(unsigned char *)OPENSSL_malloc(
|
||||
(unsigned int)num+i*2);
|
||||
else
|
||||
sp=(unsigned char *)Realloc(s,
|
||||
sp=(unsigned char *)OPENSSL_realloc(s,
|
||||
(unsigned int)num+i*2);
|
||||
if (sp == NULL)
|
||||
{
|
||||
ASN1err(ASN1_F_A2I_ASN1_INTEGER,ERR_R_MALLOC_FAILURE);
|
||||
if (s != NULL) Free(s);
|
||||
if (s != NULL) OPENSSL_free(s);
|
||||
goto err;
|
||||
}
|
||||
s=sp;
|
||||
|
@ -158,15 +158,15 @@ int a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size)
|
||||
if (num+i > slen)
|
||||
{
|
||||
if (s == NULL)
|
||||
sp=(unsigned char *)Malloc(
|
||||
sp=(unsigned char *)OPENSSL_malloc(
|
||||
(unsigned int)num+i*2);
|
||||
else
|
||||
sp=(unsigned char *)Realloc(s,
|
||||
sp=(unsigned char *)OPENSSL_realloc(s,
|
||||
(unsigned int)num+i*2);
|
||||
if (sp == NULL)
|
||||
{
|
||||
ASN1err(ASN1_F_A2I_ASN1_STRING,ERR_R_MALLOC_FAILURE);
|
||||
if (s != NULL) Free(s);
|
||||
if (s != NULL) OPENSSL_free(s);
|
||||
goto err;
|
||||
}
|
||||
s=sp;
|
||||
|
@ -105,7 +105,7 @@ int i2d_DHparams(DH *a, unsigned char **pp)
|
||||
ASN1_put_object(&p,1,tot,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL);
|
||||
|
||||
bs.type=V_ASN1_INTEGER;
|
||||
bs.data=(unsigned char *)Malloc(max+4);
|
||||
bs.data=(unsigned char *)OPENSSL_malloc(max+4);
|
||||
if (bs.data == NULL)
|
||||
{
|
||||
ASN1err(ASN1_F_I2D_DHPARAMS,ERR_R_MALLOC_FAILURE);
|
||||
@ -118,7 +118,7 @@ int i2d_DHparams(DH *a, unsigned char **pp)
|
||||
bs.length=BN_bn2bin(num[i],bs.data);
|
||||
i2d_ASN1_INTEGER(&bs,&p);
|
||||
}
|
||||
Free(bs.data);
|
||||
OPENSSL_free(bs.data);
|
||||
ret=t;
|
||||
err:
|
||||
if (num[2] != NULL) BN_free(num[2]);
|
||||
|
@ -94,7 +94,7 @@ int i2d_DSAparams(DSA *a, unsigned char **pp)
|
||||
ASN1_put_object(&p,1,tot,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL);
|
||||
|
||||
bs.type=V_ASN1_INTEGER;
|
||||
bs.data=(unsigned char *)Malloc(max+4);
|
||||
bs.data=(unsigned char *)OPENSSL_malloc(max+4);
|
||||
if (bs.data == NULL)
|
||||
{
|
||||
ASN1err(ASN1_F_I2D_DSAPARAMS,ERR_R_MALLOC_FAILURE);
|
||||
@ -107,7 +107,7 @@ int i2d_DSAparams(DSA *a, unsigned char **pp)
|
||||
bs.length=BN_bn2bin(num[i],bs.data);
|
||||
i2d_ASN1_INTEGER(&bs,&p);
|
||||
}
|
||||
Free(bs.data);
|
||||
OPENSSL_free(bs.data);
|
||||
ret=t;
|
||||
err:
|
||||
*pp=p;
|
||||
|
@ -107,7 +107,7 @@ int i2d_RSAPrivateKey(RSA *a, unsigned char **pp)
|
||||
|
||||
i2d_ASN1_INTEGER(&bs,&p);
|
||||
|
||||
bs.data=(unsigned char *)Malloc(max+4);
|
||||
bs.data=(unsigned char *)OPENSSL_malloc(max+4);
|
||||
if (bs.data == NULL)
|
||||
{
|
||||
ASN1err(ASN1_F_I2D_RSAPRIVATEKEY,ERR_R_MALLOC_FAILURE);
|
||||
@ -119,7 +119,7 @@ int i2d_RSAPrivateKey(RSA *a, unsigned char **pp)
|
||||
bs.length=BN_bn2bin(num[i],bs.data);
|
||||
i2d_ASN1_INTEGER(&bs,&p);
|
||||
}
|
||||
Free(bs.data);
|
||||
OPENSSL_free(bs.data);
|
||||
*pp=p;
|
||||
return(t);
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ int i2d_RSAPublicKey(RSA *a, unsigned char **pp)
|
||||
ASN1_put_object(&p,1,tot,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL);
|
||||
|
||||
bs.type=V_ASN1_INTEGER;
|
||||
bs.data=(unsigned char *)Malloc(max+4);
|
||||
bs.data=(unsigned char *)OPENSSL_malloc(max+4);
|
||||
if (bs.data == NULL)
|
||||
{
|
||||
ASN1err(ASN1_F_I2D_RSAPUBLICKEY,ERR_R_MALLOC_FAILURE);
|
||||
@ -105,7 +105,7 @@ int i2d_RSAPublicKey(RSA *a, unsigned char **pp)
|
||||
bs.length=BN_bn2bin(num[i],bs.data);
|
||||
i2d_ASN1_INTEGER(&bs,&p);
|
||||
}
|
||||
Free(bs.data);
|
||||
OPENSSL_free(bs.data);
|
||||
*pp=p;
|
||||
return(t);
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ int i2d_DSAPrivateKey(DSA *a, unsigned char **pp)
|
||||
|
||||
i2d_ASN1_INTEGER(&bs,&p);
|
||||
|
||||
bs.data=(unsigned char *)Malloc(max+4);
|
||||
bs.data=(unsigned char *)OPENSSL_malloc(max+4);
|
||||
if (bs.data == NULL)
|
||||
{
|
||||
ASN1err(ASN1_F_I2D_DSAPRIVATEKEY,ERR_R_MALLOC_FAILURE);
|
||||
@ -116,7 +116,7 @@ int i2d_DSAPrivateKey(DSA *a, unsigned char **pp)
|
||||
bs.length=BN_bn2bin(num[i],bs.data);
|
||||
i2d_ASN1_INTEGER(&bs,&p);
|
||||
}
|
||||
Free(bs.data);
|
||||
OPENSSL_free(bs.data);
|
||||
*pp=p;
|
||||
return(t);
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ int i2d_DSAPublicKey(DSA *a, unsigned char **pp)
|
||||
ASN1_put_object(&p,1,tot,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL);
|
||||
|
||||
bs.type=V_ASN1_INTEGER;
|
||||
bs.data=(unsigned char *)Malloc(max+4);
|
||||
bs.data=(unsigned char *)OPENSSL_malloc(max+4);
|
||||
if (bs.data == NULL)
|
||||
{
|
||||
ASN1err(ASN1_F_I2D_DSAPUBLICKEY,ERR_R_MALLOC_FAILURE);
|
||||
@ -121,7 +121,7 @@ int i2d_DSAPublicKey(DSA *a, unsigned char **pp)
|
||||
bs.length=BN_bn2bin(num[i],bs.data);
|
||||
i2d_ASN1_INTEGER(&bs,&p);
|
||||
}
|
||||
Free(bs.data);
|
||||
OPENSSL_free(bs.data);
|
||||
*pp=p;
|
||||
if(all) return(t);
|
||||
else return(tot);
|
||||
|
@ -81,6 +81,11 @@ static NETSCAPE_PKEY *NETSCAPE_PKEY_new(void);
|
||||
static void NETSCAPE_PKEY_free(NETSCAPE_PKEY *);
|
||||
|
||||
int i2d_Netscape_RSA(RSA *a, unsigned char **pp, int (*cb)())
|
||||
{
|
||||
return i2d_RSA_NET(a, pp, cb, 0);
|
||||
}
|
||||
|
||||
int i2d_RSA_NET(RSA *a, unsigned char **pp, int (*cb)(), int sgckey)
|
||||
{
|
||||
int i,j,l[6];
|
||||
NETSCAPE_PKEY *pkey;
|
||||
@ -139,8 +144,8 @@ int i2d_Netscape_RSA(RSA *a, unsigned char **pp, int (*cb)())
|
||||
}
|
||||
|
||||
if (pkey->private_key->data != NULL)
|
||||
Free(pkey->private_key->data);
|
||||
if ((pkey->private_key->data=(unsigned char *)Malloc(l[0])) == NULL)
|
||||
OPENSSL_free(pkey->private_key->data);
|
||||
if ((pkey->private_key->data=(unsigned char *)OPENSSL_malloc(l[0])) == NULL)
|
||||
{
|
||||
ASN1err(ASN1_F_I2D_NETSCAPE_RSA,ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
@ -148,7 +153,7 @@ int i2d_Netscape_RSA(RSA *a, unsigned char **pp, int (*cb)())
|
||||
zz=pkey->private_key->data;
|
||||
i2d_RSAPrivateKey(a,&zz);
|
||||
|
||||
if ((os2.data=(unsigned char *)Malloc(os2.length)) == NULL)
|
||||
if ((os2.data=(unsigned char *)OPENSSL_malloc(os2.length)) == NULL)
|
||||
{
|
||||
ASN1err(ASN1_F_I2D_NETSCAPE_RSA,ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
@ -164,8 +169,18 @@ int i2d_Netscape_RSA(RSA *a, unsigned char **pp, int (*cb)())
|
||||
ASN1err(ASN1_F_I2D_NETSCAPE_RSA,ASN1_R_BAD_PASSWORD_READ);
|
||||
goto err;
|
||||
}
|
||||
EVP_BytesToKey(EVP_rc4(),EVP_md5(),NULL,buf,
|
||||
strlen((char *)buf),1,key,NULL);
|
||||
i = strlen((char *)buf);
|
||||
/* If the key is used for SGC the algorithm is modified a little. */
|
||||
if(sgckey){
|
||||
EVP_MD_CTX mctx;
|
||||
EVP_DigestInit(&mctx, EVP_md5());
|
||||
EVP_DigestUpdate(&mctx, buf, i);
|
||||
EVP_DigestFinal(&mctx, buf, NULL);
|
||||
memcpy(buf + 16, "SGCKEYSALT", 10);
|
||||
i = 26;
|
||||
}
|
||||
|
||||
EVP_BytesToKey(EVP_rc4(),EVP_md5(),NULL,buf,i,1,key,NULL);
|
||||
memset(buf,0,256);
|
||||
|
||||
EVP_CIPHER_CTX_init(&ctx);
|
||||
@ -182,14 +197,20 @@ int i2d_Netscape_RSA(RSA *a, unsigned char **pp, int (*cb)())
|
||||
i2d_ASN1_OCTET_STRING(&os2,&p);
|
||||
ret=l[5];
|
||||
err:
|
||||
if (os2.data != NULL) Free(os2.data);
|
||||
if (os2.data != NULL) OPENSSL_free(os2.data);
|
||||
if (alg != NULL) X509_ALGOR_free(alg);
|
||||
if (pkey != NULL) NETSCAPE_PKEY_free(pkey);
|
||||
r=r;
|
||||
return(ret);
|
||||
}
|
||||
|
||||
|
||||
RSA *d2i_Netscape_RSA(RSA **a, unsigned char **pp, long length, int (*cb)())
|
||||
{
|
||||
return d2i_RSA_NET(a, pp, length, cb, 0);
|
||||
}
|
||||
|
||||
RSA *d2i_RSA_NET(RSA **a, unsigned char **pp, long length, int (*cb)(), int sgckey)
|
||||
{
|
||||
RSA *ret=NULL;
|
||||
ASN1_OCTET_STRING *os=NULL;
|
||||
@ -210,14 +231,24 @@ RSA *d2i_Netscape_RSA(RSA **a, unsigned char **pp, long length, int (*cb)())
|
||||
}
|
||||
M_ASN1_BIT_STRING_free(os);
|
||||
c.q=c.p;
|
||||
if ((ret=d2i_Netscape_RSA_2(a,&c.p,c.slen,cb)) == NULL) goto err;
|
||||
c.slen-=(c.p-c.q);
|
||||
if ((ret=d2i_RSA_NET_2(a,&c.p,c.slen,cb, sgckey)) == NULL) goto err;
|
||||
/* Note: some versions of IIS key files use length values that are
|
||||
* too small for the surrounding SEQUENCEs. This following line
|
||||
* effectively disable length checking.
|
||||
*/
|
||||
c.slen = 0;
|
||||
|
||||
M_ASN1_D2I_Finish(a,RSA_free,ASN1_F_D2I_NETSCAPE_RSA);
|
||||
}
|
||||
|
||||
RSA *d2i_Netscape_RSA_2(RSA **a, unsigned char **pp, long length,
|
||||
int (*cb)())
|
||||
{
|
||||
return d2i_RSA_NET_2(a, pp, length, cb, 0);
|
||||
}
|
||||
|
||||
RSA *d2i_RSA_NET_2(RSA **a, unsigned char **pp, long length,
|
||||
int (*cb)(), int sgckey)
|
||||
{
|
||||
NETSCAPE_PKEY *pkey=NULL;
|
||||
RSA *ret=NULL;
|
||||
@ -250,8 +281,17 @@ RSA *d2i_Netscape_RSA_2(RSA **a, unsigned char **pp, long length,
|
||||
goto err;
|
||||
}
|
||||
|
||||
EVP_BytesToKey(EVP_rc4(),EVP_md5(),NULL,buf,
|
||||
strlen((char *)buf),1,key,NULL);
|
||||
i = strlen((char *)buf);
|
||||
if(sgckey){
|
||||
EVP_MD_CTX mctx;
|
||||
EVP_DigestInit(&mctx, EVP_md5());
|
||||
EVP_DigestUpdate(&mctx, buf, i);
|
||||
EVP_DigestFinal(&mctx, buf, NULL);
|
||||
memcpy(buf + 16, "SGCKEYSALT", 10);
|
||||
i = 26;
|
||||
}
|
||||
|
||||
EVP_BytesToKey(EVP_rc4(),EVP_md5(),NULL,buf,i,1,key,NULL);
|
||||
memset(buf,0,256);
|
||||
|
||||
EVP_CIPHER_CTX_init(&ctx);
|
||||
@ -334,7 +374,7 @@ static void NETSCAPE_PKEY_free(NETSCAPE_PKEY *a)
|
||||
M_ASN1_INTEGER_free(a->version);
|
||||
X509_ALGOR_free(a->algor);
|
||||
M_ASN1_OCTET_STRING_free(a->private_key);
|
||||
Free(a);
|
||||
OPENSSL_free(a);
|
||||
}
|
||||
|
||||
#endif /* NO_RC4 */
|
||||
|
@ -114,5 +114,5 @@ void NETSCAPE_CERT_SEQUENCE_free (NETSCAPE_CERT_SEQUENCE *a)
|
||||
ASN1_OBJECT_free(a->type);
|
||||
if(a->certs)
|
||||
sk_X509_pop_free(a->certs, X509_free);
|
||||
Free (a);
|
||||
OPENSSL_free (a);
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ void PBEPARAM_free (PBEPARAM *a)
|
||||
if(a==NULL) return;
|
||||
M_ASN1_OCTET_STRING_free(a->salt);
|
||||
M_ASN1_INTEGER_free (a->iter);
|
||||
Free (a);
|
||||
OPENSSL_free (a);
|
||||
}
|
||||
|
||||
/* Return an algorithm identifier for a PKCS#5 PBE algorithm */
|
||||
@ -123,7 +123,7 @@ X509_ALGOR *PKCS5_pbe_set(int alg, int iter, unsigned char *salt,
|
||||
if(iter <= 0) iter = PKCS5_DEFAULT_ITER;
|
||||
ASN1_INTEGER_set (pbe->iter, iter);
|
||||
if (!saltlen) saltlen = PKCS5_SALT_LEN;
|
||||
if (!(pbe->salt->data = Malloc (saltlen))) {
|
||||
if (!(pbe->salt->data = OPENSSL_malloc (saltlen))) {
|
||||
ASN1err(ASN1_F_ASN1_PBE_SET,ERR_R_MALLOC_FAILURE);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ void PBE2PARAM_free (PBE2PARAM *a)
|
||||
if(a==NULL) return;
|
||||
X509_ALGOR_free(a->keyfunc);
|
||||
X509_ALGOR_free(a->encryption);
|
||||
Free (a);
|
||||
OPENSSL_free (a);
|
||||
}
|
||||
|
||||
int i2d_PBKDF2PARAM(PBKDF2PARAM *a, unsigned char **pp)
|
||||
@ -158,7 +158,7 @@ void PBKDF2PARAM_free (PBKDF2PARAM *a)
|
||||
M_ASN1_INTEGER_free(a->iter);
|
||||
M_ASN1_INTEGER_free(a->keylength);
|
||||
X509_ALGOR_free(a->prf);
|
||||
Free (a);
|
||||
OPENSSL_free (a);
|
||||
}
|
||||
|
||||
/* Return an algorithm identifier for a PKCS#5 v2.0 PBE algorithm:
|
||||
@ -210,7 +210,7 @@ X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter,
|
||||
if(!(osalt = M_ASN1_OCTET_STRING_new())) goto merr;
|
||||
|
||||
if (!saltlen) saltlen = PKCS5_SALT_LEN;
|
||||
if (!(osalt->data = Malloc (saltlen))) goto merr;
|
||||
if (!(osalt->data = OPENSSL_malloc (saltlen))) goto merr;
|
||||
osalt->length = saltlen;
|
||||
if (salt) memcpy (osalt->data, salt, saltlen);
|
||||
else if (RAND_pseudo_bytes (osalt->data, saltlen) < 0) goto merr;
|
||||
|
@ -116,6 +116,6 @@ void PKCS7_DIGEST_free(PKCS7_DIGEST *a)
|
||||
X509_ALGOR_free(a->md);
|
||||
PKCS7_free(a->contents);
|
||||
M_ASN1_OCTET_STRING_free(a->digest);
|
||||
Free(a);
|
||||
OPENSSL_free(a);
|
||||
}
|
||||
|
||||
|
@ -106,6 +106,6 @@ void PKCS7_ENCRYPT_free(PKCS7_ENCRYPT *a)
|
||||
if (a == NULL) return;
|
||||
M_ASN1_INTEGER_free(a->version);
|
||||
PKCS7_ENC_CONTENT_free(a->enc_data);
|
||||
Free(a);
|
||||
OPENSSL_free(a);
|
||||
}
|
||||
|
||||
|
@ -115,6 +115,6 @@ void PKCS7_ENC_CONTENT_free(PKCS7_ENC_CONTENT *a)
|
||||
ASN1_OBJECT_free(a->content_type);
|
||||
X509_ALGOR_free(a->algorithm);
|
||||
M_ASN1_OCTET_STRING_free(a->enc_data);
|
||||
Free(a);
|
||||
OPENSSL_free(a);
|
||||
}
|
||||
|
||||
|
@ -114,6 +114,6 @@ void PKCS7_ENVELOPE_free(PKCS7_ENVELOPE *a)
|
||||
M_ASN1_INTEGER_free(a->version);
|
||||
sk_PKCS7_RECIP_INFO_pop_free(a->recipientinfo,PKCS7_RECIP_INFO_free);
|
||||
PKCS7_ENC_CONTENT_free(a->enc_data);
|
||||
Free(a);
|
||||
OPENSSL_free(a);
|
||||
}
|
||||
|
||||
|
@ -106,6 +106,6 @@ void PKCS7_ISSUER_AND_SERIAL_free(PKCS7_ISSUER_AND_SERIAL *a)
|
||||
if (a == NULL) return;
|
||||
X509_NAME_free(a->issuer);
|
||||
M_ASN1_INTEGER_free(a->serial);
|
||||
Free(a);
|
||||
OPENSSL_free(a);
|
||||
}
|
||||
|
||||
|
@ -62,6 +62,8 @@
|
||||
#include <openssl/pkcs7.h>
|
||||
#include <openssl/objects.h>
|
||||
|
||||
#ifdef PKCS7_INDEFINITE_ENCODING
|
||||
|
||||
int i2d_PKCS7(PKCS7 *a, unsigned char **pp)
|
||||
{
|
||||
M_ASN1_I2D_vars(a);
|
||||
@ -102,6 +104,7 @@ int i2d_PKCS7(PKCS7 *a, unsigned char **pp)
|
||||
M_ASN1_I2D_len(a->d.encrypted,i2d_PKCS7_ENCRYPT);
|
||||
break;
|
||||
default:
|
||||
M_ASN1_I2D_len(a->d.other,i2d_ASN1_TYPE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -136,6 +139,7 @@ int i2d_PKCS7(PKCS7 *a, unsigned char **pp)
|
||||
M_ASN1_I2D_put(a->d.encrypted,i2d_PKCS7_ENCRYPT);
|
||||
break;
|
||||
default:
|
||||
M_ASN1_I2D_put(a->d.other,i2d_ASN1_TYPE);
|
||||
break;
|
||||
}
|
||||
M_ASN1_I2D_INF_seq_end();
|
||||
@ -144,6 +148,98 @@ int i2d_PKCS7(PKCS7 *a, unsigned char **pp)
|
||||
M_ASN1_I2D_finish();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int i2d_PKCS7(PKCS7 *a, unsigned char **pp)
|
||||
{
|
||||
int explen = 0;
|
||||
M_ASN1_I2D_vars(a);
|
||||
|
||||
if (a->asn1 != NULL)
|
||||
{
|
||||
if (pp == NULL)
|
||||
return((int)a->length);
|
||||
memcpy(*pp,a->asn1,(int)a->length);
|
||||
*pp+=a->length;
|
||||
return((int)a->length);
|
||||
}
|
||||
|
||||
M_ASN1_I2D_len(a->type,i2d_ASN1_OBJECT);
|
||||
if (a->d.ptr != NULL)
|
||||
{
|
||||
/* Save current length */
|
||||
r = ret;
|
||||
switch (OBJ_obj2nid(a->type))
|
||||
{
|
||||
case NID_pkcs7_data:
|
||||
M_ASN1_I2D_len(a->d.data,i2d_ASN1_OCTET_STRING);
|
||||
break;
|
||||
case NID_pkcs7_signed:
|
||||
M_ASN1_I2D_len(a->d.sign,i2d_PKCS7_SIGNED);
|
||||
break;
|
||||
case NID_pkcs7_enveloped:
|
||||
M_ASN1_I2D_len(a->d.enveloped,i2d_PKCS7_ENVELOPE);
|
||||
break;
|
||||
case NID_pkcs7_signedAndEnveloped:
|
||||
M_ASN1_I2D_len(a->d.signed_and_enveloped,
|
||||
i2d_PKCS7_SIGN_ENVELOPE);
|
||||
break;
|
||||
case NID_pkcs7_digest:
|
||||
M_ASN1_I2D_len(a->d.digest,i2d_PKCS7_DIGEST);
|
||||
break;
|
||||
case NID_pkcs7_encrypted:
|
||||
M_ASN1_I2D_len(a->d.encrypted,i2d_PKCS7_ENCRYPT);
|
||||
break;
|
||||
default:
|
||||
M_ASN1_I2D_len(a->d.other,i2d_ASN1_TYPE);
|
||||
break;
|
||||
}
|
||||
/* Work out explicit tag content size */
|
||||
explen = ret - r;
|
||||
/* Work out explicit tag size: Note: ASN1_object_size
|
||||
* includes the content length.
|
||||
*/
|
||||
ret = r + ASN1_object_size(1, explen, 0);
|
||||
}
|
||||
|
||||
M_ASN1_I2D_seq_total();
|
||||
|
||||
M_ASN1_I2D_put(a->type,i2d_ASN1_OBJECT);
|
||||
|
||||
if (a->d.ptr != NULL)
|
||||
{
|
||||
ASN1_put_object(&p, 1, explen, 0, V_ASN1_CONTEXT_SPECIFIC);
|
||||
switch (OBJ_obj2nid(a->type))
|
||||
{
|
||||
case NID_pkcs7_data:
|
||||
M_ASN1_I2D_put(a->d.data,i2d_ASN1_OCTET_STRING);
|
||||
break;
|
||||
case NID_pkcs7_signed:
|
||||
M_ASN1_I2D_put(a->d.sign,i2d_PKCS7_SIGNED);
|
||||
break;
|
||||
case NID_pkcs7_enveloped:
|
||||
M_ASN1_I2D_put(a->d.enveloped,i2d_PKCS7_ENVELOPE);
|
||||
break;
|
||||
case NID_pkcs7_signedAndEnveloped:
|
||||
M_ASN1_I2D_put(a->d.signed_and_enveloped,
|
||||
i2d_PKCS7_SIGN_ENVELOPE);
|
||||
break;
|
||||
case NID_pkcs7_digest:
|
||||
M_ASN1_I2D_put(a->d.digest,i2d_PKCS7_DIGEST);
|
||||
break;
|
||||
case NID_pkcs7_encrypted:
|
||||
M_ASN1_I2D_put(a->d.encrypted,i2d_PKCS7_ENCRYPT);
|
||||
break;
|
||||
default:
|
||||
M_ASN1_I2D_put(a->d.other,i2d_ASN1_TYPE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
M_ASN1_I2D_finish();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
PKCS7 *d2i_PKCS7(PKCS7 **a, unsigned char **pp, long length)
|
||||
{
|
||||
M_ASN1_D2I_vars(a,PKCS7 *,PKCS7_new);
|
||||
@ -152,7 +248,7 @@ PKCS7 *d2i_PKCS7(PKCS7 **a, unsigned char **pp, long length)
|
||||
{
|
||||
if ((*a)->asn1 != NULL)
|
||||
{
|
||||
Free((*a)->asn1);
|
||||
OPENSSL_free((*a)->asn1);
|
||||
(*a)->asn1=NULL;
|
||||
}
|
||||
(*a)->length=0;
|
||||
@ -206,10 +302,8 @@ PKCS7 *d2i_PKCS7(PKCS7 **a, unsigned char **pp, long length)
|
||||
M_ASN1_D2I_get(ret->d.encrypted,d2i_PKCS7_ENCRYPT);
|
||||
break;
|
||||
default:
|
||||
c.error=ASN1_R_BAD_PKCS7_TYPE;
|
||||
c.line=__LINE__;
|
||||
goto err;
|
||||
/* break; */
|
||||
M_ASN1_D2I_get(ret->d.other,d2i_ASN1_TYPE);
|
||||
break;
|
||||
}
|
||||
if (Tinf == (1|V_ASN1_CONSTRUCTED))
|
||||
{
|
||||
@ -251,7 +345,7 @@ void PKCS7_free(PKCS7 *a)
|
||||
{
|
||||
ASN1_OBJECT_free(a->type);
|
||||
}
|
||||
Free(a);
|
||||
OPENSSL_free(a);
|
||||
}
|
||||
|
||||
void PKCS7_content_free(PKCS7 *a)
|
||||
@ -259,7 +353,7 @@ void PKCS7_content_free(PKCS7 *a)
|
||||
if(a == NULL)
|
||||
return;
|
||||
|
||||
if (a->asn1 != NULL) Free(a->asn1);
|
||||
if (a->asn1 != NULL) OPENSSL_free(a->asn1);
|
||||
|
||||
if (a->d.ptr != NULL)
|
||||
{
|
||||
@ -286,10 +380,12 @@ void PKCS7_content_free(PKCS7 *a)
|
||||
PKCS7_ENCRYPT_free(a->d.encrypted);
|
||||
break;
|
||||
default:
|
||||
/* MEMORY LEAK */
|
||||
ASN1_TYPE_free(a->d.other);
|
||||
break;
|
||||
}
|
||||
}
|
||||
a->d.ptr=NULL;
|
||||
}
|
||||
|
||||
IMPLEMENT_STACK_OF(PKCS7)
|
||||
IMPLEMENT_ASN1_SET_OF(PKCS7)
|
||||
|
@ -118,7 +118,7 @@ void PKCS7_RECIP_INFO_free(PKCS7_RECIP_INFO *a)
|
||||
X509_ALGOR_free(a->key_enc_algor);
|
||||
M_ASN1_OCTET_STRING_free(a->enc_key);
|
||||
if (a->cert != NULL) X509_free(a->cert);
|
||||
Free(a);
|
||||
OPENSSL_free(a);
|
||||
}
|
||||
|
||||
IMPLEMENT_STACK_OF(PKCS7_RECIP_INFO)
|
||||
|
@ -140,6 +140,6 @@ void PKCS7_SIGN_ENVELOPE_free(PKCS7_SIGN_ENVELOPE *a)
|
||||
sk_X509_pop_free(a->cert,X509_free);
|
||||
sk_X509_CRL_pop_free(a->crl,X509_CRL_free);
|
||||
sk_PKCS7_SIGNER_INFO_pop_free(a->signer_info,PKCS7_SIGNER_INFO_free);
|
||||
Free(a);
|
||||
OPENSSL_free(a);
|
||||
}
|
||||
|
||||
|
@ -131,5 +131,5 @@ void PKCS7_SIGNED_free(PKCS7_SIGNED *a)
|
||||
sk_X509_pop_free(a->cert,X509_free);
|
||||
sk_X509_CRL_pop_free(a->crl,X509_CRL_free);
|
||||
sk_PKCS7_SIGNER_INFO_pop_free(a->signer_info,PKCS7_SIGNER_INFO_free);
|
||||
Free(a);
|
||||
OPENSSL_free(a);
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ void PKCS7_SIGNER_INFO_free(PKCS7_SIGNER_INFO *a)
|
||||
sk_X509_ATTRIBUTE_pop_free(a->unauth_attr,X509_ATTRIBUTE_free);
|
||||
if (a->pkey != NULL)
|
||||
EVP_PKEY_free(a->pkey);
|
||||
Free(a);
|
||||
OPENSSL_free(a);
|
||||
}
|
||||
|
||||
IMPLEMENT_STACK_OF(PKCS7_SIGNER_INFO)
|
||||
|
@ -94,7 +94,7 @@ X509 *X509_KEY_new(void)
|
||||
{
|
||||
X509_KEY *ret=NULL;
|
||||
|
||||
M_ASN1_New_Malloc(ret,X509_KEY);
|
||||
M_ASN1_New_OPENSSL_malloc(ret,X509_KEY);
|
||||
ret->references=1;
|
||||
ret->type=NID
|
||||
M_ASN1_New(ret->cert_info,X509_CINF_new);
|
||||
@ -126,6 +126,6 @@ void X509_KEY_free(X509 *a)
|
||||
X509_CINF_free(a->cert_info);
|
||||
X509_ALGOR_free(a->sig_alg);
|
||||
ASN1_BIT_STRING_free(a->signature);
|
||||
Free(a);
|
||||
OPENSSL_free(a);
|
||||
}
|
||||
|
||||
|
@ -123,5 +123,5 @@ void PKCS8_PRIV_KEY_INFO_free (PKCS8_PRIV_KEY_INFO *a)
|
||||
0, a->pkey->value.octet_string->length);
|
||||
ASN1_TYPE_free (a->pkey);
|
||||
sk_X509_ATTRIBUTE_pop_free (a->attributes, X509_ATTRIBUTE_free);
|
||||
Free (a);
|
||||
OPENSSL_free (a);
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ int RSA_print(BIO *bp, RSA *x, int off)
|
||||
int i,ret=0;
|
||||
|
||||
i=RSA_size(x);
|
||||
m=(unsigned char *)Malloc((unsigned int)i+10);
|
||||
m=(unsigned char *)OPENSSL_malloc((unsigned int)i+10);
|
||||
if (m == NULL)
|
||||
{
|
||||
RSAerr(RSA_F_RSA_PRINT,ERR_R_MALLOC_FAILURE);
|
||||
@ -133,7 +133,7 @@ int RSA_print(BIO *bp, RSA *x, int off)
|
||||
if (!print(bp,"coefficient:",x->iqmp,m,off)) goto err;
|
||||
ret=1;
|
||||
err:
|
||||
if (m != NULL) Free(m);
|
||||
if (m != NULL) OPENSSL_free(m);
|
||||
return(ret);
|
||||
}
|
||||
#endif /* NO_RSA */
|
||||
@ -176,7 +176,7 @@ int DSA_print(BIO *bp, DSA *x, int off)
|
||||
i=BN_num_bytes(bn)*2;
|
||||
else
|
||||
i=256;
|
||||
m=(unsigned char *)Malloc((unsigned int)i+10);
|
||||
m=(unsigned char *)OPENSSL_malloc((unsigned int)i+10);
|
||||
if (m == NULL)
|
||||
{
|
||||
DSAerr(DSA_F_DSA_PRINT,ERR_R_MALLOC_FAILURE);
|
||||
@ -204,7 +204,7 @@ int DSA_print(BIO *bp, DSA *x, int off)
|
||||
if ((x->g != NULL) && !print(bp,"G: ",x->g,m,off)) goto err;
|
||||
ret=1;
|
||||
err:
|
||||
if (m != NULL) Free(m);
|
||||
if (m != NULL) OPENSSL_free(m);
|
||||
return(ret);
|
||||
}
|
||||
#endif /* !NO_DSA */
|
||||
@ -284,7 +284,7 @@ int DHparams_print(BIO *bp, DH *x)
|
||||
int reason=ERR_R_BUF_LIB,i,ret=0;
|
||||
|
||||
i=BN_num_bytes(x->p);
|
||||
m=(unsigned char *)Malloc((unsigned int)i+10);
|
||||
m=(unsigned char *)OPENSSL_malloc((unsigned int)i+10);
|
||||
if (m == NULL)
|
||||
{
|
||||
reason=ERR_R_MALLOC_FAILURE;
|
||||
@ -307,7 +307,7 @@ int DHparams_print(BIO *bp, DH *x)
|
||||
err:
|
||||
DHerr(DH_F_DHPARAMS_PRINT,reason);
|
||||
}
|
||||
if (m != NULL) Free(m);
|
||||
if (m != NULL) OPENSSL_free(m);
|
||||
return(ret);
|
||||
}
|
||||
#endif
|
||||
@ -337,7 +337,7 @@ int DSAparams_print(BIO *bp, DSA *x)
|
||||
int reason=ERR_R_BUF_LIB,i,ret=0;
|
||||
|
||||
i=BN_num_bytes(x->p);
|
||||
m=(unsigned char *)Malloc((unsigned int)i+10);
|
||||
m=(unsigned char *)OPENSSL_malloc((unsigned int)i+10);
|
||||
if (m == NULL)
|
||||
{
|
||||
reason=ERR_R_MALLOC_FAILURE;
|
||||
@ -352,7 +352,7 @@ int DSAparams_print(BIO *bp, DSA *x)
|
||||
if (!print(bp,"g:",x->g,m,4)) goto err;
|
||||
ret=1;
|
||||
err:
|
||||
if (m != NULL) Free(m);
|
||||
if (m != NULL) OPENSSL_free(m);
|
||||
DSAerr(DSA_F_DSAPARAMS_PRINT,reason);
|
||||
return(ret);
|
||||
}
|
||||
|
@ -223,7 +223,7 @@ int X509_print(BIO *bp, X509 *x)
|
||||
ret=1;
|
||||
err:
|
||||
if (str != NULL) ASN1_STRING_free(str);
|
||||
if (m != NULL) Free(m);
|
||||
if (m != NULL) OPENSSL_free(m);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
|
@ -98,5 +98,13 @@ int X509_CERT_AUX_print(BIO *out, X509_CERT_AUX *aux, int indent)
|
||||
} else BIO_printf(out, "%*sNo Rejected Uses.\n", indent, "");
|
||||
if(aux->alias) BIO_printf(out, "%*sAlias: %s\n", indent, "",
|
||||
aux->alias->data);
|
||||
if(aux->keyid) {
|
||||
BIO_printf(out, "%*sKey Id: ", indent, "");
|
||||
for(i = 0; i < aux->keyid->length; i++)
|
||||
BIO_printf(out, "%s%02X",
|
||||
i ? ":" : "",
|
||||
aux->keyid->data[i]);
|
||||
BIO_write(out,"\n",1);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ void X509_ALGOR_free(X509_ALGOR *a)
|
||||
if (a == NULL) return;
|
||||
ASN1_OBJECT_free(a->algorithm);
|
||||
ASN1_TYPE_free(a->parameter);
|
||||
Free(a);
|
||||
OPENSSL_free(a);
|
||||
}
|
||||
|
||||
IMPLEMENT_STACK_OF(X509_ALGOR)
|
||||
|
@ -160,6 +160,6 @@ void X509_ATTRIBUTE_free(X509_ATTRIBUTE *a)
|
||||
sk_ASN1_TYPE_pop_free(a->value.set,ASN1_TYPE_free);
|
||||
else
|
||||
ASN1_TYPE_free(a->value.single);
|
||||
Free(a);
|
||||
OPENSSL_free(a);
|
||||
}
|
||||
|
||||
|
@ -196,6 +196,6 @@ void X509_CINF_free(X509_CINF *a)
|
||||
M_ASN1_BIT_STRING_free(a->issuerUID);
|
||||
M_ASN1_BIT_STRING_free(a->subjectUID);
|
||||
sk_X509_EXTENSION_pop_free(a->extensions,X509_EXTENSION_free);
|
||||
Free(a);
|
||||
OPENSSL_free(a);
|
||||
}
|
||||
|
||||
|
@ -61,8 +61,10 @@
|
||||
#include <openssl/asn1_mac.h>
|
||||
#include <openssl/x509.h>
|
||||
|
||||
static int X509_REVOKED_cmp(X509_REVOKED **a,X509_REVOKED **b);
|
||||
static int X509_REVOKED_seq_cmp(X509_REVOKED **a,X509_REVOKED **b);
|
||||
static int X509_REVOKED_cmp(const X509_REVOKED * const *a,
|
||||
const X509_REVOKED * const *b);
|
||||
static int X509_REVOKED_seq_cmp(const X509_REVOKED * const *a,
|
||||
const X509_REVOKED * const *b);
|
||||
int i2d_X509_REVOKED(X509_REVOKED *a, unsigned char **pp)
|
||||
{
|
||||
M_ASN1_I2D_vars(a);
|
||||
@ -100,7 +102,8 @@ int i2d_X509_CRL_INFO(X509_CRL_INFO *a, unsigned char **pp)
|
||||
{
|
||||
int v1=0;
|
||||
long l=0;
|
||||
int (*old_cmp)(X509_REVOKED **,X509_REVOKED **);
|
||||
int (*old_cmp)(const X509_REVOKED * const *,
|
||||
const X509_REVOKED * const *);
|
||||
M_ASN1_I2D_vars(a);
|
||||
|
||||
old_cmp=sk_X509_REVOKED_set_cmp_func(a->revoked,X509_REVOKED_seq_cmp);
|
||||
@ -283,7 +286,7 @@ void X509_REVOKED_free(X509_REVOKED *a)
|
||||
M_ASN1_INTEGER_free(a->serialNumber);
|
||||
M_ASN1_UTCTIME_free(a->revocationDate);
|
||||
sk_X509_EXTENSION_pop_free(a->extensions,X509_EXTENSION_free);
|
||||
Free(a);
|
||||
OPENSSL_free(a);
|
||||
}
|
||||
|
||||
void X509_CRL_INFO_free(X509_CRL_INFO *a)
|
||||
@ -297,7 +300,7 @@ void X509_CRL_INFO_free(X509_CRL_INFO *a)
|
||||
M_ASN1_UTCTIME_free(a->nextUpdate);
|
||||
sk_X509_REVOKED_pop_free(a->revoked,X509_REVOKED_free);
|
||||
sk_X509_EXTENSION_pop_free(a->extensions,X509_EXTENSION_free);
|
||||
Free(a);
|
||||
OPENSSL_free(a);
|
||||
}
|
||||
|
||||
void X509_CRL_free(X509_CRL *a)
|
||||
@ -322,17 +325,19 @@ void X509_CRL_free(X509_CRL *a)
|
||||
X509_CRL_INFO_free(a->crl);
|
||||
X509_ALGOR_free(a->sig_alg);
|
||||
M_ASN1_BIT_STRING_free(a->signature);
|
||||
Free(a);
|
||||
OPENSSL_free(a);
|
||||
}
|
||||
|
||||
static int X509_REVOKED_cmp(X509_REVOKED **a, X509_REVOKED **b)
|
||||
static int X509_REVOKED_cmp(const X509_REVOKED * const *a,
|
||||
const X509_REVOKED * const *b)
|
||||
{
|
||||
return(ASN1_STRING_cmp(
|
||||
(ASN1_STRING *)(*a)->serialNumber,
|
||||
(ASN1_STRING *)(*b)->serialNumber));
|
||||
}
|
||||
|
||||
static int X509_REVOKED_seq_cmp(X509_REVOKED **a, X509_REVOKED **b)
|
||||
static int X509_REVOKED_seq_cmp(const X509_REVOKED * const *a,
|
||||
const X509_REVOKED * const *b)
|
||||
{
|
||||
return((*a)->sequence-(*b)->sequence);
|
||||
}
|
||||
|
@ -134,6 +134,6 @@ void X509_EXTENSION_free(X509_EXTENSION *a)
|
||||
if (a == NULL) return;
|
||||
ASN1_OBJECT_free(a->object);
|
||||
M_ASN1_OCTET_STRING_free(a->value);
|
||||
Free(a);
|
||||
OPENSSL_free(a);
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ X509_INFO *X509_INFO_new(void)
|
||||
{
|
||||
X509_INFO *ret=NULL;
|
||||
|
||||
ret=(X509_INFO *)Malloc(sizeof(X509_INFO));
|
||||
ret=(X509_INFO *)OPENSSL_malloc(sizeof(X509_INFO));
|
||||
if (ret == NULL)
|
||||
{
|
||||
ASN1err(ASN1_F_X509_INFO_NEW,ERR_R_MALLOC_FAILURE);
|
||||
@ -106,8 +106,8 @@ void X509_INFO_free(X509_INFO *x)
|
||||
if (x->x509 != NULL) X509_free(x->x509);
|
||||
if (x->crl != NULL) X509_CRL_free(x->crl);
|
||||
if (x->x_pkey != NULL) X509_PKEY_free(x->x_pkey);
|
||||
if (x->enc_data != NULL) Free(x->enc_data);
|
||||
Free(x);
|
||||
if (x->enc_data != NULL) OPENSSL_free(x->enc_data);
|
||||
OPENSSL_free(x);
|
||||
}
|
||||
|
||||
IMPLEMENT_STACK_OF(X509_INFO)
|
||||
|
@ -217,7 +217,7 @@ X509_NAME *X509_NAME_new(void)
|
||||
ASN1_CTX c;
|
||||
|
||||
M_ASN1_New_Malloc(ret,X509_NAME);
|
||||
if ((ret->entries=sk_X509_NAME_ENTRY_new(NULL)) == NULL)
|
||||
if ((ret->entries=sk_X509_NAME_ENTRY_new_null()) == NULL)
|
||||
{ c.line=__LINE__; goto err2; }
|
||||
M_ASN1_New(ret->bytes,BUF_MEM_new);
|
||||
ret->modified=1;
|
||||
@ -246,7 +246,7 @@ void X509_NAME_free(X509_NAME *a)
|
||||
|
||||
BUF_MEM_free(a->bytes);
|
||||
sk_X509_NAME_ENTRY_pop_free(a->entries,X509_NAME_ENTRY_free);
|
||||
Free(a);
|
||||
OPENSSL_free(a);
|
||||
}
|
||||
|
||||
void X509_NAME_ENTRY_free(X509_NAME_ENTRY *a)
|
||||
@ -254,7 +254,7 @@ void X509_NAME_ENTRY_free(X509_NAME_ENTRY *a)
|
||||
if (a == NULL) return;
|
||||
ASN1_OBJECT_free(a->object);
|
||||
M_ASN1_BIT_STRING_free(a->value);
|
||||
Free(a);
|
||||
OPENSSL_free(a);
|
||||
}
|
||||
|
||||
int X509_NAME_set(X509_NAME **xn, X509_NAME *name)
|
||||
|
@ -146,6 +146,6 @@ void X509_PKEY_free(X509_PKEY *x)
|
||||
if (x->enc_algor != NULL) X509_ALGOR_free(x->enc_algor);
|
||||
if (x->enc_pkey != NULL) M_ASN1_OCTET_STRING_free(x->enc_pkey);
|
||||
if (x->dec_pkey != NULL)EVP_PKEY_free(x->dec_pkey);
|
||||
if ((x->key_data != NULL) && (x->key_free)) Free(x->key_data);
|
||||
Free(x);
|
||||
if ((x->key_data != NULL) && (x->key_free)) OPENSSL_free(x->key_data);
|
||||
OPENSSL_free(x);
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ void X509_PUBKEY_free(X509_PUBKEY *a)
|
||||
X509_ALGOR_free(a->algor);
|
||||
M_ASN1_BIT_STRING_free(a->public_key);
|
||||
if (a->pkey != NULL) EVP_PKEY_free(a->pkey);
|
||||
Free(a);
|
||||
OPENSSL_free(a);
|
||||
}
|
||||
|
||||
int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey)
|
||||
@ -156,14 +156,14 @@ int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey)
|
||||
dsa->write_params=0;
|
||||
ASN1_TYPE_free(a->parameter);
|
||||
i=i2d_DSAparams(dsa,NULL);
|
||||
p=(unsigned char *)Malloc(i);
|
||||
p=(unsigned char *)OPENSSL_malloc(i);
|
||||
pp=p;
|
||||
i2d_DSAparams(dsa,&pp);
|
||||
a->parameter=ASN1_TYPE_new();
|
||||
a->parameter->type=V_ASN1_SEQUENCE;
|
||||
a->parameter->value.sequence=ASN1_STRING_new();
|
||||
ASN1_STRING_set(a->parameter->value.sequence,p,i);
|
||||
Free(p);
|
||||
OPENSSL_free(p);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
@ -173,7 +173,7 @@ int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey)
|
||||
}
|
||||
|
||||
if ((i=i2d_PublicKey(pkey,NULL)) <= 0) goto err;
|
||||
if ((s=(unsigned char *)Malloc(i+1)) == NULL) goto err;
|
||||
if ((s=(unsigned char *)OPENSSL_malloc(i+1)) == NULL) goto err;
|
||||
p=s;
|
||||
i2d_PublicKey(pkey,&p);
|
||||
if (!M_ASN1_BIT_STRING_set(pk->public_key,s,i)) goto err;
|
||||
@ -181,7 +181,7 @@ int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey)
|
||||
pk->public_key->flags&= ~(ASN1_STRING_FLAG_BITS_LEFT|0x07);
|
||||
pk->public_key->flags|=ASN1_STRING_FLAG_BITS_LEFT;
|
||||
|
||||
Free(s);
|
||||
OPENSSL_free(s);
|
||||
|
||||
#if 0
|
||||
CRYPTO_add(&pkey->references,1,CRYPTO_LOCK_EVP_PKEY);
|
||||
|
@ -65,6 +65,14 @@ int i2d_X509_REQ_INFO(X509_REQ_INFO *a, unsigned char **pp)
|
||||
{
|
||||
M_ASN1_I2D_vars(a);
|
||||
|
||||
if(a->asn1) {
|
||||
if(pp) {
|
||||
memcpy(*pp, a->asn1, a->length);
|
||||
*pp += a->length;
|
||||
}
|
||||
return a->length;
|
||||
}
|
||||
|
||||
M_ASN1_I2D_len(a->version, i2d_ASN1_INTEGER);
|
||||
M_ASN1_I2D_len(a->subject, i2d_X509_NAME);
|
||||
M_ASN1_I2D_len(a->pubkey, i2d_X509_PUBKEY);
|
||||
@ -152,6 +160,7 @@ X509_REQ_INFO *X509_REQ_INFO_new(void)
|
||||
M_ASN1_New(ret->pubkey,X509_PUBKEY_new);
|
||||
M_ASN1_New(ret->attributes,sk_X509_ATTRIBUTE_new_null);
|
||||
ret->req_kludge=0;
|
||||
ret->asn1 = NULL;
|
||||
return(ret);
|
||||
M_ASN1_New_Error(ASN1_F_X509_REQ_INFO_NEW);
|
||||
}
|
||||
@ -159,11 +168,12 @@ X509_REQ_INFO *X509_REQ_INFO_new(void)
|
||||
void X509_REQ_INFO_free(X509_REQ_INFO *a)
|
||||
{
|
||||
if (a == NULL) return;
|
||||
if(a->asn1) OPENSSL_free(a->asn1);
|
||||
M_ASN1_INTEGER_free(a->version);
|
||||
X509_NAME_free(a->subject);
|
||||
X509_PUBKEY_free(a->pubkey);
|
||||
sk_X509_ATTRIBUTE_pop_free(a->attributes,X509_ATTRIBUTE_free);
|
||||
Free(a);
|
||||
OPENSSL_free(a);
|
||||
}
|
||||
|
||||
int i2d_X509_REQ(X509_REQ *a, unsigned char **pp)
|
||||
@ -189,6 +199,17 @@ X509_REQ *d2i_X509_REQ(X509_REQ **a, unsigned char **pp, long length)
|
||||
M_ASN1_D2I_Init();
|
||||
M_ASN1_D2I_start_sequence();
|
||||
M_ASN1_D2I_get(ret->req_info,d2i_X509_REQ_INFO);
|
||||
|
||||
/* Keep a copy of the original encoding for signature checking */
|
||||
ret->req_info->length = c.p - c.q;
|
||||
if(!(ret->req_info->asn1 = OPENSSL_malloc(ret->req_info->length))) {
|
||||
c.line=__LINE__;
|
||||
c.error = ERR_R_MALLOC_FAILURE;
|
||||
goto err;
|
||||
}
|
||||
|
||||
memcpy(ret->req_info->asn1, c.q, ret->req_info->length);
|
||||
|
||||
M_ASN1_D2I_get(ret->sig_alg,d2i_X509_ALGOR);
|
||||
M_ASN1_D2I_get(ret->signature,d2i_ASN1_BIT_STRING);
|
||||
M_ASN1_D2I_Finish(a,X509_REQ_free,ASN1_F_D2I_X509_REQ);
|
||||
@ -230,7 +251,7 @@ void X509_REQ_free(X509_REQ *a)
|
||||
X509_REQ_INFO_free(a->req_info);
|
||||
X509_ALGOR_free(a->sig_alg);
|
||||
M_ASN1_BIT_STRING_free(a->signature);
|
||||
Free(a);
|
||||
OPENSSL_free(a);
|
||||
}
|
||||
|
||||
|
||||
|
@ -104,7 +104,7 @@ void X509_SIG_free(X509_SIG *a)
|
||||
if (a == NULL) return;
|
||||
X509_ALGOR_free(a->algor);
|
||||
M_ASN1_OCTET_STRING_free(a->digest);
|
||||
Free(a);
|
||||
OPENSSL_free(a);
|
||||
}
|
||||
|
||||
|
||||
|
@ -109,7 +109,7 @@ void NETSCAPE_SPKAC_free(NETSCAPE_SPKAC *a)
|
||||
if (a == NULL) return;
|
||||
X509_PUBKEY_free(a->pubkey);
|
||||
M_ASN1_IA5STRING_free(a->challenge);
|
||||
Free(a);
|
||||
OPENSSL_free(a);
|
||||
}
|
||||
|
||||
int i2d_NETSCAPE_SPKI(NETSCAPE_SPKI *a, unsigned char **pp)
|
||||
@ -161,6 +161,6 @@ void NETSCAPE_SPKI_free(NETSCAPE_SPKI *a)
|
||||
NETSCAPE_SPKAC_free(a->spkac);
|
||||
X509_ALGOR_free(a->sig_algor);
|
||||
M_ASN1_BIT_STRING_free(a->signature);
|
||||
Free(a);
|
||||
OPENSSL_free(a);
|
||||
}
|
||||
|
||||
|
@ -104,6 +104,6 @@ void X509_VAL_free(X509_VAL *a)
|
||||
if (a == NULL) return;
|
||||
M_ASN1_TIME_free(a->notBefore);
|
||||
M_ASN1_TIME_free(a->notAfter);
|
||||
Free(a);
|
||||
OPENSSL_free(a);
|
||||
}
|
||||
|
||||
|
@ -61,6 +61,7 @@
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/asn1_mac.h>
|
||||
#include <openssl/x509.h>
|
||||
#include <openssl/x509v3.h>
|
||||
|
||||
static int x509_meth_num = 0;
|
||||
static STACK_OF(CRYPTO_EX_DATA_FUNCS) *x509_meth = NULL;
|
||||
@ -102,7 +103,7 @@ X509 *d2i_X509(X509 **a, unsigned char **pp, long length)
|
||||
M_ASN1_D2I_get(ret->cert_info,d2i_X509_CINF);
|
||||
M_ASN1_D2I_get(ret->sig_alg,d2i_X509_ALGOR);
|
||||
M_ASN1_D2I_get(ret->signature,d2i_ASN1_BIT_STRING);
|
||||
if (ret->name != NULL) Free(ret->name);
|
||||
if (ret->name != NULL) OPENSSL_free(ret->name);
|
||||
ret->name=X509_NAME_oneline(ret->cert_info->subject,NULL,0);
|
||||
|
||||
M_ASN1_D2I_Finish(a,X509_free,ASN1_F_D2I_X509);
|
||||
@ -114,11 +115,14 @@ X509 *X509_new(void)
|
||||
ASN1_CTX c;
|
||||
|
||||
M_ASN1_New_Malloc(ret,X509);
|
||||
ret->references=1;
|
||||
ret->valid=0;
|
||||
ret->references=1;
|
||||
ret->name = NULL;
|
||||
ret->ex_flags = 0;
|
||||
ret->name=NULL;
|
||||
ret->aux=NULL;
|
||||
ret->ex_pathlen = -1;
|
||||
ret->skid = NULL;
|
||||
ret->akid = NULL;
|
||||
ret->aux = NULL;
|
||||
M_ASN1_New(ret->cert_info,X509_CINF_new);
|
||||
M_ASN1_New(ret->sig_alg,X509_ALGOR_new);
|
||||
M_ASN1_New(ret->signature,M_ASN1_BIT_STRING_new);
|
||||
@ -151,9 +155,11 @@ void X509_free(X509 *a)
|
||||
X509_ALGOR_free(a->sig_alg);
|
||||
M_ASN1_BIT_STRING_free(a->signature);
|
||||
X509_CERT_AUX_free(a->aux);
|
||||
ASN1_OCTET_STRING_free(a->skid);
|
||||
AUTHORITY_KEYID_free(a->akid);
|
||||
|
||||
if (a->name != NULL) Free(a->name);
|
||||
Free(a);
|
||||
if (a->name != NULL) OPENSSL_free(a->name);
|
||||
OPENSSL_free(a);
|
||||
}
|
||||
|
||||
int X509_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
|
||||
|
@ -112,7 +112,7 @@ void X509_CERT_AUX_free(X509_CERT_AUX *a)
|
||||
ASN1_UTF8STRING_free(a->alias);
|
||||
ASN1_OCTET_STRING_free(a->keyid);
|
||||
sk_X509_ALGOR_pop_free(a->other, X509_ALGOR_free);
|
||||
Free(a);
|
||||
OPENSSL_free(a);
|
||||
}
|
||||
|
||||
int i2d_X509_CERT_AUX(X509_CERT_AUX *a, unsigned char **pp)
|
||||
@ -153,6 +153,14 @@ int X509_alias_set1(X509 *x, unsigned char *name, int len)
|
||||
return ASN1_STRING_set(aux->alias, name, len);
|
||||
}
|
||||
|
||||
int X509_keyid_set1(X509 *x, unsigned char *id, int len)
|
||||
{
|
||||
X509_CERT_AUX *aux;
|
||||
if(!(aux = aux_get(x))) return 0;
|
||||
if(!aux->keyid && !(aux->keyid = ASN1_OCTET_STRING_new())) return 0;
|
||||
return ASN1_STRING_set(aux->keyid, id, len);
|
||||
}
|
||||
|
||||
unsigned char *X509_alias_get0(X509 *x, int *len)
|
||||
{
|
||||
if(!x->aux || !x->aux->alias) return NULL;
|
||||
|
@ -77,7 +77,9 @@ links:
|
||||
@$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
|
||||
@$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
|
||||
|
||||
install:
|
||||
install: installs
|
||||
|
||||
installs:
|
||||
@for i in $(EXHEADER) ; \
|
||||
do \
|
||||
(cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
|
||||
|
@ -442,7 +442,8 @@ static int test(void)
|
||||
{
|
||||
BF_set_key(&key,n,key_test);
|
||||
BF_ecb_encrypt(key_data,out,&key,BF_ENCRYPT);
|
||||
if (memcmp(out,&(key_out[n-1][0]),8) != 0)
|
||||
/* mips-sgi-irix6.5-gcc vv -mabi=64 bug workaround */
|
||||
if (memcmp(out,&(key_out[i=n-1][0]),8) != 0)
|
||||
{
|
||||
printf("blowfish setkey error\n");
|
||||
err=1;
|
||||
|
@ -27,11 +27,13 @@ LIBSRC= bio_lib.c bio_cb.c bio_err.c \
|
||||
bss_file.c bss_sock.c bss_conn.c \
|
||||
bf_null.c bf_buff.c b_print.c b_dump.c \
|
||||
b_sock.c bss_acpt.c bf_nbio.c bss_log.c bss_bio.c
|
||||
# bf_lbuf.c
|
||||
LIBOBJ= bio_lib.o bio_cb.o bio_err.o \
|
||||
bss_mem.o bss_null.o bss_fd.o \
|
||||
bss_file.o bss_sock.o bss_conn.o \
|
||||
bf_null.o bf_buff.o b_print.o b_dump.o \
|
||||
b_sock.o bss_acpt.o bf_nbio.o bss_log.o bss_bio.o
|
||||
# bf_lbuf.o
|
||||
|
||||
SRC= $(LIBSRC)
|
||||
|
||||
@ -89,20 +91,23 @@ clean:
|
||||
b_dump.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
|
||||
b_dump.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
|
||||
b_dump.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
|
||||
b_dump.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
|
||||
b_dump.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
|
||||
b_dump.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
|
||||
b_dump.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
|
||||
b_dump.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
|
||||
b_dump.o: ../cryptlib.h
|
||||
b_print.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
|
||||
b_print.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
|
||||
b_print.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
|
||||
b_print.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
|
||||
b_print.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
|
||||
b_print.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
|
||||
b_print.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
|
||||
b_print.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
|
||||
b_print.o: ../cryptlib.h
|
||||
b_sock.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
|
||||
b_sock.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
|
||||
b_sock.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
|
||||
b_sock.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
|
||||
b_sock.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
|
||||
b_sock.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
|
||||
b_sock.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
|
||||
b_sock.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
|
||||
b_sock.o: ../cryptlib.h
|
||||
bf_buff.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
|
||||
bf_buff.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
|
||||
@ -111,14 +116,16 @@ bf_buff.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
|
||||
bf_buff.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
|
||||
bf_buff.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
|
||||
bf_buff.o: ../../include/openssl/err.h ../../include/openssl/evp.h
|
||||
bf_buff.o: ../../include/openssl/idea.h ../../include/openssl/md2.h
|
||||
bf_buff.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
|
||||
bf_buff.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
|
||||
bf_buff.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
|
||||
bf_buff.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
|
||||
bf_buff.o: ../../include/openssl/opensslv.h ../../include/openssl/rc2.h
|
||||
bf_buff.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
|
||||
bf_buff.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
|
||||
bf_buff.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
|
||||
bf_buff.o: ../../include/openssl/stack.h ../cryptlib.h
|
||||
bf_buff.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
|
||||
bf_buff.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
|
||||
bf_buff.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
|
||||
bf_buff.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
|
||||
bf_buff.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
|
||||
bf_buff.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
|
||||
bf_buff.o: ../../include/openssl/symhacks.h ../cryptlib.h
|
||||
bf_nbio.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
|
||||
bf_nbio.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
|
||||
bf_nbio.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
|
||||
@ -126,14 +133,16 @@ bf_nbio.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
|
||||
bf_nbio.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
|
||||
bf_nbio.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
|
||||
bf_nbio.o: ../../include/openssl/err.h ../../include/openssl/evp.h
|
||||
bf_nbio.o: ../../include/openssl/idea.h ../../include/openssl/md2.h
|
||||
bf_nbio.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
|
||||
bf_nbio.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
|
||||
bf_nbio.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
|
||||
bf_nbio.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
|
||||
bf_nbio.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h
|
||||
bf_nbio.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
|
||||
bf_nbio.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
|
||||
bf_nbio.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
|
||||
bf_nbio.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
|
||||
bf_nbio.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
|
||||
bf_nbio.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
|
||||
bf_nbio.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h
|
||||
bf_nbio.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
|
||||
bf_nbio.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
|
||||
bf_nbio.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
|
||||
bf_nbio.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
|
||||
bf_nbio.o: ../cryptlib.h
|
||||
bf_null.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
|
||||
bf_null.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
|
||||
@ -142,79 +151,93 @@ bf_null.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
|
||||
bf_null.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
|
||||
bf_null.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
|
||||
bf_null.o: ../../include/openssl/err.h ../../include/openssl/evp.h
|
||||
bf_null.o: ../../include/openssl/idea.h ../../include/openssl/md2.h
|
||||
bf_null.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
|
||||
bf_null.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
|
||||
bf_null.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
|
||||
bf_null.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
|
||||
bf_null.o: ../../include/openssl/opensslv.h ../../include/openssl/rc2.h
|
||||
bf_null.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
|
||||
bf_null.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
|
||||
bf_null.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
|
||||
bf_null.o: ../../include/openssl/stack.h ../cryptlib.h
|
||||
bf_null.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
|
||||
bf_null.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
|
||||
bf_null.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
|
||||
bf_null.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
|
||||
bf_null.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
|
||||
bf_null.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
|
||||
bf_null.o: ../../include/openssl/symhacks.h ../cryptlib.h
|
||||
bio_cb.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
|
||||
bio_cb.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
|
||||
bio_cb.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
|
||||
bio_cb.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
|
||||
bio_cb.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
|
||||
bio_cb.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
|
||||
bio_cb.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
|
||||
bio_cb.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
|
||||
bio_cb.o: ../cryptlib.h
|
||||
bio_err.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h
|
||||
bio_err.o: ../../include/openssl/err.h ../../include/openssl/opensslv.h
|
||||
bio_err.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
|
||||
bio_err.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
|
||||
bio_err.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
|
||||
bio_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
|
||||
bio_lib.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
|
||||
bio_lib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
|
||||
bio_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
|
||||
bio_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
|
||||
bio_lib.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
|
||||
bio_lib.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
|
||||
bio_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
|
||||
bio_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
|
||||
bio_lib.o: ../cryptlib.h
|
||||
bss_acpt.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
|
||||
bss_acpt.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
|
||||
bss_acpt.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
|
||||
bss_acpt.o: ../../include/openssl/opensslconf.h
|
||||
bss_acpt.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
|
||||
bss_acpt.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
|
||||
bss_acpt.o: ../../include/openssl/stack.h ../cryptlib.h
|
||||
bss_acpt.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
|
||||
bss_acpt.o: ../cryptlib.h
|
||||
bss_bio.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h
|
||||
bss_bio.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
|
||||
bss_bio.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
|
||||
bss_bio.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
|
||||
bss_bio.o: ../../include/openssl/stack.h
|
||||
bss_bio.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
|
||||
bss_bio.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
|
||||
bss_bio.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
|
||||
bss_bio.o: ../../include/openssl/symhacks.h
|
||||
bss_conn.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
|
||||
bss_conn.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
|
||||
bss_conn.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
|
||||
bss_conn.o: ../../include/openssl/opensslconf.h
|
||||
bss_conn.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
|
||||
bss_conn.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
|
||||
bss_conn.o: ../../include/openssl/stack.h ../cryptlib.h
|
||||
bss_conn.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
|
||||
bss_conn.o: ../cryptlib.h
|
||||
bss_fd.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
|
||||
bss_fd.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
|
||||
bss_fd.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
|
||||
bss_fd.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
|
||||
bss_fd.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
|
||||
bss_fd.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
|
||||
bss_fd.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
|
||||
bss_fd.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
|
||||
bss_fd.o: ../cryptlib.h bss_sock.c
|
||||
bss_file.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
|
||||
bss_file.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
|
||||
bss_file.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
|
||||
bss_file.o: ../../include/openssl/opensslconf.h
|
||||
bss_file.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
|
||||
bss_file.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
|
||||
bss_file.o: ../../include/openssl/stack.h ../cryptlib.h
|
||||
bss_file.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
|
||||
bss_file.o: ../cryptlib.h
|
||||
bss_log.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
|
||||
bss_log.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
|
||||
bss_log.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
|
||||
bss_log.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
|
||||
bss_log.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
|
||||
bss_log.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
|
||||
bss_log.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
|
||||
bss_log.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
|
||||
bss_log.o: ../cryptlib.h
|
||||
bss_mem.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
|
||||
bss_mem.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
|
||||
bss_mem.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
|
||||
bss_mem.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
|
||||
bss_mem.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
|
||||
bss_mem.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
|
||||
bss_mem.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
|
||||
bss_mem.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
|
||||
bss_mem.o: ../cryptlib.h
|
||||
bss_null.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
|
||||
bss_null.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
|
||||
bss_null.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
|
||||
bss_null.o: ../../include/openssl/opensslconf.h
|
||||
bss_null.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
|
||||
bss_null.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
|
||||
bss_null.o: ../../include/openssl/stack.h ../cryptlib.h
|
||||
bss_null.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
|
||||
bss_null.o: ../cryptlib.h
|
||||
bss_sock.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
|
||||
bss_sock.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
|
||||
bss_sock.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
|
||||
bss_sock.o: ../../include/openssl/opensslconf.h
|
||||
bss_sock.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
|
||||
bss_sock.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
|
||||
bss_sock.o: ../../include/openssl/stack.h ../cryptlib.h
|
||||
bss_sock.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
|
||||
bss_sock.o: ../cryptlib.h
|
||||
|
@ -66,63 +66,87 @@
|
||||
|
||||
#define TRUNCATE
|
||||
#define DUMP_WIDTH 16
|
||||
#define DUMP_WIDTH_LESS_INDENT(i) (DUMP_WIDTH-((i-(i>6?6:i)+3)/4))
|
||||
|
||||
int BIO_dump(BIO *bio, const char *s, int len)
|
||||
{
|
||||
int ret=0;
|
||||
char buf[160+1],tmp[20];
|
||||
int i,j,rows,trunc;
|
||||
unsigned char ch;
|
||||
|
||||
trunc=0;
|
||||
{
|
||||
return BIO_dump_indent(bio, s, len, 0);
|
||||
}
|
||||
|
||||
int BIO_dump_indent(BIO *bio, const char *s, int len, int indent)
|
||||
{
|
||||
int ret=0;
|
||||
char buf[288+1],tmp[20],str[128+1];
|
||||
int i,j,rows,trunc;
|
||||
unsigned char ch;
|
||||
int dump_width;
|
||||
|
||||
trunc=0;
|
||||
|
||||
#ifdef TRUNCATE
|
||||
for(; (len > 0) && ((s[len-1] == ' ') || (s[len-1] == '\0')); len--)
|
||||
trunc++;
|
||||
for(; (len > 0) && ((s[len-1] == ' ') || (s[len-1] == '\0')); len--)
|
||||
trunc++;
|
||||
#endif
|
||||
|
||||
rows=(len/DUMP_WIDTH);
|
||||
if ((rows*DUMP_WIDTH)<len)
|
||||
rows++;
|
||||
for(i=0;i<rows;i++) {
|
||||
buf[0]='\0'; /* start with empty string */
|
||||
sprintf(tmp,"%04x - ",i*DUMP_WIDTH);
|
||||
strcpy(buf,tmp);
|
||||
for(j=0;j<DUMP_WIDTH;j++) {
|
||||
if (((i*DUMP_WIDTH)+j)>=len) {
|
||||
strcat(buf," ");
|
||||
} else {
|
||||
ch=((unsigned char)*(s+i*DUMP_WIDTH+j)) & 0xff;
|
||||
sprintf(tmp,"%02x%c",ch,j==7?'-':' ');
|
||||
strcat(buf,tmp);
|
||||
}
|
||||
}
|
||||
strcat(buf," ");
|
||||
for(j=0;j<DUMP_WIDTH;j++) {
|
||||
if (((i*DUMP_WIDTH)+j)>=len)
|
||||
break;
|
||||
ch=((unsigned char)*(s+i*DUMP_WIDTH+j)) & 0xff;
|
||||
if (indent < 0)
|
||||
indent = 0;
|
||||
if (indent)
|
||||
{
|
||||
if (indent > 128) indent=128;
|
||||
memset(str,' ',indent);
|
||||
}
|
||||
str[indent]='\0';
|
||||
|
||||
dump_width=DUMP_WIDTH_LESS_INDENT(indent);
|
||||
rows=(len/dump_width);
|
||||
if ((rows*dump_width)<len)
|
||||
rows++;
|
||||
for(i=0;i<rows;i++)
|
||||
{
|
||||
buf[0]='\0'; /* start with empty string */
|
||||
strcpy(buf,str);
|
||||
sprintf(tmp,"%04x - ",i*dump_width);
|
||||
strcat(buf,tmp);
|
||||
for(j=0;j<dump_width;j++)
|
||||
{
|
||||
if (((i*dump_width)+j)>=len)
|
||||
{
|
||||
strcat(buf," ");
|
||||
}
|
||||
else
|
||||
{
|
||||
ch=((unsigned char)*(s+i*dump_width+j)) & 0xff;
|
||||
sprintf(tmp,"%02x%c",ch,j==7?'-':' ');
|
||||
strcat(buf,tmp);
|
||||
}
|
||||
}
|
||||
strcat(buf," ");
|
||||
for(j=0;j<dump_width;j++)
|
||||
{
|
||||
if (((i*dump_width)+j)>=len)
|
||||
break;
|
||||
ch=((unsigned char)*(s+i*dump_width+j)) & 0xff;
|
||||
#ifndef CHARSET_EBCDIC
|
||||
sprintf(tmp,"%c",((ch>=' ')&&(ch<='~'))?ch:'.');
|
||||
sprintf(tmp,"%c",((ch>=' ')&&(ch<='~'))?ch:'.');
|
||||
#else
|
||||
sprintf(tmp,"%c",((ch>=os_toascii[' '])&&(ch<=os_toascii['~']))
|
||||
? os_toebcdic[ch]
|
||||
: '.');
|
||||
sprintf(tmp,"%c",((ch>=os_toascii[' '])&&(ch<=os_toascii['~']))
|
||||
? os_toebcdic[ch]
|
||||
: '.');
|
||||
#endif
|
||||
strcat(buf,tmp);
|
||||
}
|
||||
strcat(buf,"\n");
|
||||
/* if this is the last call then update the ddt_dump thing so that
|
||||
* we will move the selection point in the debug window
|
||||
*/
|
||||
ret+=BIO_write(bio,(char *)buf,strlen(buf));
|
||||
}
|
||||
strcat(buf,tmp);
|
||||
}
|
||||
strcat(buf,"\n");
|
||||
/* if this is the last call then update the ddt_dump thing so that
|
||||
* we will move the selection point in the debug window
|
||||
*/
|
||||
ret+=BIO_write(bio,(char *)buf,strlen(buf));
|
||||
}
|
||||
#ifdef TRUNCATE
|
||||
if (trunc > 0) {
|
||||
sprintf(buf,"%04x - <SPACES/NULS>\n",len+trunc);
|
||||
ret+=BIO_write(bio,(char *)buf,strlen(buf));
|
||||
}
|
||||
if (trunc > 0)
|
||||
{
|
||||
sprintf(buf,"%s%04x - <SPACES/NULS>\n",str,len+trunc);
|
||||
ret+=BIO_write(bio,(char *)buf,strlen(buf));
|
||||
}
|
||||
#endif
|
||||
return(ret);
|
||||
}
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
@ -61,7 +61,6 @@
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <assert.h>
|
||||
@ -78,48 +77,7 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
static void dopr (char *buffer, size_t maxlen, size_t *retlen,
|
||||
const char *format, va_list args);
|
||||
#ifdef USE_ALLOCATING_PRINT
|
||||
static void doapr (char **buffer, size_t *retlen,
|
||||
const char *format, va_list args);
|
||||
#endif
|
||||
|
||||
int BIO_printf (BIO *bio, ...)
|
||||
{
|
||||
va_list args;
|
||||
char *format;
|
||||
int ret;
|
||||
size_t retlen;
|
||||
#ifdef USE_ALLOCATING_PRINT
|
||||
char *hugebuf;
|
||||
#else
|
||||
MS_STATIC char hugebuf[1024*2]; /* 10k in one chunk is the limit */
|
||||
#endif
|
||||
|
||||
va_start(args, bio);
|
||||
format=va_arg(args, char *);
|
||||
|
||||
#ifndef USE_ALLOCATING_PRINT
|
||||
hugebuf[0]='\0';
|
||||
dopr(hugebuf, sizeof(hugebuf), &retlen, format, args);
|
||||
#else
|
||||
hugebuf = NULL;
|
||||
CRYPTO_push_info("doapr()");
|
||||
doapr(&hugebuf, &retlen, format, args);
|
||||
if (hugebuf)
|
||||
{
|
||||
#endif
|
||||
ret=BIO_write(bio, hugebuf, (int)retlen);
|
||||
|
||||
#ifdef USE_ALLOCATING_PRINT
|
||||
Free(hugebuf);
|
||||
}
|
||||
CRYPTO_pop_info();
|
||||
#endif
|
||||
va_end(args);
|
||||
return(ret);
|
||||
}
|
||||
/***************************************************************************/
|
||||
|
||||
/*
|
||||
* Copyright Patrick Powell 1995
|
||||
@ -140,6 +98,7 @@ int BIO_printf (BIO *bio, ...)
|
||||
* o Andrew Tridgell <tridge@samba.org> (1998, for Samba)
|
||||
* o Luke Mewburn <lukem@netbsd.org> (1999, for LukemFTP)
|
||||
* o Ralf S. Engelschall <rse@engelschall.com> (1999, for Pth)
|
||||
* o ... (for OpenSSL)
|
||||
*/
|
||||
|
||||
#if HAVE_LONG_DOUBLE
|
||||
@ -154,25 +113,15 @@ int BIO_printf (BIO *bio, ...)
|
||||
#define LLONG long
|
||||
#endif
|
||||
|
||||
static void fmtstr (void (*)(char **, size_t *, size_t *, int),
|
||||
char **, size_t *, size_t *, const char *, int, int,
|
||||
int);
|
||||
static void fmtint (void (*)(char **, size_t *, size_t *, int),
|
||||
char **, size_t *, size_t *, LLONG, int, int, int, int);
|
||||
static void fmtfp (void (*)(char **, size_t *, size_t *, int),
|
||||
char **, size_t *, size_t *, LDOUBLE, int, int, int);
|
||||
#ifndef USE_ALLOCATING_PRINT
|
||||
static int dopr_isbig (size_t, size_t);
|
||||
static int dopr_copy (size_t);
|
||||
static void dopr_outch (char **, size_t *, size_t *, int);
|
||||
#else
|
||||
static int doapr_isbig (size_t, size_t);
|
||||
static int doapr_copy (size_t);
|
||||
static void doapr_outch (char **, size_t *, size_t *, int);
|
||||
#endif
|
||||
static void _dopr(void (*)(char **, size_t *, size_t *, int),
|
||||
int (*)(size_t, size_t), int (*)(size_t),
|
||||
char **buffer, size_t *maxlen, size_t *retlen,
|
||||
static void fmtstr (char **, char **, size_t *, size_t *,
|
||||
const char *, int, int, int);
|
||||
static void fmtint (char **, char **, size_t *, size_t *,
|
||||
LLONG, int, int, int, int);
|
||||
static void fmtfp (char **, char **, size_t *, size_t *,
|
||||
LDOUBLE, int, int, int);
|
||||
static void doapr_outch (char **, char **, size_t *, size_t *, int);
|
||||
static void _dopr(char **sbuffer, char **buffer,
|
||||
size_t *maxlen, size_t *retlen, int *truncated,
|
||||
const char *format, va_list args);
|
||||
|
||||
/* format read states */
|
||||
@ -204,41 +153,13 @@ static void _dopr(void (*)(char **, size_t *, size_t *, int),
|
||||
#define char_to_int(p) (p - '0')
|
||||
#define MAX(p,q) ((p >= q) ? p : q)
|
||||
|
||||
#ifndef USE_ALLOCATING_PRINT
|
||||
static void
|
||||
dopr(
|
||||
char *buffer,
|
||||
size_t maxlen,
|
||||
size_t *retlen,
|
||||
const char *format,
|
||||
va_list args)
|
||||
{
|
||||
_dopr(dopr_outch, dopr_isbig, dopr_copy,
|
||||
&buffer, &maxlen, retlen, format, args);
|
||||
}
|
||||
|
||||
#else
|
||||
static void
|
||||
doapr(
|
||||
char **buffer,
|
||||
size_t *retlen,
|
||||
const char *format,
|
||||
va_list args)
|
||||
{
|
||||
size_t dummy_maxlen = 0;
|
||||
_dopr(doapr_outch, doapr_isbig, doapr_copy,
|
||||
buffer, &dummy_maxlen, retlen, format, args);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
_dopr(
|
||||
void (*outch_fn)(char **, size_t *, size_t *, int),
|
||||
int (*isbig_fn)(size_t, size_t),
|
||||
int (*copy_fn)(size_t),
|
||||
char **sbuffer,
|
||||
char **buffer,
|
||||
size_t *maxlen,
|
||||
size_t *retlen,
|
||||
int *truncated,
|
||||
const char *format,
|
||||
va_list args)
|
||||
{
|
||||
@ -259,7 +180,7 @@ _dopr(
|
||||
ch = *format++;
|
||||
|
||||
while (state != DP_S_DONE) {
|
||||
if ((ch == '\0') || (*isbig_fn)(currlen, *maxlen))
|
||||
if (ch == '\0' || (buffer == NULL && currlen >= *maxlen))
|
||||
state = DP_S_DONE;
|
||||
|
||||
switch (state) {
|
||||
@ -267,7 +188,7 @@ _dopr(
|
||||
if (ch == '%')
|
||||
state = DP_S_FLAGS;
|
||||
else
|
||||
(*outch_fn)(buffer, &currlen, maxlen, ch);
|
||||
doapr_outch(sbuffer,buffer, &currlen, maxlen, ch);
|
||||
ch = *format++;
|
||||
break;
|
||||
case DP_S_FLAGS:
|
||||
@ -373,8 +294,8 @@ _dopr(
|
||||
value = va_arg(args, int);
|
||||
break;
|
||||
}
|
||||
fmtint(outch_fn, buffer, &currlen, maxlen,
|
||||
value, 10, min, max, flags);
|
||||
fmtint(sbuffer, buffer, &currlen, maxlen,
|
||||
value, 10, min, max, flags);
|
||||
break;
|
||||
case 'X':
|
||||
flags |= DP_F_UP;
|
||||
@ -399,7 +320,7 @@ _dopr(
|
||||
unsigned int);
|
||||
break;
|
||||
}
|
||||
fmtint(outch_fn, buffer, &currlen, maxlen, value,
|
||||
fmtint(sbuffer, buffer, &currlen, maxlen, value,
|
||||
ch == 'o' ? 8 : (ch == 'u' ? 10 : 16),
|
||||
min, max, flags);
|
||||
break;
|
||||
@ -408,8 +329,8 @@ _dopr(
|
||||
fvalue = va_arg(args, LDOUBLE);
|
||||
else
|
||||
fvalue = va_arg(args, double);
|
||||
fmtfp(outch_fn, buffer, &currlen, maxlen,
|
||||
fvalue, min, max, flags);
|
||||
fmtfp(sbuffer, buffer, &currlen, maxlen,
|
||||
fvalue, min, max, flags);
|
||||
break;
|
||||
case 'E':
|
||||
flags |= DP_F_UP;
|
||||
@ -428,19 +349,23 @@ _dopr(
|
||||
fvalue = va_arg(args, double);
|
||||
break;
|
||||
case 'c':
|
||||
(*outch_fn)(buffer, &currlen, maxlen,
|
||||
doapr_outch(sbuffer, buffer, &currlen, maxlen,
|
||||
va_arg(args, int));
|
||||
break;
|
||||
case 's':
|
||||
strvalue = va_arg(args, char *);
|
||||
if (max < 0)
|
||||
max = (*copy_fn)(*maxlen);
|
||||
fmtstr(outch_fn, buffer, &currlen, maxlen, strvalue,
|
||||
flags, min, max);
|
||||
if (max < 0) {
|
||||
if (buffer)
|
||||
max = INT_MAX;
|
||||
else
|
||||
max = *maxlen;
|
||||
}
|
||||
fmtstr(sbuffer, buffer, &currlen, maxlen, strvalue,
|
||||
flags, min, max);
|
||||
break;
|
||||
case 'p':
|
||||
value = (long)va_arg(args, void *);
|
||||
fmtint(outch_fn, buffer, &currlen, maxlen,
|
||||
fmtint(sbuffer, buffer, &currlen, maxlen,
|
||||
value, 16, min, max, flags);
|
||||
break;
|
||||
case 'n': /* XXX */
|
||||
@ -463,7 +388,7 @@ _dopr(
|
||||
}
|
||||
break;
|
||||
case '%':
|
||||
(*outch_fn)(buffer, &currlen, maxlen, ch);
|
||||
doapr_outch(sbuffer, buffer, &currlen, maxlen, ch);
|
||||
break;
|
||||
case 'w':
|
||||
/* not supported yet, treat as next char */
|
||||
@ -484,16 +409,17 @@ _dopr(
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (currlen >= *maxlen - 1)
|
||||
*truncated = (currlen > *maxlen - 1);
|
||||
if (*truncated)
|
||||
currlen = *maxlen - 1;
|
||||
(*buffer)[currlen] = '\0';
|
||||
*retlen = currlen;
|
||||
doapr_outch(sbuffer, buffer, &currlen, maxlen, '\0');
|
||||
*retlen = currlen - 1;
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
fmtstr(
|
||||
void (*outch_fn)(char **, size_t *, size_t *, int),
|
||||
char **sbuffer,
|
||||
char **buffer,
|
||||
size_t *currlen,
|
||||
size_t *maxlen,
|
||||
@ -516,16 +442,16 @@ fmtstr(
|
||||
padlen = -padlen;
|
||||
|
||||
while ((padlen > 0) && (cnt < max)) {
|
||||
(*outch_fn)(buffer, currlen, maxlen, ' ');
|
||||
doapr_outch(sbuffer, buffer, currlen, maxlen, ' ');
|
||||
--padlen;
|
||||
++cnt;
|
||||
}
|
||||
while (*value && (cnt < max)) {
|
||||
(*outch_fn)(buffer, currlen, maxlen, *value++);
|
||||
doapr_outch(sbuffer, buffer, currlen, maxlen, *value++);
|
||||
++cnt;
|
||||
}
|
||||
while ((padlen < 0) && (cnt < max)) {
|
||||
(*outch_fn)(buffer, currlen, maxlen, ' ');
|
||||
doapr_outch(sbuffer, buffer, currlen, maxlen, ' ');
|
||||
++padlen;
|
||||
++cnt;
|
||||
}
|
||||
@ -533,7 +459,7 @@ fmtstr(
|
||||
|
||||
static void
|
||||
fmtint(
|
||||
void (*outch_fn)(char **, size_t *, size_t *, int),
|
||||
char **sbuffer,
|
||||
char **buffer,
|
||||
size_t *currlen,
|
||||
size_t *maxlen,
|
||||
@ -590,28 +516,28 @@ fmtint(
|
||||
|
||||
/* spaces */
|
||||
while (spadlen > 0) {
|
||||
(*outch_fn)(buffer, currlen, maxlen, ' ');
|
||||
doapr_outch(sbuffer, buffer, currlen, maxlen, ' ');
|
||||
--spadlen;
|
||||
}
|
||||
|
||||
/* sign */
|
||||
if (signvalue)
|
||||
(*outch_fn)(buffer, currlen, maxlen, signvalue);
|
||||
doapr_outch(sbuffer, buffer, currlen, maxlen, signvalue);
|
||||
|
||||
/* zeros */
|
||||
if (zpadlen > 0) {
|
||||
while (zpadlen > 0) {
|
||||
(*outch_fn)(buffer, currlen, maxlen, '0');
|
||||
doapr_outch(sbuffer, buffer, currlen, maxlen, '0');
|
||||
--zpadlen;
|
||||
}
|
||||
}
|
||||
/* digits */
|
||||
while (place > 0)
|
||||
(*outch_fn)(buffer, currlen, maxlen, convert[--place]);
|
||||
doapr_outch(sbuffer, buffer, currlen, maxlen, convert[--place]);
|
||||
|
||||
/* left justified spaces */
|
||||
while (spadlen < 0) {
|
||||
(*outch_fn)(buffer, currlen, maxlen, ' ');
|
||||
doapr_outch(sbuffer, buffer, currlen, maxlen, ' ');
|
||||
++spadlen;
|
||||
}
|
||||
return;
|
||||
@ -650,7 +576,7 @@ round(LDOUBLE value)
|
||||
|
||||
static void
|
||||
fmtfp(
|
||||
void (*outch_fn)(char **, size_t *, size_t *, int),
|
||||
char **sbuffer,
|
||||
char **buffer,
|
||||
size_t *currlen,
|
||||
size_t *maxlen,
|
||||
@ -731,114 +657,158 @@ fmtfp(
|
||||
|
||||
if ((flags & DP_F_ZERO) && (padlen > 0)) {
|
||||
if (signvalue) {
|
||||
(*outch_fn)(buffer, currlen, maxlen, signvalue);
|
||||
doapr_outch(sbuffer, buffer, currlen, maxlen, signvalue);
|
||||
--padlen;
|
||||
signvalue = 0;
|
||||
}
|
||||
while (padlen > 0) {
|
||||
(*outch_fn)(buffer, currlen, maxlen, '0');
|
||||
doapr_outch(sbuffer, buffer, currlen, maxlen, '0');
|
||||
--padlen;
|
||||
}
|
||||
}
|
||||
while (padlen > 0) {
|
||||
(*outch_fn)(buffer, currlen, maxlen, ' ');
|
||||
doapr_outch(sbuffer, buffer, currlen, maxlen, ' ');
|
||||
--padlen;
|
||||
}
|
||||
if (signvalue)
|
||||
(*outch_fn)(buffer, currlen, maxlen, signvalue);
|
||||
doapr_outch(sbuffer, buffer, currlen, maxlen, signvalue);
|
||||
|
||||
while (iplace > 0)
|
||||
(*outch_fn)(buffer, currlen, maxlen, iconvert[--iplace]);
|
||||
doapr_outch(sbuffer, buffer, currlen, maxlen, iconvert[--iplace]);
|
||||
|
||||
/*
|
||||
* Decimal point. This should probably use locale to find the correct
|
||||
* char to print out.
|
||||
*/
|
||||
if (max > 0) {
|
||||
(*outch_fn)(buffer, currlen, maxlen, '.');
|
||||
doapr_outch(sbuffer, buffer, currlen, maxlen, '.');
|
||||
|
||||
while (fplace > 0)
|
||||
(*outch_fn)(buffer, currlen, maxlen, fconvert[--fplace]);
|
||||
doapr_outch(sbuffer, buffer, currlen, maxlen, fconvert[--fplace]);
|
||||
}
|
||||
while (zpadlen > 0) {
|
||||
(*outch_fn)(buffer, currlen, maxlen, '0');
|
||||
doapr_outch(sbuffer, buffer, currlen, maxlen, '0');
|
||||
--zpadlen;
|
||||
}
|
||||
|
||||
while (padlen < 0) {
|
||||
(*outch_fn)(buffer, currlen, maxlen, ' ');
|
||||
doapr_outch(sbuffer, buffer, currlen, maxlen, ' ');
|
||||
++padlen;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
dopr_copy(
|
||||
size_t len)
|
||||
{
|
||||
return len;
|
||||
}
|
||||
|
||||
#ifdef USE_ALLOCATING_PRINT
|
||||
static int
|
||||
doapr_copy(
|
||||
size_t len)
|
||||
{
|
||||
/* Return as high an integer as possible */
|
||||
return INT_MAX;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int
|
||||
dopr_isbig(
|
||||
size_t currlen,
|
||||
size_t maxlen)
|
||||
{
|
||||
return currlen > maxlen;
|
||||
}
|
||||
|
||||
#ifdef USE_ALLOCATING_PRINT
|
||||
static int
|
||||
doapr_isbig(
|
||||
size_t currlen,
|
||||
size_t maxlen)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
dopr_outch(
|
||||
char **buffer,
|
||||
size_t *currlen,
|
||||
size_t *maxlen,
|
||||
int c)
|
||||
{
|
||||
if (*currlen < *maxlen)
|
||||
(*buffer)[(*currlen)++] = (char)c;
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef USE_ALLOCATING_PRINT
|
||||
static void
|
||||
doapr_outch(
|
||||
char **sbuffer,
|
||||
char **buffer,
|
||||
size_t *currlen,
|
||||
size_t *maxlen,
|
||||
int c)
|
||||
{
|
||||
if (*buffer == NULL) {
|
||||
if (*maxlen == 0)
|
||||
*maxlen = 1024;
|
||||
*buffer = Malloc(*maxlen);
|
||||
}
|
||||
while (*currlen >= *maxlen) {
|
||||
*maxlen += 1024;
|
||||
*buffer = Realloc(*buffer, *maxlen);
|
||||
}
|
||||
/* What to do if *buffer is NULL? */
|
||||
assert(*buffer != NULL);
|
||||
/* If we haven't at least one buffer, someone has doe a big booboo */
|
||||
assert(*sbuffer != NULL || buffer != NULL);
|
||||
|
||||
if (buffer) {
|
||||
while (*currlen >= *maxlen) {
|
||||
if (*buffer == NULL) {
|
||||
assert(*sbuffer != NULL);
|
||||
if (*maxlen == 0)
|
||||
*maxlen = 1024;
|
||||
*buffer = OPENSSL_malloc(*maxlen);
|
||||
if (*currlen > 0)
|
||||
memcpy(*buffer, *sbuffer, *currlen);
|
||||
*sbuffer = NULL;
|
||||
} else {
|
||||
*maxlen += 1024;
|
||||
*buffer = OPENSSL_realloc(*buffer, *maxlen);
|
||||
}
|
||||
}
|
||||
/* What to do if *buffer is NULL? */
|
||||
assert(*sbuffer != NULL || *buffer != NULL);
|
||||
}
|
||||
|
||||
if (*currlen < *maxlen) {
|
||||
if (*sbuffer)
|
||||
(*sbuffer)[(*currlen)++] = (char)c;
|
||||
else
|
||||
(*buffer)[(*currlen)++] = (char)c;
|
||||
}
|
||||
|
||||
(*buffer)[(*currlen)++] = (char)c;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
int BIO_printf (BIO *bio, const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
int ret;
|
||||
|
||||
va_start(args, format);
|
||||
|
||||
ret = BIO_vprintf(bio, format, args);
|
||||
|
||||
va_end(args);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
int BIO_vprintf (BIO *bio, const char *format, va_list args)
|
||||
{
|
||||
int ret;
|
||||
size_t retlen;
|
||||
MS_STATIC char hugebuf[1024*10];
|
||||
char *hugebufp = hugebuf;
|
||||
size_t hugebufsize = sizeof(hugebuf);
|
||||
char *dynbuf = NULL;
|
||||
int ignored;
|
||||
|
||||
dynbuf = NULL;
|
||||
CRYPTO_push_info("doapr()");
|
||||
_dopr(&hugebufp, &dynbuf, &hugebufsize,
|
||||
&retlen, &ignored, format, args);
|
||||
if (dynbuf)
|
||||
{
|
||||
ret=BIO_write(bio, dynbuf, (int)retlen);
|
||||
OPENSSL_free(dynbuf);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret=BIO_write(bio, hugebuf, (int)retlen);
|
||||
}
|
||||
CRYPTO_pop_info();
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/* As snprintf is not available everywhere, we provide our own implementation.
|
||||
* This function has nothing to do with BIOs, but it's closely related
|
||||
* to BIO_printf, and we need *some* name prefix ...
|
||||
* (XXX the function should be renamed, but to what?) */
|
||||
int BIO_snprintf(char *buf, size_t n, const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
int ret;
|
||||
|
||||
va_start(args, format);
|
||||
|
||||
ret = BIO_vsnprintf(buf, n, format, args);
|
||||
|
||||
va_end(args);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
int BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args)
|
||||
{
|
||||
size_t retlen;
|
||||
int truncated;
|
||||
|
||||
_dopr(&buf, NULL, &n, &retlen, &truncated, format, args);
|
||||
|
||||
if (truncated)
|
||||
/* In case of truncation, return -1 like traditional snprintf.
|
||||
* (Current drafts for ISO/IEC 9899 say snprintf should return
|
||||
* the number of characters that would have been written,
|
||||
* had the buffer been large enough.) */
|
||||
return -1;
|
||||
else
|
||||
return (retlen <= INT_MAX) ? retlen : -1;
|
||||
}
|
||||
|
@ -105,17 +105,22 @@ int BIO_get_host_ip(const char *str, unsigned char *ip)
|
||||
struct hostent *he;
|
||||
|
||||
i=get_ip(str,ip);
|
||||
if (i > 0) return(1);
|
||||
if (i < 0)
|
||||
{
|
||||
BIOerr(BIO_F_BIO_GET_HOST_IP,BIO_R_INVALID_IP_ADDRESS);
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* do a gethostbyname */
|
||||
/* At this point, we have something that is most probably correct
|
||||
in some way, so let's init the socket. */
|
||||
if (!BIO_sock_init())
|
||||
return(0); /* don't generate another error code here */
|
||||
|
||||
/* If the string actually contained an IP address, we need not do
|
||||
anything more */
|
||||
if (i > 0) return(1);
|
||||
|
||||
/* do a gethostbyname */
|
||||
CRYPTO_w_lock(CRYPTO_LOCK_GETHOSTBYNAME);
|
||||
locked = 1;
|
||||
he=BIO_gethostbyname(str);
|
||||
@ -267,14 +272,14 @@ static struct hostent *ghbn_dup(struct hostent *a)
|
||||
int i,j;
|
||||
|
||||
MemCheck_off();
|
||||
ret=(struct hostent *)Malloc(sizeof(struct hostent));
|
||||
ret=(struct hostent *)OPENSSL_malloc(sizeof(struct hostent));
|
||||
if (ret == NULL) return(NULL);
|
||||
memset(ret,0,sizeof(struct hostent));
|
||||
|
||||
for (i=0; a->h_aliases[i] != NULL; i++)
|
||||
;
|
||||
i++;
|
||||
ret->h_aliases = (char **)Malloc(i*sizeof(char *));
|
||||
ret->h_aliases = (char **)OPENSSL_malloc(i*sizeof(char *));
|
||||
if (ret->h_aliases == NULL)
|
||||
goto err;
|
||||
memset(ret->h_aliases, 0, i*sizeof(char *));
|
||||
@ -282,25 +287,25 @@ static struct hostent *ghbn_dup(struct hostent *a)
|
||||
for (i=0; a->h_addr_list[i] != NULL; i++)
|
||||
;
|
||||
i++;
|
||||
ret->h_addr_list=(char **)Malloc(i*sizeof(char *));
|
||||
ret->h_addr_list=(char **)OPENSSL_malloc(i*sizeof(char *));
|
||||
if (ret->h_addr_list == NULL)
|
||||
goto err;
|
||||
memset(ret->h_addr_list, 0, i*sizeof(char *));
|
||||
|
||||
j=strlen(a->h_name)+1;
|
||||
if ((ret->h_name=Malloc(j)) == NULL) goto err;
|
||||
if ((ret->h_name=OPENSSL_malloc(j)) == NULL) goto err;
|
||||
memcpy((char *)ret->h_name,a->h_name,j);
|
||||
for (i=0; a->h_aliases[i] != NULL; i++)
|
||||
{
|
||||
j=strlen(a->h_aliases[i])+1;
|
||||
if ((ret->h_aliases[i]=Malloc(j)) == NULL) goto err;
|
||||
if ((ret->h_aliases[i]=OPENSSL_malloc(j)) == NULL) goto err;
|
||||
memcpy(ret->h_aliases[i],a->h_aliases[i],j);
|
||||
}
|
||||
ret->h_length=a->h_length;
|
||||
ret->h_addrtype=a->h_addrtype;
|
||||
for (i=0; a->h_addr_list[i] != NULL; i++)
|
||||
{
|
||||
if ((ret->h_addr_list[i]=Malloc(a->h_length)) == NULL)
|
||||
if ((ret->h_addr_list[i]=OPENSSL_malloc(a->h_length)) == NULL)
|
||||
goto err;
|
||||
memcpy(ret->h_addr_list[i],a->h_addr_list[i],a->h_length);
|
||||
}
|
||||
@ -325,17 +330,17 @@ static void ghbn_free(struct hostent *a)
|
||||
if (a->h_aliases != NULL)
|
||||
{
|
||||
for (i=0; a->h_aliases[i] != NULL; i++)
|
||||
Free(a->h_aliases[i]);
|
||||
Free(a->h_aliases);
|
||||
OPENSSL_free(a->h_aliases[i]);
|
||||
OPENSSL_free(a->h_aliases);
|
||||
}
|
||||
if (a->h_addr_list != NULL)
|
||||
{
|
||||
for (i=0; a->h_addr_list[i] != NULL; i++)
|
||||
Free(a->h_addr_list[i]);
|
||||
Free(a->h_addr_list);
|
||||
OPENSSL_free(a->h_addr_list[i]);
|
||||
OPENSSL_free(a->h_addr_list);
|
||||
}
|
||||
if (a->h_name != NULL) Free(a->h_name);
|
||||
Free(a);
|
||||
if (a->h_name != NULL) OPENSSL_free(a->h_name);
|
||||
OPENSSL_free(a);
|
||||
}
|
||||
|
||||
struct hostent *BIO_gethostbyname(const char *name)
|
||||
@ -628,7 +633,7 @@ again:
|
||||
}
|
||||
ret=1;
|
||||
err:
|
||||
if (str != NULL) Free(str);
|
||||
if (str != NULL) OPENSSL_free(str);
|
||||
if ((ret == 0) && (s != INVALID_SOCKET))
|
||||
{
|
||||
closesocket(s);
|
||||
@ -667,7 +672,7 @@ int BIO_accept(int sock, char **addr)
|
||||
port=ntohs(from.sin_port);
|
||||
if (*addr == NULL)
|
||||
{
|
||||
if ((p=Malloc(24)) == NULL)
|
||||
if ((p=OPENSSL_malloc(24)) == NULL)
|
||||
{
|
||||
BIOerr(BIO_F_BIO_ACCEPT,ERR_R_MALLOC_FAILURE);
|
||||
goto end;
|
||||
|
@ -62,14 +62,14 @@
|
||||
#include <openssl/bio.h>
|
||||
#include <openssl/evp.h>
|
||||
|
||||
static int buffer_write(BIO *h,char *buf,int num);
|
||||
static int buffer_read(BIO *h,char *buf,int size);
|
||||
static int buffer_puts(BIO *h,char *str);
|
||||
static int buffer_gets(BIO *h,char *str,int size);
|
||||
static long buffer_ctrl(BIO *h,int cmd,long arg1,char *arg2);
|
||||
static int buffer_write(BIO *h, const char *buf,int num);
|
||||
static int buffer_read(BIO *h, char *buf, int size);
|
||||
static int buffer_puts(BIO *h, const char *str);
|
||||
static int buffer_gets(BIO *h, char *str, int size);
|
||||
static long buffer_ctrl(BIO *h, int cmd, long arg1, void *arg2);
|
||||
static int buffer_new(BIO *h);
|
||||
static int buffer_free(BIO *data);
|
||||
static long buffer_callback_ctrl(BIO *h,int cmd, void (*fp)());
|
||||
static long buffer_callback_ctrl(BIO *h, int cmd, bio_info_cb *fp);
|
||||
#define DEFAULT_BUFFER_SIZE 1024
|
||||
|
||||
static BIO_METHOD methods_buffer=
|
||||
@ -95,12 +95,12 @@ static int buffer_new(BIO *bi)
|
||||
{
|
||||
BIO_F_BUFFER_CTX *ctx;
|
||||
|
||||
ctx=(BIO_F_BUFFER_CTX *)Malloc(sizeof(BIO_F_BUFFER_CTX));
|
||||
ctx=(BIO_F_BUFFER_CTX *)OPENSSL_malloc(sizeof(BIO_F_BUFFER_CTX));
|
||||
if (ctx == NULL) return(0);
|
||||
ctx->ibuf=(char *)Malloc(DEFAULT_BUFFER_SIZE);
|
||||
if (ctx->ibuf == NULL) { Free(ctx); return(0); }
|
||||
ctx->obuf=(char *)Malloc(DEFAULT_BUFFER_SIZE);
|
||||
if (ctx->obuf == NULL) { Free(ctx->ibuf); Free(ctx); return(0); }
|
||||
ctx->ibuf=(char *)OPENSSL_malloc(DEFAULT_BUFFER_SIZE);
|
||||
if (ctx->ibuf == NULL) { OPENSSL_free(ctx); return(0); }
|
||||
ctx->obuf=(char *)OPENSSL_malloc(DEFAULT_BUFFER_SIZE);
|
||||
if (ctx->obuf == NULL) { OPENSSL_free(ctx->ibuf); OPENSSL_free(ctx); return(0); }
|
||||
ctx->ibuf_size=DEFAULT_BUFFER_SIZE;
|
||||
ctx->obuf_size=DEFAULT_BUFFER_SIZE;
|
||||
ctx->ibuf_len=0;
|
||||
@ -120,9 +120,9 @@ static int buffer_free(BIO *a)
|
||||
|
||||
if (a == NULL) return(0);
|
||||
b=(BIO_F_BUFFER_CTX *)a->ptr;
|
||||
if (b->ibuf != NULL) Free(b->ibuf);
|
||||
if (b->obuf != NULL) Free(b->obuf);
|
||||
Free(a->ptr);
|
||||
if (b->ibuf != NULL) OPENSSL_free(b->ibuf);
|
||||
if (b->obuf != NULL) OPENSSL_free(b->obuf);
|
||||
OPENSSL_free(a->ptr);
|
||||
a->ptr=NULL;
|
||||
a->init=0;
|
||||
a->flags=0;
|
||||
@ -195,7 +195,7 @@ start:
|
||||
goto start;
|
||||
}
|
||||
|
||||
static int buffer_write(BIO *b, char *in, int inl)
|
||||
static int buffer_write(BIO *b, const char *in, int inl)
|
||||
{
|
||||
int i,num=0;
|
||||
BIO_F_BUFFER_CTX *ctx;
|
||||
@ -268,7 +268,7 @@ start:
|
||||
goto start;
|
||||
}
|
||||
|
||||
static long buffer_ctrl(BIO *b, int cmd, long num, char *ptr)
|
||||
static long buffer_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
{
|
||||
BIO *dbio;
|
||||
BIO_F_BUFFER_CTX *ctx;
|
||||
@ -319,9 +319,9 @@ static long buffer_ctrl(BIO *b, int cmd, long num, char *ptr)
|
||||
case BIO_C_SET_BUFF_READ_DATA:
|
||||
if (num > ctx->ibuf_size)
|
||||
{
|
||||
p1=Malloc((int)num);
|
||||
p1=OPENSSL_malloc((int)num);
|
||||
if (p1 == NULL) goto malloc_error;
|
||||
if (ctx->ibuf != NULL) Free(ctx->ibuf);
|
||||
if (ctx->ibuf != NULL) OPENSSL_free(ctx->ibuf);
|
||||
ctx->ibuf=p1;
|
||||
}
|
||||
ctx->ibuf_off=0;
|
||||
@ -353,21 +353,21 @@ static long buffer_ctrl(BIO *b, int cmd, long num, char *ptr)
|
||||
p2=ctx->obuf;
|
||||
if ((ibs > DEFAULT_BUFFER_SIZE) && (ibs != ctx->ibuf_size))
|
||||
{
|
||||
p1=(char *)Malloc((int)num);
|
||||
p1=(char *)OPENSSL_malloc((int)num);
|
||||
if (p1 == NULL) goto malloc_error;
|
||||
}
|
||||
if ((obs > DEFAULT_BUFFER_SIZE) && (obs != ctx->obuf_size))
|
||||
{
|
||||
p2=(char *)Malloc((int)num);
|
||||
p2=(char *)OPENSSL_malloc((int)num);
|
||||
if (p2 == NULL)
|
||||
{
|
||||
if (p1 != ctx->ibuf) Free(p1);
|
||||
if (p1 != ctx->ibuf) OPENSSL_free(p1);
|
||||
goto malloc_error;
|
||||
}
|
||||
}
|
||||
if (ctx->ibuf != p1)
|
||||
{
|
||||
Free(ctx->ibuf);
|
||||
OPENSSL_free(ctx->ibuf);
|
||||
ctx->ibuf=p1;
|
||||
ctx->ibuf_off=0;
|
||||
ctx->ibuf_len=0;
|
||||
@ -375,7 +375,7 @@ static long buffer_ctrl(BIO *b, int cmd, long num, char *ptr)
|
||||
}
|
||||
if (ctx->obuf != p2)
|
||||
{
|
||||
Free(ctx->obuf);
|
||||
OPENSSL_free(ctx->obuf);
|
||||
ctx->obuf=p2;
|
||||
ctx->obuf_off=0;
|
||||
ctx->obuf_len=0;
|
||||
@ -439,7 +439,7 @@ malloc_error:
|
||||
return(0);
|
||||
}
|
||||
|
||||
static long buffer_callback_ctrl(BIO *b, int cmd, void (*fp)())
|
||||
static long buffer_callback_ctrl(BIO *b, int cmd, bio_info_cb *fp)
|
||||
{
|
||||
long ret=1;
|
||||
|
||||
@ -504,8 +504,8 @@ static int buffer_gets(BIO *b, char *buf, int size)
|
||||
}
|
||||
}
|
||||
|
||||
static int buffer_puts(BIO *b, char *str)
|
||||
static int buffer_puts(BIO *b, const char *str)
|
||||
{
|
||||
return(BIO_write(b,str,strlen(str)));
|
||||
return(buffer_write(b,str,strlen(str)));
|
||||
}
|
||||
|
||||
|
397
lib/libcrypto/bio/bf_lbuf.c
Normal file
397
lib/libcrypto/bio/bf_lbuf.c
Normal file
@ -0,0 +1,397 @@
|
||||
/* crypto/bio/bf_buff.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include "cryptlib.h"
|
||||
#include <openssl/bio.h>
|
||||
#include <openssl/evp.h>
|
||||
|
||||
static int linebuffer_write(BIO *h, const char *buf,int num);
|
||||
static int linebuffer_read(BIO *h, char *buf, int size);
|
||||
static int linebuffer_puts(BIO *h, const char *str);
|
||||
static int linebuffer_gets(BIO *h, char *str, int size);
|
||||
static long linebuffer_ctrl(BIO *h, int cmd, long arg1, void *arg2);
|
||||
static int linebuffer_new(BIO *h);
|
||||
static int linebuffer_free(BIO *data);
|
||||
static long linebuffer_callback_ctrl(BIO *h, int cmd, bio_info_cb *fp);
|
||||
|
||||
/* A 10k maximum should be enough for most purposes */
|
||||
#define DEFAULT_LINEBUFFER_SIZE 1024*10
|
||||
|
||||
/* #define DEBUG */
|
||||
|
||||
static BIO_METHOD methods_linebuffer=
|
||||
{
|
||||
BIO_TYPE_LINEBUFFER,
|
||||
"linebuffer",
|
||||
linebuffer_write,
|
||||
linebuffer_read,
|
||||
linebuffer_puts,
|
||||
linebuffer_gets,
|
||||
linebuffer_ctrl,
|
||||
linebuffer_new,
|
||||
linebuffer_free,
|
||||
linebuffer_callback_ctrl,
|
||||
};
|
||||
|
||||
BIO_METHOD *BIO_f_linebuffer(void)
|
||||
{
|
||||
return(&methods_linebuffer);
|
||||
}
|
||||
|
||||
typedef struct bio_linebuffer_ctx_struct
|
||||
{
|
||||
char *obuf; /* the output char array */
|
||||
int obuf_size; /* how big is the output buffer */
|
||||
int obuf_len; /* how many bytes are in it */
|
||||
} BIO_LINEBUFFER_CTX;
|
||||
|
||||
static int linebuffer_new(BIO *bi)
|
||||
{
|
||||
BIO_LINEBUFFER_CTX *ctx;
|
||||
|
||||
ctx=(BIO_LINEBUFFER_CTX *)OPENSSL_malloc(sizeof(BIO_LINEBUFFER_CTX));
|
||||
if (ctx == NULL) return(0);
|
||||
ctx->obuf=(char *)OPENSSL_malloc(DEFAULT_LINEBUFFER_SIZE);
|
||||
if (ctx->obuf == NULL) { OPENSSL_free(ctx); return(0); }
|
||||
ctx->obuf_size=DEFAULT_LINEBUFFER_SIZE;
|
||||
ctx->obuf_len=0;
|
||||
|
||||
bi->init=1;
|
||||
bi->ptr=(char *)ctx;
|
||||
bi->flags=0;
|
||||
return(1);
|
||||
}
|
||||
|
||||
static int linebuffer_free(BIO *a)
|
||||
{
|
||||
BIO_LINEBUFFER_CTX *b;
|
||||
|
||||
if (a == NULL) return(0);
|
||||
b=(BIO_LINEBUFFER_CTX *)a->ptr;
|
||||
if (b->obuf != NULL) OPENSSL_free(b->obuf);
|
||||
OPENSSL_free(a->ptr);
|
||||
a->ptr=NULL;
|
||||
a->init=0;
|
||||
a->flags=0;
|
||||
return(1);
|
||||
}
|
||||
|
||||
static int linebuffer_read(BIO *b, char *out, int outl)
|
||||
{
|
||||
int ret=0;
|
||||
|
||||
if (out == NULL) return(0);
|
||||
if (b->next_bio == NULL) return(0);
|
||||
ret=BIO_read(b->next_bio,out,outl);
|
||||
BIO_clear_retry_flags(b);
|
||||
BIO_copy_next_retry(b);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static int linebuffer_write(BIO *b, const char *in, int inl)
|
||||
{
|
||||
int i,num=0,foundnl;
|
||||
BIO_LINEBUFFER_CTX *ctx;
|
||||
|
||||
if ((in == NULL) || (inl <= 0)) return(0);
|
||||
ctx=(BIO_LINEBUFFER_CTX *)b->ptr;
|
||||
if ((ctx == NULL) || (b->next_bio == NULL)) return(0);
|
||||
|
||||
BIO_clear_retry_flags(b);
|
||||
|
||||
do
|
||||
{
|
||||
const char *p;
|
||||
|
||||
for(p = in; p < in + inl && *p != '\n'; p++)
|
||||
;
|
||||
if (*p == '\n')
|
||||
{
|
||||
p++;
|
||||
foundnl = 1;
|
||||
}
|
||||
else
|
||||
foundnl = 0;
|
||||
|
||||
/* If a NL was found and we already have text in the save
|
||||
buffer, concatenate them and write */
|
||||
while ((foundnl || p - in > ctx->obuf_size - ctx->obuf_len)
|
||||
&& ctx->obuf_len > 0)
|
||||
{
|
||||
int orig_olen = ctx->obuf_len;
|
||||
|
||||
i = ctx->obuf_size - ctx->obuf_len;
|
||||
if (p - in > 0)
|
||||
{
|
||||
if (i >= p - in)
|
||||
{
|
||||
memcpy(&(ctx->obuf[ctx->obuf_len]),
|
||||
in,p - in);
|
||||
ctx->obuf_len += p - in;
|
||||
inl -= p - in;
|
||||
num += p - in;
|
||||
in = p;
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(&(ctx->obuf[ctx->obuf_len]),
|
||||
in,i);
|
||||
ctx->obuf_len += i;
|
||||
inl -= i;
|
||||
in += i;
|
||||
num += i;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
BIO_write(b->next_bio, "<*<", 3);
|
||||
#endif
|
||||
i=BIO_write(b->next_bio,
|
||||
ctx->obuf, ctx->obuf_len);
|
||||
if (i <= 0)
|
||||
{
|
||||
ctx->obuf_len = orig_olen;
|
||||
BIO_copy_next_retry(b);
|
||||
|
||||
#ifdef DEBUG
|
||||
BIO_write(b->next_bio, ">*>", 3);
|
||||
#endif
|
||||
if (i < 0) return((num > 0)?num:i);
|
||||
if (i == 0) return(num);
|
||||
}
|
||||
#ifdef DEBUG
|
||||
BIO_write(b->next_bio, ">*>", 3);
|
||||
#endif
|
||||
if (i < ctx->obuf_len)
|
||||
memmove(ctx->obuf, ctx->obuf + i,
|
||||
ctx->obuf_len - i);
|
||||
ctx->obuf_len-=i;
|
||||
}
|
||||
|
||||
/* Now that the save buffer is emptied, let's write the input
|
||||
buffer if a NL was found and there is anything to write. */
|
||||
if ((foundnl || p - in > ctx->obuf_size) && p - in > 0)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
BIO_write(b->next_bio, "<*<", 3);
|
||||
#endif
|
||||
i=BIO_write(b->next_bio,in,p - in);
|
||||
if (i <= 0)
|
||||
{
|
||||
BIO_copy_next_retry(b);
|
||||
#ifdef DEBUG
|
||||
BIO_write(b->next_bio, ">*>", 3);
|
||||
#endif
|
||||
if (i < 0) return((num > 0)?num:i);
|
||||
if (i == 0) return(num);
|
||||
}
|
||||
#ifdef DEBUG
|
||||
BIO_write(b->next_bio, ">*>", 3);
|
||||
#endif
|
||||
num+=i;
|
||||
in+=i;
|
||||
inl-=i;
|
||||
}
|
||||
}
|
||||
while(foundnl && inl > 0);
|
||||
/* We've written as much as we can. The rest of the input buffer, if
|
||||
any, is text that doesn't and with a NL and therefore needs to be
|
||||
saved for the next trip. */
|
||||
if (inl > 0)
|
||||
{
|
||||
memcpy(&(ctx->obuf[ctx->obuf_len]), in, inl);
|
||||
ctx->obuf_len += inl;
|
||||
num += inl;
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
static long linebuffer_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
{
|
||||
BIO *dbio;
|
||||
BIO_LINEBUFFER_CTX *ctx;
|
||||
long ret=1;
|
||||
char *p;
|
||||
int r;
|
||||
int obs;
|
||||
|
||||
ctx=(BIO_LINEBUFFER_CTX *)b->ptr;
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
case BIO_CTRL_RESET:
|
||||
ctx->obuf_len=0;
|
||||
if (b->next_bio == NULL) return(0);
|
||||
ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
|
||||
break;
|
||||
case BIO_CTRL_INFO:
|
||||
ret=(long)ctx->obuf_len;
|
||||
break;
|
||||
case BIO_CTRL_WPENDING:
|
||||
ret=(long)ctx->obuf_len;
|
||||
if (ret == 0)
|
||||
{
|
||||
if (b->next_bio == NULL) return(0);
|
||||
ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
|
||||
}
|
||||
break;
|
||||
case BIO_C_SET_BUFF_SIZE:
|
||||
obs=(int)num;
|
||||
p=ctx->obuf;
|
||||
if ((obs > DEFAULT_LINEBUFFER_SIZE) && (obs != ctx->obuf_size))
|
||||
{
|
||||
p=(char *)OPENSSL_malloc((int)num);
|
||||
if (p == NULL)
|
||||
goto malloc_error;
|
||||
}
|
||||
if (ctx->obuf != p)
|
||||
{
|
||||
if (ctx->obuf_len > obs)
|
||||
{
|
||||
ctx->obuf_len = obs;
|
||||
}
|
||||
memcpy(p, ctx->obuf, ctx->obuf_len);
|
||||
OPENSSL_free(ctx->obuf);
|
||||
ctx->obuf=p;
|
||||
ctx->obuf_size=obs;
|
||||
}
|
||||
break;
|
||||
case BIO_C_DO_STATE_MACHINE:
|
||||
if (b->next_bio == NULL) return(0);
|
||||
BIO_clear_retry_flags(b);
|
||||
ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
|
||||
BIO_copy_next_retry(b);
|
||||
break;
|
||||
|
||||
case BIO_CTRL_FLUSH:
|
||||
if (b->next_bio == NULL) return(0);
|
||||
if (ctx->obuf_len <= 0)
|
||||
{
|
||||
ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
|
||||
break;
|
||||
}
|
||||
|
||||
for (;;)
|
||||
{
|
||||
BIO_clear_retry_flags(b);
|
||||
if (ctx->obuf_len > 0)
|
||||
{
|
||||
r=BIO_write(b->next_bio,
|
||||
ctx->obuf, ctx->obuf_len);
|
||||
#if 0
|
||||
fprintf(stderr,"FLUSH %3d -> %3d\n",ctx->obuf_len,r);
|
||||
#endif
|
||||
BIO_copy_next_retry(b);
|
||||
if (r <= 0) return((long)r);
|
||||
if (r < ctx->obuf_len)
|
||||
memmove(ctx->obuf, ctx->obuf + r,
|
||||
ctx->obuf_len - r);
|
||||
ctx->obuf_len-=r;
|
||||
}
|
||||
else
|
||||
{
|
||||
ctx->obuf_len=0;
|
||||
ret=1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
|
||||
break;
|
||||
case BIO_CTRL_DUP:
|
||||
dbio=(BIO *)ptr;
|
||||
if ( !BIO_set_write_buffer_size(dbio,ctx->obuf_size))
|
||||
ret=0;
|
||||
break;
|
||||
default:
|
||||
if (b->next_bio == NULL) return(0);
|
||||
ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
|
||||
break;
|
||||
}
|
||||
return(ret);
|
||||
malloc_error:
|
||||
BIOerr(BIO_F_LINEBUFFER_CTRL,ERR_R_MALLOC_FAILURE);
|
||||
return(0);
|
||||
}
|
||||
|
||||
static long linebuffer_callback_ctrl(BIO *b, int cmd, bio_info_cb *fp)
|
||||
{
|
||||
long ret=1;
|
||||
|
||||
if (b->next_bio == NULL) return(0);
|
||||
switch (cmd)
|
||||
{
|
||||
default:
|
||||
ret=BIO_callback_ctrl(b->next_bio,cmd,fp);
|
||||
break;
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static int linebuffer_gets(BIO *b, char *buf, int size)
|
||||
{
|
||||
if (b->next_bio == NULL) return(0);
|
||||
return(BIO_gets(b->next_bio,buf,size));
|
||||
}
|
||||
|
||||
static int linebuffer_puts(BIO *b, const char *str)
|
||||
{
|
||||
return(linebuffer_write(b,str,strlen(str)));
|
||||
}
|
||||
|
@ -66,14 +66,14 @@
|
||||
/* BIO_put and BIO_get both add to the digest,
|
||||
* BIO_gets returns the digest */
|
||||
|
||||
static int nbiof_write(BIO *h,char *buf,int num);
|
||||
static int nbiof_write(BIO *h,const char *buf,int num);
|
||||
static int nbiof_read(BIO *h,char *buf,int size);
|
||||
static int nbiof_puts(BIO *h,char *str);
|
||||
static int nbiof_puts(BIO *h,const char *str);
|
||||
static int nbiof_gets(BIO *h,char *str,int size);
|
||||
static long nbiof_ctrl(BIO *h,int cmd,long arg1,char *arg2);
|
||||
static long nbiof_ctrl(BIO *h,int cmd,long arg1,void *arg2);
|
||||
static int nbiof_new(BIO *h);
|
||||
static int nbiof_free(BIO *data);
|
||||
static long nbiof_callback_ctrl(BIO *h,int cmd,void (*fp)());
|
||||
static long nbiof_callback_ctrl(BIO *h,int cmd,bio_info_cb *fp);
|
||||
typedef struct nbio_test_st
|
||||
{
|
||||
/* only set if we sent a 'should retry' error */
|
||||
@ -104,7 +104,7 @@ static int nbiof_new(BIO *bi)
|
||||
{
|
||||
NBIO_TEST *nt;
|
||||
|
||||
nt=(NBIO_TEST *)Malloc(sizeof(NBIO_TEST));
|
||||
nt=(NBIO_TEST *)OPENSSL_malloc(sizeof(NBIO_TEST));
|
||||
nt->lrn= -1;
|
||||
nt->lwn= -1;
|
||||
bi->ptr=(char *)nt;
|
||||
@ -117,7 +117,7 @@ static int nbiof_free(BIO *a)
|
||||
{
|
||||
if (a == NULL) return(0);
|
||||
if (a->ptr != NULL)
|
||||
Free(a->ptr);
|
||||
OPENSSL_free(a->ptr);
|
||||
a->ptr=NULL;
|
||||
a->init=0;
|
||||
a->flags=0;
|
||||
@ -159,7 +159,7 @@ static int nbiof_read(BIO *b, char *out, int outl)
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static int nbiof_write(BIO *b, char *in, int inl)
|
||||
static int nbiof_write(BIO *b, const char *in, int inl)
|
||||
{
|
||||
NBIO_TEST *nt;
|
||||
int ret=0;
|
||||
@ -204,7 +204,7 @@ static int nbiof_write(BIO *b, char *in, int inl)
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static long nbiof_ctrl(BIO *b, int cmd, long num, char *ptr)
|
||||
static long nbiof_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
{
|
||||
long ret;
|
||||
|
||||
@ -226,7 +226,7 @@ static long nbiof_ctrl(BIO *b, int cmd, long num, char *ptr)
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static long nbiof_callback_ctrl(BIO *b, int cmd, void (*fp)())
|
||||
static long nbiof_callback_ctrl(BIO *b, int cmd, bio_info_cb *fp)
|
||||
{
|
||||
long ret=1;
|
||||
|
||||
@ -247,7 +247,7 @@ static int nbiof_gets(BIO *bp, char *buf, int size)
|
||||
}
|
||||
|
||||
|
||||
static int nbiof_puts(BIO *bp, char *str)
|
||||
static int nbiof_puts(BIO *bp, const char *str)
|
||||
{
|
||||
if (bp->next_bio == NULL) return(0);
|
||||
return(BIO_puts(bp->next_bio,str));
|
||||
|
@ -65,14 +65,14 @@
|
||||
/* BIO_put and BIO_get both add to the digest,
|
||||
* BIO_gets returns the digest */
|
||||
|
||||
static int nullf_write(BIO *h,char *buf,int num);
|
||||
static int nullf_read(BIO *h,char *buf,int size);
|
||||
static int nullf_puts(BIO *h,char *str);
|
||||
static int nullf_gets(BIO *h,char *str,int size);
|
||||
static long nullf_ctrl(BIO *h,int cmd,long arg1,char *arg2);
|
||||
static int nullf_write(BIO *h, const char *buf, int num);
|
||||
static int nullf_read(BIO *h, char *buf, int size);
|
||||
static int nullf_puts(BIO *h, const char *str);
|
||||
static int nullf_gets(BIO *h, char *str, int size);
|
||||
static long nullf_ctrl(BIO *h, int cmd, long arg1, void *arg2);
|
||||
static int nullf_new(BIO *h);
|
||||
static int nullf_free(BIO *data);
|
||||
static long nullf_callback_ctrl(BIO *h,int cmd,void (*fp)());
|
||||
static long nullf_callback_ctrl(BIO *h, int cmd, bio_info_cb *fp);
|
||||
static BIO_METHOD methods_nullf=
|
||||
{
|
||||
BIO_TYPE_NULL_FILTER,
|
||||
@ -121,7 +121,7 @@ static int nullf_read(BIO *b, char *out, int outl)
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static int nullf_write(BIO *b, char *in, int inl)
|
||||
static int nullf_write(BIO *b, const char *in, int inl)
|
||||
{
|
||||
int ret=0;
|
||||
|
||||
@ -133,7 +133,7 @@ static int nullf_write(BIO *b, char *in, int inl)
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static long nullf_ctrl(BIO *b, int cmd, long num, char *ptr)
|
||||
static long nullf_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
{
|
||||
long ret;
|
||||
|
||||
@ -154,7 +154,7 @@ static long nullf_ctrl(BIO *b, int cmd, long num, char *ptr)
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static long nullf_callback_ctrl(BIO *b, int cmd, void (*fp)())
|
||||
static long nullf_callback_ctrl(BIO *b, int cmd, bio_info_cb *fp)
|
||||
{
|
||||
long ret=1;
|
||||
|
||||
@ -175,7 +175,7 @@ static int nullf_gets(BIO *bp, char *buf, int size)
|
||||
}
|
||||
|
||||
|
||||
static int nullf_puts(BIO *bp, char *str)
|
||||
static int nullf_puts(BIO *bp, const char *str)
|
||||
{
|
||||
if (bp->next_bio == NULL) return(0);
|
||||
return(BIO_puts(bp->next_bio,str));
|
||||
|
@ -59,14 +59,17 @@
|
||||
#ifndef HEADER_BIO_H
|
||||
#define HEADER_BIO_H
|
||||
|
||||
#ifndef NO_FP_API
|
||||
# include <stdio.h>
|
||||
#endif
|
||||
#include <stdarg.h>
|
||||
|
||||
#include <openssl/crypto.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <openssl/crypto.h>
|
||||
|
||||
/* These are the 'types' of BIOs */
|
||||
#define BIO_TYPE_NONE 0
|
||||
#define BIO_TYPE_MEM (1|0x0400)
|
||||
@ -88,6 +91,7 @@ extern "C" {
|
||||
#define BIO_TYPE_NULL_FILTER (17|0x0200)
|
||||
#define BIO_TYPE_BER (18|0x0200) /* BER -> bin filter */
|
||||
#define BIO_TYPE_BIO (19|0x0400) /* (half a) BIO pair */
|
||||
#define BIO_TYPE_LINEBUFFER (20|0x0200) /* filter */
|
||||
|
||||
#define BIO_TYPE_DESCRIPTOR 0x0100 /* socket, fd, connect or accept */
|
||||
#define BIO_TYPE_FILTER 0x0200
|
||||
@ -207,19 +211,23 @@ extern "C" {
|
||||
#define BIO_method_name(b) ((b)->method->name)
|
||||
#define BIO_method_type(b) ((b)->method->type)
|
||||
|
||||
typedef struct bio_st BIO;
|
||||
|
||||
typedef void bio_info_cb(struct bio_st *, int, const char *, int, long, long);
|
||||
|
||||
#ifndef WIN16
|
||||
typedef struct bio_method_st
|
||||
{
|
||||
int type;
|
||||
const char *name;
|
||||
int (*bwrite)();
|
||||
int (*bread)();
|
||||
int (*bputs)();
|
||||
int (*bgets)();
|
||||
long (*ctrl)();
|
||||
int (*create)();
|
||||
int (*destroy)();
|
||||
long (*callback_ctrl)();
|
||||
int (*bwrite)(BIO *, const char *, int);
|
||||
int (*bread)(BIO *, char *, int);
|
||||
int (*bputs)(BIO *, const char *);
|
||||
int (*bgets)(BIO *, char *, int);
|
||||
long (*ctrl)(BIO *, int, long, void *);
|
||||
int (*create)(BIO *);
|
||||
int (*destroy)(BIO *);
|
||||
long (*callback_ctrl)(BIO *, int, bio_info_cb *);
|
||||
} BIO_METHOD;
|
||||
#else
|
||||
typedef struct bio_method_st
|
||||
@ -237,7 +245,7 @@ typedef struct bio_method_st
|
||||
} BIO_METHOD;
|
||||
#endif
|
||||
|
||||
typedef struct bio_st
|
||||
struct bio_st
|
||||
{
|
||||
BIO_METHOD *method;
|
||||
/* bio, mode, argp, argi, argl, ret */
|
||||
@ -257,7 +265,9 @@ typedef struct bio_st
|
||||
unsigned long num_write;
|
||||
|
||||
CRYPTO_EX_DATA ex_data;
|
||||
} BIO;
|
||||
};
|
||||
|
||||
DECLARE_STACK_OF(BIO)
|
||||
|
||||
typedef struct bio_f_buffer_ctx_struct
|
||||
{
|
||||
@ -454,8 +464,8 @@ int BIO_read_filename(BIO *b,const char *name);
|
||||
size_t BIO_ctrl_pending(BIO *b);
|
||||
size_t BIO_ctrl_wpending(BIO *b);
|
||||
#define BIO_flush(b) (int)BIO_ctrl(b,BIO_CTRL_FLUSH,0,NULL)
|
||||
#define BIO_get_info_callback(b,cbp) (int)BIO_ctrl(b,BIO_CTRL_GET_CALLBACK,0,(void (**)())(cbp))
|
||||
#define BIO_set_info_callback(b,cb) (int)BIO_callback_ctrl(b,BIO_CTRL_SET_CALLBACK,(void (*)())(cb))
|
||||
#define BIO_get_info_callback(b,cbp) (int)BIO_ctrl(b,BIO_CTRL_GET_CALLBACK,0,(bio_info_cb **)(cbp))
|
||||
#define BIO_set_info_callback(b,cb) (int)BIO_callback_ctrl(b,BIO_CTRL_SET_CALLBACK,(bio_info_cb *)(cb))
|
||||
|
||||
/* For the BIO_f_buffer() type */
|
||||
#define BIO_buffer_get_num_lines(b) BIO_ctrl(b,BIO_CTRL_GET,0,NULL)
|
||||
@ -465,6 +475,7 @@ size_t BIO_ctrl_wpending(BIO *b);
|
||||
#define BIO_get_write_buf_size(b,size) (size_t)BIO_ctrl(b,BIO_C_GET_WRITE_BUF_SIZE,size,NULL)
|
||||
#define BIO_make_bio_pair(b1,b2) (int)BIO_ctrl(b1,BIO_C_MAKE_BIO_PAIR,0,b2)
|
||||
#define BIO_destroy_bio_pair(b) (int)BIO_ctrl(b,BIO_C_DESTROY_BIO_PAIR,0,NULL)
|
||||
#define BIO_shutdown_wr(b) (int)BIO_ctrl(b, BIO_C_SHUTDOWN_WR, 0, NULL)
|
||||
/* macros with inappropriate type -- but ...pending macros use int too: */
|
||||
#define BIO_get_write_guarantee(b) (int)BIO_ctrl(b,BIO_C_GET_WRITE_GUARANTEE,0,NULL)
|
||||
#define BIO_get_read_request(b) (int)BIO_ctrl(b,BIO_C_GET_READ_REQUEST,0,NULL)
|
||||
@ -472,11 +483,6 @@ size_t BIO_ctrl_get_write_guarantee(BIO *b);
|
||||
size_t BIO_ctrl_get_read_request(BIO *b);
|
||||
int BIO_ctrl_reset_read_request(BIO *b);
|
||||
|
||||
#ifdef NO_STDIO
|
||||
#define NO_FP_API
|
||||
#endif
|
||||
|
||||
|
||||
/* These two aren't currently implemented */
|
||||
/* int BIO_get_ex_num(BIO *bio); */
|
||||
/* void BIO_set_ex_free_func(BIO *bio,int idx,void (*cb)()); */
|
||||
@ -487,6 +493,7 @@ int BIO_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
|
||||
unsigned long BIO_number_read(BIO *bio);
|
||||
unsigned long BIO_number_written(BIO *bio);
|
||||
|
||||
# ifndef NO_FP_API
|
||||
# if defined(WIN16) && defined(_WINDLL)
|
||||
BIO_METHOD *BIO_s_file_internal(void);
|
||||
BIO *BIO_new_file_internal(char *filename, char *mode);
|
||||
@ -502,21 +509,24 @@ BIO *BIO_new_fp(FILE *stream, int close_flag);
|
||||
# define BIO_new_file_internal BIO_new_file
|
||||
# define BIO_new_fp_internal BIO_s_file
|
||||
# endif /* FP_API */
|
||||
# endif
|
||||
BIO * BIO_new(BIO_METHOD *type);
|
||||
int BIO_set(BIO *a,BIO_METHOD *type);
|
||||
int BIO_free(BIO *a);
|
||||
void BIO_vfree(BIO *a);
|
||||
int BIO_read(BIO *b, void *data, int len);
|
||||
int BIO_gets(BIO *bp,char *buf, int size);
|
||||
int BIO_write(BIO *b, const void *data, int len);
|
||||
int BIO_puts(BIO *bp,const char *buf);
|
||||
long BIO_ctrl(BIO *bp,int cmd,long larg,void *parg);
|
||||
long BIO_callback_ctrl(BIO *bp,int cmd,void (*fp)());
|
||||
long BIO_callback_ctrl(BIO *b, int cmd, void (*fp)(struct bio_st *, int, const char *, int, long, long));
|
||||
char * BIO_ptr_ctrl(BIO *bp,int cmd,long larg);
|
||||
long BIO_int_ctrl(BIO *bp,int cmd,long larg,int iarg);
|
||||
BIO * BIO_push(BIO *b,BIO *append);
|
||||
BIO * BIO_pop(BIO *b);
|
||||
void BIO_free_all(BIO *a);
|
||||
BIO * BIO_find_type(BIO *b,int bio_type);
|
||||
BIO * BIO_next(BIO *b);
|
||||
BIO * BIO_get_retry_BIO(BIO *bio, int *reason);
|
||||
int BIO_get_retry_reason(BIO *bio);
|
||||
BIO * BIO_dup_chain(BIO *in);
|
||||
@ -545,6 +555,9 @@ BIO_METHOD *BIO_s_bio(void);
|
||||
BIO_METHOD *BIO_s_null(void);
|
||||
BIO_METHOD *BIO_f_null(void);
|
||||
BIO_METHOD *BIO_f_buffer(void);
|
||||
#ifdef VMS
|
||||
BIO_METHOD *BIO_f_linebuffer(void);
|
||||
#endif
|
||||
BIO_METHOD *BIO_f_nbio_test(void);
|
||||
/* BIO_METHOD *BIO_f_ber(void); */
|
||||
|
||||
@ -553,6 +566,7 @@ int BIO_sock_non_fatal_error(int error);
|
||||
int BIO_fd_should_retry(int i);
|
||||
int BIO_fd_non_fatal_error(int error);
|
||||
int BIO_dump(BIO *b,const char *bytes,int len);
|
||||
int BIO_dump_indent(BIO *b,const char *bytes,int len,int indent);
|
||||
|
||||
struct hostent *BIO_gethostbyname(const char *name);
|
||||
/* We might want a thread-safe interface too:
|
||||
@ -592,7 +606,10 @@ void BIO_copy_next_retry(BIO *b);
|
||||
|
||||
long BIO_ghbn_ctrl(int cmd,int iarg,char *parg);
|
||||
|
||||
int BIO_printf(BIO *bio, ...);
|
||||
int BIO_printf(BIO *bio, const char *format, ...);
|
||||
int BIO_vprintf(BIO *bio, const char *format, va_list args);
|
||||
int BIO_snprintf(char *buf, size_t n, const char *format, ...);
|
||||
int BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args);
|
||||
|
||||
/* BEGIN ERROR CODES */
|
||||
/* The following lines are auto generated by the script mkerr.pl. Any changes
|
||||
@ -627,6 +644,8 @@ int BIO_printf(BIO *bio, ...);
|
||||
#define BIO_F_CONN_CTRL 127
|
||||
#define BIO_F_CONN_STATE 115
|
||||
#define BIO_F_FILE_CTRL 116
|
||||
#define BIO_F_LINEBUFFER_CTRL 129
|
||||
#define BIO_F_MEM_READ 128
|
||||
#define BIO_F_MEM_WRITE 117
|
||||
#define BIO_F_SSL_NEW 118
|
||||
#define BIO_F_WSASTARTUP 119
|
||||
@ -637,6 +656,7 @@ int BIO_printf(BIO *bio, ...);
|
||||
#define BIO_R_BAD_HOSTNAME_LOOKUP 102
|
||||
#define BIO_R_BROKEN_PIPE 124
|
||||
#define BIO_R_CONNECT_ERROR 103
|
||||
#define BIO_R_EOF_ON_MEMORY_BIO 127
|
||||
#define BIO_R_ERROR_SETTING_NBIO 104
|
||||
#define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPTED_SOCKET 105
|
||||
#define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPT_SOCKET 106
|
||||
|
@ -91,6 +91,8 @@ static ERR_STRING_DATA BIO_str_functs[]=
|
||||
{ERR_PACK(0,BIO_F_CONN_CTRL,0), "CONN_CTRL"},
|
||||
{ERR_PACK(0,BIO_F_CONN_STATE,0), "CONN_STATE"},
|
||||
{ERR_PACK(0,BIO_F_FILE_CTRL,0), "FILE_CTRL"},
|
||||
{ERR_PACK(0,BIO_F_LINEBUFFER_CTRL,0), "LINEBUFFER_CTRL"},
|
||||
{ERR_PACK(0,BIO_F_MEM_READ,0), "MEM_READ"},
|
||||
{ERR_PACK(0,BIO_F_MEM_WRITE,0), "MEM_WRITE"},
|
||||
{ERR_PACK(0,BIO_F_SSL_NEW,0), "SSL_new"},
|
||||
{ERR_PACK(0,BIO_F_WSASTARTUP,0), "WSASTARTUP"},
|
||||
@ -104,6 +106,7 @@ static ERR_STRING_DATA BIO_str_reasons[]=
|
||||
{BIO_R_BAD_HOSTNAME_LOOKUP ,"bad hostname lookup"},
|
||||
{BIO_R_BROKEN_PIPE ,"broken pipe"},
|
||||
{BIO_R_CONNECT_ERROR ,"connect error"},
|
||||
{BIO_R_EOF_ON_MEMORY_BIO ,"EOF on memory BIO"},
|
||||
{BIO_R_ERROR_SETTING_NBIO ,"error setting nbio"},
|
||||
{BIO_R_ERROR_SETTING_NBIO_ON_ACCEPTED_SOCKET,"error setting nbio on accepted socket"},
|
||||
{BIO_R_ERROR_SETTING_NBIO_ON_ACCEPT_SOCKET,"error setting nbio on accept socket"},
|
||||
@ -124,8 +127,8 @@ static ERR_STRING_DATA BIO_str_reasons[]=
|
||||
{BIO_R_UNABLE_TO_LISTEN_SOCKET ,"unable to listen socket"},
|
||||
{BIO_R_UNINITIALIZED ,"uninitialized"},
|
||||
{BIO_R_UNSUPPORTED_METHOD ,"unsupported method"},
|
||||
{BIO_R_WRITE_TO_READ_ONLY_BIO ,"write to read only bio"},
|
||||
{BIO_R_WSASTARTUP ,"wsastartup"},
|
||||
{BIO_R_WRITE_TO_READ_ONLY_BIO ,"write to read only BIO"},
|
||||
{BIO_R_WSASTARTUP ,"WSAStartup"},
|
||||
{0,NULL}
|
||||
};
|
||||
|
||||
|
@ -70,7 +70,7 @@ BIO *BIO_new(BIO_METHOD *method)
|
||||
{
|
||||
BIO *ret=NULL;
|
||||
|
||||
ret=(BIO *)Malloc(sizeof(BIO));
|
||||
ret=(BIO *)OPENSSL_malloc(sizeof(BIO));
|
||||
if (ret == NULL)
|
||||
{
|
||||
BIOerr(BIO_F_BIO_NEW,ERR_R_MALLOC_FAILURE);
|
||||
@ -78,7 +78,7 @@ BIO *BIO_new(BIO_METHOD *method)
|
||||
}
|
||||
if (!BIO_set(ret,method))
|
||||
{
|
||||
Free(ret);
|
||||
OPENSSL_free(ret);
|
||||
ret=NULL;
|
||||
}
|
||||
return(ret);
|
||||
@ -133,10 +133,13 @@ int BIO_free(BIO *a)
|
||||
|
||||
if ((a->method == NULL) || (a->method->destroy == NULL)) return(1);
|
||||
ret=a->method->destroy(a);
|
||||
Free(a);
|
||||
OPENSSL_free(a);
|
||||
return(1);
|
||||
}
|
||||
|
||||
void BIO_vfree(BIO *a)
|
||||
{ BIO_free(a); }
|
||||
|
||||
int BIO_read(BIO *b, void *out, int outl)
|
||||
{
|
||||
int i;
|
||||
@ -198,13 +201,7 @@ int BIO_write(BIO *b, const void *in, int inl)
|
||||
|
||||
if (i > 0) b->num_write+=(unsigned long)i;
|
||||
|
||||
/* This is evil and not thread safe. If the BIO has been freed,
|
||||
* we must not call the callback. The only way to be able to
|
||||
* determine this is the reference count which is now invalid since
|
||||
* the memory has been free()ed.
|
||||
*/
|
||||
if (b->references <= 0) abort();
|
||||
if (cb != NULL) /* && (b->references >= 1)) */
|
||||
if (cb != NULL)
|
||||
i=(int)cb(b,BIO_CB_WRITE|BIO_CB_RETURN,in,inl,
|
||||
0L,(long)i);
|
||||
return(i);
|
||||
@ -235,6 +232,8 @@ int BIO_puts(BIO *b, const char *in)
|
||||
|
||||
i=b->method->bputs(b,in);
|
||||
|
||||
if (i > 0) b->num_write+=(unsigned long)i;
|
||||
|
||||
if (cb != NULL)
|
||||
i=(int)cb(b,BIO_CB_PUTS|BIO_CB_RETURN,in,0,
|
||||
0L,(long)i);
|
||||
@ -317,7 +316,7 @@ long BIO_ctrl(BIO *b, int cmd, long larg, void *parg)
|
||||
return(ret);
|
||||
}
|
||||
|
||||
long BIO_callback_ctrl(BIO *b, int cmd, void (*fp)())
|
||||
long BIO_callback_ctrl(BIO *b, int cmd, void (*fp)(struct bio_st *, int, const char *, int, long, long))
|
||||
{
|
||||
long ret;
|
||||
long (*cb)();
|
||||
@ -419,6 +418,7 @@ BIO *BIO_find_type(BIO *bio, int type)
|
||||
{
|
||||
int mt,mask;
|
||||
|
||||
if(!bio) return NULL;
|
||||
mask=type&0xff;
|
||||
do {
|
||||
if (bio->method != NULL)
|
||||
@ -437,6 +437,12 @@ BIO *BIO_find_type(BIO *bio, int type)
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
BIO *BIO_next(BIO *b)
|
||||
{
|
||||
if(!b) return NULL;
|
||||
return b->next_bio;
|
||||
}
|
||||
|
||||
void BIO_free_all(BIO *bio)
|
||||
{
|
||||
BIO *b;
|
||||
@ -532,3 +538,5 @@ unsigned long BIO_number_written(BIO *bio)
|
||||
if(bio) return bio->num_write;
|
||||
return 0;
|
||||
}
|
||||
|
||||
IMPLEMENT_STACK_OF(BIO)
|
||||
|
@ -92,10 +92,10 @@ typedef struct bio_accept_st
|
||||
BIO *bio_chain;
|
||||
} BIO_ACCEPT;
|
||||
|
||||
static int acpt_write(BIO *h,char *buf,int num);
|
||||
static int acpt_read(BIO *h,char *buf,int size);
|
||||
static int acpt_puts(BIO *h,char *str);
|
||||
static long acpt_ctrl(BIO *h,int cmd,long arg1,char *arg2);
|
||||
static int acpt_write(BIO *h, const char *buf, int num);
|
||||
static int acpt_read(BIO *h, char *buf, int size);
|
||||
static int acpt_puts(BIO *h, const char *str);
|
||||
static long acpt_ctrl(BIO *h, int cmd, long arg1, void *arg2);
|
||||
static int acpt_new(BIO *h);
|
||||
static int acpt_free(BIO *data);
|
||||
static int acpt_state(BIO *b, BIO_ACCEPT *c);
|
||||
@ -145,7 +145,7 @@ BIO_ACCEPT *BIO_ACCEPT_new(void)
|
||||
{
|
||||
BIO_ACCEPT *ret;
|
||||
|
||||
if ((ret=(BIO_ACCEPT *)Malloc(sizeof(BIO_ACCEPT))) == NULL)
|
||||
if ((ret=(BIO_ACCEPT *)OPENSSL_malloc(sizeof(BIO_ACCEPT))) == NULL)
|
||||
return(NULL);
|
||||
|
||||
memset(ret,0,sizeof(BIO_ACCEPT));
|
||||
@ -159,10 +159,10 @@ void BIO_ACCEPT_free(BIO_ACCEPT *a)
|
||||
if(a == NULL)
|
||||
return;
|
||||
|
||||
if (a->param_addr != NULL) Free(a->param_addr);
|
||||
if (a->addr != NULL) Free(a->addr);
|
||||
if (a->param_addr != NULL) OPENSSL_free(a->param_addr);
|
||||
if (a->addr != NULL) OPENSSL_free(a->addr);
|
||||
if (a->bio_chain != NULL) BIO_free(a->bio_chain);
|
||||
Free(a);
|
||||
OPENSSL_free(a);
|
||||
}
|
||||
|
||||
static void acpt_close_socket(BIO *bio)
|
||||
@ -307,7 +307,7 @@ static int acpt_read(BIO *b, char *out, int outl)
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static int acpt_write(BIO *b, char *in, int inl)
|
||||
static int acpt_write(BIO *b, const char *in, int inl)
|
||||
{
|
||||
int ret;
|
||||
BIO_ACCEPT *data;
|
||||
@ -326,7 +326,7 @@ static int acpt_write(BIO *b, char *in, int inl)
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static long acpt_ctrl(BIO *b, int cmd, long num, char *ptr)
|
||||
static long acpt_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
{
|
||||
BIO *dbio;
|
||||
int *ip;
|
||||
@ -355,7 +355,7 @@ static long acpt_ctrl(BIO *b, int cmd, long num, char *ptr)
|
||||
{
|
||||
b->init=1;
|
||||
if (data->param_addr != NULL)
|
||||
Free(data->param_addr);
|
||||
OPENSSL_free(data->param_addr);
|
||||
data->param_addr=BUF_strdup(ptr);
|
||||
}
|
||||
else if (num == 1)
|
||||
@ -440,7 +440,7 @@ static long acpt_ctrl(BIO *b, int cmd, long num, char *ptr)
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static int acpt_puts(BIO *bp, char *str)
|
||||
static int acpt_puts(BIO *bp, const char *str)
|
||||
{
|
||||
int n,ret;
|
||||
|
||||
|
@ -30,9 +30,9 @@
|
||||
static int bio_new(BIO *bio);
|
||||
static int bio_free(BIO *bio);
|
||||
static int bio_read(BIO *bio, char *buf, int size);
|
||||
static int bio_write(BIO *bio, char *buf, int num);
|
||||
static int bio_write(BIO *bio, const char *buf, int num);
|
||||
static long bio_ctrl(BIO *bio, int cmd, long num, void *ptr);
|
||||
static int bio_puts(BIO *bio, char *str);
|
||||
static int bio_puts(BIO *bio, const char *str);
|
||||
|
||||
static int bio_make_pair(BIO *bio1, BIO *bio2);
|
||||
static void bio_destroy_pair(BIO *bio);
|
||||
@ -80,7 +80,7 @@ static int bio_new(BIO *bio)
|
||||
{
|
||||
struct bio_bio_st *b;
|
||||
|
||||
b = Malloc(sizeof *b);
|
||||
b = OPENSSL_malloc(sizeof *b);
|
||||
if (b == NULL)
|
||||
return 0;
|
||||
|
||||
@ -108,10 +108,10 @@ static int bio_free(BIO *bio)
|
||||
|
||||
if (b->buf != NULL)
|
||||
{
|
||||
Free(b->buf);
|
||||
OPENSSL_free(b->buf);
|
||||
}
|
||||
|
||||
Free(b);
|
||||
OPENSSL_free(b);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -283,7 +283,7 @@ static ssize_t bio_nread(BIO *bio, char **buf, size_t num_)
|
||||
}
|
||||
|
||||
|
||||
static int bio_write(BIO *bio, char *buf, int num_)
|
||||
static int bio_write(BIO *bio, const char *buf, int num_)
|
||||
{
|
||||
size_t num = num_;
|
||||
size_t rest;
|
||||
@ -464,7 +464,7 @@ static long bio_ctrl(BIO *bio, int cmd, long num, void *ptr)
|
||||
{
|
||||
if (b->buf)
|
||||
{
|
||||
Free(b->buf);
|
||||
OPENSSL_free(b->buf);
|
||||
b->buf = NULL;
|
||||
}
|
||||
b->size = new_size;
|
||||
@ -628,7 +628,7 @@ static long bio_ctrl(BIO *bio, int cmd, long num, void *ptr)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int bio_puts(BIO *bio, char *str)
|
||||
static int bio_puts(BIO *bio, const char *str)
|
||||
{
|
||||
return bio_write(bio, str, strlen(str));
|
||||
}
|
||||
@ -652,7 +652,7 @@ static int bio_make_pair(BIO *bio1, BIO *bio2)
|
||||
|
||||
if (b1->buf == NULL)
|
||||
{
|
||||
b1->buf = Malloc(b1->size);
|
||||
b1->buf = OPENSSL_malloc(b1->size);
|
||||
if (b1->buf == NULL)
|
||||
{
|
||||
BIOerr(BIO_F_BIO_MAKE_PAIR, ERR_R_MALLOC_FAILURE);
|
||||
@ -664,7 +664,7 @@ static int bio_make_pair(BIO *bio1, BIO *bio2)
|
||||
|
||||
if (b2->buf == NULL)
|
||||
{
|
||||
b2->buf = Malloc(b2->size);
|
||||
b2->buf = OPENSSL_malloc(b2->size);
|
||||
if (b2->buf == NULL)
|
||||
{
|
||||
BIOerr(BIO_F_BIO_MAKE_PAIR, ERR_R_MALLOC_FAILURE);
|
||||
|
@ -98,13 +98,13 @@ typedef struct bio_connect_st
|
||||
int (*info_callback)();
|
||||
} BIO_CONNECT;
|
||||
|
||||
static int conn_write(BIO *h,char *buf,int num);
|
||||
static int conn_read(BIO *h,char *buf,int size);
|
||||
static int conn_puts(BIO *h,char *str);
|
||||
static long conn_ctrl(BIO *h,int cmd,long arg1,char *arg2);
|
||||
static int conn_write(BIO *h, const char *buf, int num);
|
||||
static int conn_read(BIO *h, char *buf, int size);
|
||||
static int conn_puts(BIO *h, const char *str);
|
||||
static long conn_ctrl(BIO *h, int cmd, long arg1, void *arg2);
|
||||
static int conn_new(BIO *h);
|
||||
static int conn_free(BIO *data);
|
||||
static long conn_callback_ctrl(BIO *h,int cmd,void *(*fp)());
|
||||
static long conn_callback_ctrl(BIO *h, int cmd, bio_info_cb *);
|
||||
|
||||
static int conn_state(BIO *b, BIO_CONNECT *c);
|
||||
static void conn_close_socket(BIO *data);
|
||||
@ -165,7 +165,7 @@ static int conn_state(BIO *b, BIO_CONNECT *c)
|
||||
break;
|
||||
}
|
||||
if (c->param_port != NULL)
|
||||
Free(c->param_port);
|
||||
OPENSSL_free(c->param_port);
|
||||
c->param_port=BUF_strdup(p);
|
||||
}
|
||||
}
|
||||
@ -188,7 +188,7 @@ static int conn_state(BIO *b, BIO_CONNECT *c)
|
||||
case BIO_CONN_S_GET_PORT:
|
||||
if (c->param_port == NULL)
|
||||
{
|
||||
abort();
|
||||
/* abort(); */
|
||||
goto exit_loop;
|
||||
}
|
||||
else if (BIO_get_port(c->param_port,&c->port) <= 0)
|
||||
@ -236,7 +236,7 @@ static int conn_state(BIO *b, BIO_CONNECT *c)
|
||||
}
|
||||
c->state=BIO_CONN_S_CONNECT;
|
||||
|
||||
#ifdef SO_KEEPALIVE
|
||||
#if defined(SO_KEEPALIVE) && !defined(MPE)
|
||||
i=1;
|
||||
i=setsockopt(b->num,SOL_SOCKET,SO_KEEPALIVE,(char *)&i,sizeof(i));
|
||||
if (i < 0)
|
||||
@ -299,7 +299,7 @@ static int conn_state(BIO *b, BIO_CONNECT *c)
|
||||
ret=1;
|
||||
goto exit_loop;
|
||||
default:
|
||||
abort();
|
||||
/* abort(); */
|
||||
goto exit_loop;
|
||||
}
|
||||
|
||||
@ -322,7 +322,7 @@ BIO_CONNECT *BIO_CONNECT_new(void)
|
||||
{
|
||||
BIO_CONNECT *ret;
|
||||
|
||||
if ((ret=(BIO_CONNECT *)Malloc(sizeof(BIO_CONNECT))) == NULL)
|
||||
if ((ret=(BIO_CONNECT *)OPENSSL_malloc(sizeof(BIO_CONNECT))) == NULL)
|
||||
return(NULL);
|
||||
ret->state=BIO_CONN_S_BEFORE;
|
||||
ret->param_hostname=NULL;
|
||||
@ -344,10 +344,10 @@ void BIO_CONNECT_free(BIO_CONNECT *a)
|
||||
return;
|
||||
|
||||
if (a->param_hostname != NULL)
|
||||
Free(a->param_hostname);
|
||||
OPENSSL_free(a->param_hostname);
|
||||
if (a->param_port != NULL)
|
||||
Free(a->param_port);
|
||||
Free(a);
|
||||
OPENSSL_free(a->param_port);
|
||||
OPENSSL_free(a);
|
||||
}
|
||||
|
||||
BIO_METHOD *BIO_s_connect(void)
|
||||
@ -426,7 +426,7 @@ static int conn_read(BIO *b, char *out, int outl)
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static int conn_write(BIO *b, char *in, int inl)
|
||||
static int conn_write(BIO *b, const char *in, int inl)
|
||||
{
|
||||
int ret;
|
||||
BIO_CONNECT *data;
|
||||
@ -449,7 +449,7 @@ static int conn_write(BIO *b, char *in, int inl)
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static long conn_ctrl(BIO *b, int cmd, long num, char *ptr)
|
||||
static long conn_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
{
|
||||
BIO *dbio;
|
||||
int *ip;
|
||||
@ -507,23 +507,24 @@ static long conn_ctrl(BIO *b, int cmd, long num, char *ptr)
|
||||
if (num == 0)
|
||||
{
|
||||
if (data->param_hostname != NULL)
|
||||
Free(data->param_hostname);
|
||||
OPENSSL_free(data->param_hostname);
|
||||
data->param_hostname=BUF_strdup(ptr);
|
||||
}
|
||||
else if (num == 1)
|
||||
{
|
||||
if (data->param_port != NULL)
|
||||
Free(data->param_port);
|
||||
OPENSSL_free(data->param_port);
|
||||
data->param_port=BUF_strdup(ptr);
|
||||
}
|
||||
else if (num == 2)
|
||||
{
|
||||
char buf[16];
|
||||
char *p = ptr;
|
||||
|
||||
sprintf(buf,"%d.%d.%d.%d",
|
||||
ptr[0],ptr[1],ptr[2],ptr[3]);
|
||||
p[0],p[1],p[2],p[3]);
|
||||
if (data->param_hostname != NULL)
|
||||
Free(data->param_hostname);
|
||||
OPENSSL_free(data->param_hostname);
|
||||
data->param_hostname=BUF_strdup(buf);
|
||||
memcpy(&(data->ip[0]),ptr,4);
|
||||
}
|
||||
@ -533,7 +534,7 @@ static long conn_ctrl(BIO *b, int cmd, long num, char *ptr)
|
||||
|
||||
sprintf(buf,"%d",*(int *)ptr);
|
||||
if (data->param_port != NULL)
|
||||
Free(data->param_port);
|
||||
OPENSSL_free(data->param_port);
|
||||
data->param_port=BUF_strdup(buf);
|
||||
data->port= *(int *)ptr;
|
||||
}
|
||||
@ -573,7 +574,7 @@ static long conn_ctrl(BIO *b, int cmd, long num, char *ptr)
|
||||
if (data->param_hostname)
|
||||
BIO_set_conn_hostname(dbio,data->param_hostname);
|
||||
BIO_set_nbio(dbio,data->nbio);
|
||||
(void)BIO_set_info_callback(dbio,(void *(*)())(data->info_callback));
|
||||
(void)BIO_set_info_callback(dbio,data->info_callback);
|
||||
}
|
||||
break;
|
||||
case BIO_CTRL_SET_CALLBACK:
|
||||
@ -601,7 +602,7 @@ static long conn_ctrl(BIO *b, int cmd, long num, char *ptr)
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static long conn_callback_ctrl(BIO *b, int cmd, void *(*fp)())
|
||||
static long conn_callback_ctrl(BIO *b, int cmd, bio_info_cb *fp)
|
||||
{
|
||||
long ret=1;
|
||||
BIO_CONNECT *data;
|
||||
@ -622,7 +623,7 @@ static long conn_callback_ctrl(BIO *b, int cmd, void *(*fp)())
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static int conn_puts(BIO *bp, char *str)
|
||||
static int conn_puts(BIO *bp, const char *str)
|
||||
{
|
||||
int n,ret;
|
||||
|
||||
|
@ -73,11 +73,11 @@
|
||||
|
||||
#if !defined(NO_STDIO)
|
||||
|
||||
static int MS_CALLBACK file_write(BIO *h,char *buf,int num);
|
||||
static int MS_CALLBACK file_read(BIO *h,char *buf,int size);
|
||||
static int MS_CALLBACK file_puts(BIO *h,char *str);
|
||||
static int MS_CALLBACK file_gets(BIO *h,char *str,int size);
|
||||
static long MS_CALLBACK file_ctrl(BIO *h,int cmd,long arg1,char *arg2);
|
||||
static int MS_CALLBACK file_write(BIO *h, const char *buf, int num);
|
||||
static int MS_CALLBACK file_read(BIO *h, char *buf, int size);
|
||||
static int MS_CALLBACK file_puts(BIO *h, const char *str);
|
||||
static int MS_CALLBACK file_gets(BIO *h, char *str, int size);
|
||||
static long MS_CALLBACK file_ctrl(BIO *h, int cmd, long arg1, void *arg2);
|
||||
static int MS_CALLBACK file_new(BIO *h);
|
||||
static int MS_CALLBACK file_free(BIO *data);
|
||||
static BIO_METHOD methods_filep=
|
||||
@ -163,7 +163,7 @@ static int MS_CALLBACK file_read(BIO *b, char *out, int outl)
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static int MS_CALLBACK file_write(BIO *b, char *in, int inl)
|
||||
static int MS_CALLBACK file_write(BIO *b, const char *in, int inl)
|
||||
{
|
||||
int ret=0;
|
||||
|
||||
@ -179,7 +179,7 @@ static int MS_CALLBACK file_write(BIO *b, char *in, int inl)
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static long MS_CALLBACK file_ctrl(BIO *b, int cmd, long num, char *ptr)
|
||||
static long MS_CALLBACK file_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
{
|
||||
long ret=1;
|
||||
FILE *fp=(FILE *)b->ptr;
|
||||
@ -294,7 +294,7 @@ static int MS_CALLBACK file_gets(BIO *bp, char *buf, int size)
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static int MS_CALLBACK file_puts(BIO *bp, char *str)
|
||||
static int MS_CALLBACK file_puts(BIO *bp, const char *str)
|
||||
{
|
||||
int n,ret;
|
||||
|
||||
|
@ -110,14 +110,26 @@
|
||||
#define LOG_DAEMON OPC$M_NM_NTWORK
|
||||
#endif
|
||||
|
||||
static int MS_CALLBACK slg_write(BIO *h,char *buf,int num);
|
||||
static int MS_CALLBACK slg_puts(BIO *h,char *str);
|
||||
static long MS_CALLBACK slg_ctrl(BIO *h,int cmd,long arg1,char *arg2);
|
||||
static int MS_CALLBACK slg_write(BIO *h, const char *buf, int num);
|
||||
static int MS_CALLBACK slg_puts(BIO *h, const char *str);
|
||||
static long MS_CALLBACK slg_ctrl(BIO *h, int cmd, long arg1, void *arg2);
|
||||
static int MS_CALLBACK slg_new(BIO *h);
|
||||
static int MS_CALLBACK slg_free(BIO *data);
|
||||
static void xopenlog(BIO* bp, const char* name, int level);
|
||||
static void xopenlog(BIO* bp, char* name, int level);
|
||||
static void xsyslog(BIO* bp, int priority, const char* string);
|
||||
static void xcloselog(BIO* bp);
|
||||
#ifdef WIN32
|
||||
LONG (WINAPI *go_for_advapi)() = RegOpenKeyEx;
|
||||
HANDLE (WINAPI *register_event_source)() = NULL;
|
||||
BOOL (WINAPI *deregister_event_source)() = NULL;
|
||||
BOOL (WINAPI *report_event)() = NULL;
|
||||
#define DL_PROC(m,f) (GetProcAddress( m, f ))
|
||||
#ifdef UNICODE
|
||||
#define DL_PROC_X(m,f) DL_PROC( m, f "W" )
|
||||
#else
|
||||
#define DL_PROC_X(m,f) DL_PROC( m, f "A" )
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static BIO_METHOD methods_slg=
|
||||
{
|
||||
@ -153,40 +165,60 @@ static int MS_CALLBACK slg_free(BIO *a)
|
||||
return(1);
|
||||
}
|
||||
|
||||
static int MS_CALLBACK slg_write(BIO *b, char *in, int inl)
|
||||
static int MS_CALLBACK slg_write(BIO *b, const char *in, int inl)
|
||||
{
|
||||
int ret= inl;
|
||||
char* buf= in;
|
||||
char* buf;
|
||||
char* pp;
|
||||
int priority;
|
||||
int priority, i;
|
||||
static struct
|
||||
{
|
||||
int strl;
|
||||
char str[10];
|
||||
int log_level;
|
||||
}
|
||||
mapping[] =
|
||||
{
|
||||
{ 6, "PANIC ", LOG_EMERG },
|
||||
{ 6, "EMERG ", LOG_EMERG },
|
||||
{ 4, "EMR ", LOG_EMERG },
|
||||
{ 6, "ALERT ", LOG_ALERT },
|
||||
{ 4, "ALR ", LOG_ALERT },
|
||||
{ 5, "CRIT ", LOG_CRIT },
|
||||
{ 4, "CRI ", LOG_CRIT },
|
||||
{ 6, "ERROR ", LOG_ERR },
|
||||
{ 4, "ERR ", LOG_ERR },
|
||||
{ 8, "WARNING ", LOG_WARNING },
|
||||
{ 5, "WARN ", LOG_WARNING },
|
||||
{ 4, "WAR ", LOG_WARNING },
|
||||
{ 7, "NOTICE ", LOG_NOTICE },
|
||||
{ 5, "NOTE ", LOG_NOTICE },
|
||||
{ 4, "NOT ", LOG_NOTICE },
|
||||
{ 5, "INFO ", LOG_INFO },
|
||||
{ 4, "INF ", LOG_INFO },
|
||||
{ 6, "DEBUG ", LOG_DEBUG },
|
||||
{ 4, "DBG ", LOG_DEBUG },
|
||||
{ 0, "", LOG_ERR } /* The default */
|
||||
};
|
||||
|
||||
if((buf= (char *)Malloc(inl+ 1)) == NULL){
|
||||
if((buf= (char *)OPENSSL_malloc(inl+ 1)) == NULL){
|
||||
return(0);
|
||||
}
|
||||
strncpy(buf, in, inl);
|
||||
buf[inl]= '\0';
|
||||
|
||||
if(strncmp(buf, "ERR ", 4) == 0){
|
||||
priority= LOG_ERR;
|
||||
pp= buf+ 4;
|
||||
}else if(strncmp(buf, "WAR ", 4) == 0){
|
||||
priority= LOG_WARNING;
|
||||
pp= buf+ 4;
|
||||
}else if(strncmp(buf, "INF ", 4) == 0){
|
||||
priority= LOG_INFO;
|
||||
pp= buf+ 4;
|
||||
}else{
|
||||
priority= LOG_ERR;
|
||||
pp= buf;
|
||||
}
|
||||
i = 0;
|
||||
while(strncmp(buf, mapping[i].str, mapping[i].strl) != 0) i++;
|
||||
priority = mapping[i].log_level;
|
||||
pp = buf + mapping[i].strl;
|
||||
|
||||
xsyslog(b, priority, pp);
|
||||
|
||||
Free(buf);
|
||||
OPENSSL_free(buf);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static long MS_CALLBACK slg_ctrl(BIO *b, int cmd, long num, char *ptr)
|
||||
static long MS_CALLBACK slg_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
{
|
||||
switch (cmd)
|
||||
{
|
||||
@ -200,7 +232,7 @@ static long MS_CALLBACK slg_ctrl(BIO *b, int cmd, long num, char *ptr)
|
||||
return(0);
|
||||
}
|
||||
|
||||
static int MS_CALLBACK slg_puts(BIO *bp, char *str)
|
||||
static int MS_CALLBACK slg_puts(BIO *bp, const char *str)
|
||||
{
|
||||
int n,ret;
|
||||
|
||||
@ -211,9 +243,29 @@ static int MS_CALLBACK slg_puts(BIO *bp, char *str)
|
||||
|
||||
#if defined(WIN32)
|
||||
|
||||
static void xopenlog(BIO* bp, const char* name, int level)
|
||||
static void xopenlog(BIO* bp, char* name, int level)
|
||||
{
|
||||
bp->ptr= (char *)RegisterEventSource(NULL, name);
|
||||
if ( !register_event_source )
|
||||
{
|
||||
HANDLE advapi;
|
||||
if ( !(advapi = GetModuleHandle("advapi32")) )
|
||||
return;
|
||||
register_event_source = (HANDLE (WINAPI *)())DL_PROC_X(advapi,
|
||||
"RegisterEventSource" );
|
||||
deregister_event_source = (BOOL (WINAPI *)())DL_PROC(advapi,
|
||||
"DeregisterEventSource");
|
||||
report_event = (BOOL (WINAPI *)())DL_PROC_X(advapi,
|
||||
"ReportEvent" );
|
||||
if ( !(register_event_source && deregister_event_source &&
|
||||
report_event) )
|
||||
{
|
||||
register_event_source = NULL;
|
||||
deregister_event_source = NULL;
|
||||
report_event = NULL;
|
||||
return;
|
||||
}
|
||||
}
|
||||
bp->ptr= (char *)register_event_source(NULL, name);
|
||||
}
|
||||
|
||||
static void xsyslog(BIO *bp, int priority, const char *string)
|
||||
@ -225,16 +277,22 @@ static void xsyslog(BIO *bp, int priority, const char *string)
|
||||
|
||||
switch (priority)
|
||||
{
|
||||
case LOG_EMERG:
|
||||
case LOG_ALERT:
|
||||
case LOG_CRIT:
|
||||
case LOG_ERR:
|
||||
evtype = EVENTLOG_ERROR_TYPE;
|
||||
break;
|
||||
case LOG_WARNING:
|
||||
evtype = EVENTLOG_WARNING_TYPE;
|
||||
break;
|
||||
case LOG_NOTICE:
|
||||
case LOG_INFO:
|
||||
case LOG_DEBUG:
|
||||
evtype = EVENTLOG_INFORMATION_TYPE;
|
||||
break;
|
||||
default:
|
||||
default: /* Should never happen, but set it
|
||||
as error anyway. */
|
||||
evtype = EVENTLOG_ERROR_TYPE;
|
||||
break;
|
||||
}
|
||||
@ -243,15 +301,15 @@ static void xsyslog(BIO *bp, int priority, const char *string)
|
||||
lpszStrings[0] = pidbuf;
|
||||
lpszStrings[1] = string;
|
||||
|
||||
if(bp->ptr)
|
||||
ReportEvent(bp->ptr, evtype, 0, 1024, NULL, 2, 0,
|
||||
if(report_event && bp->ptr)
|
||||
report_event(bp->ptr, evtype, 0, 1024, NULL, 2, 0,
|
||||
lpszStrings, NULL);
|
||||
}
|
||||
|
||||
static void xcloselog(BIO* bp)
|
||||
{
|
||||
if(bp->ptr)
|
||||
DeregisterEventSource((HANDLE)(bp->ptr));
|
||||
if(deregister_event_source && bp->ptr)
|
||||
deregister_event_source((HANDLE)(bp->ptr));
|
||||
bp->ptr= NULL;
|
||||
}
|
||||
|
||||
@ -259,7 +317,7 @@ static void xcloselog(BIO* bp)
|
||||
|
||||
static int VMS_OPC_target = LOG_DAEMON;
|
||||
|
||||
static void xopenlog(BIO* bp, const char* name, int level)
|
||||
static void xopenlog(BIO* bp, char* name, int level)
|
||||
{
|
||||
VMS_OPC_target = level;
|
||||
}
|
||||
@ -294,7 +352,7 @@ static void xsyslog(BIO *bp, int priority, const char *string)
|
||||
lib$sys_fao(&fao_cmd, &len, &buf_dsc, priority_tag, string);
|
||||
|
||||
/* we know there's an 8 byte header. That's documented */
|
||||
opcdef_p = (struct opcdef *) Malloc(8 + len);
|
||||
opcdef_p = (struct opcdef *) OPENSSL_malloc(8 + len);
|
||||
opcdef_p->opc$b_ms_type = OPC$_RQ_RQST;
|
||||
memcpy(opcdef_p->opc$z_ms_target_classes, &VMS_OPC_target, 3);
|
||||
opcdef_p->opc$l_ms_rqstid = 0;
|
||||
@ -307,7 +365,7 @@ static void xsyslog(BIO *bp, int priority, const char *string)
|
||||
|
||||
sys$sndopr(opc_dsc, 0);
|
||||
|
||||
Free(opcdef_p);
|
||||
OPENSSL_free(opcdef_p);
|
||||
}
|
||||
|
||||
static void xcloselog(BIO* bp)
|
||||
@ -316,7 +374,7 @@ static void xcloselog(BIO* bp)
|
||||
|
||||
#else /* Unix */
|
||||
|
||||
static void xopenlog(BIO* bp, const char* name, int level)
|
||||
static void xopenlog(BIO* bp, char* name, int level)
|
||||
{
|
||||
openlog(name, LOG_PID|LOG_CONS, level);
|
||||
}
|
||||
|
@ -61,11 +61,11 @@
|
||||
#include "cryptlib.h"
|
||||
#include <openssl/bio.h>
|
||||
|
||||
static int mem_write(BIO *h,char *buf,int num);
|
||||
static int mem_read(BIO *h,char *buf,int size);
|
||||
static int mem_puts(BIO *h,char *str);
|
||||
static int mem_gets(BIO *h,char *str,int size);
|
||||
static long mem_ctrl(BIO *h,int cmd,long arg1,char *arg2);
|
||||
static int mem_write(BIO *h, const char *buf, int num);
|
||||
static int mem_read(BIO *h, char *buf, int size);
|
||||
static int mem_puts(BIO *h, const char *str);
|
||||
static int mem_gets(BIO *h, char *str, int size);
|
||||
static long mem_ctrl(BIO *h, int cmd, long arg1, void *arg2);
|
||||
static int mem_new(BIO *h);
|
||||
static int mem_free(BIO *data);
|
||||
static BIO_METHOD mem_method=
|
||||
@ -163,14 +163,14 @@ static int mem_read(BIO *b, char *out, int outl)
|
||||
}
|
||||
} else if (bm->length == 0)
|
||||
{
|
||||
if (b->num != 0)
|
||||
ret = b->num;
|
||||
if (ret != 0)
|
||||
BIO_set_retry_read(b);
|
||||
ret= b->num;
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static int mem_write(BIO *b, char *in, int inl)
|
||||
static int mem_write(BIO *b, const char *in, int inl)
|
||||
{
|
||||
int ret= -1;
|
||||
int blen;
|
||||
@ -198,7 +198,7 @@ end:
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static long mem_ctrl(BIO *b, int cmd, long num, char *ptr)
|
||||
static long mem_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
{
|
||||
long ret=1;
|
||||
char **pptr;
|
||||
@ -208,15 +208,20 @@ static long mem_ctrl(BIO *b, int cmd, long num, char *ptr)
|
||||
switch (cmd)
|
||||
{
|
||||
case BIO_CTRL_RESET:
|
||||
if (bm->data != NULL) {
|
||||
if (bm->data != NULL)
|
||||
{
|
||||
/* For read only case reset to the start again */
|
||||
if(b->flags & BIO_FLAGS_MEM_RDONLY)
|
||||
bm->data -= bm->max - bm->length;
|
||||
else {
|
||||
{
|
||||
bm->data -= bm->max - bm->length;
|
||||
bm->length = bm->max;
|
||||
}
|
||||
else
|
||||
{
|
||||
memset(bm->data,0,bm->max);
|
||||
bm->length=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case BIO_CTRL_EOF:
|
||||
ret=(long)(bm->length == 0);
|
||||
@ -300,7 +305,7 @@ static int mem_gets(BIO *bp, char *buf, int size)
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static int mem_puts(BIO *bp, char *str)
|
||||
static int mem_puts(BIO *bp, const char *str)
|
||||
{
|
||||
int n,ret;
|
||||
|
||||
|
@ -61,11 +61,11 @@
|
||||
#include "cryptlib.h"
|
||||
#include <openssl/bio.h>
|
||||
|
||||
static int null_write(BIO *h,char *buf,int num);
|
||||
static int null_read(BIO *h,char *buf,int size);
|
||||
static int null_puts(BIO *h,char *str);
|
||||
static int null_gets(BIO *h,char *str,int size);
|
||||
static long null_ctrl(BIO *h,int cmd,long arg1,char *arg2);
|
||||
static int null_write(BIO *h, const char *buf, int num);
|
||||
static int null_read(BIO *h, char *buf, int size);
|
||||
static int null_puts(BIO *h, const char *str);
|
||||
static int null_gets(BIO *h, char *str, int size);
|
||||
static long null_ctrl(BIO *h, int cmd, long arg1, void *arg2);
|
||||
static int null_new(BIO *h);
|
||||
static int null_free(BIO *data);
|
||||
static BIO_METHOD null_method=
|
||||
@ -106,12 +106,12 @@ static int null_read(BIO *b, char *out, int outl)
|
||||
return(0);
|
||||
}
|
||||
|
||||
static int null_write(BIO *b, char *in, int inl)
|
||||
static int null_write(BIO *b, const char *in, int inl)
|
||||
{
|
||||
return(inl);
|
||||
}
|
||||
|
||||
static long null_ctrl(BIO *b, int cmd, long num, char *ptr)
|
||||
static long null_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
{
|
||||
long ret=1;
|
||||
|
||||
@ -142,7 +142,7 @@ static int null_gets(BIO *bp, char *buf, int size)
|
||||
return(0);
|
||||
}
|
||||
|
||||
static int null_puts(BIO *bp, char *str)
|
||||
static int null_puts(BIO *bp, const char *str)
|
||||
{
|
||||
if (str == NULL) return(0);
|
||||
return(strlen(str));
|
||||
|
@ -88,11 +88,11 @@ struct rpc_ctx {
|
||||
struct rpc_msg msg;
|
||||
};
|
||||
|
||||
static int rtcp_write(BIO *h,char *buf,int num);
|
||||
static int rtcp_write(BIO *h,const char *buf,int num);
|
||||
static int rtcp_read(BIO *h,char *buf,int size);
|
||||
static int rtcp_puts(BIO *h,char *str);
|
||||
static int rtcp_puts(BIO *h,const char *str);
|
||||
static int rtcp_gets(BIO *h,char *str,int size);
|
||||
static long rtcp_ctrl(BIO *h,int cmd,long arg1,char *arg2);
|
||||
static long rtcp_ctrl(BIO *h,int cmd,long arg1,void *arg2);
|
||||
static int rtcp_new(BIO *h);
|
||||
static int rtcp_free(BIO *data);
|
||||
|
||||
@ -156,7 +156,7 @@ static int rtcp_new(BIO *bi)
|
||||
bi->init=1;
|
||||
bi->num=0;
|
||||
bi->flags = 0;
|
||||
bi->ptr=Malloc(sizeof(struct rpc_ctx));
|
||||
bi->ptr=OPENSSL_malloc(sizeof(struct rpc_ctx));
|
||||
ctx = (struct rpc_ctx *) bi->ptr;
|
||||
ctx->filled = 0;
|
||||
ctx->pos = 0;
|
||||
@ -166,7 +166,7 @@ static int rtcp_new(BIO *bi)
|
||||
static int rtcp_free(BIO *a)
|
||||
{
|
||||
if (a == NULL) return(0);
|
||||
if ( a->ptr ) Free ( a->ptr );
|
||||
if ( a->ptr ) OPENSSL_free ( a->ptr );
|
||||
a->ptr = NULL;
|
||||
return(1);
|
||||
}
|
||||
@ -218,7 +218,7 @@ static int rtcp_read(BIO *b, char *out, int outl)
|
||||
return length;
|
||||
}
|
||||
|
||||
static int rtcp_write(BIO *b, char *in, int inl)
|
||||
static int rtcp_write(BIO *b, const char *in, int inl)
|
||||
{
|
||||
int status, i, segment, length;
|
||||
struct rpc_ctx *ctx;
|
||||
@ -247,7 +247,7 @@ static int rtcp_write(BIO *b, char *in, int inl)
|
||||
return(i);
|
||||
}
|
||||
|
||||
static long rtcp_ctrl(BIO *b, int cmd, long num, char *ptr)
|
||||
static long rtcp_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
{
|
||||
long ret=1;
|
||||
|
||||
@ -283,7 +283,7 @@ static int rtcp_gets(BIO *bp, char *buf, int size)
|
||||
return(0);
|
||||
}
|
||||
|
||||
static int rtcp_puts(BIO *bp, char *str)
|
||||
static int rtcp_puts(BIO *bp, const char *str)
|
||||
{
|
||||
int length;
|
||||
if (str == NULL) return(0);
|
||||
|
@ -65,19 +65,19 @@
|
||||
#include <openssl/bio.h>
|
||||
|
||||
#ifndef BIO_FD
|
||||
static int sock_write(BIO *h,char *buf,int num);
|
||||
static int sock_read(BIO *h,char *buf,int size);
|
||||
static int sock_puts(BIO *h,char *str);
|
||||
static long sock_ctrl(BIO *h,int cmd,long arg1,char *arg2);
|
||||
static int sock_write(BIO *h, const char *buf, int num);
|
||||
static int sock_read(BIO *h, char *buf, int size);
|
||||
static int sock_puts(BIO *h, const char *str);
|
||||
static long sock_ctrl(BIO *h, int cmd, long arg1, void *arg2);
|
||||
static int sock_new(BIO *h);
|
||||
static int sock_free(BIO *data);
|
||||
int BIO_sock_should_retry(int s);
|
||||
#else
|
||||
|
||||
static int fd_write(BIO *h,char *buf,int num);
|
||||
static int fd_read(BIO *h,char *buf,int size);
|
||||
static int fd_puts(BIO *h,char *str);
|
||||
static long fd_ctrl(BIO *h,int cmd,long arg1,char *arg2);
|
||||
static int fd_write(BIO *h, const char *buf, int num);
|
||||
static int fd_read(BIO *h, char *buf, int size);
|
||||
static int fd_puts(BIO *h, const char *str);
|
||||
static long fd_ctrl(BIO *h, int cmd, long arg1, void *arg2);
|
||||
static int fd_new(BIO *h);
|
||||
static int fd_free(BIO *data);
|
||||
int BIO_fd_should_retry(int s);
|
||||
@ -209,9 +209,9 @@ static int fd_read(BIO *b, char *out,int outl)
|
||||
}
|
||||
|
||||
#ifndef BIO_FD
|
||||
static int sock_write(BIO *b, char *in, int inl)
|
||||
static int sock_write(BIO *b, const char *in, int inl)
|
||||
#else
|
||||
static int fd_write(BIO *b, char *in, int inl)
|
||||
static int fd_write(BIO *b, const char *in, int inl)
|
||||
#endif
|
||||
{
|
||||
int ret;
|
||||
@ -237,9 +237,9 @@ static int fd_write(BIO *b, char *in, int inl)
|
||||
}
|
||||
|
||||
#ifndef BIO_FD
|
||||
static long sock_ctrl(BIO *b, int cmd, long num, char *ptr)
|
||||
static long sock_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
#else
|
||||
static long fd_ctrl(BIO *b, int cmd, long num, char *ptr)
|
||||
static long fd_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
#endif
|
||||
{
|
||||
long ret=1;
|
||||
@ -313,9 +313,9 @@ static int sock_gets(BIO *bp, char *buf,int size)
|
||||
#endif
|
||||
|
||||
#ifndef BIO_FD
|
||||
static int sock_puts(BIO *bp, char *str)
|
||||
static int sock_puts(BIO *bp, const char *str)
|
||||
#else
|
||||
static int fd_puts(BIO *bp, char *str)
|
||||
static int fd_puts(BIO *bp, const char *str)
|
||||
#endif
|
||||
{
|
||||
int n,ret;
|
||||
|
@ -170,118 +170,143 @@ clean:
|
||||
bn_add.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
|
||||
bn_add.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
|
||||
bn_add.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
|
||||
bn_add.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
|
||||
bn_add.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
|
||||
bn_add.o: ../../include/openssl/stack.h ../cryptlib.h bn_lcl.h
|
||||
bn_add.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
|
||||
bn_add.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
|
||||
bn_add.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
|
||||
bn_add.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_lcl.h
|
||||
bn_asm.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
|
||||
bn_asm.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
|
||||
bn_asm.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
|
||||
bn_asm.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
|
||||
bn_asm.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
|
||||
bn_asm.o: ../../include/openssl/stack.h ../cryptlib.h bn_lcl.h
|
||||
bn_asm.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
|
||||
bn_asm.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
|
||||
bn_asm.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
|
||||
bn_asm.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_lcl.h
|
||||
bn_blind.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
|
||||
bn_blind.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
|
||||
bn_blind.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
|
||||
bn_blind.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
|
||||
bn_blind.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
|
||||
bn_blind.o: ../../include/openssl/opensslconf.h
|
||||
bn_blind.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
|
||||
bn_blind.o: ../../include/openssl/stack.h ../cryptlib.h bn_lcl.h
|
||||
bn_blind.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
|
||||
bn_blind.o: ../cryptlib.h bn_lcl.h
|
||||
bn_ctx.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
|
||||
bn_ctx.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
|
||||
bn_ctx.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
|
||||
bn_ctx.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
|
||||
bn_ctx.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
|
||||
bn_ctx.o: ../../include/openssl/stack.h ../cryptlib.h
|
||||
bn_ctx.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
|
||||
bn_ctx.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
|
||||
bn_ctx.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
|
||||
bn_ctx.o: ../../include/openssl/symhacks.h ../cryptlib.h
|
||||
bn_div.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
|
||||
bn_div.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
|
||||
bn_div.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
|
||||
bn_div.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
|
||||
bn_div.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
|
||||
bn_div.o: ../../include/openssl/stack.h ../cryptlib.h bn_lcl.h
|
||||
bn_err.o: ../../include/openssl/bn.h ../../include/openssl/err.h
|
||||
bn_err.o: ../../include/openssl/opensslconf.h
|
||||
bn_div.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
|
||||
bn_div.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
|
||||
bn_div.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
|
||||
bn_div.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_lcl.h
|
||||
bn_err.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
|
||||
bn_err.o: ../../include/openssl/crypto.h ../../include/openssl/err.h
|
||||
bn_err.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
|
||||
bn_err.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
|
||||
bn_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
|
||||
bn_exp.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
|
||||
bn_exp.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
|
||||
bn_exp.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
|
||||
bn_exp.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
|
||||
bn_exp.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
|
||||
bn_exp.o: ../../include/openssl/stack.h ../cryptlib.h bn_lcl.h
|
||||
bn_exp.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
|
||||
bn_exp.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
|
||||
bn_exp.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
|
||||
bn_exp.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_lcl.h
|
||||
bn_exp2.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
|
||||
bn_exp2.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
|
||||
bn_exp2.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
|
||||
bn_exp2.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
|
||||
bn_exp2.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
|
||||
bn_exp2.o: ../../include/openssl/stack.h ../cryptlib.h bn_lcl.h
|
||||
bn_exp2.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
|
||||
bn_exp2.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
|
||||
bn_exp2.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
|
||||
bn_exp2.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_lcl.h
|
||||
bn_gcd.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
|
||||
bn_gcd.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
|
||||
bn_gcd.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
|
||||
bn_gcd.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
|
||||
bn_gcd.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
|
||||
bn_gcd.o: ../../include/openssl/stack.h ../cryptlib.h bn_lcl.h
|
||||
bn_gcd.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
|
||||
bn_gcd.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
|
||||
bn_gcd.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
|
||||
bn_gcd.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_lcl.h
|
||||
bn_lib.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
|
||||
bn_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
|
||||
bn_lib.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
|
||||
bn_lib.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
|
||||
bn_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
|
||||
bn_lib.o: ../../include/openssl/stack.h ../cryptlib.h bn_lcl.h
|
||||
bn_lib.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
|
||||
bn_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
|
||||
bn_lib.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
|
||||
bn_lib.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_lcl.h
|
||||
bn_mont.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
|
||||
bn_mont.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
|
||||
bn_mont.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
|
||||
bn_mont.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
|
||||
bn_mont.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
|
||||
bn_mont.o: ../../include/openssl/stack.h ../cryptlib.h bn_lcl.h
|
||||
bn_mont.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
|
||||
bn_mont.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
|
||||
bn_mont.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
|
||||
bn_mont.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_lcl.h
|
||||
bn_mpi.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
|
||||
bn_mpi.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
|
||||
bn_mpi.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
|
||||
bn_mpi.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
|
||||
bn_mpi.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
|
||||
bn_mpi.o: ../../include/openssl/stack.h ../cryptlib.h bn_lcl.h
|
||||
bn_mpi.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
|
||||
bn_mpi.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
|
||||
bn_mpi.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
|
||||
bn_mpi.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_lcl.h
|
||||
bn_mul.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
|
||||
bn_mul.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
|
||||
bn_mul.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
|
||||
bn_mul.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
|
||||
bn_mul.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
|
||||
bn_mul.o: ../../include/openssl/stack.h ../cryptlib.h bn_lcl.h
|
||||
bn_mul.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
|
||||
bn_mul.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
|
||||
bn_mul.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
|
||||
bn_mul.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_lcl.h
|
||||
bn_prime.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
|
||||
bn_prime.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
|
||||
bn_prime.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
|
||||
bn_prime.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
|
||||
bn_prime.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
|
||||
bn_prime.o: ../../include/openssl/opensslconf.h
|
||||
bn_prime.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h
|
||||
bn_prime.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
|
||||
bn_prime.o: ../cryptlib.h bn_lcl.h bn_prime.h
|
||||
bn_prime.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_lcl.h bn_prime.h
|
||||
bn_print.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
|
||||
bn_print.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
|
||||
bn_print.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
|
||||
bn_print.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
|
||||
bn_print.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
|
||||
bn_print.o: ../../include/openssl/opensslconf.h
|
||||
bn_print.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
|
||||
bn_print.o: ../../include/openssl/stack.h ../cryptlib.h bn_lcl.h
|
||||
bn_print.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
|
||||
bn_print.o: ../cryptlib.h bn_lcl.h
|
||||
bn_rand.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
|
||||
bn_rand.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
|
||||
bn_rand.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
|
||||
bn_rand.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
|
||||
bn_rand.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h
|
||||
bn_rand.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
|
||||
bn_rand.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
|
||||
bn_rand.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
|
||||
bn_rand.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
|
||||
bn_rand.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
|
||||
bn_rand.o: ../cryptlib.h bn_lcl.h
|
||||
bn_recp.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
|
||||
bn_recp.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
|
||||
bn_recp.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
|
||||
bn_recp.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
|
||||
bn_recp.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
|
||||
bn_recp.o: ../../include/openssl/stack.h ../cryptlib.h bn_lcl.h
|
||||
bn_recp.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
|
||||
bn_recp.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
|
||||
bn_recp.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
|
||||
bn_recp.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_lcl.h
|
||||
bn_shift.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
|
||||
bn_shift.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
|
||||
bn_shift.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
|
||||
bn_shift.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
|
||||
bn_shift.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
|
||||
bn_shift.o: ../../include/openssl/opensslconf.h
|
||||
bn_shift.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
|
||||
bn_shift.o: ../../include/openssl/stack.h ../cryptlib.h bn_lcl.h
|
||||
bn_shift.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
|
||||
bn_shift.o: ../cryptlib.h bn_lcl.h
|
||||
bn_sqr.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
|
||||
bn_sqr.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
|
||||
bn_sqr.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
|
||||
bn_sqr.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
|
||||
bn_sqr.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
|
||||
bn_sqr.o: ../../include/openssl/stack.h ../cryptlib.h bn_lcl.h
|
||||
bn_sqr.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
|
||||
bn_sqr.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
|
||||
bn_sqr.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
|
||||
bn_sqr.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_lcl.h
|
||||
bn_word.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
|
||||
bn_word.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
|
||||
bn_word.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
|
||||
bn_word.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h
|
||||
bn_word.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
|
||||
bn_word.o: ../../include/openssl/stack.h ../cryptlib.h bn_lcl.h
|
||||
bn_word.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
|
||||
bn_word.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
|
||||
bn_word.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
|
||||
bn_word.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_lcl.h
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user