<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hello,<div class=""><br class=""></div><div class="">You can do something like the following.</div><div class=""><br class=""></div><div class="">First make a type corresponding to a stack of x509 attributes:</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>typedef STACK_OF(X509_ATTRIBUTE) SEQ_X509_ATTRIBUTE;</div><div class=""><span class="Apple-tab-span" style="white-space:pre">      </span>DECLARE_ASN1_FUNCTIONS(SEQ_X509_ATTRIBUTE);</div><div class=""><br class=""></div><div class="">Then make an asn1 template that specifies how the stack should be encoded.  (You can use ASN1_TFLG_SET_OF instead of ..SEQUENCE_OF here, depending on the DER you're trying to interpret, I don't know.)</div><div class=""><br class=""></div><div class=""><div class=""><span class="Apple-tab-span" style="white-space:pre">    </span>ASN1_ITEM_TEMPLATE(SEQ_X509_ATTRIBUTE) =</div><div class=""><span class="Apple-tab-span" style="white-space:pre">          </span>ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, x509attribute, X509_ATTRIBUTE)</div><div class=""><span class="Apple-tab-span" style="white-space:pre">    </span>ASN1_ITEM_TEMPLATE_END(SEQ_X509_ATTRIBUTE)</div></div><div class=""><span class="Apple-tab-span" style="white-space:pre">    </span>IMPLEMENT_ASN1_FUNCTIONS(SEQ_X509_ATTRIBUTE)</div><div class=""><br class=""></div><div class="">Now your type has its own d2i and i2d functions, and you can use them:</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>STACK_OF(X509_ATTRIBUTE) *attrs = d2i_SEQ_X509_ATTRIBUTE(NULL, &data, length);</div><div class=""><br class=""></div><div class="">Cheers,</div><div class="">  -Dave</div><div class=""><br class=""></div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Nov 15, 2017, at 07:26, Libor Chocholaty <<a href="mailto:ossl@mts.cz" class="">ossl@mts.cz</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" class=""><div style="font-size: 10pt; font-family: Verdana,Geneva,sans-serif" class=""><p class="">Hello,</p><p class="">I would like to parse DER encoded x509 attributes and have no clue how to use d2i_ASN1_SET_OF_X509_ATTRIBUTE. There are params that cannot find what to pass like free_func.</p><p class="">I am trying to uderstand by collecting pieces of known code, looking into openssl sources but...</p><p class="">PKCS7_SIGNER_INFO *p7si = PKCS7_SIGNER_INFO_new();<br class="">d2i_ASN1_SET_OF_X509_ATTRIBUTE(&p7si->auth_attr, &der_data, der_data_length, d2i_X509_ATTRIBUTE, free_func, V_ASN1_SET, V_ASN1_UNIVERSAL);</p><p class="">Could somebody help how to do it or give a link to some useful documentation?<br class="">Search internet looks completely not useful in this topic... or do not know how to ask...</p><p class="">Regards,<br class="">Libor</p>
<div class=""> </div>
</div>
-- <br class="">openssl-users mailing list<br class="">To unsubscribe: <a href="https://mta.openssl.org/mailman/listinfo/openssl-users" class="">https://mta.openssl.org/mailman/listinfo/openssl-users</a><br class=""></div></blockquote></div><br class=""></div></body></html>