pkcs7_parse.c File Reference

PKCS #7 message parsing. More...

#include "core/crypto.h"
#include "pkcs7/pkcs7_parse.h"
#include "pkix/x509_cert_parse.h"
#include "pkix/x509_sign_parse.h"
#include "encoding/asn1.h"
#include "encoding/oid.h"
#include "debug.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   CRYPTO_TRACE_LEVEL
 

Functions

error_t pkcs7ParseContentInfo (const uint8_t *data, size_t length, size_t *totalLength, Pkcs7ContentInfo *contentInfo)
 Parse contentInfo structure. More...
 
error_t pkcs7ParseSignedData (const uint8_t *data, size_t length, Pkcs7SignedData *signedData)
 Parse signed-data content. More...
 
error_t pkcs7ParseEnvelopedData (const uint8_t *data, size_t length, Pkcs7EnvelopedData *envelopedData)
 Parse enveloped-data content. More...
 
error_t pkcs7ParseDigestAlgos (const uint8_t *data, size_t length, size_t *totalLength, Pkcs7DigestAlgos *digestAlgos)
 Parse digestAlgorithms structure. More...
 
error_t pkcs7ParseCertificates (const uint8_t *data, size_t length, size_t *totalLength, Pkcs7Certificates *certificates)
 Parse certificates. More...
 
error_t pkcs7ParseCrls (const uint8_t *data, size_t length, size_t *totalLength, Pkcs7Crls *crls)
 Parse CRLs. More...
 
error_t pkcs7ParseSignerInfos (const uint8_t *data, size_t length, size_t *totalLength, Pkcs7SignerInfos *signerInfos)
 Parse signerInfos structure. More...
 
error_t pkcs7ParseSignerInfo (const uint8_t *data, size_t length, size_t *totalLength, Pkcs7SignerInfo *signerInfo)
 Parse SignerInfo structure. More...
 
error_t pkcs7ParseIssuerAndSerialNumber (const uint8_t *data, size_t length, size_t *totalLength, Pkcs7IssuerAndSerialNumber *issuerAndSerialNumber)
 Parse IssuerAndSerialNumber structure. More...
 
error_t pkcs7ParseAuthenticatedAttributes (const uint8_t *data, size_t length, size_t *totalLength, Pkcs7AuthenticatedAttributes *authenticatedAttributes)
 Parse authenticatedAttributes structure. More...
 
error_t pkcs7ParseDigestEncryptionAlgo (const uint8_t *data, size_t length, size_t *totalLength, X509SignAlgoId *digestEncryptionAlgo)
 Parse digestEncryptionAlgorithm structure. More...
 
error_t pkcs7ParseEncryptedDigest (const uint8_t *data, size_t length, size_t *totalLength, X509OctetString *encryptedDigest)
 Parse encryptedDigest structure. More...
 
error_t pkcs7ParseUnauthenticatedAttributes (const uint8_t *data, size_t length, size_t *totalLength, Pkcs7UnauthenticatedAttributes *unauthenticatedAttributes)
 Parse unauthenticatedAttributes structure. More...
 
error_t pkcs7ParseAttribute (const uint8_t *data, size_t length, size_t *totalLength, Pkcs7Attribute *attribute)
 Parse attribute. More...
 
error_t pkcs7FindAttribute (const uint8_t *data, size_t length, const uint8_t *oid, size_t oidLen, Pkcs7Attribute *attribute)
 Search a set of attributes for a given attribute type. More...
 
error_t pkcs7ParseRecipientInfos (const uint8_t *data, size_t length, size_t *totalLength, Pkcs7RecipientInfos *recipientInfos)
 Parse recipientInfos structure. More...
 
error_t pkcs7ParseRecipientInfo (const uint8_t *data, size_t length, size_t *totalLength, Pkcs7RecipientInfo *recipientInfo)
 Parse RecipientInfo structure. More...
 
error_t pkcs7ParseEncryptedKey (const uint8_t *data, size_t length, size_t *totalLength, X509OctetString *encryptedKey)
 Parse encryptedKey structure. More...
 
error_t pkcs7ParseEncryptedContentInfo (const uint8_t *data, size_t length, size_t *totalLength, Pkcs7EncryptedContentInfo *encryptedContentInfo)
 Parse encryptedContentInfo structure. More...
 
