ASN1 Private Constructor
Sean Hinde
sean.hinde@REDACTED
Wed Apr 7 20:27:57 CEST 2004
Hi,
On 7 Apr 2004, at 16:58, Bertil Karlsson wrote:
> Try with something like:
>
> P ::= SEQUENCE {
> a INTEGER,
> b BOOLEAN
> }
>
> PwithPRIVATEtag ::= CHOICE {
> c [PRIVATE 1] P
> }
The Erlang asn1 compiler produces the following from this (with a
change to 2 integers):
asn1ct:compile("CTPG.asn1").
Erlang ASN.1 version "2003.07.11" compiling "CTPG.asn1"
Compiler Options: []
--{generated,"CTPG.asn1db"}--
--{generated,"CTPG.hrl"}--
--{generated,"CTPG.erl"}--
ok
148> c('CTPG').
{ok,'CTPG'}
149> 'CTPG':encode('PwithPRIVATEtag', {c, {'P', 1, 1}}).
{ok,[225,8,48,6,2,1,1,2,1,1]}
150> shlib:formathex(<<225,8,48,6,2,1,1,2,1,1>>).
< 0> e1 08 30 06 02 01 01 02 01 01
So, the e1 has been generated, great, but It has also generated a
UNIVERSAL SEQUENCE before getting to the content. I am trying to
generate:
e1 06 02 01 01 02 01 01
It may be a bug in the compiler, or it may be something it is not
possible to specify in a source file, or maybe the correct sequence of
magic words has not been found - I have been unable to tell by reading
around. It does appear to be valid BER.
Sean
>
> /Bertil
>
> Sean Hinde wrote:
>> Hi all,
>> Anyone have any idea how to specify a privately tagged constructor in
>> an asn1 source file? In other words it should behave like SEQUENCE
>> but have a different tag value
>> The reason is that I need to create a specific encoding which begins
>> with 0xE1 then goes straight into the sequence of values, and I'd
>> quite like to use the asn1 compiler.
>> Thanks,
>> Sean
>
More information about the erlang-questions
mailing list