static STACK_OF(CMS_RevocationInfoChoice)
**cms_get0_revocation_choices(CMS_ContentInfo *cms)
{
switch (OBJ_obj2nid(cms->contentType)) {
case NID_pkcs7_signed:
return &cms->d.signedData->crls;
Another question says it's
#define STACK_OF(type) struct stack_st_##type
But when I search the openssl code with regex #define\s*STACK_OF
I do not find any entries.
What is STACK_OF
?
CodePudding user response:
"Stacks" are the way OpenSSL handles a set/array of objects. They are macro-accessed structures that provide the ability to operate on those objects.
The STACK_OF()
macro is defined as:
# define STACK_OF(type) struct stack_st_##type
For the X509
type, the structure is defined as:
struct x509_st {
X509_CINF cert_info;
X509_ALGOR sig_alg;
.
.
.
char *propq;
} /* X509 */ ;
Per the OpenSSL Wiki:
STACK API
The stack library provides a generic way to handle collections of objects in OpenSSL. A comparison function can be registered to sort the collection.
Interface is split in two headers, <openssl/stack.h> and <openssl/safestack.h>. The former declares the C functions that will execute the insert, delete, pop, push, and other operations on the stack, while the latter declares a bunch of macros to enforce some type-checking by the compiler; these macros are mostly auto-generated by mkstack.pl.
It is highly discouraged to use the C functions declared in <openssl/stack.h>. Rather, use the macros defined in <openssl/safestack.h> for OpenSSL built-in stacks, and declare your own type-checking wrappers for your custom stacks.
Basic Use
A stack type is defined with the DECLARE_STACK_OF() macro and its instances are declared with the STACK_OF() macro.
...