pkcs7_common.h File Reference

PKCS #7 common definitions. More...

#include "core/crypto.h"
#include "pkix/x509_common.h"

Go to the source code of this file.

Data Structures

struct  Pkcs7DigestAlgos
 Collection of digest algorithm identifiers. More...
 
struct  Pkcs7Certificates
 Collection of certificates. More...
 
struct  Pkcs7Crls
 Collection of CRLs. More...
 
struct  Pkcs7IssuerAndSerialNumber
 Issuer and serial number. More...
 
struct  Pkcs7Attribute
 Attribute. More...
 
struct  Pkcs7AuthenticatedAttributes
 Authenticated attributes. More...
 
struct  Pkcs7UnauthenticatedAttributes
 Unauthenticated attributes. More...
 
struct  Pkcs7SignerInfo
 Signer information. More...
 
struct  Pkcs7SignerInfos
 Collection of signer informations. More...
 
struct  Pkcs7RecipientInfo
 Recipient information. More...
 
struct  Pkcs7RecipientInfos
 Collection of recipient informations. More...
 
struct  Pkcs7ContentInfo
 Content information. More...
 
struct  Pkcs7ContentEncrAlgo
 Content encryption algorithm. More...
 
struct  Pkcs7EncryptedContentInfo
 Encrypted content information. More...
 
struct  Pkcs7SignedData
 Signed data content. More...
 
struct  Pkcs7EnvelopedData
 Enveloped data content. More...
 

Macros

#define PKCS7_DES_SUPPORT   DISABLED
 
#define PKCS7_3DES_SUPPORT   DISABLED
 
#define PKCS7_AES_SUPPORT   ENABLED
 
#define PKCS7_MD5_SUPPORT   DISABLED
 
#define PKCS7_SHA1_SUPPORT   DISABLED
 
#define PKCS7_SHA224_SUPPORT   DISABLED
 
#define PKCS7_SHA256_SUPPORT   ENABLED
 
#define PKCS7_SHA384_SUPPORT   ENABLED
 
#define PKCS7_SHA512_SUPPORT   ENABLED
 
#define PKCS7_RSA_SUPPORT   ENABLED
 
#define PKCS7_MAX_DIGEST_ALGO_IDENTIFIERS   2
 
#define PKCS7_MAX_CERTIFICATES   4
 
#define PKCS7_MAX_CRLS   4
 
#define PKCS7_MAX_SIGNER_INFOS   2
 
#define PKCS7_MAX_RECIPIENT_INFOS   2
 
#define PKCS7_MAX_CUSTOM_ATTRIBUTES   4
 
#define PKCS7_MAX_ENCR_KEY_SIZE   32
 

Enumerations

enum  Pkcs7Version {
  PKCS7_VERSION_0 = 0, PKCS7_VERSION_1 = 1, PKCS7_VERSION_2 = 2, PKCS7_VERSION_3 = 3,
  PKCS7_VERSION_4 = 4, PKCS7_VERSION_5 = 5
}
 Syntax version number. More...
 

Functions

const HashAlgopkcs7GetHashAlgo (const uint8_t *oid, size_t length)
 Get the hash algorithm that matches the specified OID. More...
 
const HashAlgopkcs7GetSignHashAlgo (const uint8_t *oid, size_t length)
 Get the signature hash algorithm that matches the specified OID. More...
 
const CipherAlgopkcs7GetCipherAlgo (const uint8_t *oid, size_t length)
 Get the cipher algorithm that matches the specified OID. More...
 
uint_t pkcs7GetKeyLength (const uint8_t *oid, size_t length)
 Get the encryption key length to be used for PBES2 operation. More...
 
int_t pkcs7CompAttributes (const uint8_t *attribute1, size_t attributeLen1, const uint8_t *attribute2, size_t attributeLen2)
 Compare attributes. More...
 
error_t pkcs7DigestAuthenticatedAttributes (const Pkcs7SignerInfo *signerInfo, const uint8_t *data, size_t length, uint8_t *digest)
 Digest the DER encoding of the authenticatedAttributes field. More...
 

Variables

const uint8_t PKCS7_OID [8]
 
const uint8_t PKCS7_DATA_OID [9]
 
const uint8_t PKCS7_SIGNED_DATA_OID [9]
 
const uint8_t PKCS7_ENVELOPED_DATA_OID [9]
 
