pem_decrypt.h File Reference

PEM file decryption. More...

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

Go to the source code of this file.

Functions

error_t pemDecryptPrivateKey (const char_t *input, size_t inputLen, const char_t *password, char_t *output, size_t *outputLen)
 PEM private key decryption. More...
 
error_t pemDecryptMessage (const PemHeader *header, const char_t *password, const uint8_t *ciphertext, size_t ciphertextLen, uint8_t *plaintext, size_t *plaintextLen)
 PEM message decryption. More...
 
error_t pemFormatIv (const PemHeader *header, uint8_t *iv, size_t ivLen)
 Extract the IV from the PEM encapsulated header. More...
 
error_t pemKdf (const char_t *p, size_t pLen, const uint8_t *s, size_t sLen, uint8_t *dk, size_t dkLen)
 Key derivation function. More...
 

Detailed Description

PEM file decryption.

License

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

Copyright (C) 2010-2024 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.4.0

Definition in file pem_decrypt.h.

Function Documentation

◆ pemDecryptMessage()

error_t pemDecryptMessage ( const PemHeader header,
const char_t password,
const uint8_t *  ciphertext,
size_t  ciphertextLen,
uint8_t *  plaintext,
size_t *  plaintextLen 
)

PEM message decryption.

Parameters
[in]headerPEM encapsulated header
[in]passwordNULL-terminated string containing the password
[in]ciphertextPointer to the ciphertext data
[in]ciphertextLenLength of the ciphertext data, in bytes
[out]plaintextPointer to the plaintext data
[out]plaintextLenLength of the plaintext data, in bytes
Returns
Error code

Definition at line 361 of file pem_decrypt.c.

◆ pemDecryptPrivateKey()

error_t pemDecryptPrivateKey ( const char_t input,
size_t  inputLen,
const char_t password,
char_t output,
size_t *  outputLen 
)

PEM private key decryption.

Parameters
[in]inputPointer to the encrypted private key (PEM format)
[in]inputLenLength of the encrypted private key
[in]passwordNULL-terminated string containing the password
[out]outputPointer to decrypted private key (PEM format)
[out]outputLenLength of the decrypted private key
Returns
Error code

Definition at line 58 of file pem_decrypt.c.

◆ pemFormatIv()

error_t pemFormatIv ( const PemHeader header,
uint8_t *  iv,
size_t  ivLen 
)

Extract the IV from the PEM encapsulated header.

Parameters
[in]headerPEM encapsulated header
[out]ivInitialization vector
[in]ivLenLength of the initialization vector, in bytes
Returns
Error code

Definition at line 495 of file pem_decrypt.c.

◆ pemKdf()

error_t pemKdf ( const char_t p,
size_t  pLen,
const uint8_t *  s,
size_t  sLen,
uint8_t *  dk,
size_t  dkLen 
)

Key derivation function.

Parameters
[in]pPassword, an octet string
[in]pLenLength in octets of password
[in]sSalt, an octet string
[in]sLenLength in octets of salt
[out]dkDerived key
[in]dkLenIntended length in octets of the derived key
Returns
Error code

Definition at line 548 of file pem_decrypt.c.