Is there documentation (aside from looking at the header files) on how to
use things like STACK_OF(type) and the sk_*_find() functions?
Perhaps I'm going about it wrong, but I can't figure it out.
Any help would be most apprecianted. I'm trying to do this:
given a STACK_OF(PKCS12_SAFEBAG) instance and a
STACK_OF(X509_ATTRIBUTES) instance, I'm trying to find the
safebag which has all of the attributes in the given attribute stack. So,
here's the code pseudo-code (omitting return values):
void find_bag(STACK_OF(PKCS12_SAFEBAG) *bags,
STACK_OF(X509_ATTRIBUTES) *attribs) {
foreach (s in safebag) {
bag_attribs = safebag[s]->attrib;
foreach (i in attribs) {
attrib = sk_X509_ATTRIBUTE_value(attribs, i);
if ((attrib_pos = sk_X509_ATTRIBUTE_find(bag_attribs, attrib)) < 0) {
printf("couldn't find attrib %d\n", i);
return;
} else {
printf("FOUND attrib at position %d\n", attrib_pos);
}
}
/* all given attributes found in this bag */
printf("bag %d has all the attributes, it's the one you want", s);
}
The sk_X509_ATTRIBUTE_find() *always* returns -1. I believe this is
because the base OpenSSL installation does not include a compare function
for the X509_ATTRIBUTE type, so the sk_*_find function can't find an
X509_ATTRIBUTE given a STACK_OF them. I tried declaring a compare
function myself with the signature:
int my_cmp(X509_ATTRIBUTE *a, X509_ATTRIBUTE *b);
but when it's called during the sk_*_find invocation, it is passing invalid
arguments (i.e. they're not pointers to X509_ATTRIBUTE structures).
Anyone have any idea of a better way to do this, or if there is indeed a good
X509_ATTRIBUTE compare function I can use when calling the sk_* functions
when dealing with X509_ATTRIBUTES?
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List [EMAIL PROTECTED]
Automated List Manager [EMAIL PROTECTED]