error_t pkcs7ParseContentEncrAlgo (const uint8_t *data, size_t length, size_t *totalLength, Pkcs7ContentEncrAlgo *contentEncrAlgo)
 Parse contentEncryptionAlgorithm structure. More...
 
error_t pkcs7ParseAlgoId (const uint8_t *data, size_t length, size_t *totalLength, X509AlgoId *algoId)
 Parse AlgorithmIdentifier structure. More...
 

Detailed Description

PKCS #7 message parsing.

License

SPDX-License-Identifier: GPL-2.0-or-later

Copyright (C) 2010-2025 Oryx Embedded SARL. All rights reserved.

This file is part of CycloneCRYPTO Open.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
2.5.2

Definition in file pkcs7_parse.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   CRYPTO_TRACE_LEVEL

Definition at line 32 of file pkcs7_parse.c.

Function Documentation

◆ pkcs7FindAttribute()

error_t pkcs7FindAttribute ( const uint8_t *  data,
size_t  length,
const uint8_t *  oid,
size_t  oidLen,
Pkcs7Attribute attribute 
)

Search a set of attributes for a given attribute type.

Parameters
[in]dataPointer to the set of attributes
[in]lengthLength of the set of attributes, in bytes
[out]oidObject identifier that specified the attribute type
[out]oidLenLength of the object identifier
[out]attributePointer to the matching attribute, if any
Returns
Error code

Definition at line 1088 of file pkcs7_parse.c.

◆ pkcs7ParseAlgoId()

error_t pkcs7ParseAlgoId ( const uint8_t *  data,
size_t  length,
size_t *  totalLength,
X509AlgoId algoId 
)

Parse AlgorithmIdentifier structure.

Parameters
[in]dataPointer to the ASN.1 structure to parse
[in]lengthLength of the ASN.1 structure
[out]totalLengthNumber of bytes that have been parsed
[out]algoIdInformation resulting from the parsing process
Returns
Error code

Definition at line 1447 of file pkcs7_parse.c.

◆ pkcs7ParseAttribute()

error_t pkcs7ParseAttribute ( const uint8_t *  data,
size_t  length,
size_t *  totalLength,
Pkcs7Attribute attribute 
)

Parse attribute.

Parameters
[in]dataPointer to the ASN.1 structure to parse
[in]lengthLength of the ASN.1 structure
[out]totalLengthNumber of bytes that have been parsed
[out]attributeInformation resulting from the parsing process
Returns
Error code

Definition at line 1011 of file pkcs7_parse.c.

◆ pkcs7ParseAuthenticatedAttributes()

error_t pkcs7ParseAuthenticatedAttributes ( const uint8_t *  data,
size_t  length,
size_t *  totalLength,
Pkcs7AuthenticatedAttributes authenticatedAttributes 
)

Parse authenticatedAttributes structure.

Parameters
[in]dataPointer to the ASN.1 structure to parse
[in]lengthLength of the ASN.1 structure
[out]totalLengthNumber of bytes that have been parsed
[out]authenticatedAttributesInformation resulting from the parsing process
Returns
Error code

Definition at line 737 of file pkcs7_parse.c.

◆ pkcs7ParseCertificates()

error_t pkcs7ParseCertificates ( const uint8_t *  data,
size_t  length,
size_t *  totalLength,
Pkcs7Certificates certificates 
)

Parse certificates.

Parameters
[in]dataPointer to the ASN.1 structure to parse
[in]lengthLength of the ASN.1 structure
[out]totalLengthNumber of bytes that have been parsed
[out]certificatesInformation resulting from the parsing process
Returns
Error code

Definition at line 356 of file pkcs7_parse.c.

◆ pkcs7ParseContentEncrAlgo()

error_t pkcs7ParseContentEncrAlgo ( const uint8_t *  data,
size_t  length,
size_t *  totalLength,
Pkcs7ContentEncrAlgo contentEncrAlgo 
)

Parse contentEncryptionAlgorithm structure.

Parameters
[in]dataPointer to the ASN.1 structure to parse
[in]lengthLength of the ASN.1 structure
[out]totalLengthNumber of bytes that have been parsed
[out]contentEncrAlgoInformation resulting from the parsing process
Returns
Error code

