Subject: defining extension

From: Peter Sylvester <[email-masked]>
Date: Tue, 21 May 2002 20:21:18 +0200 (MET DST)

Althogh this is probably not the right list:

can some tell me what in the 2002 versions of X.6XX 
the XXX {DER, CER, BER, XER, PER) encoding of an
OCTET STRING defined with a constraint like

     xxx         OCTET STRING ( CONTAINING abc )

is? Does it mean that the value should/must be encoded using the
same encoding rules as the data that contain an instance of
xxx?  

Peter

---

From: Geoff Elgey <[email-masked]>
Date: Wed, 22 May 2002 07:39:27 +1000

G'day Peter,

> same encoding rules as the data that contain an instance of

Yes, the value of the type 'abc' is encoded using the same encoding 
scheme, and that encoding becomes the payload of the outer OCTET STRING.

For example:

T1 ::= SEQUENCE {
   a INTEGER
}

T2 ::= OCTET STRING (CONTAINING T1)

v1 T2 ::= { a 0 }

If using a DER encoding, the value v1 would be encoded as 0x04, 0x05, 
0x30, 0x03, 0x02, 0x01, 0x00.

If using a BER encoding, the value v1 could be encoded as above, or by 
using indefinite length for the inner SEQUENCE: 0x04, 0x06, 0x30, 0x80, 
0x02, 0x01, 0x00, 0x00.

If you need to specify a difference encoding within the CONTAINING 
constraint, then you would use the ENCODED BY constraint:

T3 ::= OCTET STRING (
                 CONTAINING T1
                 ENCODED BY {joint-iso-itu-t asn1(1) ber-derived(2) 
distinguished-encoding(1)}) -- DER

v2 T3 ::= { a 0 }

If using a DER encoding, the value v2 would be encoded as 0x04, 0x05, 
0x30, 0x03, 0x02, 0x01, 0x00 (ie it is equivalent to encoding v1 under DER).

If using a BER encoding, then the inner SEQUENCE must be encoded as DER, 
so it cannot use indefinite length. This restricts the possible BER 
encodings of v2 to 0x04, 0x05, 0x30, 0x03, 0x02, 0x01, 0x00 (ie, the 
same as the DER encoding).

Hope this helps.

Cheers,
Geoff