pkcs7_parse.h
Go to the documentation of this file.
1 /**
2  * @file pkcs7_parse.h
3  * @brief PKCS #7 message parsing
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2025 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneCRYPTO Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 2.5.2
29  **/
30 
31 #ifndef _PKCS7_PARSE_H
32 #define _PKCS7_PARSE_H
33 
34 //Dependencies
35 #include "core/crypto.h"
36 #include "pkcs7/pkcs7_common.h"
37 
38 //C++ guard
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 //PKCS #7 related functions
44 error_t pkcs7ParseContentInfo(const uint8_t *data, size_t length,
45  size_t *totalLength, Pkcs7ContentInfo *contentInfo);
46 
47 error_t pkcs7ParseSignedData(const uint8_t *data, size_t length,
48  Pkcs7SignedData *signedData);
49 
50 error_t pkcs7ParseEnvelopedData(const uint8_t *data, size_t length,
51  Pkcs7EnvelopedData *envelopedData);
52 
53 error_t pkcs7ParseDigestAlgos(const uint8_t *data, size_t length,
54  size_t *totalLength, Pkcs7DigestAlgos *digestAlgos);
55 
56 error_t pkcs7ParseCertificates(const uint8_t *data, size_t length,
57  size_t *totalLength, Pkcs7Certificates *certificates);
58 
59 error_t pkcs7ParseCrls(const uint8_t *data, size_t length,
60  size_t *totalLength, Pkcs7Crls *crls);
61 
62 error_t pkcs7ParseSignerInfos(const uint8_t *data, size_t length,
63  size_t *totalLength, Pkcs7SignerInfos *signerInfos);
64 
65 error_t pkcs7ParseSignerInfo(const uint8_t *data, size_t length,
66  size_t *totalLength, Pkcs7SignerInfo *signerInfo);
67 
68 error_t pkcs7ParseIssuerAndSerialNumber(const uint8_t *data, size_t length,
69  size_t *totalLength, Pkcs7IssuerAndSerialNumber *issuerAndSerialNumber);
70 
72  size_t *totalLength, Pkcs7AuthenticatedAttributes *authenticatedAttributes);
73 
74 error_t pkcs7ParseDigestEncryptionAlgo(const uint8_t *data, size_t length,
75  size_t *totalLength, X509SignAlgoId *digestEncryptionAlgo);
76 
77 error_t pkcs7ParseEncryptedDigest(const uint8_t *data, size_t length,
78  size_t *totalLength, X509OctetString *encryptedDigest);
79 
81  size_t *totalLength, Pkcs7UnauthenticatedAttributes *unauthenticatedAttributes);
82 
83 error_t pkcs7ParseAttribute(const uint8_t *data, size_t length,
84  size_t *totalLength, Pkcs7Attribute *attribute);
85 
86 error_t pkcs7FindAttribute(const uint8_t *data, size_t length,
87  const uint8_t *oid, size_t oidLen, Pkcs7Attribute *attribute);
88 
89 error_t pkcs7ParseRecipientInfos(const uint8_t *data, size_t length,
90  size_t *totalLength, Pkcs7RecipientInfos *recipientInfos);
91 
92 error_t pkcs7ParseRecipientInfo(const uint8_t *data, size_t length,
93  size_t *totalLength, Pkcs7RecipientInfo *recipientInfo);
94 
95 error_t pkcs7ParseEncryptedKey(const uint8_t *data, size_t length,
96  size_t *totalLength, X509OctetString *encryptedKey);
97 
98 error_t pkcs7ParseEncryptedContentInfo(const uint8_t *data, size_t length,
99  size_t *totalLength, Pkcs7EncryptedContentInfo *encryptedContentInfo);
100 
101 error_t pkcs7ParseContentEncrAlgo(const uint8_t *data, size_t length,
102  size_t *totalLength, Pkcs7ContentEncrAlgo *contentEncrAlgo);
103 
104 error_t pkcs7ParseAlgoId(const uint8_t *data, size_t length,
105  size_t *totalLength, X509AlgoId *algoId);
106 
107 //C++ guard
108 #ifdef __cplusplus
109 }
110 #endif
111 
112 #endif
error_t pkcs7ParseEncryptedContentInfo(const uint8_t *data, size_t length, size_t *totalLength, Pkcs7EncryptedContentInfo *encryptedContentInfo)
Parse encryptedContentInfo structure.
Definition: pkcs7_parse.c:1309
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.
Definition: pkcs7_parse.c:1088
uint8_t data[]
Definition: ethernet.h:224
error_t pkcs7ParseSignedData(const uint8_t *data, size_t length, Pkcs7SignedData *signedData)
Parse signed-data content.
Definition: pkcs7_parse.c:131
error_t pkcs7ParseEnvelopedData(const uint8_t *data, size_t length, Pkcs7EnvelopedData *envelopedData)
Parse enveloped-data content.
Definition: pkcs7_parse.c:224
error_t pkcs7ParseCrls(const uint8_t *data, size_t length, size_t *totalLength, Pkcs7Crls *crls)
Parse CRLs.
Definition: pkcs7_parse.c:431
error_t pkcs7ParseAlgoId(const uint8_t *data, size_t length, size_t *totalLength, X509AlgoId *algoId)
Parse AlgorithmIdentifier structure.
Definition: pkcs7_parse.c:1447
Content information.
Definition: pkcs7_common.h:317
uint16_t totalLength
Definition: ipv4.h:323
error_t pkcs7ParseUnauthenticatedAttributes(const uint8_t *data, size_t length, size_t *totalLength, Pkcs7UnauthenticatedAttributes *unauthenticatedAttributes)
Parse unauthenticatedAttributes structure.
Definition: pkcs7_parse.c:946
uint8_t oid[]
Definition: lldp_tlv.h:300
Content encryption algorithm.
Definition: pkcs7_common.h:328
error_t pkcs7ParseIssuerAndSerialNumber(const uint8_t *data, size_t length, size_t *totalLength, Pkcs7IssuerAndSerialNumber *issuerAndSerialNumber)
Parse IssuerAndSerialNumber structure.
Definition: pkcs7_parse.c:686
error_t pkcs7ParseContentEncrAlgo(const uint8_t *data, size_t length, size_t *totalLength, Pkcs7ContentEncrAlgo *contentEncrAlgo)
Parse contentEncryptionAlgorithm structure.
Definition: pkcs7_parse.c:1390
PKCS #7 common definitions.
error_t pkcs7ParseEncryptedDigest(const uint8_t *data, size_t length, size_t *totalLength, X509OctetString *encryptedDigest)
Parse encryptedDigest structure.
Definition: pkcs7_parse.c:913
error_t
Error codes.
Definition: error.h:43
Encrypted content information.
Definition: pkcs7_common.h:339
uint8_t algoId[]
Definition: ike.h:1537
Signer information.
Definition: pkcs7_common.h:264
error_t pkcs7ParseRecipientInfos(const uint8_t *data, size_t length, size_t *totalLength, Pkcs7RecipientInfos *recipientInfos)
Parse recipientInfos structure.
Definition: pkcs7_parse.c:1129
General definitions for cryptographic algorithms.
error_t pkcs7ParseAttribute(const uint8_t *data, size_t length, size_t *totalLength, Pkcs7Attribute *attribute)
Parse attribute.
Definition: pkcs7_parse.c:1011
error_t pkcs7ParseDigestEncryptionAlgo(const uint8_t *data, size_t length, size_t *totalLength, X509SignAlgoId *digestEncryptionAlgo)
Parse digestEncryptionAlgorithm structure.
Definition: pkcs7_parse.c:850
error_t pkcs7ParseEncryptedKey(const uint8_t *data, size_t length, size_t *totalLength, X509OctetString *encryptedKey)
Parse encryptedKey structure.
Definition: pkcs7_parse.c:1276
uint8_t length
Definition: tcp.h:375
Recipient information.
Definition: pkcs7_common.h:292
Collection of digest algorithm identifiers.
Definition: pkcs7_common.h:179
error_t pkcs7ParseRecipientInfo(const uint8_t *data, size_t length, size_t *totalLength, Pkcs7RecipientInfo *recipientInfo)
Parse RecipientInfo structure.
Definition: pkcs7_parse.c:1203
error_t pkcs7ParseSignerInfo(const uint8_t *data, size_t length, size_t *totalLength, Pkcs7SignerInfo *signerInfo)
Parse SignerInfo structure.
Definition: pkcs7_parse.c:577
Signed data content.
Definition: pkcs7_common.h:351
Collection of signer informations.
Definition: pkcs7_common.h:280
Issuer and serial number.
Definition: pkcs7_common.h:214
error_t pkcs7ParseAuthenticatedAttributes(const uint8_t *data, size_t length, size_t *totalLength, Pkcs7AuthenticatedAttributes *authenticatedAttributes)
Parse authenticatedAttributes structure.
Definition: pkcs7_parse.c:737
Unauthenticated attributes.
Definition: pkcs7_common.h:252
uint8_t oidLen
Definition: lldp_tlv.h:299
Collection of CRLs.
Definition: pkcs7_common.h:202
Collection of certificates.
Definition: pkcs7_common.h:190
error_t pkcs7ParseContentInfo(const uint8_t *data, size_t length, size_t *totalLength, Pkcs7ContentInfo *contentInfo)
Parse contentInfo structure.
Definition: pkcs7_parse.c:56
Authenticated attributes.
Definition: pkcs7_common.h:237
Octet string.
Definition: x509_common.h:701
error_t pkcs7ParseCertificates(const uint8_t *data, size_t length, size_t *totalLength, Pkcs7Certificates *certificates)
Parse certificates.
Definition: pkcs7_parse.c:356
Collection of recipient informations.
Definition: pkcs7_common.h:305
Enveloped data content.
Definition: pkcs7_common.h:366
error_t pkcs7ParseSignerInfos(const uint8_t *data, size_t length, size_t *totalLength, Pkcs7SignerInfos *signerInfos)
Parse signerInfos structure.
Definition: pkcs7_parse.c:506
Signature algorithm identifier.
Definition: x509_common.h:1088
Algorithm identifier.
Definition: x509_common.h:774
error_t pkcs7ParseDigestAlgos(const uint8_t *data, size_t length, size_t *totalLength, Pkcs7DigestAlgos *digestAlgos)
Parse digestAlgorithms structure.
Definition: pkcs7_parse.c:289
Attribute.
Definition: pkcs7_common.h:225