Definition at line 1390 of file pkcs7_parse.c.

◆ pkcs7ParseContentInfo()

error_t pkcs7ParseContentInfo ( const uint8_t *  data,
size_t  length,
size_t *  totalLength,
Pkcs7ContentInfo contentInfo 
)

Parse contentInfo structure.

Parameters
[in]dataPointer to the ASN.1 structure to parse
[in]lengthLength of the ASN.1 structure
[out]totalLengthNumber of bytes that have been parsed
[out]contentInfoInformation resulting from the parsing process
Returns
Error code

Definition at line 56 of file pkcs7_parse.c.

◆ pkcs7ParseCrls()

error_t pkcs7ParseCrls ( const uint8_t *  data,
size_t  length,
size_t *  totalLength,
Pkcs7Crls crls 
)

Parse CRLs.

Parameters
[in]dataPointer to the ASN.1 structure to parse
[in]lengthLength of the ASN.1 structure
[out]totalLengthNumber of bytes that have been parsed
[out]crlsInformation resulting from the parsing process
Returns
Error code

Definition at line 431 of file pkcs7_parse.c.

◆ pkcs7ParseDigestAlgos()

error_t pkcs7ParseDigestAlgos ( const uint8_t *  data,
size_t  length,
size_t *  totalLength,
Pkcs7DigestAlgos digestAlgos 
)

Parse digestAlgorithms structure.

Parameters
[in]dataPointer to the ASN.1 structure to parse
[in]lengthLength of the ASN.1 structure
[out]totalLengthNumber of bytes that have been parsed
[out]digestAlgosInformation resulting from the parsing process
Returns
Error code

Definition at line 289 of file pkcs7_parse.c.

◆ pkcs7ParseDigestEncryptionAlgo()

error_t pkcs7ParseDigestEncryptionAlgo ( const uint8_t *  data,
size_t  length,
size_t *  totalLength,
X509SignAlgoId digestEncryptionAlgo 
)

Parse digestEncryptionAlgorithm structure.

Parameters
[in]dataPointer to the ASN.1 structure to parse
[in]lengthLength of the ASN.1 structure
[out]totalLengthNumber of bytes that have been parsed
[out]digestEncryptionAlgoInformation resulting from the parsing process
Returns
Error code

Definition at line 850 of file pkcs7_parse.c.

◆ pkcs7ParseEncryptedContentInfo()

error_t pkcs7ParseEncryptedContentInfo ( const uint8_t *  data,
size_t  length,
size_t *  totalLength,
Pkcs7EncryptedContentInfo encryptedContentInfo 
)

Parse encryptedContentInfo structure.

Parameters
[in]dataPointer to the ASN.1 structure to parse
[in]lengthLength of the ASN.1 structure
[out]totalLengthNumber of bytes that have been parsed
[out]encryptedContentInfoInformation resulting from the parsing process
Returns
Error code

Definition at line 1309 of file pkcs7_parse.c.

◆ pkcs7ParseEncryptedDigest()

error_t pkcs7ParseEncryptedDigest ( const uint8_t *  data,
size_t  length,
size_t *  totalLength,
X509OctetString encryptedDigest 
)

Parse encryptedDigest structure.

Parameters
[in]dataPointer to the ASN.1 structure to parse
[in]lengthLength of the ASN.1 structure
[out]totalLengthNumber of bytes that have been parsed
[out]encryptedDigestInformation resulting from the parsing process
Returns
Error code

Definition at line 913 of file pkcs7_parse.c.

◆ pkcs7ParseEncryptedKey()

error_t pkcs7ParseEncryptedKey ( const uint8_t *  data,
size_t  length,
size_t *  totalLength,
X509OctetString encryptedKey 
)

Parse encryptedKey structure.

Parameters
[in]dataPointer to the ASN.1 structure to parse
[in]lengthLength of the ASN.1 structure
[out]totalLengthNumber of bytes that have been parsed
[out]encryptedKeyInformation resulting from the parsing process
Returns
Error code

Definition at line 1276 of file pkcs7_parse.c.

◆ pkcs7ParseEnvelopedData()

error_t pkcs7ParseEnvelopedData ( const uint8_t *  data,
size_t  length,
Pkcs7EnvelopedData envelopedData 
)

