openssl-什么是stack_of?

发布于 2025-02-09 20:34:43 字数 727 浏览 1 评论 0 原文

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;

问题说是,

#define STACK_OF(type) struct stack_st_##type

但是当我搜索Regex ###时,我搜索OpenSSL代码时定义\ s*stack_of 我找不到任何条目。

什么是 stack_of

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;

source

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

世界和平 2025-02-16 20:34:43

“堆栈”是OpenSSL处理对象的集合/数组的方式。它们是宏观访问的结构,可提供在这些对象上操作的能力。

macro is defined as:

# define STACK_OF(type) struct stack_st_##type

For the X509 type,

struct x509_st {
    X509_CINF cert_info;
    X509_ALGOR sig_alg;
      .
      .
      .
    char *propq;
} /* X509 */ ;

per openssl wiki

堆栈API

堆栈库提供了一种处理收集的通用方法
OpenSSL中的对象。可以注册比较功能进行排序
收藏。

接口分为两个标题,< openssl/stack.h>和
< openssl/safestack.h>。前者声明C函数将
执行插入,删除,pop,push和其他操作
堆栈,而后者则宣布一堆宏来强制执行一些
编译器的类型检查;这些宏主要是自动生成的
由mkstack.pl。

高度不鼓励使用在
< openssl/stack.h>。而是使用定义的宏
< openssl/safestack.h>对于OpenSSL内置堆栈,并声明您的
您的自定义堆栈的类型检查包装器。

基本用途

用dectare_stack_of()宏定义了堆栈类型及其
用stack_of()宏来声明实例。

...

"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.

...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文