Thank you Jimmy and Stephen!

Thanks to your answer, I've finally been able to parse countersignatures at
any depth!

Regards,
Massimiliano Ziccardi

On Tue, May 20, 2008 at 5:43 PM, Dr. Stephen Henson <[EMAIL PROTECTED]>
wrote:

> On Tue, May 20, 2008, Massimiliano Ziccardi wrote:
>
> > I'm sure OpenSSL is able to parse more than one counter signature per
> > signature.
> >
> > Can pleas some OpenSSL expert tell me how to do it? I think the code I
> sent
> > in the previous
> > e-mail should be close to the solution. I just need to know how to get
> the
> > other counter signatures
> > (I already did in Java with Bouncycastle, and it has been
> straightforward).
> >
> > I've searched through the net for some documentation, but, as stated on
> the
> > site, the OpenSSL documentation
> > is very incomplete, and I couldn't find any useful information.
> >
>
> Unfortunately the attribute handling functions are undocumented at present.
> They opearate in a manner similar to the documented X509_NAME functions
> though.
>
> This is an outline of what you do....
>
> If you call PKCS7_get_attributes() you will get back a
> STACK_OF(X509_ATTRIBUTE). Using that you can look through it using the
> attribute utility functions.
>
> int X509at_get_attr_by_NID(const STACK_OF(X509_ATTRIBUTE) *x, int nid,
>                          int lastpos);
>
>
> You loop round calling X509at_get_attr_by_NID() to retrieve the index of
> each
> countersignature attribute, you get -1 when no more can be found. You set
> lastpos to the last index or -1 initially.
>
> For each index you can get the corresponding attribute with:
>
> X509_ATTRIBUTE *X509at_get_attr(const STACK_OF(X509_ATTRIBUTE) *x, int
> loc);
>
> Then for each X509_ATTRIBUTE you can retrieve the count of attributes with
> X509_ATTRIBUTE_count(). Then each individual using:
>
> void *X509_ATTRIBUTE_get0_data(X509_ATTRIBUTE *attr, int idx,
>                                        int atrtype, void *data);
>
> You set idx to the index of each one (starting from zero) atrtype to
> V_ASN1_SEQUENCE and you get back an ASN1_STRING structure or NULL if the
> type
> isn't a SEQUENCE: that shouldn't happen unless the countersignature is
> malformed.
>
> The for each string you parse the countersignature as before.
>
> 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