| OLD | NEW |
| 1 /* tasn_enc.c */ | 1 /* tasn_enc.c */ |
| 2 /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 2 /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
| 3 * project 2000. | 3 * project 2000. |
| 4 */ | 4 */ |
| 5 /* ==================================================================== | 5 /* ==================================================================== |
| 6 * Copyright (c) 2000-2004 The OpenSSL Project. All rights reserved. | 6 * Copyright (c) 2000-2004 The OpenSSL Project. All rights reserved. |
| 7 * | 7 * |
| 8 * Redistribution and use in source and binary forms, with or without | 8 * Redistribution and use in source and binary forms, with or without |
| 9 * modification, are permitted provided that the following conditions | 9 * modification, are permitted provided that the following conditions |
| 10 * are met: | 10 * are met: |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 if (it->templates) | 151 if (it->templates) |
| 152 return asn1_template_ex_i2d(pval, out, it->templates, | 152 return asn1_template_ex_i2d(pval, out, it->templates, |
| 153 tag, aclass); | 153 tag, aclass); |
| 154 return asn1_i2d_ex_primitive(pval, out, it, tag, aclass); | 154 return asn1_i2d_ex_primitive(pval, out, it, tag, aclass); |
| 155 break; | 155 break; |
| 156 | 156 |
| 157 case ASN1_ITYPE_MSTRING: | 157 case ASN1_ITYPE_MSTRING: |
| 158 return asn1_i2d_ex_primitive(pval, out, it, -1, aclass); | 158 return asn1_i2d_ex_primitive(pval, out, it, -1, aclass); |
| 159 | 159 |
| 160 case ASN1_ITYPE_CHOICE: | 160 case ASN1_ITYPE_CHOICE: |
| 161 » » if (asn1_cb && !asn1_cb(ASN1_OP_I2D_PRE, pval, it)) | 161 » » if (asn1_cb && !asn1_cb(ASN1_OP_I2D_PRE, pval, it, NULL)) |
| 162 return 0; | 162 return 0; |
| 163 i = asn1_get_choice_selector(pval, it); | 163 i = asn1_get_choice_selector(pval, it); |
| 164 if ((i >= 0) && (i < it->tcount)) | 164 if ((i >= 0) && (i < it->tcount)) |
| 165 { | 165 { |
| 166 ASN1_VALUE **pchval; | 166 ASN1_VALUE **pchval; |
| 167 const ASN1_TEMPLATE *chtt; | 167 const ASN1_TEMPLATE *chtt; |
| 168 chtt = it->templates + i; | 168 chtt = it->templates + i; |
| 169 pchval = asn1_get_field_ptr(pval, chtt); | 169 pchval = asn1_get_field_ptr(pval, chtt); |
| 170 return asn1_template_ex_i2d(pchval, out, chtt, | 170 return asn1_template_ex_i2d(pchval, out, chtt, |
| 171 -1, aclass); | 171 -1, aclass); |
| 172 } | 172 } |
| 173 /* Fixme: error condition if selector out of range */ | 173 /* Fixme: error condition if selector out of range */ |
| 174 » » if (asn1_cb && !asn1_cb(ASN1_OP_I2D_POST, pval, it)) | 174 » » if (asn1_cb && !asn1_cb(ASN1_OP_I2D_POST, pval, it, NULL)) |
| 175 return 0; | 175 return 0; |
| 176 break; | 176 break; |
| 177 | 177 |
| 178 case ASN1_ITYPE_EXTERN: | 178 case ASN1_ITYPE_EXTERN: |
| 179 /* If new style i2d it does all the work */ | 179 /* If new style i2d it does all the work */ |
| 180 ef = it->funcs; | 180 ef = it->funcs; |
| 181 return ef->asn1_ex_i2d(pval, out, it, tag, aclass); | 181 return ef->asn1_ex_i2d(pval, out, it, tag, aclass); |
| 182 | 182 |
| 183 case ASN1_ITYPE_COMPAT: | 183 case ASN1_ITYPE_COMPAT: |
| 184 /* old style hackery... */ | 184 /* old style hackery... */ |
| (...skipping 24 matching lines...) Expand all Loading... |
| 209 /* Otherwise carry on */ | 209 /* Otherwise carry on */ |
| 210 seqcontlen = 0; | 210 seqcontlen = 0; |
| 211 /* If no IMPLICIT tagging set to SEQUENCE, UNIVERSAL */ | 211 /* If no IMPLICIT tagging set to SEQUENCE, UNIVERSAL */ |
| 212 if (tag == -1) | 212 if (tag == -1) |
| 213 { | 213 { |
| 214 tag = V_ASN1_SEQUENCE; | 214 tag = V_ASN1_SEQUENCE; |
| 215 /* Retain any other flags in aclass */ | 215 /* Retain any other flags in aclass */ |
| 216 aclass = (aclass & ~ASN1_TFLG_TAG_CLASS) | 216 aclass = (aclass & ~ASN1_TFLG_TAG_CLASS) |
| 217 | V_ASN1_UNIVERSAL; | 217 | V_ASN1_UNIVERSAL; |
| 218 } | 218 } |
| 219 » » if (asn1_cb && !asn1_cb(ASN1_OP_I2D_PRE, pval, it)) | 219 » » if (asn1_cb && !asn1_cb(ASN1_OP_I2D_PRE, pval, it, NULL)) |
| 220 return 0; | 220 return 0; |
| 221 /* First work out sequence content length */ | 221 /* First work out sequence content length */ |
| 222 for (i = 0, tt = it->templates; i < it->tcount; tt++, i++) | 222 for (i = 0, tt = it->templates; i < it->tcount; tt++, i++) |
| 223 { | 223 { |
| 224 const ASN1_TEMPLATE *seqtt; | 224 const ASN1_TEMPLATE *seqtt; |
| 225 ASN1_VALUE **pseqval; | 225 ASN1_VALUE **pseqval; |
| 226 seqtt = asn1_do_adb(pval, tt, 1); | 226 seqtt = asn1_do_adb(pval, tt, 1); |
| 227 if (!seqtt) | 227 if (!seqtt) |
| 228 return 0; | 228 return 0; |
| 229 pseqval = asn1_get_field_ptr(pval, seqtt); | 229 pseqval = asn1_get_field_ptr(pval, seqtt); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 243 ASN1_VALUE **pseqval; | 243 ASN1_VALUE **pseqval; |
| 244 seqtt = asn1_do_adb(pval, tt, 1); | 244 seqtt = asn1_do_adb(pval, tt, 1); |
| 245 if (!seqtt) | 245 if (!seqtt) |
| 246 return 0; | 246 return 0; |
| 247 pseqval = asn1_get_field_ptr(pval, seqtt); | 247 pseqval = asn1_get_field_ptr(pval, seqtt); |
| 248 /* FIXME: check for errors in enhanced version */ | 248 /* FIXME: check for errors in enhanced version */ |
| 249 asn1_template_ex_i2d(pseqval, out, seqtt, -1, aclass); | 249 asn1_template_ex_i2d(pseqval, out, seqtt, -1, aclass); |
| 250 } | 250 } |
| 251 if (ndef == 2) | 251 if (ndef == 2) |
| 252 ASN1_put_eoc(out); | 252 ASN1_put_eoc(out); |
| 253 » » if (asn1_cb && !asn1_cb(ASN1_OP_I2D_POST, pval, it)) | 253 » » if (asn1_cb && !asn1_cb(ASN1_OP_I2D_POST, pval, it, NULL)) |
| 254 return 0; | 254 return 0; |
| 255 return seqlen; | 255 return seqlen; |
| 256 | 256 |
| 257 default: | 257 default: |
| 258 return 0; | 258 return 0; |
| 259 | 259 |
| 260 } | 260 } |
| 261 return 0; | 261 return 0; |
| 262 } | 262 } |
| 263 | 263 |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 | 562 |
| 563 /* Produce content octets from a structure */ | 563 /* Produce content octets from a structure */ |
| 564 | 564 |
| 565 int asn1_ex_i2c(ASN1_VALUE **pval, unsigned char *cout, int *putype, | 565 int asn1_ex_i2c(ASN1_VALUE **pval, unsigned char *cout, int *putype, |
| 566 const ASN1_ITEM *it) | 566 const ASN1_ITEM *it) |
| 567 { | 567 { |
| 568 ASN1_BOOLEAN *tbool = NULL; | 568 ASN1_BOOLEAN *tbool = NULL; |
| 569 ASN1_STRING *strtmp; | 569 ASN1_STRING *strtmp; |
| 570 ASN1_OBJECT *otmp; | 570 ASN1_OBJECT *otmp; |
| 571 int utype; | 571 int utype; |
| 572 » unsigned char *cont, c; | 572 » const unsigned char *cont; |
| 573 » unsigned char c; |
| 573 int len; | 574 int len; |
| 574 const ASN1_PRIMITIVE_FUNCS *pf; | 575 const ASN1_PRIMITIVE_FUNCS *pf; |
| 575 pf = it->funcs; | 576 pf = it->funcs; |
| 576 if (pf && pf->prim_i2c) | 577 if (pf && pf->prim_i2c) |
| 577 return pf->prim_i2c(pval, cout, putype, it); | 578 return pf->prim_i2c(pval, cout, putype, it); |
| 578 | 579 |
| 579 /* Should type be omitted? */ | 580 /* Should type be omitted? */ |
| 580 if ((it->itype != ASN1_ITYPE_PRIMITIVE) | 581 if ((it->itype != ASN1_ITYPE_PRIMITIVE) |
| 581 || (it->utype != V_ASN1_BOOLEAN)) | 582 || (it->utype != V_ASN1_BOOLEAN)) |
| 582 { | 583 { |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 cont = strtmp->data; | 682 cont = strtmp->data; |
| 682 len = strtmp->length; | 683 len = strtmp->length; |
| 683 | 684 |
| 684 break; | 685 break; |
| 685 | 686 |
| 686 } | 687 } |
| 687 if (cout && len) | 688 if (cout && len) |
| 688 memcpy(cout, cont, len); | 689 memcpy(cout, cont, len); |
| 689 return len; | 690 return len; |
| 690 } | 691 } |
| OLD | NEW |