I have one question about the BER encoding of a constructed OCTETSTRING.
In MS Outlook 2000, a digitally signed message is encoded with BER.
The eContent part of the encoded result is as following :
A0 80 24 80 04 82 04 6F 43 6F 6E 74 65 6E
74 2D ..$....oContent-
54 79 70 65 3A 20 74 65 78 74 2F 70 6C
61 69 6E Type: text/plain
3B 0D 0A 09 63 68 61 72 73 65 74 3D 22
6B 73 5F ;...charset="ks_
63 5F 35 36 30 31 2D 31 39 38 37 22 0D
0A 43 6F c_5601-1987"..Co
6E 74 65 6E 74 2D 54 72 61 6E 73 66 65
72 2D 45 ntent-Transfer-E
6E 63 6F 64 69 6E 67 3A 20 37 62 69 74
0D 0A 0D ncoding: 7bit...
0A 31 31 31 31 31 31 31 31 31 31 32 32
32 32 32 .111111111122222
.........
31 32 33 34 0D 0A 00 00 00 00
1234......
And the ans.1 notation for it is as following :
ContentInfo ::= SEQUENCE {
contentType ContentType,
content [0] EXPLICIT ANY DEFINED
BY contentType }
ContentType ::= OBJECT IDENTIFIER
SignedData ::= SEQUENCE {
version CMSVersion,
digestAlgorithms DigestAlgorithmIdentifiers,
encapContentInfo
EncapsulatedContentInfo, <----------<<
certificates [0] IMPLICIT CertificateSet
OPTIONAL,
crls [1] IMPLICIT CertificateRevocationLists
OPTIONAL,
signerInfos SignerInfos }
DigestAlgorithmIdentifiers ::= SET OF DigestAlgorithmIdentifier
SignerInfos ::= SET OF SignerInfo
EncapsulatedContentInfo ::= SEQUENCE {
eContentType ContentType,
eContent [0]
EXPLICIT OCTET STRING OPTIONAL } <------<<
I think each bytes have following means.
A0 : Context Specific tagging
80 : Indefinite length
24 : constructed OCTET STRING
80 : Indefinite length
04 : OCTET STRING
82 : length of length field
04 6F : length
43 6F 6E 74 65 6E 74 2D.... : values
00 00 : end of inner indefinite data
00 00 : end of outter indefinite data
But, in MS Outlook Express and Netscape Messenger, a constructed OCTET STRING is not encoded such as above.
The following message is an enveloped message with EnvelopedData form.
A0 80 04 82 04 00 3A FE B2 39 B0 E9 CB 9F
FF C9 ......:..9......
72 5B E9 B5 54 1D 92 44 CF 19 B2 C7 8D
88 FF D6 r[..T..D........
5C 5B 7A 78 ED 06 5C 9F 55 DA 7A D4 69
93 7B 67 \[zx..\.U.z.i.{g
3A 69 20 7C 27 E2 EF 21 52 E1 3B 24 3E
82 A7 D2 :i |'..!R.;$>...
...
6F 6B 89 0F 6C 90 04 82 03 20 8B 5C AA 20
BD FF ok..l.... .\. ..
4E 72 9D C6 22 4B 60 FD D0 61 9B EA A6
4B 4B EE Nr.."K`..a...KK.
60 26 8C C6 F5 F7 D9 DE F1 D9 FB 1B 4F
F3 3D FC `&..........O.=.
...
86 04 A4 C8 2B 08 05 92 10 8C 23 33 73
4F B0 6A ....+.....#3sO.j
18 97 9D 45 E6 B6 6F 9E 04 DC 00 00
...E..o.....
The asn.1 notation for this is as following:
EnvelopedData ::= SEQUENCE {
version CMSVersion,
originatorInfo [0] IMPLICIT OriginatorInfo
OPTIONAL,
recipientInfos RecipientInfos,
encryptedContentInfo
EncryptedContentInfo,
unprotectedAttrs [1] IMPLICIT UnprotectedAttributes
OPTIONAL }
OriginatorInfo ::= SEQUENCE {
certs [0] IMPLICIT CertificateSet
OPTIONAL,
crls [1] IMPLICIT CertificateRevocationLists
OPTIONAL }
RecipientInfos ::= SET OF RecipientInfo
EncryptedContentInfo ::= SEQUENCE {
contentType ContentType,
contentEncryptionAlgorithm ContentEncryptionAlgorithmIdentifier,
encryptedContent[0]
IMPLICIT EncryptedContent OPTIONAL }
EncryptedContent ::=
OCTET STRING
I think each bytes have following means.
A0 80 04 82 04 00 3A
A0 : Context Specific Explicit tagging
80 : Indefinite length
04 : the first OCTET STRING
82 : length of length field
04 00 : length
3A FE B2 .... : values
04 : the second OCTET STRING
82 : length of length field
03 20 : length
8B 5C AA .... : values
00 00 : end of indefinite data
This is a constructed BER encoding bute I can not find any information or indicator for "constructed".
Which is a correct encoding result?
Or what is my misunderstanding?
Please let me know about this.
Thank you.
