pkcs7_decrypt.c File Reference

PKCS #7 message decryption. More...

#include "core/crypto.h"
#include "pkcs7/pkcs7_parse.h"
#include "pkcs7/pkcs7_decrypt.h"
#include "cipher/cipher_algorithms.h"
#include "cipher_modes/cbc.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 pkcs7DecryptEnvelopedData (const Pkcs7EnvelopedData *envelopedData, const X509CertInfo *recipientCertInfo, const void *recipientPrivateKey, uint8_t *plaintext, size_t *plaintextLen)
 Decrypt enveloped-data content. More...
 
error_t pkcs7DecryptKey (const Pkcs7RecipientInfo *recipientInfo, const void *recipientPrivateKey, uint8_t *plaintext, size_t *plaintextLen)
 Perform key decryption. More...
 
error_t pkcs7DecryptData (const Pkcs7EncryptedContentInfo *encryptedContentInfo, const uint8_t *key, size_t keyLen, uint8_t *plaintext, size_t *plaintextLen)
 Perform data decryption. More...
 
error_t pkcs7FindRecipient (const Pkcs7RecipientInfos *recipientInfos, const X509CertInfo *recipientCertInfo, Pkcs7RecipientInfo *recipientInfo)
 Search a list of per-recipient informations for a given recipient. More...
 

Detailed Description

PKCS #7 message decryption.

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_decrypt.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   CRYPTO_TRACE_LEVEL

Definition at line 32 of file pkcs7_decrypt.c.

Function Documentation

◆ pkcs7DecryptData()

error_t pkcs7DecryptData ( const Pkcs7EncryptedContentInfo encryptedContentInfo,
const uint8_t *  key,
size_t  keyLen,
uint8_t *  plaintext,
size_t *  plaintextLen 
)

Perform data decryption.

Parameters
[in]encryptedContentInfoPointer to the encryptedContentInfo structure
[in]keyPointer to the encryption key
[in]keyLenLength of the encryption key, in bytes
[out]plaintextPlaintext resulting from the decryption operation
[out]plaintextLenLength of the resulting plaintext
Returns
Error code

Definition at line 138 of file pkcs7_decrypt.c.

◆ pkcs7DecryptEnvelopedData()

error_t pkcs7DecryptEnvelopedData ( const Pkcs7EnvelopedData envelopedData,
const X509CertInfo recipientCertInfo,
const void *  recipientPrivateKey,
uint8_t *  plaintext,
size_t *  plaintextLen 
)

Decrypt enveloped-data content.

Parameters
[in]envelopedDataPointer to the enveloped-data content
[in]recipientCertInfoRecipient's certificate
[in]recipientPrivateKeyRecipient's private key
[out]plaintextPlaintext resulting from the decryption operation
[out]plaintextLenLength of the resulting plaintext
Returns
Error code

Definition at line 57 of file pkcs7_decrypt.c.

◆ pkcs7DecryptKey()

error_t pkcs7DecryptKey ( const Pkcs7RecipientInfo recipientInfo,
const void *  recipientPrivateKey,
uint8_t *  plaintext,
size_t *  plaintextLen 
)

Perform key decryption.

Parameters
[in]recipientInfoPointer to the RecipientInfo structure
[in]recipientPrivateKeyRecipient's private key
[out]plaintextKey resulting from the decryption operation
[out]plaintextLenLength of the resulting key
Returns
Error code

Definition at line 100 of file pkcs7_decrypt.c.

◆ pkcs7FindRecipient()

error_t pkcs7FindRecipient ( const Pkcs7RecipientInfos recipientInfos,
const X509CertInfo recipientCertInfo,
Pkcs7RecipientInfo recipientInfo 
)

Search a list of per-recipient informations for a given recipient.

Parameters
[in]recipientInfosPointer to the collection of per-recipient information
[in]recipientCertInfoRecipient's certificate
[out]recipientInfoPointer to the matching RecipientInfo structure, if any
Returns
Error code

Definition at line 230 of file pkcs7_decrypt.c.