I am completely fresher to ASN.1 world.
Please go to http://www.oss.com/asn1/booksintro.html where you may
download two ASN.1 reference books which should help you better understand
encoding.
I am trying to encode following ASN.1 structure w.r.t. DER.
I intended to make a CHOICE of "certificates" type.
PKCS15Objects ::= CHOICE {
privateKeys [0] PrivateKeys,
publicKeys [1] PublicKeys,
trustedPublicKeys [2] PublicKeys,
secretKeys [3] SecretKeys,
certificates [4] Certificates,
trustedCertificates [5] Certificates,
usefulCertificates [6] Certificates,
dataObjects [7] DataObjects,
authObjects [8] AuthObjects,
... -- For future extensions
}
Certificates ::= PathOrObjects {CertificateType}
PathOrObjects {ObjectType} ::= CHOICE {
path Path,
objects [0] SEQUENCE OF ObjectType,
...,
indirect-protected [1] ReferencedValue {EnvelopedData {SEQUENCE OF
ObjectType}},
direct-protected [2] EnvelopedData {SEQUENCE OF ObjectType},
}
Path ::= SEQUENCE {
path OCTET STRING,
index INTEGER (0..pkcs15-ub-index) OPTIONAL,
length [0] INTEGER (0..pkcs15-ub-index) OPTIONAL
}( WITH COMPONENTS {..., index PRESENT, length PRESENT}
I think Ill follow as steps mentioned below. (Please correct me if I am going
in wrong way)
1>I create CDF path in OCTET String form.
2> There to are optional, so lets omit them
index INTEGER (0..pkcs15-ub-index) OPTIONAL,
length [0] INTEGER (0..pkcs15-ub-index) OPTIONAL
3> "30" Tag indicates SEQUENCE TAG in ASN.1 representation
4> So now Path would look like
30 [Length of Octet String (path of CDF)] [Value(OCTET
Representation of PATH)]
I don't have any clue to how to proceed further.
Please help me in encoding CHOICE Tag, in above described Example.
I don't know what you mean by "CDF".
CHOICE has no tag of its own. It takes the tag of the alternative which is
chosen. Thus, if privateKeys were chosen, the tag would be [0],
while if publicKeys were chosen, the tag would be [1].
And while looking on internet I found following example for encoding
CHOICE type
ExtendedCertificateOrCertificate ::= CHOICE {
certificate Certificate, -- X.509
extendedCertificate [0] IMPLICIT ExtendedCertificate
}
"The identifier octets for the BER encoding are 30 if the chosen
alternative is certificate and a0 if the chosen alternative is
extendedCertificate."
Please correct me if I am interpreting this statement wrongly, 1st item
of CHOICE becomes 30 and 2nd item of CHOICE becomes a0 ... But what abt
3rd 4th...10th Item...?
It's not that the first is 30 and the second is A0. It's that the first
has the tag of the first and the second the tag of the second. Further, if
it's a constructed type, the constructed bit is turned on.
30 0011 0000
00xx xxxx Universal tag
xx1x xxxx constructed
xxx1 0000 16
so 30 represents a UNIVERSAL 16 tag, which is the default for SEQUENCE.
A0 1010 0000
10xx xxxx Context-specific tag
xx1x xxxx constructed
xxx0 0000 0
so A0 represents a context-specific 0 ([0]).
Am I missing something here?
Are there any links where I can see some ASN.1 is encoded in to DER format?
Yes, you're missing a lot. Please refer to the reference books.
=====================================================================
Conrad Sigona Voice Mail : 1-732-302-9669 x400
OSS Nokalva Fax : 1-614-388-4156
[EMAIL PROTECTED] My direct line : 1-315-845-1773
_______________________________________________
Asn1 mailing list
[email protected]
http://lists.asn1.org/mailman/listinfo/asn1