⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cms_asn1.c

📁 OpenSSL 0.9.8k 最新版OpenSSL
💻 C
📖 第 1 页 / 共 2 页
字号:
/* crypto/cms/cms_asn1.c *//* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. *//* ==================================================================== * Copyright (c) 2008 The OpenSSL Project.  All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions and the following disclaimer.  * * 2. Redistributions in binary form must reproduce the above copyright *    notice, this list of conditions and the following disclaimer in *    the documentation and/or other materials provided with the *    distribution. * * 3. All advertising materials mentioning features or use of this *    software must display the following acknowledgment: *    "This product includes software developed by the OpenSSL Project *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to *    endorse or promote products derived from this software without *    prior written permission. For written permission, please contact *    licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" *    nor may "OpenSSL" appear in their names without prior written *    permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following *    acknowledgment: *    "This product includes software developed by the OpenSSL Project *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. * ==================================================================== */#include <openssl/asn1t.h>#include <openssl/pem.h>#include <openssl/x509v3.h>#include "cms.h"#include "cms_lcl.h"ASN1_SEQUENCE(CMS_IssuerAndSerialNumber) = {	ASN1_SIMPLE(CMS_IssuerAndSerialNumber, issuer, X509_NAME),	ASN1_SIMPLE(CMS_IssuerAndSerialNumber, serialNumber, ASN1_INTEGER)} ASN1_SEQUENCE_END(CMS_IssuerAndSerialNumber)ASN1_SEQUENCE(CMS_OtherCertificateFormat) = {	ASN1_SIMPLE(CMS_OtherCertificateFormat, otherCertFormat, ASN1_OBJECT),	ASN1_OPT(CMS_OtherCertificateFormat, otherCert, ASN1_ANY)} ASN1_SEQUENCE_END(CMS_OtherCertificateFormat)ASN1_CHOICE(CMS_CertificateChoices) = {	ASN1_SIMPLE(CMS_CertificateChoices, d.certificate, X509),	ASN1_IMP(CMS_CertificateChoices, d.extendedCertificate, ASN1_SEQUENCE, 0),	ASN1_IMP(CMS_CertificateChoices, d.v1AttrCert, ASN1_SEQUENCE, 1),	ASN1_IMP(CMS_CertificateChoices, d.v2AttrCert, ASN1_SEQUENCE, 2),	ASN1_IMP(CMS_CertificateChoices, d.other, CMS_OtherCertificateFormat, 3)} ASN1_CHOICE_END(CMS_CertificateChoices)ASN1_CHOICE(CMS_SignerIdentifier) = {	ASN1_SIMPLE(CMS_SignerIdentifier, d.issuerAndSerialNumber, CMS_IssuerAndSerialNumber),	ASN1_IMP(CMS_SignerIdentifier, d.subjectKeyIdentifier, ASN1_OCTET_STRING, 0)} ASN1_CHOICE_END(CMS_SignerIdentifier)ASN1_NDEF_SEQUENCE(CMS_EncapsulatedContentInfo) = {	ASN1_SIMPLE(CMS_EncapsulatedContentInfo, eContentType, ASN1_OBJECT),	ASN1_NDEF_EXP_OPT(CMS_EncapsulatedContentInfo, eContent, ASN1_OCTET_STRING_NDEF, 0)} ASN1_NDEF_SEQUENCE_END(CMS_EncapsulatedContentInfo)/* Minor tweak to operation: free up signer key, cert */static int cms_si_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it)	{	if(operation == ASN1_OP_FREE_POST)		{		CMS_SignerInfo *si = (CMS_SignerInfo *)*pval;		if (si->pkey)			EVP_PKEY_free(si->pkey);		if (si->signer)			X509_free(si->signer);		}	return 1;	}ASN1_SEQUENCE_cb(CMS_SignerInfo, cms_si_cb) = {	ASN1_SIMPLE(CMS_SignerInfo, version, LONG),	ASN1_SIMPLE(CMS_SignerInfo, sid, CMS_SignerIdentifier),	ASN1_SIMPLE(CMS_SignerInfo, digestAlgorithm, X509_ALGOR),	ASN1_IMP_SET_OF_OPT(CMS_SignerInfo, signedAttrs, X509_ATTRIBUTE, 0),	ASN1_SIMPLE(CMS_SignerInfo, signatureAlgorithm, X509_ALGOR),	ASN1_SIMPLE(CMS_SignerInfo, signature, ASN1_OCTET_STRING),	ASN1_IMP_SET_OF_OPT(CMS_SignerInfo, unsignedAttrs, X509_ATTRIBUTE, 1)} ASN1_SEQUENCE_END_cb(CMS_SignerInfo, CMS_SignerInfo)ASN1_SEQUENCE(CMS_OtherRevocationInfoFormat) = {	ASN1_SIMPLE(CMS_OtherRevocationInfoFormat, otherRevInfoFormat, ASN1_OBJECT),	ASN1_OPT(CMS_OtherRevocationInfoFormat, otherRevInfo, ASN1_ANY)} ASN1_SEQUENCE_END(CMS_OtherRevocationInfoFormat)ASN1_CHOICE(CMS_RevocationInfoChoice) = {	ASN1_SIMPLE(CMS_RevocationInfoChoice, d.crl, X509_CRL),	ASN1_IMP(CMS_RevocationInfoChoice, d.other, CMS_OtherRevocationInfoFormat, 1)} ASN1_CHOICE_END(CMS_RevocationInfoChoice)ASN1_NDEF_SEQUENCE(CMS_SignedData) = {	ASN1_SIMPLE(CMS_SignedData, version, LONG),	ASN1_SET_OF(CMS_SignedData, digestAlgorithms, X509_ALGOR),	ASN1_SIMPLE(CMS_SignedData, encapContentInfo, CMS_EncapsulatedContentInfo),	ASN1_IMP_SET_OF_OPT(CMS_SignedData, certificates, CMS_CertificateChoices, 0),	ASN1_IMP_SET_OF_OPT(CMS_SignedData, crls, CMS_RevocationInfoChoice, 1),	ASN1_SET_OF(CMS_SignedData, signerInfos, CMS_SignerInfo)} ASN1_NDEF_SEQUENCE_END(CMS_SignedData)ASN1_SEQUENCE(CMS_OriginatorInfo) = {	ASN1_IMP_SET_OF_OPT(CMS_SignedData, certificates, CMS_CertificateChoices, 0),	ASN1_IMP_SET_OF_OPT(CMS_SignedData, crls, CMS_RevocationInfoChoice, 1)} ASN1_SEQUENCE_END(CMS_OriginatorInfo)ASN1_NDEF_SEQUENCE(CMS_EncryptedContentInfo) = {	ASN1_SIMPLE(CMS_EncryptedContentInfo, contentType, ASN1_OBJECT),	ASN1_SIMPLE(CMS_EncryptedContentInfo, contentEncryptionAlgorithm, X509_ALGOR),	ASN1_IMP_OPT(CMS_EncryptedContentInfo, encryptedContent, ASN1_OCTET_STRING_NDEF, 0)} ASN1_NDEF_SEQUENCE_END(CMS_EncryptedContentInfo)ASN1_SEQUENCE(CMS_KeyTransRecipientInfo) = {	ASN1_SIMPLE(CMS_KeyTransRecipientInfo, version, LONG),	ASN1_SIMPLE(CMS_KeyTransRecipientInfo, rid, CMS_SignerIdentifier),	ASN1_SIMPLE(CMS_KeyTransRecipientInfo, keyEncryptionAlgorithm, X509_ALGOR),	ASN1_SIMPLE(CMS_KeyTransRecipientInfo, encryptedKey, ASN1_OCTET_STRING)} ASN1_SEQUENCE_END(CMS_KeyTransRecipientInfo)ASN1_SEQUENCE(CMS_OtherKeyAttribute) = {	ASN1_SIMPLE(CMS_OtherKeyAttribute, keyAttrId, ASN1_OBJECT),	ASN1_OPT(CMS_OtherKeyAttribute, keyAttr, ASN1_ANY)} ASN1_SEQUENCE_END(CMS_OtherKeyAttribute)ASN1_SEQUENCE(CMS_RecipientKeyIdentifier) = {	ASN1_SIMPLE(CMS_RecipientKeyIdentifier, subjectKeyIdentifier, ASN1_OCTET_STRING),	ASN1_OPT(CMS_RecipientKeyIdentifier, date, ASN1_GENERALIZEDTIME),	ASN1_OPT(CMS_RecipientKeyIdentifier, other, CMS_OtherKeyAttribute)} ASN1_SEQUENCE_END(CMS_RecipientKeyIdentifier)ASN1_CHOICE(CMS_KeyAgreeRecipientIdentifier) = {  ASN1_SIMPLE(CMS_KeyAgreeRecipientIdentifier, d.issuerAndSerialNumber, CMS_IssuerAndSerialNumber),  ASN1_IMP(CMS_KeyAgreeRecipientIdentifier, d.rKeyId, CMS_RecipientKeyIdentifier, 0)} ASN1_CHOICE_END(CMS_KeyAgreeRecipientIdentifier)ASN1_SEQUENCE(CMS_RecipientEncryptedKey) = {	ASN1_SIMPLE(CMS_RecipientEncryptedKey, rid, CMS_KeyAgreeRecipientIdentifier),	ASN1_SIMPLE(CMS_RecipientEncryptedKey, encryptedKey, ASN1_OCTET_STRING)} ASN1_SEQUENCE_END(CMS_RecipientEncryptedKey)ASN1_SEQUENCE(CMS_OriginatorPublicKey) = {  ASN1_SIMPLE(CMS_OriginatorPublicKey, algorithm, X509_ALGOR),  ASN1_SIMPLE(CMS_OriginatorPublicKey, publicKey, ASN1_BIT_STRING)} ASN1_SEQUENCE_END(CMS_OriginatorPublicKey)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -