PEM common definitions. More...
#include "core/crypto.h"
#include "pkix/pem_common.h"
#include "encoding/oid.h"
#include "encoding/base64.h"
#include "cipher/cipher_algorithms.h"
#include "debug.h"
Go to the source code of this file.
Macros | |
#define | TRACE_LEVEL CRYPTO_TRACE_LEVEL |
Functions | |
error_t | pemDecodeFile (const char_t *input, size_t inputLen, const char_t *label, uint8_t *output, size_t *outputLen, PemHeader *header, size_t *consumed) |
Convert PEM container to ASN.1 format. More... | |
error_t | pemEncodeFile (const void *input, size_t inputLen, const char_t *label, char_t *output, size_t *outputLen) |
Convert ASN.1 data to PEM encoding. More... | |
error_t | pemParseHeader (const char_t *input, size_t inputLen, PemHeader *header, size_t *consumed) |
Parse PEM encapsulated header. More... | |
void | pemParseHeaderField (PemString *line, PemHeader *header) |
Parse header field. More... | |
int_t | pemFindTag (const char_t *input, size_t inputLen, const char_t *tag1, const char_t *tag2, const char_t *tag3) |
Search a string for a given tag. More... | |
int_t | pemFindChar (const PemString *s, char_t c) |
Search a string for a given character. More... | |
bool_t | pemCompareString (const PemString *string, const char_t *value) |
Compare a string against the supplied value. More... | |
bool_t | pemTokenizeString (PemString *s, char_t c, PemString *token) |
Split a string into tokens. More... | |
void | pemTrimWhitespace (PemString *s) |
Removes all leading and trailing whitespace from a string. More... | |
const CipherAlgo * | pemGetCipherAlgo (const PemString *algo) |
Get the cipher algorithm to be used for PEM encryption/decryption. More... | |
uint_t | pemGetKeyLength (const PemString *algo) |
Get the encryption key length to be used for PEM encryption/decryption. More... | |
Detailed Description
PEM common definitions.
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.
- Version
- 2.4.4
Definition in file pem_common.c.
Macro Definition Documentation
◆ TRACE_LEVEL
#define TRACE_LEVEL CRYPTO_TRACE_LEVEL |
Definition at line 32 of file pem_common.c.
Function Documentation
◆ pemCompareString()
Compare a string against the supplied value.
- Parameters
-
[in] string String to be compared [in] value NULL-terminated string
- Returns
- Comparison result
Definition at line 414 of file pem_common.c.
◆ pemDecodeFile()
error_t pemDecodeFile | ( | const char_t * | input, |
size_t | inputLen, | ||
const char_t * | label, | ||
uint8_t * | output, | ||
size_t * | outputLen, | ||
PemHeader * | header, | ||
size_t * | consumed | ||
) |
Convert PEM container to ASN.1 format.
- Parameters
-
[in] input PEM container to decode [in] inputLen Length of the PEM container to decode [in] label Label indicating the type of data [out] output ASN.1 data (optional parameter) [out] outputLen Length of the ASN.1 data [out] header PEM encapsulated header (optional parameter) [out] consumed Total number of characters that have been consumed (optional parameter)
Definition at line 58 of file pem_common.c.
◆ pemEncodeFile()
error_t pemEncodeFile | ( | const void * | input, |
size_t | inputLen, | ||
const char_t * | label, | ||
char_t * | output, | ||
size_t * | outputLen | ||
) |
Convert ASN.1 data to PEM encoding.
- Parameters
-
[in] input ASN.1 data to encode [in] inputLen Length of the ASN.1 data to encode [in] label Label indicating the type of data [out] output PEM container (optional parameter) [out] outputLen Length of the PEM container
Definition at line 118 of file pem_common.c.
◆ pemFindChar()
Search a string for a given character.
- Parameters
-
[in] s String to be scanned [in] c Character to be searched
- Returns
- Index of the first occurrence of the character
Definition at line 384 of file pem_common.c.
◆ pemFindTag()
int_t pemFindTag | ( | const char_t * | input, |
size_t | inputLen, | ||
const char_t * | tag1, | ||
const char_t * | tag2, | ||
const char_t * | tag3 | ||
) |
Search a string for a given tag.
- Parameters
-
[in] input String to search [in] inputLen Length of the string to search [in] tag1 First part of the tag (NULL-terminated string) [in] tag2 Second part of the tag (NULL-terminated string) [in] tag3 Third part of the tag (NULL-terminated string)
- Returns
- The index of the first occurrence of the tag in the string, or -1 if the tag does not appear in the string
Definition at line 323 of file pem_common.c.
◆ pemGetCipherAlgo()
const CipherAlgo* pemGetCipherAlgo | ( | const PemString * | algo | ) |
Get the cipher algorithm to be used for PEM encryption/decryption.
- Parameters
-
[in] algo Encryption algorithm
- Returns
- Cipher algorithm
Definition at line 526 of file pem_common.c.
◆ pemGetKeyLength()
Get the encryption key length to be used for PEM encryption/decryption.
- Parameters
-
[in] algo Encryption algorithm
- Returns
- Encryption key length
Definition at line 624 of file pem_common.c.
◆ pemParseHeader()
error_t pemParseHeader | ( | const char_t * | input, |
size_t | inputLen, | ||
PemHeader * | header, | ||
size_t * | consumed | ||
) |
Parse PEM encapsulated header.
- Parameters
-
[in] input PEM message body [in] inputLen Length of the PEM message body [in] header PEM encapsulated header (optional parameter) [out] consumed Total number of bytes that have been consumed
- Returns
- Error code
Definition at line 181 of file pem_common.c.
◆ pemParseHeaderField()
Parse header field.
- Parameters
-
[in] line Header field [in] header PEM encapsulated header (optional parameter)
Definition at line 251 of file pem_common.c.
◆ pemTokenizeString()
Split a string into tokens.
- Parameters
-
[in,out] s String to be split [in] c Delimiter character [out] token Resulting token
- Returns
- TRUE if a token has been found, else FALSE
Definition at line 452 of file pem_common.c.
◆ pemTrimWhitespace()
void pemTrimWhitespace | ( | PemString * | s | ) |
Removes all leading and trailing whitespace from a string.
- Parameters
-
[in] s String to be trimmed
Definition at line 503 of file pem_common.c.