Parse enveloped-data content.

Parameters
[in]dataPointer to the ASN.1 structure to parse
[in]lengthLength of the ASN.1 structure
[out]envelopedDataInformation resulting from the parsing process
Returns
Error code

Definition at line 224 of file pkcs7_parse.c.

◆ pkcs7ParseIssuerAndSerialNumber()

error_t pkcs7ParseIssuerAndSerialNumber ( const uint8_t *  data,
size_t  length,
size_t *  totalLength,
Pkcs7IssuerAndSerialNumber issuerAndSerialNumber 
)

Parse IssuerAndSerialNumber structure.

Parameters
[in]dataPointer to the ASN.1 structure to parse
[in]lengthLength of the ASN.1 structure
[out]totalLengthNumber of bytes that have been parsed
[out]issuerAndSerialNumberInformation resulting from the parsing process
Returns
Error code

Definition at line 686 of file pkcs7_parse.c.

◆ pkcs7ParseRecipientInfo()

error_t pkcs7ParseRecipientInfo ( const uint8_t *  data,
size_t  length,
size_t *  totalLength,
Pkcs7RecipientInfo recipientInfo 
)

Parse RecipientInfo structure.

Parameters
[in]dataPointer to the ASN.1 structure to parse
[in]lengthLength of the ASN.1 structure
[out]totalLengthNumber of bytes that have been parsed
[out]recipientInfoInformation resulting from the parsing process
Returns
Error code

Definition at line 1203 of file pkcs7_parse.c.

◆ pkcs7ParseRecipientInfos()

error_t pkcs7ParseRecipientInfos ( const uint8_t *  data,
size_t  length,
size_t *  totalLength,
Pkcs7RecipientInfos recipientInfos 
)

Parse recipientInfos structure.

Parameters
[in]dataPointer to the ASN.1 structure to parse
[in]lengthLength of the ASN.1 structure
[out]totalLengthNumber of bytes that have been parsed
[out]recipientInfosInformation resulting from the parsing process
Returns
Error code

Definition at line 1129 of file pkcs7_parse.c.

◆ pkcs7ParseSignedData()

error_t pkcs7ParseSignedData ( const uint8_t *  data,
size_t  length,
Pkcs7SignedData signedData 
)

Parse signed-data content.

Parameters
[in]dataPointer to the ASN.1 structure to parse
[in]lengthLength of the ASN.1 structure
[out]signedDataInformation resulting from the parsing process
Returns
Error code

Definition at line 131 of file pkcs7_parse.c.

◆ pkcs7ParseSignerInfo()

error_t pkcs7ParseSignerInfo ( const uint8_t *  data,
size_t  length,
size_t *  totalLength,
Pkcs7SignerInfo signerInfo 
)

Parse SignerInfo structure.

Parameters
[in]dataPointer to the ASN.1 structure to parse
[in]lengthLength of the ASN.1 structure
[out]totalLengthNumber of bytes that have been parsed
[out]signerInfoInformation resulting from the parsing process
Returns
Error code

Definition at line 577 of file pkcs7_parse.c.

◆ pkcs7ParseSignerInfos()

error_t pkcs7ParseSignerInfos ( const uint8_t *  data,
size_t  length,
size_t *  totalLength,
Pkcs7SignerInfos signerInfos 
)

Parse signerInfos structure.

Parameters
[in]dataPointer to the ASN.1 structure to parse
[in]lengthLength of the ASN.1 structure
[out]totalLengthNumber of bytes that have been parsed
[out]signerInfosInformation resulting from the parsing process
Returns
Error code

Definition at line 506 of file pkcs7_parse.c.

◆ pkcs7ParseUnauthenticatedAttributes()

error_t pkcs7ParseUnauthenticatedAttributes ( const uint8_t *  data,
size_t  length,
size_t *  totalLength,
Pkcs7UnauthenticatedAttributes unauthenticatedAttributes 
)

Parse unauthenticatedAttributes structure.

Parameters
[in]dataPointer to the ASN.1 structure to parse
[in]lengthLength of the ASN.1 structure
[out]totalLengthNumber of bytes that have been parsed
[out]unauthenticatedAttributesInformation resulting from the parsing process
Returns
Error code

Definition at line 946 of file pkcs7_parse.c.