[openssl-users] ASN1 & Recursive Structures definition
Dr. Pala
madwolf at openca.org
Sat Dec 2 03:22:09 UTC 2017
Hi Richard,
thanks :D That worked. I have a new challenge for you now. Here's what I
am trying to do:
ASN1_SEQUENCE(TEST);
ASN1_SEQUENCE(TBS_TEST) = {
ASN1_SIMPLE(TBS_TEST, version, ASN1_INTEGER),
ASN1_EXP_SEQUENCE_OF_OPT(TBS_TEST, otherTests, TEST, 0)
} ASN1_SEQUENCE_END(TEST)
IMPLEMENT_ASN1_FUNCTIONS(TBS_TEST) [**]
ASN1_SEQUENCE(TEST) = {
ASN1_SIMPLE(TEST, tbsTest, ASN1_INTEGER),
ASN1_EXP_OPT(TEST, optionalSignature, TEST_SIGNATURE, 0)
} ASN1_SEQUENCE_END(TEST)
IMPLEMENT_ASN1_FUNCTIONS(TEST) [**]
In this case, the difference is that TBS_TEST has, inside the otherTests
that are of type TEST. The TEST is built out of a tbsTest and an
optionalSignature - but it is defined after TBS_TEST.
What to do in this case ?
Cheers,
Max
On 12/1/17 4:22 PM, Richard Levitte wrote:
> In message <2c480bc2-3367-38e9-f4d8-3e7b37e42cb8 at openca.org> on Fri, 1 Dec 2017 12:14:54 -0700, "Dr. Pala" <director at openca.org> said:
>
> director> I am trying to define an ASN1 structure similar to this:
> director>
> director> ASN1_SEQUENCE(TEST) = {
> director> ASN1_SIMPLE(TEST, version, ASN1_INTEGER),
> director> ASN1_EXP_SEQUENCE_OF_OPT(TEST, otherTests, TEST, 0)
> director> } ASN1_SEQUENCE_END(TEST)
> director>
> director> IMPLEMENT_ASN1_FUNCTIONS(TEST) [**]
> director>
> director> what is the correct procedure for doing that ? The problem
> director> is that the "otherTests" field should be a sequence of
> director> "TEST" structures, but defined like that it won't work.
> director>
> director> Is there a way to solve the issue ? Or shall we use
> director> something like ASN1_ANY to avoid the circular reference ?
>
> Nope... all it takes is a forward declaration:
>
> ASN1_SEQUENCE(TEST);
> ASN1_SEQUENCE(TEST) = {
> ASN1_SIMPLE(TEST, version, ASN1_INTEGER),
> ASN1_EXP_SEQUENCE_OF_OPT(TEST, otherTests, TEST, 0)
> } ASN1_SEQUENCE_END(TEST)
>
> IMPLEMENT_ASN1_FUNCTIONS(TEST)
>
> (I tested that just now)
>
> Cheers,
> Richard
>
More information about the openssl-users
mailing list