Re: [openssl-users] ASN1 & Recursive Structures definition

2017-12-04 Thread Richard Levitte
Ah, sorry then, I may have been wrong.  The forward declaration that's
actually needed seems to be this (one for each applicable type):

DECLARE_ASN1_ITEM(TEST)

(I'm digging through the ASN.1 stuff myself, slowly learning)

Cheers,
Richard

In message <0089b413-278e-34b1-32b3-2e71b48e5...@openca.org> on Sun, 3 Dec 2017 
11:37:56 -0700, "Dr. Pala"  said:

madwolf> Hi Richard, all,
madwolf> 
madwolf> I tried to do the forward declaration also for the TEST_SIGNATURE 
together with the TEST one, but
madwolf> that did not really work :( It is still complaining about the use of 
'sizeof' on an incomplete type. In
madwolf> particular, the two errors are:
madwolf> 
madwolf>  src/ocspv2/: error: use of undeclared identifier 'TEST_it'
madwolf>  ASN1_EXP_SEQUENCE_OF_OPT(TEST_TBS, otherTests, TEST, 5),
madwolf>  ^
madwolf> 
madwolf>  and
madwolf> 
madwolf>  src/ocspv2/: error: invalid application of 'sizeof' to an 
incomplete type 'const
madwolf>  ASN1_TEMPLATE []'
madwolf>  } ASN1_SEQUENCE_END(TEST_TBS)
madwolf>  ^~~~
madwolf> 
madwolf> I guess I need to checkout the macros a bit more.. :D
madwolf> 
madwolf> Question: does anybody know if there is any other structure already 
implemented in OpenSSL that
madwolf> resembles the one I am trying to do here? I tried to look for 
something similar, but no success.. :D
madwolf> 
madwolf> If there is no easy answer, I guess I will have to either change the 
envisioned approach (maybe
madwolf> introducing an intermediate data structure of some kind..?) or use the 
ASN1_ANY approach.
madwolf> 
madwolf> Cheers,
madwolf> Max
madwolf> 
madwolf> On 12/2/17 4:54 AM, Richard Levitte wrote:
madwolf> 
madwolf>  In message  on Fri, 
1 Dec 2017 20:22:09 -0700,
madwolf>  "Dr. Pala"  said:
madwolf> 
madwolf> madwolf> Hi Richard,
madwolf> madwolf>
madwolf> madwolf> thanks :D That worked. I have a new challenge for you now. 
Here's what
madwolf> madwolf> I am trying to do:
madwolf> madwolf>
madwolf> madwolf> ASN1_SEQUENCE(TEST);
madwolf> madwolf> ASN1_SEQUENCE(TBS_TEST) = {
madwolf> madwolf> ASN1_SIMPLE(TBS_TEST, version, ASN1_INTEGER),
madwolf> madwolf> ASN1_EXP_SEQUENCE_OF_OPT(TBS_TEST, otherTests, TEST, 0)
madwolf> madwolf> } ASN1_SEQUENCE_END(TEST)
madwolf> madwolf>
madwolf> madwolf> IMPLEMENT_ASN1_FUNCTIONS(TBS_TEST) [**]
madwolf> madwolf>
madwolf> madwolf> ASN1_SEQUENCE(TEST) = {
madwolf> madwolf> ASN1_SIMPLE(TEST, tbsTest, ASN1_INTEGER),
madwolf> madwolf> ASN1_EXP_OPT(TEST, optionalSignature, TEST_SIGNATURE, 0)
madwolf> madwolf> } ASN1_SEQUENCE_END(TEST)
madwolf> madwolf>
madwolf> madwolf> IMPLEMENT_ASN1_FUNCTIONS(TEST) [**]
madwolf> madwolf>
madwolf> madwolf> In this case, the difference is that TBS_TEST has, inside the
madwolf> madwolf> otherTests that are of type TEST. The TEST is built out of a 
tbsTest
madwolf> madwolf> and an optionalSignature - but it is defined after TBS_TEST.
madwolf> madwolf>
madwolf> madwolf> What to do in this case ?
madwolf> 
madwolf> It seems to me that you need to do some kind of forward declaration of
madwolf> TEST_SIGNATURE as well, before the construction of TEST.  (also, to be
madwolf> picky, you need to make sure that ASN1_SEQUENCE(TBS_TEST) is ended
madwolf> with ASN1_SEQUENCE_END(TBS_TEST), not ASN1_SEQUENCE_END(TEST))
madwolf> 
madwolf> Cheers,
madwolf> Richard
madwolf> 
-- 
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users


Re: [openssl-users] ASN1 & Recursive Structures definition

2017-12-03 Thread Dr. Pala

Hi Richard, all,

I tried to do the forward declaration also for the TEST_SIGNATURE 
together with the TEST one, but that did not really work :( It is still 
complaining about the use of 'sizeof' on an incomplete type. In 
particular, the two errors are:


   src/ocspv2/: error: use of undeclared identifier 'TEST_it'
   ASN1_EXP_SEQUENCE_OF_OPT(TEST_TBS, otherTests, TEST, 5),
   ^

   and

   src/ocspv2/: error: invalid application of 'sizeof' to an
   incomplete type 'const ASN1_TEMPLATE []'
   } ASN1_SEQUENCE_END(TEST_TBS)
   ^~~~

I guess I need to checkout the macros a bit more.. :D

Question: does anybody know if  there is any other structure already 
implemented in OpenSSL that resembles the one I am trying to do here? I 
tried to look for something similar, but no success.. :D


If there is no easy answer, I guess I will have to either change the 
envisioned approach (maybe introducing an intermediate data structure of 
some kind..?) or use the ASN1_ANY approach.


Cheers,
Max


On 12/2/17 4:54 AM, Richard Levitte wrote:

In message  on Fri, 1 Dec 2017 20:22:09 -0700, 
"Dr. Pala"  said:

madwolf> Hi Richard,
madwolf>
madwolf> thanks :D That worked. I have a new challenge for you now. Here's what
madwolf> I am trying to do:
madwolf>
madwolf> ASN1_SEQUENCE(TEST);
madwolf> ASN1_SEQUENCE(TBS_TEST) = {
madwolf> ASN1_SIMPLE(TBS_TEST, version, ASN1_INTEGER),
madwolf> ASN1_EXP_SEQUENCE_OF_OPT(TBS_TEST, otherTests, TEST, 0)
madwolf> } ASN1_SEQUENCE_END(TEST)
madwolf>
madwolf> IMPLEMENT_ASN1_FUNCTIONS(TBS_TEST) [**]
madwolf>
madwolf> ASN1_SEQUENCE(TEST) = {
madwolf> ASN1_SIMPLE(TEST, tbsTest, ASN1_INTEGER),
madwolf> ASN1_EXP_OPT(TEST, optionalSignature, TEST_SIGNATURE, 0)
madwolf> } ASN1_SEQUENCE_END(TEST)
madwolf>
madwolf> IMPLEMENT_ASN1_FUNCTIONS(TEST) [**]
madwolf>
madwolf> In this case, the difference is that TBS_TEST has, inside the
madwolf> otherTests that are of type TEST. The TEST is built out of a tbsTest
madwolf> and an optionalSignature - but it is defined after TBS_TEST.
madwolf>
madwolf> What to do in this case ?

It seems to me that you need to do some kind of forward declaration of
TEST_SIGNATURE as well, before the construction of TEST.  (also, to be
picky, you need to make sure that ASN1_SEQUENCE(TBS_TEST) is ended
with ASN1_SEQUENCE_END(TBS_TEST), not ASN1_SEQUENCE_END(TEST))

Cheers,
Richard



-- 
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users


Re: [openssl-users] ASN1 & Recursive Structures definition

2017-12-02 Thread Richard Levitte
In message  on Fri, 1 Dec 2017 
20:22:09 -0700, "Dr. Pala"  said:

madwolf> Hi Richard,
madwolf> 
madwolf> thanks :D That worked. I have a new challenge for you now. Here's what
madwolf> I am trying to do:
madwolf> 
madwolf> ASN1_SEQUENCE(TEST);
madwolf> ASN1_SEQUENCE(TBS_TEST) = {
madwolf> ASN1_SIMPLE(TBS_TEST, version, ASN1_INTEGER),
madwolf> ASN1_EXP_SEQUENCE_OF_OPT(TBS_TEST, otherTests, TEST, 0)
madwolf> } ASN1_SEQUENCE_END(TEST)
madwolf> 
madwolf> IMPLEMENT_ASN1_FUNCTIONS(TBS_TEST) [**]
madwolf> 
madwolf> ASN1_SEQUENCE(TEST) = {
madwolf> ASN1_SIMPLE(TEST, tbsTest, ASN1_INTEGER),
madwolf> ASN1_EXP_OPT(TEST, optionalSignature, TEST_SIGNATURE, 0)
madwolf> } ASN1_SEQUENCE_END(TEST)
madwolf> 
madwolf> IMPLEMENT_ASN1_FUNCTIONS(TEST) [**]
madwolf> 
madwolf> In this case, the difference is that TBS_TEST has, inside the
madwolf> otherTests that are of type TEST. The TEST is built out of a tbsTest
madwolf> and an optionalSignature - but it is defined after TBS_TEST.
madwolf> 
madwolf> What to do in this case ?

It seems to me that you need to do some kind of forward declaration of
TEST_SIGNATURE as well, before the construction of TEST.  (also, to be
picky, you need to make sure that ASN1_SEQUENCE(TBS_TEST) is ended
with ASN1_SEQUENCE_END(TBS_TEST), not ASN1_SEQUENCE_END(TEST))

Cheers,
Richard

-- 
Richard Levitte levi...@openssl.org
OpenSSL Project http://www.openssl.org/~levitte/
-- 
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users


Re: [openssl-users] ASN1 & Recursive Structures definition

2017-12-01 Thread Dr. Pala

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-3e7b37e42...@openca.org> on Fri, 1 Dec 2017 12:14:54 -0700, 
"Dr. Pala"  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



--
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users


Re: [openssl-users] ASN1 & Recursive Structures definition

2017-12-01 Thread Richard Levitte
In message <2c480bc2-3367-38e9-f4d8-3e7b37e42...@openca.org> on Fri, 1 Dec 2017 
12:14:54 -0700, "Dr. Pala"  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

-- 
Richard Levitte levi...@openssl.org
OpenSSL Project http://www.openssl.org/~levitte/
-- 
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users


[openssl-users] ASN1 & Recursive Structures definition

2017-12-01 Thread Dr. Pala

Hi all,

I am trying to define an ASN1 structure similar to this:

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) [**]

what is the correct procedure for doing that ? The problem is that the 
"otherTests" field should be a sequence of "TEST" structures, but 
defined like that it won't work.


Is there a way to solve the issue ? Or shall we use something like 
ASN1_ANY to avoid the circular reference ?


Cheers,
Max

[**] = For completeness, that is what is defined in the test.c - in 
test.h we define the struct as usual


    struct test_st;
typedef struct test_st TEST;

    typedef struct test_st {
ASN1_INTEGER * version;
STACK_OF(TEST) * otherTests;
} TEST;

    DECLARE_ASN1_FUNCTIONS(TEST)

--
Best Regards,
Massimiliano Pala, Ph.D.
OpenCA Labs Director
OpenCA Logo
-- 
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users