![](https://csdnimg.cn/release/download_crawler_static/86858930/bg1.jpg)
openssl 学习笔记之 pkcs7-1
1. 概述
openssl 之 pkcs7 介绍
openssl实现了 pkcs7(加密消息语法标准)。在中。
p7 包 括 6 种 数 据 内 容 : 数 据 (data), 签 名 数 据 ( sign ), 数 字 信 封 数 据 ( enveloped ), 签 名 数 字 信 封 数 据
(signed_and_enveloped),摘要数据(digest),加密数据(encrypted)。
后面将一一介绍如何对 6 种数据类型进行封装。
PKCS7 结构体定义如下:
typedef struct pkcs7_st
{
/* The following is non NULL if it contains ASN1 encoding of
* this structure */
unsigned char *asn1;
long length;
#define PKCS7_S_HEADER 0
#define PKCS7_S_BODY 1
#define PKCS7_S_TAIL 2
int state; /* used during processing */
int detached;
ASN1_OBJECT *type;
/* content as defined by the type */
/* all encryption/message digests are applied to the 'contents',
* leaving out the 'type' field. */
union {
char *ptr;
/* NID_pkcs7_data */
ASN1_OCTET_STRING *data;
/* NID_pkcs7_signed */
PKCS7_SIGNED *sign;
/* NID_pkcs7_enveloped */
PKCS7_ENVELOPE *enveloped;
/* NID_pkcs7_signedAndEnveloped */
PKCS7_SIGN_ENVELOPE *signed_and_enveloped;
/* NID_pkcs7_digest */
PKCS7_DIGEST *digest;