diff options
Diffstat (limited to 'src/lib/libcrypto/asn1/tasn_enc.c')
-rw-r--r-- | src/lib/libcrypto/asn1/tasn_enc.c | 168 |
1 files changed, 65 insertions, 103 deletions
diff --git a/src/lib/libcrypto/asn1/tasn_enc.c b/src/lib/libcrypto/asn1/tasn_enc.c index 230164107d..f7bdd11edf 100644 --- a/src/lib/libcrypto/asn1/tasn_enc.c +++ b/src/lib/libcrypto/asn1/tasn_enc.c | |||
@@ -103,8 +103,7 @@ int ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it) | |||
103 | static int asn1_item_flags_i2d(ASN1_VALUE *val, unsigned char **out, | 103 | static int asn1_item_flags_i2d(ASN1_VALUE *val, unsigned char **out, |
104 | const ASN1_ITEM *it, int flags) | 104 | const ASN1_ITEM *it, int flags) |
105 | { | 105 | { |
106 | if (out && !*out) | 106 | if (out && !*out) { |
107 | { | ||
108 | unsigned char *p, *buf; | 107 | unsigned char *p, *buf; |
109 | int len; | 108 | int len; |
110 | len = ASN1_item_ex_i2d(&val, NULL, it, -1, flags); | 109 | len = ASN1_item_ex_i2d(&val, NULL, it, -1, flags); |
@@ -144,25 +143,23 @@ int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out, | |||
144 | if (aux && aux->asn1_cb) | 143 | if (aux && aux->asn1_cb) |
145 | asn1_cb = aux->asn1_cb; | 144 | asn1_cb = aux->asn1_cb; |
146 | 145 | ||
147 | switch(it->itype) | 146 | switch(it->itype) { |
148 | { | ||
149 | 147 | ||
150 | case ASN1_ITYPE_PRIMITIVE: | 148 | case ASN1_ITYPE_PRIMITIVE: |
151 | if (it->templates) | 149 | if (it->templates) |
152 | return asn1_template_ex_i2d(pval, out, it->templates, | 150 | return asn1_template_ex_i2d(pval, out, it->templates, |
153 | tag, aclass); | 151 | tag, aclass); |
154 | return asn1_i2d_ex_primitive(pval, out, it, tag, aclass); | 152 | return asn1_i2d_ex_primitive(pval, out, it, tag, aclass); |
155 | break; | 153 | break; |
156 | 154 | ||
157 | case ASN1_ITYPE_MSTRING: | 155 | case ASN1_ITYPE_MSTRING: |
158 | return asn1_i2d_ex_primitive(pval, out, it, -1, aclass); | 156 | return asn1_i2d_ex_primitive(pval, out, it, -1, aclass); |
159 | 157 | ||
160 | case ASN1_ITYPE_CHOICE: | 158 | case ASN1_ITYPE_CHOICE: |
161 | if (asn1_cb && !asn1_cb(ASN1_OP_I2D_PRE, pval, it, NULL)) | 159 | if (asn1_cb && !asn1_cb(ASN1_OP_I2D_PRE, pval, it, NULL)) |
162 | return 0; | 160 | return 0; |
163 | i = asn1_get_choice_selector(pval, it); | 161 | i = asn1_get_choice_selector(pval, it); |
164 | if ((i >= 0) && (i < it->tcount)) | 162 | if ((i >= 0) && (i < it->tcount)) { |
165 | { | ||
166 | ASN1_VALUE **pchval; | 163 | ASN1_VALUE **pchval; |
167 | const ASN1_TEMPLATE *chtt; | 164 | const ASN1_TEMPLATE *chtt; |
168 | chtt = it->templates + i; | 165 | chtt = it->templates + i; |
@@ -175,12 +172,12 @@ int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out, | |||
175 | return 0; | 172 | return 0; |
176 | break; | 173 | break; |
177 | 174 | ||
178 | case ASN1_ITYPE_EXTERN: | 175 | case ASN1_ITYPE_EXTERN: |
179 | /* If new style i2d it does all the work */ | 176 | /* If new style i2d it does all the work */ |
180 | ef = it->funcs; | 177 | ef = it->funcs; |
181 | return ef->asn1_ex_i2d(pval, out, it, tag, aclass); | 178 | return ef->asn1_ex_i2d(pval, out, it, tag, aclass); |
182 | 179 | ||
183 | case ASN1_ITYPE_COMPAT: | 180 | case ASN1_ITYPE_COMPAT: |
184 | /* old style hackery... */ | 181 | /* old style hackery... */ |
185 | cf = it->funcs; | 182 | cf = it->funcs; |
186 | if (out) | 183 | if (out) |
@@ -193,12 +190,12 @@ int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out, | |||
193 | *p = aclass | tag | (*p & V_ASN1_CONSTRUCTED); | 190 | *p = aclass | tag | (*p & V_ASN1_CONSTRUCTED); |
194 | return i; | 191 | return i; |
195 | 192 | ||
196 | case ASN1_ITYPE_NDEF_SEQUENCE: | 193 | case ASN1_ITYPE_NDEF_SEQUENCE: |
197 | /* Use indefinite length constructed if requested */ | 194 | /* Use indefinite length constructed if requested */ |
198 | if (aclass & ASN1_TFLG_NDEF) ndef = 2; | 195 | if (aclass & ASN1_TFLG_NDEF) ndef = 2; |
199 | /* fall through */ | 196 | /* fall through */ |
200 | 197 | ||
201 | case ASN1_ITYPE_SEQUENCE: | 198 | case ASN1_ITYPE_SEQUENCE: |
202 | i = asn1_enc_restore(&seqcontlen, out, pval, it); | 199 | i = asn1_enc_restore(&seqcontlen, out, pval, it); |
203 | /* An error occurred */ | 200 | /* An error occurred */ |
204 | if (i < 0) | 201 | if (i < 0) |
@@ -209,8 +206,7 @@ int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out, | |||
209 | /* Otherwise carry on */ | 206 | /* Otherwise carry on */ |
210 | seqcontlen = 0; | 207 | seqcontlen = 0; |
211 | /* If no IMPLICIT tagging set to SEQUENCE, UNIVERSAL */ | 208 | /* If no IMPLICIT tagging set to SEQUENCE, UNIVERSAL */ |
212 | if (tag == -1) | 209 | if (tag == -1) { |
213 | { | ||
214 | tag = V_ASN1_SEQUENCE; | 210 | tag = V_ASN1_SEQUENCE; |
215 | /* Retain any other flags in aclass */ | 211 | /* Retain any other flags in aclass */ |
216 | aclass = (aclass & ~ASN1_TFLG_TAG_CLASS) | 212 | aclass = (aclass & ~ASN1_TFLG_TAG_CLASS) |
@@ -219,8 +215,7 @@ int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out, | |||
219 | if (asn1_cb && !asn1_cb(ASN1_OP_I2D_PRE, pval, it, NULL)) | 215 | if (asn1_cb && !asn1_cb(ASN1_OP_I2D_PRE, pval, it, NULL)) |
220 | return 0; | 216 | return 0; |
221 | /* First work out sequence content length */ | 217 | /* First work out sequence content length */ |
222 | for (i = 0, tt = it->templates; i < it->tcount; tt++, i++) | 218 | for (i = 0, tt = it->templates; i < it->tcount; tt++, i++) { |
223 | { | ||
224 | const ASN1_TEMPLATE *seqtt; | 219 | const ASN1_TEMPLATE *seqtt; |
225 | ASN1_VALUE **pseqval; | 220 | ASN1_VALUE **pseqval; |
226 | seqtt = asn1_do_adb(pval, tt, 1); | 221 | seqtt = asn1_do_adb(pval, tt, 1); |
@@ -237,8 +232,7 @@ int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out, | |||
237 | return seqlen; | 232 | return seqlen; |
238 | /* Output SEQUENCE header */ | 233 | /* Output SEQUENCE header */ |
239 | ASN1_put_object(out, ndef, seqcontlen, tag, aclass); | 234 | ASN1_put_object(out, ndef, seqcontlen, tag, aclass); |
240 | for (i = 0, tt = it->templates; i < it->tcount; tt++, i++) | 235 | for (i = 0, tt = it->templates; i < it->tcount; tt++, i++) { |
241 | { | ||
242 | const ASN1_TEMPLATE *seqtt; | 236 | const ASN1_TEMPLATE *seqtt; |
243 | ASN1_VALUE **pseqval; | 237 | ASN1_VALUE **pseqval; |
244 | seqtt = asn1_do_adb(pval, tt, 1); | 238 | seqtt = asn1_do_adb(pval, tt, 1); |
@@ -278,8 +272,7 @@ static int asn1_template_ex_i2d(ASN1_VALUE **pval, unsigned char **out, | |||
278 | * the iclass argument may contain some additional flags | 272 | * the iclass argument may contain some additional flags |
279 | * which should be noted and passed down to other levels. | 273 | * which should be noted and passed down to other levels. |
280 | */ | 274 | */ |
281 | if (flags & ASN1_TFLG_TAG_MASK) | 275 | if (flags & ASN1_TFLG_TAG_MASK) { |
282 | { | ||
283 | /* Error if argument and template tagging */ | 276 | /* Error if argument and template tagging */ |
284 | if (tag != -1) | 277 | if (tag != -1) |
285 | /* FIXME: error code here */ | 278 | /* FIXME: error code here */ |
@@ -287,15 +280,11 @@ static int asn1_template_ex_i2d(ASN1_VALUE **pval, unsigned char **out, | |||
287 | /* Get tagging from template */ | 280 | /* Get tagging from template */ |
288 | ttag = tt->tag; | 281 | ttag = tt->tag; |
289 | tclass = flags & ASN1_TFLG_TAG_CLASS; | 282 | tclass = flags & ASN1_TFLG_TAG_CLASS; |
290 | } | 283 | } else if (tag != -1) { |
291 | else if (tag != -1) | ||
292 | { | ||
293 | /* No template tagging, get from arguments */ | 284 | /* No template tagging, get from arguments */ |
294 | ttag = tag; | 285 | ttag = tag; |
295 | tclass = iclass & ASN1_TFLG_TAG_CLASS; | 286 | tclass = iclass & ASN1_TFLG_TAG_CLASS; |
296 | } | 287 | } else { |
297 | else | ||
298 | { | ||
299 | ttag = -1; | 288 | ttag = -1; |
300 | tclass = 0; | 289 | tclass = 0; |
301 | } | 290 | } |
@@ -314,8 +303,7 @@ static int asn1_template_ex_i2d(ASN1_VALUE **pval, unsigned char **out, | |||
314 | ndef = 2; | 303 | ndef = 2; |
315 | else ndef = 1; | 304 | else ndef = 1; |
316 | 305 | ||
317 | if (flags & ASN1_TFLG_SK_MASK) | 306 | if (flags & ASN1_TFLG_SK_MASK) { |
318 | { | ||
319 | /* SET OF, SEQUENCE OF */ | 307 | /* SET OF, SEQUENCE OF */ |
320 | STACK_OF(ASN1_VALUE) *sk = (STACK_OF(ASN1_VALUE) *)*pval; | 308 | STACK_OF(ASN1_VALUE) *sk = (STACK_OF(ASN1_VALUE) *)*pval; |
321 | int isset, sktag, skaclass; | 309 | int isset, sktag, skaclass; |
@@ -325,8 +313,7 @@ static int asn1_template_ex_i2d(ASN1_VALUE **pval, unsigned char **out, | |||
325 | if (!*pval) | 313 | if (!*pval) |
326 | return 0; | 314 | return 0; |
327 | 315 | ||
328 | if (flags & ASN1_TFLG_SET_OF) | 316 | if (flags & ASN1_TFLG_SET_OF) { |
329 | { | ||
330 | isset = 1; | 317 | isset = 1; |
331 | /* 2 means we reorder */ | 318 | /* 2 means we reorder */ |
332 | if (flags & ASN1_TFLG_SEQUENCE_OF) | 319 | if (flags & ASN1_TFLG_SEQUENCE_OF) |
@@ -337,13 +324,10 @@ static int asn1_template_ex_i2d(ASN1_VALUE **pval, unsigned char **out, | |||
337 | /* Work out inner tag value: if EXPLICIT | 324 | /* Work out inner tag value: if EXPLICIT |
338 | * or no tagging use underlying type. | 325 | * or no tagging use underlying type. |
339 | */ | 326 | */ |
340 | if ((ttag != -1) && !(flags & ASN1_TFLG_EXPTAG)) | 327 | if ((ttag != -1) && !(flags & ASN1_TFLG_EXPTAG)) { |
341 | { | ||
342 | sktag = ttag; | 328 | sktag = ttag; |
343 | skaclass = tclass; | 329 | skaclass = tclass; |
344 | } | 330 | } else { |
345 | else | ||
346 | { | ||
347 | skaclass = V_ASN1_UNIVERSAL; | 331 | skaclass = V_ASN1_UNIVERSAL; |
348 | if (isset) | 332 | if (isset) |
349 | sktag = V_ASN1_SET; | 333 | sktag = V_ASN1_SET; |
@@ -352,8 +336,7 @@ static int asn1_template_ex_i2d(ASN1_VALUE **pval, unsigned char **out, | |||
352 | 336 | ||
353 | /* Determine total length of items */ | 337 | /* Determine total length of items */ |
354 | skcontlen = 0; | 338 | skcontlen = 0; |
355 | for (i = 0; i < sk_ASN1_VALUE_num(sk); i++) | 339 | for (i = 0; i < sk_ASN1_VALUE_num(sk); i++) { |
356 | { | ||
357 | skitem = sk_ASN1_VALUE_value(sk, i); | 340 | skitem = sk_ASN1_VALUE_value(sk, i); |
358 | skcontlen += ASN1_item_ex_i2d(&skitem, NULL, | 341 | skcontlen += ASN1_item_ex_i2d(&skitem, NULL, |
359 | ASN1_ITEM_ptr(tt->item), | 342 | ASN1_ITEM_ptr(tt->item), |
@@ -377,8 +360,7 @@ static int asn1_template_ex_i2d(ASN1_VALUE **pval, unsigned char **out, | |||
377 | /* And the stuff itself */ | 360 | /* And the stuff itself */ |
378 | asn1_set_seq_out(sk, out, skcontlen, ASN1_ITEM_ptr(tt->item), | 361 | asn1_set_seq_out(sk, out, skcontlen, ASN1_ITEM_ptr(tt->item), |
379 | isset, iclass); | 362 | isset, iclass); |
380 | if (ndef == 2) | 363 | if (ndef == 2) { |
381 | { | ||
382 | ASN1_put_eoc(out); | 364 | ASN1_put_eoc(out); |
383 | if (flags & ASN1_TFLG_EXPTAG) | 365 | if (flags & ASN1_TFLG_EXPTAG) |
384 | ASN1_put_eoc(out); | 366 | ASN1_put_eoc(out); |
@@ -387,8 +369,7 @@ static int asn1_template_ex_i2d(ASN1_VALUE **pval, unsigned char **out, | |||
387 | return ret; | 369 | return ret; |
388 | } | 370 | } |
389 | 371 | ||
390 | if (flags & ASN1_TFLG_EXPTAG) | 372 | if (flags & ASN1_TFLG_EXPTAG) { |
391 | { | ||
392 | /* EXPLICIT tagging */ | 373 | /* EXPLICIT tagging */ |
393 | /* Find length of tagged item */ | 374 | /* Find length of tagged item */ |
394 | i = ASN1_item_ex_i2d(pval, NULL, ASN1_ITEM_ptr(tt->item), | 375 | i = ASN1_item_ex_i2d(pval, NULL, ASN1_ITEM_ptr(tt->item), |
@@ -397,8 +378,7 @@ static int asn1_template_ex_i2d(ASN1_VALUE **pval, unsigned char **out, | |||
397 | return 0; | 378 | return 0; |
398 | /* Find length of EXPLICIT tag */ | 379 | /* Find length of EXPLICIT tag */ |
399 | ret = ASN1_object_size(ndef, i, ttag); | 380 | ret = ASN1_object_size(ndef, i, ttag); |
400 | if (out) | 381 | if (out) { |
401 | { | ||
402 | /* Output tag and item */ | 382 | /* Output tag and item */ |
403 | ASN1_put_object(out, ndef, i, ttag, tclass); | 383 | ASN1_put_object(out, ndef, i, ttag, tclass); |
404 | ASN1_item_ex_i2d(pval, out, ASN1_ITEM_ptr(tt->item), | 384 | ASN1_item_ex_i2d(pval, out, ASN1_ITEM_ptr(tt->item), |
@@ -449,8 +429,7 @@ static int asn1_set_seq_out(STACK_OF(ASN1_VALUE) *sk, unsigned char **out, | |||
449 | /* Don't need to sort less than 2 items */ | 429 | /* Don't need to sort less than 2 items */ |
450 | if (sk_ASN1_VALUE_num(sk) < 2) | 430 | if (sk_ASN1_VALUE_num(sk) < 2) |
451 | do_sort = 0; | 431 | do_sort = 0; |
452 | else | 432 | else { |
453 | { | ||
454 | derlst = malloc(sk_ASN1_VALUE_num(sk) | 433 | derlst = malloc(sk_ASN1_VALUE_num(sk) |
455 | * sizeof(*derlst)); | 434 | * sizeof(*derlst)); |
456 | tmpdat = malloc(skcontlen); | 435 | tmpdat = malloc(skcontlen); |
@@ -461,10 +440,8 @@ static int asn1_set_seq_out(STACK_OF(ASN1_VALUE) *sk, unsigned char **out, | |||
461 | } | 440 | } |
462 | } | 441 | } |
463 | /* If not sorting just output each item */ | 442 | /* If not sorting just output each item */ |
464 | if (!do_sort) | 443 | if (!do_sort) { |
465 | { | 444 | for (i = 0; i < sk_ASN1_VALUE_num(sk); i++) { |
466 | for (i = 0; i < sk_ASN1_VALUE_num(sk); i++) | ||
467 | { | ||
468 | skitem = sk_ASN1_VALUE_value(sk, i); | 445 | skitem = sk_ASN1_VALUE_value(sk, i); |
469 | ASN1_item_ex_i2d(&skitem, out, item, -1, iclass); | 446 | ASN1_item_ex_i2d(&skitem, out, item, -1, iclass); |
470 | } | 447 | } |
@@ -473,8 +450,7 @@ static int asn1_set_seq_out(STACK_OF(ASN1_VALUE) *sk, unsigned char **out, | |||
473 | p = tmpdat; | 450 | p = tmpdat; |
474 | 451 | ||
475 | /* Doing sort: build up a list of each member's DER encoding */ | 452 | /* Doing sort: build up a list of each member's DER encoding */ |
476 | for (i = 0, tder = derlst; i < sk_ASN1_VALUE_num(sk); i++, tder++) | 453 | for (i = 0, tder = derlst; i < sk_ASN1_VALUE_num(sk); i++, tder++) { |
477 | { | ||
478 | skitem = sk_ASN1_VALUE_value(sk, i); | 454 | skitem = sk_ASN1_VALUE_value(sk, i); |
479 | tder->data = p; | 455 | tder->data = p; |
480 | tder->length = ASN1_item_ex_i2d(&skitem, &p, item, -1, iclass); | 456 | tder->length = ASN1_item_ex_i2d(&skitem, &p, item, -1, iclass); |
@@ -485,17 +461,14 @@ static int asn1_set_seq_out(STACK_OF(ASN1_VALUE) *sk, unsigned char **out, | |||
485 | qsort(derlst, sk_ASN1_VALUE_num(sk), sizeof(*derlst), der_cmp); | 461 | qsort(derlst, sk_ASN1_VALUE_num(sk), sizeof(*derlst), der_cmp); |
486 | /* Output sorted DER encoding */ | 462 | /* Output sorted DER encoding */ |
487 | p = *out; | 463 | p = *out; |
488 | for (i = 0, tder = derlst; i < sk_ASN1_VALUE_num(sk); i++, tder++) | 464 | for (i = 0, tder = derlst; i < sk_ASN1_VALUE_num(sk); i++, tder++) { |
489 | { | ||
490 | memcpy(p, tder->data, tder->length); | 465 | memcpy(p, tder->data, tder->length); |
491 | p += tder->length; | 466 | p += tder->length; |
492 | } | 467 | } |
493 | *out = p; | 468 | *out = p; |
494 | /* If do_sort is 2 then reorder the STACK */ | 469 | /* If do_sort is 2 then reorder the STACK */ |
495 | if (do_sort == 2) | 470 | if (do_sort == 2) { |
496 | { | 471 | for (i = 0, tder = derlst; i < sk_ASN1_VALUE_num(sk); i++, tder++) |
497 | for (i = 0, tder = derlst; i < sk_ASN1_VALUE_num(sk); | ||
498 | i++, tder++) | ||
499 | (void)sk_ASN1_VALUE_set(sk, i, tder->field); | 472 | (void)sk_ASN1_VALUE_set(sk, i, tder->field); |
500 | } | 473 | } |
501 | free(derlst); | 474 | free(derlst); |
@@ -536,8 +509,7 @@ static int asn1_i2d_ex_primitive(ASN1_VALUE **pval, unsigned char **out, | |||
536 | return 0; | 509 | return 0; |
537 | 510 | ||
538 | /* -2 return is special meaning use ndef */ | 511 | /* -2 return is special meaning use ndef */ |
539 | if (len == -2) | 512 | if (len == -2) { |
540 | { | ||
541 | ndef = 2; | 513 | ndef = 2; |
542 | len = 0; | 514 | len = 0; |
543 | } | 515 | } |
@@ -546,8 +518,7 @@ static int asn1_i2d_ex_primitive(ASN1_VALUE **pval, unsigned char **out, | |||
546 | if (tag == -1) tag = utype; | 518 | if (tag == -1) tag = utype; |
547 | 519 | ||
548 | /* Output tag+length followed by content octets */ | 520 | /* Output tag+length followed by content octets */ |
549 | if (out) | 521 | if (out) { |
550 | { | ||
551 | if (usetag) | 522 | if (usetag) |
552 | ASN1_put_object(out, ndef, len, tag, aclass); | 523 | ASN1_put_object(out, ndef, len, tag, aclass); |
553 | asn1_ex_i2c(pval, *out, &utype, it); | 524 | asn1_ex_i2c(pval, *out, &utype, it); |
@@ -580,21 +551,16 @@ int asn1_ex_i2c(ASN1_VALUE **pval, unsigned char *cout, int *putype, | |||
580 | return pf->prim_i2c(pval, cout, putype, it); | 551 | return pf->prim_i2c(pval, cout, putype, it); |
581 | 552 | ||
582 | /* Should type be omitted? */ | 553 | /* Should type be omitted? */ |
583 | if ((it->itype != ASN1_ITYPE_PRIMITIVE) | 554 | if ((it->itype != ASN1_ITYPE_PRIMITIVE) || (it->utype != V_ASN1_BOOLEAN)) { |
584 | || (it->utype != V_ASN1_BOOLEAN)) | ||
585 | { | ||
586 | if (!*pval) return -1; | 555 | if (!*pval) return -1; |
587 | } | 556 | } |
588 | 557 | ||
589 | if (it->itype == ASN1_ITYPE_MSTRING) | 558 | if (it->itype == ASN1_ITYPE_MSTRING) { |
590 | { | ||
591 | /* If MSTRING type set the underlying type */ | 559 | /* If MSTRING type set the underlying type */ |
592 | strtmp = (ASN1_STRING *)*pval; | 560 | strtmp = (ASN1_STRING *)*pval; |
593 | utype = strtmp->type; | 561 | utype = strtmp->type; |
594 | *putype = utype; | 562 | *putype = utype; |
595 | } | 563 | } else if (it->utype == V_ASN1_ANY) { |
596 | else if (it->utype == V_ASN1_ANY) | ||
597 | { | ||
598 | /* If ANY set type and pointer to value */ | 564 | /* If ANY set type and pointer to value */ |
599 | ASN1_TYPE *typ; | 565 | ASN1_TYPE *typ; |
600 | typ = (ASN1_TYPE *)*pval; | 566 | typ = (ASN1_TYPE *)*pval; |
@@ -604,25 +570,23 @@ int asn1_ex_i2c(ASN1_VALUE **pval, unsigned char *cout, int *putype, | |||
604 | } | 570 | } |
605 | else utype = *putype; | 571 | else utype = *putype; |
606 | 572 | ||
607 | switch(utype) | 573 | switch(utype) { |
608 | { | 574 | case V_ASN1_OBJECT: |
609 | case V_ASN1_OBJECT: | ||
610 | otmp = (ASN1_OBJECT *)*pval; | 575 | otmp = (ASN1_OBJECT *)*pval; |
611 | cont = otmp->data; | 576 | cont = otmp->data; |
612 | len = otmp->length; | 577 | len = otmp->length; |
613 | break; | 578 | break; |
614 | 579 | ||
615 | case V_ASN1_NULL: | 580 | case V_ASN1_NULL: |
616 | cont = NULL; | 581 | cont = NULL; |
617 | len = 0; | 582 | len = 0; |
618 | break; | 583 | break; |
619 | 584 | ||
620 | case V_ASN1_BOOLEAN: | 585 | case V_ASN1_BOOLEAN: |
621 | tbool = (ASN1_BOOLEAN *)pval; | 586 | tbool = (ASN1_BOOLEAN *)pval; |
622 | if (*tbool == -1) | 587 | if (*tbool == -1) |
623 | return -1; | 588 | return -1; |
624 | if (it->utype != V_ASN1_ANY) | 589 | if (it->utype != V_ASN1_ANY) { |
625 | { | ||
626 | /* Default handling if value == size field then omit */ | 590 | /* Default handling if value == size field then omit */ |
627 | if (*tbool && (it->size > 0)) | 591 | if (*tbool && (it->size > 0)) |
628 | return -1; | 592 | return -1; |
@@ -634,15 +598,15 @@ int asn1_ex_i2c(ASN1_VALUE **pval, unsigned char *cout, int *putype, | |||
634 | len = 1; | 598 | len = 1; |
635 | break; | 599 | break; |
636 | 600 | ||
637 | case V_ASN1_BIT_STRING: | 601 | case V_ASN1_BIT_STRING: |
638 | return i2c_ASN1_BIT_STRING((ASN1_BIT_STRING *)*pval, | 602 | return i2c_ASN1_BIT_STRING((ASN1_BIT_STRING *)*pval, |
639 | cout ? &cout : NULL); | 603 | cout ? &cout : NULL); |
640 | break; | 604 | break; |
641 | 605 | ||
642 | case V_ASN1_INTEGER: | 606 | case V_ASN1_INTEGER: |
643 | case V_ASN1_NEG_INTEGER: | 607 | case V_ASN1_NEG_INTEGER: |
644 | case V_ASN1_ENUMERATED: | 608 | case V_ASN1_ENUMERATED: |
645 | case V_ASN1_NEG_ENUMERATED: | 609 | case V_ASN1_NEG_ENUMERATED: |
646 | /* These are all have the same content format | 610 | /* These are all have the same content format |
647 | * as ASN1_INTEGER | 611 | * as ASN1_INTEGER |
648 | */ | 612 | */ |
@@ -650,31 +614,29 @@ int asn1_ex_i2c(ASN1_VALUE **pval, unsigned char *cout, int *putype, | |||
650 | cout ? &cout : NULL); | 614 | cout ? &cout : NULL); |
651 | break; | 615 | break; |
652 | 616 | ||
653 | case V_ASN1_OCTET_STRING: | 617 | case V_ASN1_OCTET_STRING: |
654 | case V_ASN1_NUMERICSTRING: | 618 | case V_ASN1_NUMERICSTRING: |
655 | case V_ASN1_PRINTABLESTRING: | 619 | case V_ASN1_PRINTABLESTRING: |
656 | case V_ASN1_T61STRING: | 620 | case V_ASN1_T61STRING: |
657 | case V_ASN1_VIDEOTEXSTRING: | 621 | case V_ASN1_VIDEOTEXSTRING: |
658 | case V_ASN1_IA5STRING: | 622 | case V_ASN1_IA5STRING: |
659 | case V_ASN1_UTCTIME: | 623 | case V_ASN1_UTCTIME: |
660 | case V_ASN1_GENERALIZEDTIME: | 624 | case V_ASN1_GENERALIZEDTIME: |
661 | case V_ASN1_GRAPHICSTRING: | 625 | case V_ASN1_GRAPHICSTRING: |
662 | case V_ASN1_VISIBLESTRING: | 626 | case V_ASN1_VISIBLESTRING: |
663 | case V_ASN1_GENERALSTRING: | 627 | case V_ASN1_GENERALSTRING: |
664 | case V_ASN1_UNIVERSALSTRING: | 628 | case V_ASN1_UNIVERSALSTRING: |
665 | case V_ASN1_BMPSTRING: | 629 | case V_ASN1_BMPSTRING: |
666 | case V_ASN1_UTF8STRING: | 630 | case V_ASN1_UTF8STRING: |
667 | case V_ASN1_SEQUENCE: | 631 | case V_ASN1_SEQUENCE: |
668 | case V_ASN1_SET: | 632 | case V_ASN1_SET: |
669 | default: | 633 | default: |
670 | /* All based on ASN1_STRING and handled the same */ | 634 | /* All based on ASN1_STRING and handled the same */ |
671 | strtmp = (ASN1_STRING *)*pval; | 635 | strtmp = (ASN1_STRING *)*pval; |
672 | /* Special handling for NDEF */ | 636 | /* Special handling for NDEF */ |
673 | if ((it->size == ASN1_TFLG_NDEF) | 637 | if ((it->size == ASN1_TFLG_NDEF) |
674 | && (strtmp->flags & ASN1_STRING_FLAG_NDEF)) | 638 | && (strtmp->flags & ASN1_STRING_FLAG_NDEF)) { |
675 | { | 639 | if (cout) { |
676 | if (cout) | ||
677 | { | ||
678 | strtmp->data = cout; | 640 | strtmp->data = cout; |
679 | strtmp->length = 0; | 641 | strtmp->length = 0; |
680 | } | 642 | } |