On Tue, Mar 12, 2013, Patrick Patterson wrote:
> Hi Steve,
>
> Ok - but if I have an IETF ASN.1 like this:
>
> * Request ::= SEQUENCE {
> * name [1] GeneralName OPTIONAL,
> * text [2] UTF8String (SIZE (1..256))
> OPTIONAL }
>
> What would be the right way to code up the resulting struct and ASN1_SEQUENCE
> { }?? From my understanding, the IETF uses IMPLICIT tagging for everything.
>
There is a rule in ASN1 that a tag on a choice type is EXPLICIT even if the
default tagging is IMPLICIT. An ASN1 compiler will typically do this
automatically and if you try to enfornce an IMPLICIT tag on a CHOICE type it
may throw an error or just misbehave when you try to decode a structure.
If you think about how this is encoded on the wire it makes sense.
If you have a CHOICE type the tag of the type is used by the decoder to see
which of the options is present.
An IMPLICIT tag on a non-choice type changes the tag of the underlying type.
So if you allowed both it would be impossible to tell which (if any) CHOICE
type is present.
This rule applies even if the CHOICE type only contains one element. The
directoryName option of the GeneralName structure uses an EXPLICIT tag as a
result.
Steve.
--
Dr Stephen N. Henson. OpenSSL project core developer.
Commercial tech support now available see: http://www.openssl.org
______________________________________________________________________
OpenSSL Project http://www.openssl.org
Development Mailing List [email protected]
Automated List Manager [email protected]