@ -80,9 +80,7 @@ static int asn1_set_seq_out(STACK_OF(ASN1_VALUE) *sk, unsigned char **out,
static int asn1_template_ex_i2d ( ASN1_VALUE * * pval , unsigned char * * out ,
const ASN1_TEMPLATE * tt , int tag , int aclass ) ;
/*
* Top level i2d equivalents
*/
// Top level i2d equivalents
int ASN1_item_i2d ( ASN1_VALUE * val , unsigned char * * out , const ASN1_ITEM * it ) {
if ( out & & ! * out ) {
@ -109,10 +107,8 @@ int ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it) {
return ASN1_item_ex_i2d ( & val , out , it , /*tag=*/ - 1 , /*aclass=*/ 0 ) ;
}
/*
* Encode an item , taking care of IMPLICIT tagging ( if any ) . This function
* performs the normal item handling : it can be used in external types .
*/
// Encode an item, taking care of IMPLICIT tagging (if any). This function
// performs the normal item handling: it can be used in external types.
int ASN1_item_ex_i2d ( ASN1_VALUE * * pval , unsigned char * * out ,
const ASN1_ITEM * it , int tag , int aclass ) {
@ -121,22 +117,22 @@ int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
return ret ;
}
/* asn1_item_ex_i2d_opt behaves like |ASN1_item_ex_i2d| but, if |optional| is
* non - zero and | * pval | is omitted , it returns zero and writes no bytes . */
// asn1_item_ex_i2d_opt behaves like |ASN1_item_ex_i2d| but, if |optional| is
// non-zero and |*pval| is omitted, it returns zero and writes no bytes.
int asn1_item_ex_i2d_opt ( ASN1_VALUE * * pval , unsigned char * * out ,
const ASN1_ITEM * it , int tag , int aclass ,
int optional ) {
const ASN1_TEMPLATE * tt = NULL ;
int i , seqcontlen , seqlen ;
/* Historically, |aclass| was repurposed to pass additional flags into the
* encoding process . */
// Historically, |aclass| was repurposed to pass additional flags into the
// encoding process.
assert ( ( aclass & ASN1_TFLG_TAG_CLASS ) = = aclass ) ;
/* If not overridding the tag, |aclass| is ignored and should be zero. */
// If not overridding the tag, |aclass| is ignored and should be zero.
assert ( tag ! = - 1 | | aclass = = 0 ) ;
/* All fields are pointers, except for boolean |ASN1_ITYPE_PRIMITIVE|s.
* Optional primitives are handled later . */
// All fields are pointers, except for boolean |ASN1_ITYPE_PRIMITIVE|s.
// Optional primitives are handled later.
if ( ( it - > itype ! = ASN1_ITYPE_PRIMITIVE ) & & ! * pval ) {
if ( optional ) {
return 0 ;
@ -157,10 +153,8 @@ int asn1_item_ex_i2d_opt(ASN1_VALUE **pval, unsigned char **out,
return asn1_i2d_ex_primitive ( pval , out , it , tag , aclass , optional ) ;
case ASN1_ITYPE_MSTRING :
/*
* It never makes sense for multi - strings to have implicit tagging , so
* if tag ! = - 1 , then this looks like an error in the template .
*/
// It never makes sense for multi-strings to have implicit tagging, so
// if tag != -1, then this looks like an error in the template.
if ( tag ! = - 1 ) {
OPENSSL_PUT_ERROR ( ASN1 , ASN1_R_BAD_TEMPLATE ) ;
return - 1 ;
@ -168,10 +162,8 @@ int asn1_item_ex_i2d_opt(ASN1_VALUE **pval, unsigned char **out,
return asn1_i2d_ex_primitive ( pval , out , it , - 1 , 0 , optional ) ;
case ASN1_ITYPE_CHOICE : {
/*
* It never makes sense for CHOICE types to have implicit tagging , so if
* tag ! = - 1 , then this looks like an error in the template .
*/
// It never makes sense for CHOICE types to have implicit tagging, so if
// tag != -1, then this looks like an error in the template.
if ( tag ! = - 1 ) {
OPENSSL_PUT_ERROR ( ASN1 , ASN1_R_BAD_TEMPLATE ) ;
return - 1 ;
@ -191,13 +183,13 @@ int asn1_item_ex_i2d_opt(ASN1_VALUE **pval, unsigned char **out,
}
case ASN1_ITYPE_EXTERN : {
/* If new style i2d it does all the work */
// If new style i2d it does all the work
const ASN1_EXTERN_FUNCS * ef = it - > funcs ;
int ret = ef - > asn1_ex_i2d ( pval , out , it , tag , aclass ) ;
if ( ret = = 0 ) {
/* |asn1_ex_i2d| should never return zero. We have already checked
* for optional values generically , and | ASN1_ITYPE_EXTERN | fields
* must be pointers . */
// |asn1_ex_i2d| should never return zero. We have already checked
// for optional values generically, and |ASN1_ITYPE_EXTERN| fields
// must be pointers.
OPENSSL_PUT_ERROR ( ASN1 , ERR_R_INTERNAL_ERROR ) ;
return - 1 ;
}
@ -206,22 +198,22 @@ int asn1_item_ex_i2d_opt(ASN1_VALUE **pval, unsigned char **out,
case ASN1_ITYPE_SEQUENCE : {
i = asn1_enc_restore ( & seqcontlen , out , pval , it ) ;
/* An error occurred */
// An error occurred
if ( i < 0 ) {
return - 1 ;
}
/* We have a valid cached encoding... */
// We have a valid cached encoding...
if ( i > 0 ) {
return seqcontlen ;
}
/* Otherwise carry on */
// Otherwise carry on
seqcontlen = 0 ;
/* If no IMPLICIT tagging set to SEQUENCE, UNIVERSAL */
// If no IMPLICIT tagging set to SEQUENCE, UNIVERSAL
if ( tag = = - 1 ) {
tag = V_ASN1_SEQUENCE ;
aclass = V_ASN1_UNIVERSAL ;
}
/* First work out sequence content length */
// First work out sequence content length
for ( i = 0 , tt = it - > templates ; i < it - > tcount ; tt + + , i + + ) {
const ASN1_TEMPLATE * seqtt ;
ASN1_VALUE * * pseqval ;
@ -242,7 +234,7 @@ int asn1_item_ex_i2d_opt(ASN1_VALUE **pval, unsigned char **out,
if ( ! out | | seqlen = = - 1 ) {
return seqlen ;
}
/* Output SEQUENCE header */
// Output SEQUENCE header
ASN1_put_object ( out , /*constructed=*/ 1 , seqcontlen , tag , aclass ) ;
for ( i = 0 , tt = it - > templates ; i < it - > tcount ; tt + + , i + + ) {
const ASN1_TEMPLATE * seqtt ;
@ -265,38 +257,36 @@ int asn1_item_ex_i2d_opt(ASN1_VALUE **pval, unsigned char **out,
}
}
/* asn1_template_ex_i2d behaves like |asn1_item_ex_i2d_opt| but uses an
* | ASN1_TEMPLATE | instead of an | ASN1_ITEM | . An | ASN1_TEMPLATE | wraps an
* | ASN1_ITEM | with modifiers such as tagging , SEQUENCE or SET , etc . Instead of
* taking an | optional | parameter , it uses the | ASN1_TFLG_OPTIONAL | flag . */
// asn1_template_ex_i2d behaves like |asn1_item_ex_i2d_opt| but uses an
// |ASN1_TEMPLATE| instead of an |ASN1_ITEM|. An |ASN1_TEMPLATE| wraps an
// |ASN1_ITEM| with modifiers such as tagging, SEQUENCE or SET, etc. Instead of
// taking an |optional| parameter, it uses the |ASN1_TFLG_OPTIONAL| flag.
static int asn1_template_ex_i2d ( ASN1_VALUE * * pval , unsigned char * * out ,
const ASN1_TEMPLATE * tt , int tag , int iclass ) {
int i , ret , flags , ttag , tclass ;
size_t j ;
flags = tt - > flags ;
/* Historically, |iclass| was repurposed to pass additional flags into the
* encoding process . */
// Historically, |iclass| was repurposed to pass additional flags into the
// encoding process.
assert ( ( iclass & ASN1_TFLG_TAG_CLASS ) = = iclass ) ;
/* If not overridding the tag, |iclass| is ignored and should be zero. */
// If not overridding the tag, |iclass| is ignored and should be zero.
assert ( tag ! = - 1 | | iclass = = 0 ) ;
/*
* Work out tag and class to use : tagging may come either from the
* template or the arguments , not both because this would create
* ambiguity .
*/
// Work out tag and class to use: tagging may come either from the
// template or the arguments, not both because this would create
// ambiguity.
if ( flags & ASN1_TFLG_TAG_MASK ) {
/* Error if argument and template tagging */
// Error if argument and template tagging
if ( tag ! = - 1 ) {
OPENSSL_PUT_ERROR ( ASN1 , ASN1_R_BAD_TEMPLATE ) ;
return - 1 ;
}
/* Get tagging from template */
// Get tagging from template
ttag = tt - > tag ;
tclass = flags & ASN1_TFLG_TAG_CLASS ;
} else if ( tag ! = - 1 ) {
/* No template tagging, get from arguments */
// No template tagging, get from arguments
ttag = tag ;
tclass = iclass & ASN1_TFLG_TAG_CLASS ;
} else {
@ -306,13 +296,11 @@ static int asn1_template_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
const int optional = ( flags & ASN1_TFLG_OPTIONAL ) ! = 0 ;
/*
* At this point ' ttag ' contains the outer tag to use , and ' tclass ' is the
* class .
*/
// At this point 'ttag' contains the outer tag to use, and 'tclass' is the
// class.
if ( flags & ASN1_TFLG_SK_MASK ) {
/* SET OF, SEQUENCE OF */
// SET OF, SEQUENCE OF
STACK_OF ( ASN1_VALUE ) * sk = ( STACK_OF ( ASN1_VALUE ) * ) * pval ;
int isset , sktag , skaclass ;
int skcontlen , sklen ;
@ -328,17 +316,15 @@ static int asn1_template_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
if ( flags & ASN1_TFLG_SET_OF ) {
isset = 1 ;
/* Historically, types with both bits set were mutated when
* serialized to apply the sort . We no longer support this . */
// Historically, types with both bits set were mutated when
// serialized to apply the sort. We no longer support this.
assert ( ( flags & ASN1_TFLG_SEQUENCE_OF ) = = 0 ) ;
} else {
isset = 0 ;
}
/*
* Work out inner tag value : if EXPLICIT or no tagging use underlying
* type .
*/
// Work out inner tag value: if EXPLICIT or no tagging use underlying
// type.
if ( ( ttag ! = - 1 ) & & ! ( flags & ASN1_TFLG_EXPTAG ) ) {
sktag = ttag ;
skaclass = tclass ;
@ -351,7 +337,7 @@ static int asn1_template_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
}
}
/* Determine total length of items */
// Determine total length of items
skcontlen = 0 ;
for ( j = 0 ; j < sk_ASN1_VALUE_num ( sk ) ; j + + ) {
int tmplen ;
@ -366,7 +352,7 @@ static int asn1_template_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
if ( sklen = = - 1 ) {
return - 1 ;
}
/* If EXPLICIT need length of surrounding tag */
// If EXPLICIT need length of surrounding tag
if ( flags & ASN1_TFLG_EXPTAG ) {
ret = ASN1_object_size ( /*constructed=*/ 1 , sklen , ttag ) ;
} else {
@ -377,14 +363,14 @@ static int asn1_template_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
return ret ;
}
/* Now encode this lot... */
/* EXPLICIT tag */
// Now encode this lot...
// EXPLICIT tag
if ( flags & ASN1_TFLG_EXPTAG ) {
ASN1_put_object ( out , /*constructed=*/ 1 , sklen , ttag , tclass ) ;
}
/* SET or SEQUENCE and IMPLICIT tag */
// SET or SEQUENCE and IMPLICIT tag
ASN1_put_object ( out , /*constructed=*/ 1 , skcontlen , sktag , skaclass ) ;
/* And the stuff itself */
// And the stuff itself
if ( ! asn1_set_seq_out ( sk , out , skcontlen , ASN1_ITEM_ptr ( tt - > item ) , isset ) ) {
return - 1 ;
}
@ -392,17 +378,17 @@ static int asn1_template_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
}
if ( flags & ASN1_TFLG_EXPTAG ) {
/* EXPLICIT tagging */
/* Find length of tagged item */
// EXPLICIT tagging
// Find length of tagged item
i = asn1_item_ex_i2d_opt ( pval , NULL , ASN1_ITEM_ptr ( tt - > item ) , - 1 , 0 ,
optional ) ;
if ( i < = 0 ) {
return i ;
}
/* Find length of EXPLICIT tag */
// Find length of EXPLICIT tag
ret = ASN1_object_size ( /*constructed=*/ 1 , i , ttag ) ;
if ( out & & ret ! = - 1 ) {
/* Output tag and item */
// Output tag and item
ASN1_put_object ( out , /*constructed=*/ 1 , i , ttag , tclass ) ;
if ( ASN1_item_ex_i2d ( pval , out , ASN1_ITEM_ptr ( tt - > item ) , - 1 , 0 ) < 0 ) {
return - 1 ;
@ -411,12 +397,12 @@ static int asn1_template_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
return ret ;
}
/* Either normal or IMPLICIT tagging */
// Either normal or IMPLICIT tagging
return asn1_item_ex_i2d_opt ( pval , out , ASN1_ITEM_ptr ( tt - > item ) , ttag , tclass ,
optional ) ;
}
/* Temporary structure used to hold DER encoding of items for SET OF */
// Temporary structure used to hold DER encoding of items for SET OF
typedef struct {
unsigned char * data ;
@ -434,14 +420,14 @@ static int der_cmp(const void *a, const void *b) {
return d1 - > length - d2 - > length ;
}
/* asn1_set_seq_out writes |sk| to |out| under the i2d output convention,
* excluding the tag and length . It returns one on success and zero on error .
* | skcontlen | must be the total encoded size . If | do_sort | is non - zero , the
* elements are sorted for a SET OF type . Each element of | sk | has type
* | item | . */
// asn1_set_seq_out writes |sk| to |out| under the i2d output convention,
// excluding the tag and length. It returns one on success and zero on error.
// |skcontlen| must be the total encoded size. If |do_sort| is non-zero, the
// elements are sorted for a SET OF type. Each element of |sk| has type
// |item|.
static int asn1_set_seq_out ( STACK_OF ( ASN1_VALUE ) * sk , unsigned char * * out ,
int skcontlen , const ASN1_ITEM * item , int do_sort ) {
/* No need to sort if there are fewer than two items. */
// No need to sort if there are fewer than two items.
if ( ! do_sort | | sk_ASN1_VALUE_num ( sk ) < 2 ) {
for ( size_t i = 0 ; i < sk_ASN1_VALUE_num ( sk ) ; i + + ) {
ASN1_VALUE * skitem = sk_ASN1_VALUE_value ( sk , i ) ;
@ -465,7 +451,7 @@ static int asn1_set_seq_out(STACK_OF(ASN1_VALUE) *sk, unsigned char **out,
goto err ;
}
/* Encode all the elements into |buf| and populate |encoded|. */
// Encode all the elements into |buf| and populate |encoded|.
unsigned char * p = buf ;
for ( size_t i = 0 ; i < sk_ASN1_VALUE_num ( sk ) ; i + + ) {
ASN1_VALUE * skitem = sk_ASN1_VALUE_value ( sk , i ) ;
@ -479,7 +465,7 @@ static int asn1_set_seq_out(STACK_OF(ASN1_VALUE) *sk, unsigned char **out,
qsort ( encoded , sk_ASN1_VALUE_num ( sk ) , sizeof ( * encoded ) , der_cmp ) ;
/* Output the elements in sorted order. */
// Output the elements in sorted order.
p = * out ;
for ( size_t i = 0 ; i < sk_ASN1_VALUE_num ( sk ) ; i + + ) {
OPENSSL_memcpy ( p , encoded [ i ] . data , encoded [ i ] . length ) ;
@ -495,12 +481,12 @@ err:
return ret ;
}
/* asn1_i2d_ex_primitive behaves like |ASN1_item_ex_i2d| but |item| must be a
* a PRIMITIVE or MSTRING type that is not an | ASN1_ITEM_TEMPLATE | . */
// asn1_i2d_ex_primitive behaves like |ASN1_item_ex_i2d| but |item| must be a
// a PRIMITIVE or MSTRING type that is not an |ASN1_ITEM_TEMPLATE|.
static int asn1_i2d_ex_primitive ( ASN1_VALUE * * pval , unsigned char * * out ,
const ASN1_ITEM * it , int tag , int aclass ,
int optional ) {
/* Get length of content octets and maybe find out the underlying type. */
// Get length of content octets and maybe find out the underlying type.
int omit ;
int utype = it - > utype ;
int len = asn1_ex_i2c ( pval , NULL , & omit , & utype , it ) ;
@ -515,20 +501,18 @@ static int asn1_i2d_ex_primitive(ASN1_VALUE **pval, unsigned char **out,
return - 1 ;
}
/*
* If SEQUENCE , SET or OTHER then header is included in pseudo content
* octets so don ' t include tag + length . We need to check here because the
* call to asn1_ex_i2c ( ) could change utype .
*/
// If SEQUENCE, SET or OTHER then header is included in pseudo content
// octets so don't include tag+length. We need to check here because the
// call to asn1_ex_i2c() could change utype.
int usetag =
utype ! = V_ASN1_SEQUENCE & & utype ! = V_ASN1_SET & & utype ! = V_ASN1_OTHER ;
/* If not implicitly tagged get tag from underlying type */
// If not implicitly tagged get tag from underlying type
if ( tag = = - 1 ) {
tag = utype ;
}
/* Output tag+length followed by content octets */
// Output tag+length followed by content octets
if ( out ) {
if ( usetag ) {
ASN1_put_object ( out , /*constructed=*/ 0 , len , tag , aclass ) ;
@ -548,22 +532,22 @@ static int asn1_i2d_ex_primitive(ASN1_VALUE **pval, unsigned char **out,
return len ;
}
/* asn1_ex_i2c writes the |*pval| to |cout| under the i2d output convention,
* excluding the tag and length . It returns the number of bytes written ,
* possibly zero , on success or - 1 on error . If | * pval | should be omitted , it
* returns zero and sets | * out_omit | to true .
*
* If | it | is an MSTRING or ANY type , it gets the underlying type from | * pval | ,
* which must be an | ASN1_STRING | or | ASN1_TYPE | , respectively . It then updates
* | * putype | with the tag number of type used , or | V_ASN1_OTHER | if it was not a
* universal type . If | * putype | is set to | V_ASN1_SEQUENCE | , | V_ASN1_SET | , or
* | V_ASN1_OTHER | , it additionally outputs the tag and length , so the caller
* must not do so .
*
* Otherwise , | * putype | must contain | it - > utype | .
*
* WARNING : Unlike most functions in this file , | asn1_ex_i2c | can return zero
* without omitting the element . ASN .1 values may have empty contents . */
// asn1_ex_i2c writes the |*pval| to |cout| under the i2d output convention,
// excluding the tag and length. It returns the number of bytes written,
// possibly zero, on success or -1 on error. If |*pval| should be omitted, it
// returns zero and sets |*out_omit| to true.
//
// If |it| is an MSTRING or ANY type, it gets the underlying type from |*pval|,
// which must be an |ASN1_STRING| or |ASN1_TYPE|, respectively. It then updates
// |*putype| with the tag number of type used, or |V_ASN1_OTHER| if it was not a
// universal type. If |*putype| is set to |V_ASN1_SEQUENCE|, |V_ASN1_SET|, or
// |V_ASN1_OTHER|, it additionally outputs the tag and length, so the caller
// must not do so.
//
// Otherwise, |*putype| must contain |it->utype|.
//
// WARNING: Unlike most functions in this file, |asn1_ex_i2c| can return zero
// without omitting the element. ASN.1 values may have empty contents.
static int asn1_ex_i2c ( ASN1_VALUE * * pval , unsigned char * cout , int * out_omit ,
int * putype , const ASN1_ITEM * it ) {
ASN1_BOOLEAN * tbool = NULL ;
@ -574,13 +558,13 @@ static int asn1_ex_i2c(ASN1_VALUE **pval, unsigned char *cout, int *out_omit,
unsigned char c ;
int len ;
/* Historically, |it->funcs| for primitive types contained an
* | ASN1_PRIMITIVE_FUNCS | table of callbacks . */
// Historically, |it->funcs| for primitive types contained an
// |ASN1_PRIMITIVE_FUNCS| table of callbacks.
assert ( it - > funcs = = NULL ) ;
* out_omit = 0 ;
/* Should type be omitted? */
// Should type be omitted?
if ( ( it - > itype ! = ASN1_ITYPE_PRIMITIVE ) | | ( it - > utype ! = V_ASN1_BOOLEAN ) ) {
if ( ! * pval ) {
* out_omit = 1 ;
@ -589,23 +573,23 @@ static int asn1_ex_i2c(ASN1_VALUE **pval, unsigned char *cout, int *out_omit,
}
if ( it - > itype = = ASN1_ITYPE_MSTRING ) {
/* If MSTRING type set the underlying type */
// If MSTRING type set the underlying type
strtmp = ( ASN1_STRING * ) * pval ;
utype = strtmp - > type ;
if ( utype < 0 & & utype ! = V_ASN1_OTHER ) {
/* MSTRINGs can have type -1 when default-constructed. */
// MSTRINGs can have type -1 when default-constructed.
OPENSSL_PUT_ERROR ( ASN1 , ASN1_R_WRONG_TYPE ) ;
return - 1 ;
}
/* Negative INTEGER and ENUMERATED values use |ASN1_STRING| type values
* that do not match their corresponding utype values . INTEGERs cannot
* participate in MSTRING types , but ENUMERATEDs can .
*
* TODO ( davidben ) : Is this a bug ? Although arguably one of the MSTRING
* types should contain more values , rather than less . See
* https : //crbug.com/boringssl/412. But it is not possible to fit all
* possible ANY values into an | ASN1_STRING | , so matching the spec here
* is somewhat hopeless . */
// Negative INTEGER and ENUMERATED values use |ASN1_STRING| type values
// that do not match their corresponding utype values. INTEGERs cannot
// participate in MSTRING types, but ENUMERATEDs can.
//
// TODO(davidben): Is this a bug? Although arguably one of the MSTRING
// types should contain more values, rather than less. See
// https: //crbug.com/boringssl/412. But it is not possible to fit all
// possible ANY values into an |ASN1_STRING|, so matching the spec here
// is somewhat hopeless.
if ( utype = = V_ASN1_NEG_INTEGER ) {
utype = V_ASN1_INTEGER ;
} else if ( utype = = V_ASN1_NEG_ENUMERATED ) {
@ -613,12 +597,12 @@ static int asn1_ex_i2c(ASN1_VALUE **pval, unsigned char *cout, int *out_omit,
}
* putype = utype ;
} else if ( it - > utype = = V_ASN1_ANY ) {
/* If ANY set type and pointer to value */
// If ANY set type and pointer to value
ASN1_TYPE * typ ;
typ = ( ASN1_TYPE * ) * pval ;
utype = typ - > type ;
if ( utype < 0 & & utype ! = V_ASN1_OTHER ) {
/* |ASN1_TYPE|s can have type -1 when default-constructed. */
// |ASN1_TYPE|s can have type -1 when default-constructed.
OPENSSL_PUT_ERROR ( ASN1 , ASN1_R_WRONG_TYPE ) ;
return - 1 ;
}
@ -634,7 +618,7 @@ static int asn1_ex_i2c(ASN1_VALUE **pval, unsigned char *cout, int *out_omit,
cont = otmp - > data ;
len = otmp - > length ;
if ( len = = 0 ) {
/* Some |ASN1_OBJECT|s do not have OIDs and cannot be serialized. */
// Some |ASN1_OBJECT|s do not have OIDs and cannot be serialized.
OPENSSL_PUT_ERROR ( ASN1 , ASN1_R_ILLEGAL_OBJECT ) ;
return - 1 ;
}
@ -652,9 +636,7 @@ static int asn1_ex_i2c(ASN1_VALUE **pval, unsigned char *cout, int *out_omit,
return 0 ;
}
if ( it - > utype ! = V_ASN1_ANY ) {
/*
* Default handling if value = = size field then omit
*/
// Default handling if value == size field then omit
if ( ( * tbool & & ( it - > size > 0 ) ) | | ( ! * tbool & & ! it - > size ) ) {
* out_omit = 1 ;
return 0 ;
@ -668,15 +650,15 @@ static int asn1_ex_i2c(ASN1_VALUE **pval, unsigned char *cout, int *out_omit,
case V_ASN1_BIT_STRING : {
int ret =
i2c_ASN1_BIT_STRING ( ( ASN1_BIT_STRING * ) * pval , cout ? & cout : NULL ) ;
/* |i2c_ASN1_BIT_STRING| returns zero on error instead of -1. */
// |i2c_ASN1_BIT_STRING| returns zero on error instead of -1.
return ret < = 0 ? - 1 : ret ;
}
case V_ASN1_INTEGER :
case V_ASN1_ENUMERATED : {
/* |i2c_ASN1_INTEGER| also handles ENUMERATED. */
// |i2c_ASN1_INTEGER| also handles ENUMERATED.
int ret = i2c_ASN1_INTEGER ( ( ASN1_INTEGER * ) * pval , cout ? & cout : NULL ) ;
/* |i2c_ASN1_INTEGER| returns zero on error instead of -1. */
// |i2c_ASN1_INTEGER| returns zero on error instead of -1.
return ret < = 0 ? - 1 : ret ;
}
@ -697,7 +679,7 @@ static int asn1_ex_i2c(ASN1_VALUE **pval, unsigned char *cout, int *out_omit,
case V_ASN1_SEQUENCE :
case V_ASN1_SET :
default :
/* All based on ASN1_STRING and handled the same */
// All based on ASN1_STRING and handled the same
strtmp = ( ASN1_STRING * ) * pval ;
cont = strtmp - > data ;
len = strtmp - > length ;