const uint8_t PKCS7_SIGNED_AND_ENVELOPED_DATA_OID [9]
 
const uint8_t PKCS7_DIGESTED_DATA_OID [9]
 
const uint8_t PKCS7_ENCRYPTED_DATA_OID [9]
 
const uint8_t PKCS9_CONTENT_TYPE_OID [9]
 
const uint8_t PKCS9_MESSAGE_DIGEST_OID [9]
 
const uint8_t PKCS9_SIGNING_TIME_OID [9]
 

Detailed Description

PKCS #7 common definitions.

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_common.h.

Macro Definition Documentation

◆ PKCS7_3DES_SUPPORT

#define PKCS7_3DES_SUPPORT   DISABLED

Definition at line 47 of file pkcs7_common.h.

◆ PKCS7_AES_SUPPORT

#define PKCS7_AES_SUPPORT   ENABLED

Definition at line 54 of file pkcs7_common.h.

◆ PKCS7_DES_SUPPORT

#define PKCS7_DES_SUPPORT   DISABLED

Definition at line 40 of file pkcs7_common.h.

◆ PKCS7_MAX_CERTIFICATES

#define PKCS7_MAX_CERTIFICATES   4

Definition at line 117 of file pkcs7_common.h.

◆ PKCS7_MAX_CRLS

#define PKCS7_MAX_CRLS   4

Definition at line 124 of file pkcs7_common.h.

◆ PKCS7_MAX_CUSTOM_ATTRIBUTES

#define PKCS7_MAX_CUSTOM_ATTRIBUTES   4

Definition at line 145 of file pkcs7_common.h.

◆ PKCS7_MAX_DIGEST_ALGO_IDENTIFIERS

#define PKCS7_MAX_DIGEST_ALGO_IDENTIFIERS   2

Definition at line 110 of file pkcs7_common.h.

◆ PKCS7_MAX_ENCR_KEY_SIZE

#define PKCS7_MAX_ENCR_KEY_SIZE   32

Definition at line 151 of file pkcs7_common.h.

◆ PKCS7_MAX_RECIPIENT_INFOS

#define PKCS7_MAX_RECIPIENT_INFOS   2

Definition at line 138 of file pkcs7_common.h.

◆ PKCS7_MAX_SIGNER_INFOS

#define PKCS7_MAX_SIGNER_INFOS   2

Definition at line 131 of file pkcs7_common.h.

◆ PKCS7_MD5_SUPPORT

#define PKCS7_MD5_SUPPORT   DISABLED

Definition at line 61 of file pkcs7_common.h.

◆ PKCS7_RSA_SUPPORT

#define PKCS7_RSA_SUPPORT   ENABLED

Definition at line 103 of file pkcs7_common.h.

◆ PKCS7_SHA1_SUPPORT

#define PKCS7_SHA1_SUPPORT   DISABLED

Definition at line 68 of file pkcs7_common.h.

◆ PKCS7_SHA224_SUPPORT

#define PKCS7_SHA224_SUPPORT   DISABLED

Definition at line 75 of file pkcs7_common.h.

◆ PKCS7_SHA256_SUPPORT

#define PKCS7_SHA256_SUPPORT   ENABLED

Definition at line 82 of file pkcs7_common.h.

◆ PKCS7_SHA384_SUPPORT

#define PKCS7_SHA384_SUPPORT   ENABLED

Definition at line 89 of file pkcs7_common.h.

◆ PKCS7_SHA512_SUPPORT

#define PKCS7_SHA512_SUPPORT   ENABLED

Definition at line 96 of file pkcs7_common.h.

Enumeration Type Documentation

◆ Pkcs7Version

Syntax version number.

Enumerator
PKCS7_VERSION_0 

v0

PKCS7_VERSION_1 

v1

PKCS7_VERSION_2 

v2

PKCS7_VERSION_3 

v3

PKCS7_VERSION_4 

v4

PKCS7_VERSION_5 

v5

Definition at line 163 of file pkcs7_common.h.

Function Documentation

◆ pkcs7CompAttributes()

int_t pkcs7CompAttributes ( const uint8_t *  attribute1,
size_t  attributeLen1,
const uint8_t *  attribute2,
size_t  attributeLen2 
)

Compare attributes.

