Hi Stephen.
Thank you very much!

This is my code (just a snippet):

STACK_OF(X509_ATTRIBUTE)* unauth_attr = pSignerInfo->unauth_attr;
ASN1_TYPE *res = PKCS7_get_attribute(m_pSignerInfo,
NID_pkcs9_countersignature);

Now, res should point to a SEQUENCE of COUNTER SIGNATUREs.

You told:

>You need to extract the ASN1_STRING structure form ASN1_TYPE and then its
data
>and length

you mean:

res->value.sequence->data
res->value.sequence->length

?

Then:

>If you want to see if there is more
>than one you need to loop round all attributes of the correct type.

If I'm not wrong, those counter signatures should be all inside the same
ASN1 Sequence, right?
How can I loop through all the ASN1 Sequence elements?

Thanks you very much!

Regards,
Massimiliano Ziccardi

On Mon, May 19, 2008 at 12:17 PM, Dr. Stephen Henson <[EMAIL PROTECTED]>
wrote:

> On Mon, May 19, 2008, Massimiliano Ziccardi wrote:
>
> > Hi all.
> >
> > Here is my problem.
> >
> > I have a P7M file with 2 signatures. Every signature contains a
> > countersignature.
> >
> > I've already successfully parsed the P7M file, and I've got the two
> > Signature infos.
> >
> > What I do next is:
> >
> > ASN1_TYPE *res = PKCS7_get_attribute(m_pSignerInfo,
> > NID_pkcs9_countersignature);
> > printf ("SEQUENCE  ? %d\n", V_ASN1_SEQUENCE == res->type);
> >
> > The output is
> >
> > SEQUENCE ? 1
> >
> > So, I'm sure I got an ASN1_SEQUENCE.
> >
> > How can I loop through the values of the sequence? Do I have to convert
> it
> > to a STACK_OF(PKCS7_SIGNER_INFO)  ? If yes, how can I do it (sorry, I'm
> not
> > very expert about OpenSSL...) ?
> >
>
> You need to extract the ASN1_STRING structure form ASN1_TYPE and then its
> data
> and length. If you pass those through d2i_PKCS7_SIGNER_INFO() you'll get
> the
> parsed structure.
>
> Note that the above will only retrieve a single countersignature. There
> could
> be more than on per SignerInfo structure. If you want to see if there is
> more
> than one you need to loop round all attributes of the correct type.
>
> Steve.
> --
> Dr Stephen N. Henson. Email, S/MIME and PGP keys: see homepage
> OpenSSL project core developer and freelance consultant.
> Homepage: http://www.drh-consultancy.demon.co.uk
> ______________________________________________________________________
> OpenSSL Project                                 http://www.openssl.org
> User Support Mailing List                    [email protected]
> Automated List Manager                           [EMAIL PROTECTED]
>

Reply via email to