[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
asn1Coding(1) a CHOICE
From: |
Ivan Shmakov |
Subject: |
asn1Coding(1) a CHOICE |
Date: |
Mon, 08 Oct 2012 12:41:27 +0700 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) |
>>>>> Nikos Mavrogiannopoulos <address@hidden> writes:
>>>>> On 10/04/2012 08:09 AM, Ivan Shmakov wrote:
[…]
>> Also, the documentation doesn't seem to mention on how to encode a
>> CHOICE with asn1Coding(1) [3], and just omitting the “unused”
>> element(s) leads to a failure.
> I also noticed. The asn1Coding tool is pretty primitive and needs a
> lot of changes to be of any use.
Fortunately, it's only a minor documentation issue, as the
asn1Coding documentation fails to mention that may use
“'' field-name” to choose a field from a CHOICE.
It follows from the fragments of the asn1_write_value ()
documentation and the asn1Coding.c source quoted below.
--cut: http://www.gnu.org/software/libtasn1/manual/libtasn1.html --
CHOICE: if NAME indicates a choice type, VALUE must specify one of
the alternatives with a null terminated string. LEN != 0. Using
“pkix.asn”:
result
= asn1_write_value (cert,
"certificate1.tbsCertificate.subject",
"rdnSequence", 1);
--cut: http://www.gnu.org/software/libtasn1/manual/libtasn1.html --
$ nl -ba < asn1Coding.c
…
69 static int
70 readAssignment (FILE * file, char *varName, char *value)
71 {
…
78 if (!strcmp (varName, "''"))
79 varName[0] = 0;
80
81 ret = fscanf (file, "%s", value);
82 if (ret == EOF)
83 return ASSIGNMENT_ERROR;
84
85 return ASSIGNMENT_SUCCESS;
86 }
…
$
Thus:
$ asn1Coding -o /dev/null asn.1 \
<(printf %s\\n 'x Example.Foo' "'' bar" 'bar 42')
Parse: done.
var=x, value=Example.Foo
var=, value=bar
var=bar, value=42
name:NULL type:CHOICE
name:bar type:INTEGER value:0x2a
Coding: SUCCESS
-----------------
Number of bytes=3
02 01 2a
-----------------
OutputFile=/dev/null
Writing: done.
$ cat < asn.1
Example { } DEFINITIONS EXPLICIT TAGS ::=
BEGIN
Null ::= NULL
Foo ::= CHOICE {
bar INTEGER,
baz GeneralString
}
END
$
--
FSF associate member #7257
- asn1Decoding(1) fails to decode a CHOICE?, Ivan Shmakov, 2012/10/04
- Re: asn1Decoding(1) fails to decode a CHOICE?, Nikos Mavrogiannopoulos, 2012/10/06
- Re: asn1Decoding(1) fails to decode a CHOICE?, Ivan Shmakov, 2012/10/06
- Re: asn1Decoding(1) fails to decode a CHOICE?, Nikos Mavrogiannopoulos, 2012/10/06
- Re: asn1Decoding(1) fails to decode a CHOICE?, Ivan Shmakov, 2012/10/06
- Re: asn1Decoding(1) fails to decode a CHOICE?, Nikos Mavrogiannopoulos, 2012/10/07
- Re: asn1Decoding(1) fails to decode a CHOICE?, Ivan Shmakov, 2012/10/07
- Re: asn1Decoding(1) fails to decode a CHOICE?, Nikos Mavrogiannopoulos, 2012/10/07
- PRIVATE tags handling, Ivan Shmakov, 2012/10/08
- [SOLVED] PRIVATE tags handling, Ivan Shmakov, 2012/10/08
asn1Coding(1) a CHOICE,
Ivan Shmakov <=