X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=crypto%2Fasn1%2Fa_set.c;h=caf5a1419c98cbe201acbacfc8e24b99ecd58eab;hb=9ef9e78520eba0fb3d92b581dc4f895a5f464387;hp=17c49946cf404df05d950b05807f1abf5606d15e;hpb=7dfb0b774e6592dcbfe47015168a0ac8b44e2a17;p=oweals%2Fopenssl.git diff --git a/crypto/asn1/a_set.c b/crypto/asn1/a_set.c index 17c49946cf..caf5a1419c 100644 --- a/crypto/asn1/a_set.c +++ b/crypto/asn1/a_set.c @@ -58,21 +58,40 @@ #include #include "cryptlib.h" -#include "asn1_mac.h" +#include -/* ASN1err(ASN1_F_ASN1_TYPE_NEW,ERR_R_MALLOC_FAILURE); +typedef struct + { + unsigned char *pbData; + int cbData; + } MYBLOB; + +/* SetBlobCmp + * This function compares two elements of SET_OF block */ +static int SetBlobCmp(const void *elem1, const void *elem2 ) + { + const MYBLOB *b1 = (const MYBLOB *)elem1; + const MYBLOB *b2 = (const MYBLOB *)elem2; + int r; + + r = memcmp(b1->pbData, b2->pbData, + b1->cbData < b2->cbData ? b1->cbData : b2->cbData); + if(r != 0) + return r; + return b1->cbData-b2->cbData; + } -int i2d_ASN1_SET(a,pp,func,ex_tag,ex_class) -STACK *a; -unsigned char **pp; -int (*func)(); -int ex_tag; -int ex_class; +/* int is_set: if TRUE, then sort the contents (i.e. it isn't a SEQUENCE) */ +int i2d_ASN1_SET(STACK *a, unsigned char **pp, int (*func)(), int ex_tag, + int ex_class, int is_set) { int ret=0,r; int i; unsigned char *p; + unsigned char *pStart, *pTempMem; + MYBLOB *rgSetBlob; + int totSize; if (a == NULL) return(0); for (i=sk_num(a)-1; i>=0; i--) @@ -82,26 +101,64 @@ int ex_class; p= *pp; ASN1_put_object(&p,1,ret,ex_tag,ex_class); - for (i=0; i