请给出openssl 库pkcs9.h 和pkcs9.c的源码
时间: 2024-03-05 16:48:09 浏览: 103
以下是 OpenSSL 库中 pkcs9.h 文件的基本结构:
#ifndef OPENSSL_PKCS9
#define OPENSSL_PKCS9_H
#include <openssl/asn1.h>
#include <openssl/x509.h>
#ifdef __cplusplus
extern "C" {
#endif
/* PKCS#9 extended certificates attributes */
#define SMIME_CAPABILITY_NONE 0
#define SMIME_CAPABILITY_RC2_CBC_40 1
#define SMIME_CAPABILITY_RC2_CBC_64 2
#define SMIME_CAPABILITY_RC2_CBC_128 3
#define SMIME_CAPABILITY_DES_EDE3_CBC 4
#define SMIME_CAPABILITY_AES_128_CBC 5
#define SMIME_CAPABILITY_AES_192_CBC 6
#define SMIME_CAPABILITY_AES_256_CBC 7
#define SMIME_CAPABILITY_CAMELLIA_128_CBC 8
#define SMIME_CAPABILITY_CAMELLIA_192_CBC 9
#define SMIME_CAPABILITY_CAMELLIA_256_CBC 10
typedef struct SMIME_capability_st {
int algorithm;
STACK_OF(ASN1_OBJECT) *parameters;
} SMIME_capability;
typedef STACK_OF(SMIME_capability) SMIME_CAPABILITIES;
DECLARE_STACK_OF(SMIME_capability)
typedef struct SMIMECapabilities_st {
SMIME_CAPABILITIES *capabilities;
} SMIME_CAPABILITIES_SIGNED;
DECLARE_ASN1_FUNCTIONS(SMIME_CAPABILITIES_SIGNED)
DECLARE_ASN1_PRINT_FUNCTION(SMIME_CAPABILITIES_SIGNED)
typedef struct SMIMECapability_unwrapped_st {
ASN1_OBJECT *capabilityID;
ASN1_TYPE *parameters;
} SMIMECapability_unwrapped;
DECLARE_STACK_OF(SMIMECapability_unwrapped)
DECLARE_ASN1_FUNCTIONS(SMIMECapability_unwrapped)
typedef struct SMIMECapabilities_unwrapped_st {
SMIMECapability_unwrapped *capabilities;
} SMIMECapabilities_unwrapped;
DECLARE_ASN1_FUNCTIONS(SMIMECapabilities_unwrapped)
DECLARE_ASN1_PRINT_FUNCTION(SMIMECapabilities_unwrapped)
#ifdef __cplusplus
}
#endif
#endif /* OPENSSL_PKCS9_H */
以下是 OpenSSL 库中 pkcs9.c 文件的部分源码:
#include "pkcs9.h"
ASN1_SEQUENCE(SMIMECapability) = {
ASN1_SIMPLE(SMIMECapability, algorithm, ASN1_OBJECT),
ASN1_SET_OF_OPT(SMIMECapability, parameters, ASN1_TYPE)
} ASN1_SEQUENCE_END(SMIMECapability)
IMPLEMENT_ASN1_FUNCTIONS(SMIMECapability)
ASN1_SEQUENCE(SMIMECapabilities) = {
ASN1_SET_OF(SMIMECapabilities, capabilities, SMIMECapability)
} ASN1_SEQUENCE_END(SMIMECapabilities)
IMPLEMENT_ASN1_FUNCTIONS(SMIMECapabilities)
ASN1_SEQUENCE(SMIMECapability_unwrapped) = {
ASN1_SIMPLE(SMIMECapability_unwrapped, capabilityID, ASN1_OBJECT),
ASN1_SIMPLE(SMIMECapability_unwrapped, parameters, ASN1_ANY)
} ASN1_SEQUENCE_END(SMIMECapability_unwrapped)
IMPLEMENT_ASN1_FUNCTIONS(SMIMECapability_unwrapped)
ASN1_SEQUENCE(SMIMECapabilities_unwrapped) = {
ASN1_SET_OF(SMIMECapabilities_unwrapped, capabilities, SMIMECapability_unwrapped)
} ASN1_SEQUENCE_END(SMIMECapabilities_unwrapped)
IMPLEMENT_ASN1_FUNCTIONS(SMIMECapabilities_unwrapped)
int SMIME_write_CMS(BIO *bio, CMS_ContentInfo *cms)
{
/* Write out the ContentInfo */
if (!i2d_CMS_ContentInfo_bio(bio, cms))
return 0;
/* Write out any detached content */
if (cms->d.enveloped->enc_data->enc_data)
return 1;
return BIO_write(bio, cms->d.enveloped->enc_data->enc_data->data,
cms->d.enveloped->enc_data->enc_data->length);
}
注意:以上代码仅供参考,实际使用时可能需要进行适当修改。
相关推荐
















