1

在 openssl C 代码中,(aes_core.c、set_key.c、spr.h 等)有“__fips_constseg”。

我不知道“__fips_constseg”的意思。

它的作用是什么?是汇编代码吗?

源代码如下:


#include <openssl/crypto.h>

#include "des_locl.h"

OPENSSL_IMPLEMENT_GLOBAL(int,DES_check_key,0) /* 默认为 false */

__fips_constseg

静态常量无符号字符奇偶校验[256]={};


4

1 回答 1

2

从 OpenSSL 源代码:

crypto/crypto.h

#if defined(OPENSSL_FIPSCANISTER)
# include <openssl/fipssyms.h>
#else
# define __fips_constseg
#endif

fips/fipssyms.h

#if defined(_MSC_VER)
# pragma const_seg("fipsro$b")
# pragma const_seg()
# define __fips_constseg __declspec(allocate("fipsro$b"))
#else
# define __fips_constseg
#endif

因此,__fips_constseg常数仅定义为一个值,如果

  • OPENSSL_FIPSCANISTER被定义并且
  • 代码是使用 Microsoft C 编译器编译的(可以通过定义的_MSC_VER常量来检测)。

然后,将标有该常量的代码放在名为的常量数据段中fipsro$b(有关详细信息,请参阅MSDN 文档中的allocate说明符)。

如果不满足上述任何条件,则将其__fips_constseg定义为空,因此标有该常量的变量将放入它们通常所在的数据段中。

于 2013-08-13T08:32:30.287 回答