Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(490)

Side by Side Diff: openssl/crypto/asn1/a_set.c

Issue 9254031: Upgrade chrome's OpenSSL to same version Android ships with. (Closed) Base URL: http://src.chromium.org/svn/trunk/deps/third_party/openssl/
Patch Set: '' Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « openssl/crypto/asn1/a_octet.c ('k') | openssl/crypto/asn1/a_sign.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* crypto/asn1/a_set.c */ 1 /* crypto/asn1/a_set.c */
2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
5 * This package is an SSL implementation written 5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com). 6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL. 7 * The implementation was written so as to conform with Netscapes SSL.
8 * 8 *
9 * This library is free for commercial and non-commercial use as long as 9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions 10 * the following conditions are aheared to. The following conditions
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 int r; 78 int r;
79 79
80 r = memcmp(b1->pbData, b2->pbData, 80 r = memcmp(b1->pbData, b2->pbData,
81 b1->cbData < b2->cbData ? b1->cbData : b2->cbData); 81 b1->cbData < b2->cbData ? b1->cbData : b2->cbData);
82 if(r != 0) 82 if(r != 0)
83 return r; 83 return r;
84 return b1->cbData-b2->cbData; 84 return b1->cbData-b2->cbData;
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;
93 unsigned char *p; 94 unsigned char *p;
94 unsigned char *pStart, *pTempMem; 95 unsigned char *pStart, *pTempMem;
95 MYBLOB *rgSetBlob; 96 MYBLOB *rgSetBlob;
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
104 p= *pp; 105 p= *pp;
105 ASN1_put_object(&p,1,ret,ex_tag,ex_class); 106 ASN1_put_object(&p,1,ret,ex_tag,ex_class);
106 107
107 /* Modified by gp@nsj.co.jp */ 108 /* Modified by gp@nsj.co.jp */
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);
118 } 119 }
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(MYBL OB));
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 */
136 } 137 }
137 *pp=p; 138 *pp=p;
138 totSize = p - pStart; /* This is the total size of all set blobs */ 139 totSize = p - pStart; /* This is the total size of all set blobs */
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);
146 return(0); 147 return(0);
147 } 148 }
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;
155 } 156 }
156 157
157 /* Copy back to user mem*/ 158 /* Copy back to user mem*/
158 memcpy(pStart, pTempMem, totSize); 159 memcpy(pStart, pTempMem, totSize);
159 OPENSSL_free(pTempMem); 160 OPENSSL_free(pTempMem);
160 OPENSSL_free(rgSetBlob); 161 OPENSSL_free(rgSetBlob);
161 162
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;
178 } 181 }
179 } 182 }
180 else 183 else
181 ret=(*a); 184 ret=(*a);
182 185
183 c.p= *pp; 186 c.p= *pp;
184 c.max=(length == 0)?0:(c.p+length); 187 c.max=(length == 0)?0:(c.p+length);
(...skipping 24 matching lines...) Expand all
209 while (c.p < c.max) 212 while (c.p < c.max)
210 { 213 {
211 char *s; 214 char *s;
212 215
213 if (M_ASN1_D2I_end_sequence()) break; 216 if (M_ASN1_D2I_end_sequence()) break;
214 /* XXX: This was called with 4 arguments, incorrectly, it seems 217 /* XXX: This was called with 4 arguments, incorrectly, it seems
215 if ((s=func(NULL,&c.p,c.slen,c.max-c.p)) == NULL) */ 218 if ((s=func(NULL,&c.p,c.slen,c.max-c.p)) == NULL) */
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_ELE MENT); 221 ASN1err(ASN1_F_D2I_ASN1_SET,ASN1_R_ERROR_PARSING_SET_ELE MENT);
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;
226 return(ret); 229 return(ret);
227 err: 230 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 }
237 240
238 #endif 241 #endif
OLDNEW
« no previous file with comments | « openssl/crypto/asn1/a_octet.c ('k') | openssl/crypto/asn1/a_sign.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698