Subject: RE: ASN.1 , Constructed Encoding

From: [email-masked]
Date: Mon, 3 Apr 2000 12:51:32 -0400

I thought, as you did, that the sensible encoding would have an inner
tag of 0x16 for IA5String.  Unfortunately for this viewpoint, X.690 section
8.20.5.4 gives a VisibleString example with an inner tag of 0x04 rather
than 0x1A.  For that matter, so does X.209 section 23.5.4.
     I'm sorry to have been wrong in the first place, but I hope this
clears up a misconception that I am sure was shared by more than just the
two of us.

          Tom Gindin

"Darren Harter" <[email-masked]> on 04/03/2000 11:51:49 AM

To:   "'Hans Schupp'" <[email-masked]>
cc:   <[email-masked]>, <[email-masked]>
Subject:  RE: ASN.1 , Constructed Encoding

Hans,

[UNIVERSAL X] IMPLICIT OCTET STRING always gets a tag encoded as (in
binary)
001X XXXX where XXXXX is the X in the [UNIVERSAL X].  The IMPLICIT keywords
forces the encoding of OCTET STRING, but not its tag.  So in the case of
IA5String, it is indeed 0x36 when constructed (or part of an explicit
encoding) and 0x16 when not constructed (and not part of an explicit
encoding).

If the definition was IA5String ::= [UNIVERSAL 22] EXPLICIT OCTET STRING,
instead of IA5String ::= [UNIVERSAL 22] IMPLICIT OCTET STRING you would get
the following:

36 1B 04 19
          36 07 04 05 test1
          36 03 04 01 @
          36 09 04 07 rsa.com

Because it is IMPLICIT the three contained strings fall back to their
default (unconstructed) tags on 0x16, but the outer (constructed) tag stays
a 0x36.  The explicit OCTET STRING tags of 0x04 disappear in this case.

The original poster's encoding was correct as

36 13
     16 05 test1
     16 01 @
     16 07 rsa.com

You are correct in that the only leagal X.690 encoding of this is in a
single non-constructed IA5String with the following encoding:

16 0D [email-masked]

Hope this all helps,

Darren

---------------------------------------------------------------------
Darren Harter B.Sc. (Hons) MBCS CEng
European Professional Services Group,
Entegrity Solutions Corp.

Tel: +44 (0) 1452 371383
Fax: +44 (0) 1452 371384
Cell:     +44 (0) 7801 812850

Mail: <mailto:[email-masked]>
Web: <http://www.entegrity.com>

---------------------------------------------------------------------
Visit us on Stand No 654 at Infosecurity 2000 and enter our
FREE competition to WIN A HALF CASE OF CHAMPAGNE!

11-13 April in the National Hall, Olympia Exhibition Centre, London
---------------------------------------------------------------------

-----Original Message-----
From: Hans Schupp [mailto:[email-masked]]
Sent: 03 April 2000 16:08
To: [email-masked]
Cc: [email-masked]; [email-masked]
Subject: Re: ASN.1 , Constructed Encoding

[email-masked] wrote

>      The 0x20 bit of the tag byte (or the tag first byte when the
> tag value is 31 or above) means "constructed".  Thus a constructed
> IA5 string will have an outer tag of 0x36 and an inner tag of 0x16,

Wrong.
At least if one sticks to X.690, where the encoding of ASN.1 character
strings is defined. There it says, that each character string is encoded
as if it were defined [UNIVERSAL x] IMPLICIT OCTET STRING
This results in the inner tag being 0x04!

> a constructed octet string will have an outer tag of 0x24 and an
> inner tag of 0x04, and a constructed bit string with definition
> [2] IMPLICIT BIT STRING would have an outer tag of 0xA2 and an inner
> tag of 0x03 while a primitive with that definition would have a tag
> of 0x82.

Correct. :-)

> 36 13
>      16 05 74 65 73 74 31
>      16 01 40
>      16 07 72 73 61 2e 63 6f 6d

Given the above argument, this encoding is not correct. It should be
36 13
      04 05 74 65 73 74 31
      04 01 40
      04 07 72 73 61 2e 63 6f 6d

> And also please let me know  If there is any delimeter for
> words apart from @.

The '@' character is no delimiter here. The string can be divided at
arbitrary places (i.e. the character at this position doesn't mean
anything).
Logically, the whole thing is still one string, it is only the encoding,
that is split into several parts.

Hope it helps,
Hans Schupp