Parameters
[in]attribute1Pointer to the first attribute
[in]attributeLen1Length of the first attribute
[in]attribute2Pointer to the second attribute
[in]attributeLen2Length of the second attribute
Return values
0Attributes are equal
-1The first attribute precedes the second attribute
1The second attribute precedes the first attribute

Definition at line 329 of file pkcs7_common.c.

◆ pkcs7DigestAuthenticatedAttributes()

error_t pkcs7DigestAuthenticatedAttributes ( const Pkcs7SignerInfo signerInfo,
const uint8_t *  data,
size_t  length,
uint8_t *  digest 
)

Digest the DER encoding of the authenticatedAttributes field.

Parameters
[in]signerInfoPointer to the signer information
[in]dataContent octets of authenticatedAttributes field
[in]lengthLength of the content octets
[out]digestResulting message digest
Returns
Error code

Definition at line 382 of file pkcs7_common.c.

◆ pkcs7GetCipherAlgo()

const CipherAlgo* pkcs7GetCipherAlgo ( const uint8_t *  oid,
size_t  length 
)

Get the cipher algorithm that matches the specified OID.

Parameters
[in]oidAlgorithm identifier
[in]lengthLength of the algorithm identifier, in bytes
Returns
Cipher algorithm

Definition at line 215 of file pkcs7_common.c.

◆ pkcs7GetHashAlgo()

const HashAlgo* pkcs7GetHashAlgo ( const uint8_t *  oid,
size_t  length 
)

Get the hash algorithm that matches the specified OID.

Parameters
[in]oidAlgorithm identifier
[in]lengthLength of the algorithm identifier, in bytes
Returns
Hash algorithm

Definition at line 77 of file pkcs7_common.c.

◆ pkcs7GetKeyLength()

uint_t pkcs7GetKeyLength ( const uint8_t *  oid,
size_t  length 
)

Get the encryption key length to be used for PBES2 operation.

Parameters
[in]oidEncryption algorithm identifier
[in]lengthLength of the encryption algorithm identifier, in bytes
Returns
Encryption key length

Definition at line 270 of file pkcs7_common.c.

◆ pkcs7GetSignHashAlgo()

const HashAlgo* pkcs7GetSignHashAlgo ( const uint8_t *  oid,
size_t  length 
)

Get the signature hash algorithm that matches the specified OID.

Parameters
[in]oidAlgorithm identifier
[in]lengthLength of the algorithm identifier, in bytes
Returns
Hash algorithm

Definition at line 146 of file pkcs7_common.c.

Variable Documentation

◆ PKCS7_DATA_OID

const uint8_t PKCS7_DATA_OID[9]
extern

Definition at line 50 of file pkcs7_common.c.

◆ PKCS7_DIGESTED_DATA_OID

const uint8_t PKCS7_DIGESTED_DATA_OID[9]
extern

Definition at line 58 of file pkcs7_common.c.

◆ PKCS7_ENCRYPTED_DATA_OID

const uint8_t PKCS7_ENCRYPTED_DATA_OID[9]
extern

Definition at line 60 of file pkcs7_common.c.

◆ PKCS7_ENVELOPED_DATA_OID

const uint8_t PKCS7_ENVELOPED_DATA_OID[9]
extern

Definition at line 54 of file pkcs7_common.c.

◆ PKCS7_OID

const uint8_t PKCS7_OID[8]
extern

Definition at line 48 of file pkcs7_common.c.

◆ PKCS7_SIGNED_AND_ENVELOPED_DATA_OID

const uint8_t PKCS7_SIGNED_AND_ENVELOPED_DATA_OID[9]
extern

Definition at line 56 of file pkcs7_common.c.

◆ PKCS7_SIGNED_DATA_OID

const uint8_t PKCS7_SIGNED_DATA_OID[9]
extern

Definition at line 52 of file pkcs7_common.c.

◆ PKCS9_CONTENT_TYPE_OID

const uint8_t PKCS9_CONTENT_TYPE_OID[9]
extern

Definition at line 63 of file pkcs7_common.c.

◆ PKCS9_MESSAGE_DIGEST_OID

const uint8_t PKCS9_MESSAGE_DIGEST_OID[9]
extern

Definition at line 65 of file pkcs7_common.c.

◆ PKCS9_SIGNING_TIME_OID

const uint8_t PKCS9_SIGNING_TIME_OID[9]
extern

Definition at line 67 of file pkcs7_common.c.