diff options
| author | djm <> | 2010-10-01 22:59:01 +0000 |
|---|---|---|
| committer | djm <> | 2010-10-01 22:59:01 +0000 |
| commit | 8922d4bc4a8b8893d72a48deb2cdf58215f98505 (patch) | |
| tree | 939b752540947d33507b3acc48d76a8bfb7c3dc3 /src/lib/libcrypto/asn1/a_set.c | |
| parent | 76262f7bf9262f965142b1b2b2105cb279c5c696 (diff) | |
| download | openbsd-8922d4bc4a8b8893d72a48deb2cdf58215f98505.tar.gz openbsd-8922d4bc4a8b8893d72a48deb2cdf58215f98505.tar.bz2 openbsd-8922d4bc4a8b8893d72a48deb2cdf58215f98505.zip | |
resolve conflicts, fix local changes
Diffstat (limited to 'src/lib/libcrypto/asn1/a_set.c')
| -rw-r--r-- | src/lib/libcrypto/asn1/a_set.c | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/src/lib/libcrypto/asn1/a_set.c b/src/lib/libcrypto/asn1/a_set.c index 958558c204..d726c8d3a8 100644 --- a/src/lib/libcrypto/asn1/a_set.c +++ b/src/lib/libcrypto/asn1/a_set.c | |||
| @@ -85,8 +85,9 @@ static int SetBlobCmp(const void *elem1, const void *elem2 ) | |||
| 85 | } | 85 | } |
| 86 | 86 | ||
| 87 | /* int is_set: if TRUE, then sort the contents (i.e. it isn't a SEQUENCE) */ | 87 | /* int is_set: if TRUE, then sort the contents (i.e. it isn't a SEQUENCE) */ |
| 88 | int i2d_ASN1_SET(STACK *a, unsigned char **pp, i2d_of_void *i2d, int ex_tag, | 88 | int i2d_ASN1_SET(STACK_OF(OPENSSL_BLOCK) *a, unsigned char **pp, |
| 89 | int ex_class, int is_set) | 89 | i2d_of_void *i2d, int ex_tag, int ex_class, |
| 90 | int is_set) | ||
| 90 | { | 91 | { |
| 91 | int ret=0,r; | 92 | int ret=0,r; |
| 92 | int i; | 93 | int i; |
| @@ -96,8 +97,8 @@ int i2d_ASN1_SET(STACK *a, unsigned char **pp, i2d_of_void *i2d, int ex_tag, | |||
| 96 | int totSize; | 97 | int totSize; |
| 97 | 98 | ||
| 98 | if (a == NULL) return(0); | 99 | if (a == NULL) return(0); |
| 99 | for (i=sk_num(a)-1; i>=0; i--) | 100 | for (i=sk_OPENSSL_BLOCK_num(a)-1; i>=0; i--) |
| 100 | ret+=i2d(sk_value(a,i),NULL); | 101 | ret+=i2d(sk_OPENSSL_BLOCK_value(a,i),NULL); |
| 101 | r=ASN1_object_size(1,ret,ex_tag); | 102 | r=ASN1_object_size(1,ret,ex_tag); |
| 102 | if (pp == NULL) return(r); | 103 | if (pp == NULL) return(r); |
| 103 | 104 | ||
| @@ -108,10 +109,10 @@ int i2d_ASN1_SET(STACK *a, unsigned char **pp, i2d_of_void *i2d, int ex_tag, | |||
| 108 | /* And then again by Ben */ | 109 | /* And then again by Ben */ |
| 109 | /* And again by Steve */ | 110 | /* And again by Steve */ |
| 110 | 111 | ||
| 111 | if(!is_set || (sk_num(a) < 2)) | 112 | if(!is_set || (sk_OPENSSL_BLOCK_num(a) < 2)) |
| 112 | { | 113 | { |
| 113 | for (i=0; i<sk_num(a); i++) | 114 | for (i=0; i<sk_OPENSSL_BLOCK_num(a); i++) |
| 114 | i2d(sk_value(a,i),&p); | 115 | i2d(sk_OPENSSL_BLOCK_value(a,i),&p); |
| 115 | 116 | ||
| 116 | *pp=p; | 117 | *pp=p; |
| 117 | return(r); | 118 | return(r); |
| @@ -119,17 +120,17 @@ int i2d_ASN1_SET(STACK *a, unsigned char **pp, i2d_of_void *i2d, int ex_tag, | |||
| 119 | 120 | ||
| 120 | pStart = p; /* Catch the beg of Setblobs*/ | 121 | pStart = p; /* Catch the beg of Setblobs*/ |
| 121 | /* In this array we will store the SET blobs */ | 122 | /* In this array we will store the SET blobs */ |
| 122 | rgSetBlob = (MYBLOB *)OPENSSL_malloc(sk_num(a) * sizeof(MYBLOB)); | 123 | rgSetBlob = OPENSSL_malloc(sk_OPENSSL_BLOCK_num(a) * sizeof(MYBLOB)); |
| 123 | if (rgSetBlob == NULL) | 124 | if (rgSetBlob == NULL) |
| 124 | { | 125 | { |
| 125 | ASN1err(ASN1_F_I2D_ASN1_SET,ERR_R_MALLOC_FAILURE); | 126 | ASN1err(ASN1_F_I2D_ASN1_SET,ERR_R_MALLOC_FAILURE); |
| 126 | return(0); | 127 | return(0); |
| 127 | } | 128 | } |
| 128 | 129 | ||
| 129 | for (i=0; i<sk_num(a); i++) | 130 | for (i=0; i<sk_OPENSSL_BLOCK_num(a); i++) |
| 130 | { | 131 | { |
| 131 | rgSetBlob[i].pbData = p; /* catch each set encode blob */ | 132 | rgSetBlob[i].pbData = p; /* catch each set encode blob */ |
| 132 | i2d(sk_value(a,i),&p); | 133 | i2d(sk_OPENSSL_BLOCK_value(a,i),&p); |
| 133 | rgSetBlob[i].cbData = p - rgSetBlob[i].pbData; /* Length of this | 134 | rgSetBlob[i].cbData = p - rgSetBlob[i].pbData; /* Length of this |
| 134 | SetBlob | 135 | SetBlob |
| 135 | */ | 136 | */ |
| @@ -139,7 +140,7 @@ SetBlob | |||
| 139 | 140 | ||
| 140 | /* Now we have to sort the blobs. I am using a simple algo. | 141 | /* Now we have to sort the blobs. I am using a simple algo. |
| 141 | *Sort ptrs *Copy to temp-mem *Copy from temp-mem to user-mem*/ | 142 | *Sort ptrs *Copy to temp-mem *Copy from temp-mem to user-mem*/ |
| 142 | qsort( rgSetBlob, sk_num(a), sizeof(MYBLOB), SetBlobCmp); | 143 | qsort( rgSetBlob, sk_OPENSSL_BLOCK_num(a), sizeof(MYBLOB), SetBlobCmp); |
| 143 | if (!(pTempMem = OPENSSL_malloc(totSize))) | 144 | if (!(pTempMem = OPENSSL_malloc(totSize))) |
| 144 | { | 145 | { |
| 145 | ASN1err(ASN1_F_I2D_ASN1_SET,ERR_R_MALLOC_FAILURE); | 146 | ASN1err(ASN1_F_I2D_ASN1_SET,ERR_R_MALLOC_FAILURE); |
| @@ -148,7 +149,7 @@ SetBlob | |||
| 148 | 149 | ||
| 149 | /* Copy to temp mem */ | 150 | /* Copy to temp mem */ |
| 150 | p = pTempMem; | 151 | p = pTempMem; |
| 151 | for(i=0; i<sk_num(a); ++i) | 152 | for(i=0; i<sk_OPENSSL_BLOCK_num(a); ++i) |
| 152 | { | 153 | { |
| 153 | memcpy(p, rgSetBlob[i].pbData, rgSetBlob[i].cbData); | 154 | memcpy(p, rgSetBlob[i].pbData, rgSetBlob[i].cbData); |
| 154 | p += rgSetBlob[i].cbData; | 155 | p += rgSetBlob[i].cbData; |
| @@ -162,16 +163,18 @@ SetBlob | |||
| 162 | return(r); | 163 | return(r); |
| 163 | } | 164 | } |
| 164 | 165 | ||
| 165 | STACK *d2i_ASN1_SET(STACK **a, const unsigned char **pp, long length, | 166 | STACK_OF(OPENSSL_BLOCK) *d2i_ASN1_SET(STACK_OF(OPENSSL_BLOCK) **a, |
| 166 | d2i_of_void *d2i, void (*free_func)(void *), int ex_tag, | 167 | const unsigned char **pp, |
| 167 | int ex_class) | 168 | long length, d2i_of_void *d2i, |
| 169 | void (*free_func)(OPENSSL_BLOCK), int ex_tag, | ||
| 170 | int ex_class) | ||
| 168 | { | 171 | { |
| 169 | ASN1_const_CTX c; | 172 | ASN1_const_CTX c; |
| 170 | STACK *ret=NULL; | 173 | STACK_OF(OPENSSL_BLOCK) *ret=NULL; |
| 171 | 174 | ||
| 172 | if ((a == NULL) || ((*a) == NULL)) | 175 | if ((a == NULL) || ((*a) == NULL)) |
| 173 | { | 176 | { |
| 174 | if ((ret=sk_new_null()) == NULL) | 177 | if ((ret=sk_OPENSSL_BLOCK_new_null()) == NULL) |
| 175 | { | 178 | { |
| 176 | ASN1err(ASN1_F_D2I_ASN1_SET,ERR_R_MALLOC_FAILURE); | 179 | ASN1err(ASN1_F_D2I_ASN1_SET,ERR_R_MALLOC_FAILURE); |
| 177 | goto err; | 180 | goto err; |
| @@ -216,10 +219,10 @@ STACK *d2i_ASN1_SET(STACK **a, const unsigned char **pp, long length, | |||
| 216 | if ((s=d2i(NULL,&c.p,c.slen)) == NULL) | 219 | if ((s=d2i(NULL,&c.p,c.slen)) == NULL) |
| 217 | { | 220 | { |
| 218 | ASN1err(ASN1_F_D2I_ASN1_SET,ASN1_R_ERROR_PARSING_SET_ELEMENT); | 221 | ASN1err(ASN1_F_D2I_ASN1_SET,ASN1_R_ERROR_PARSING_SET_ELEMENT); |
| 219 | asn1_add_error(*pp,(int)(c.q- *pp)); | 222 | asn1_add_error(*pp,(int)(c.p- *pp)); |
| 220 | goto err; | 223 | goto err; |
| 221 | } | 224 | } |
| 222 | if (!sk_push(ret,s)) goto err; | 225 | if (!sk_OPENSSL_BLOCK_push(ret,s)) goto err; |
| 223 | } | 226 | } |
| 224 | if (a != NULL) (*a)=ret; | 227 | if (a != NULL) (*a)=ret; |
| 225 | *pp=c.p; | 228 | *pp=c.p; |
| @@ -228,9 +231,9 @@ err: | |||
| 228 | if ((ret != NULL) && ((a == NULL) || (*a != ret))) | 231 | if ((ret != NULL) && ((a == NULL) || (*a != ret))) |
| 229 | { | 232 | { |
| 230 | if (free_func != NULL) | 233 | if (free_func != NULL) |
| 231 | sk_pop_free(ret,free_func); | 234 | sk_OPENSSL_BLOCK_pop_free(ret,free_func); |
| 232 | else | 235 | else |
| 233 | sk_free(ret); | 236 | sk_OPENSSL_BLOCK_free(ret); |
| 234 | } | 237 | } |
| 235 | return(NULL); | 238 | return(NULL); |
| 236 | } | 239 | } |
