Formatting of ASN.1 encoded keys. More...
#include "core/crypto.h"
#include "pkix/x509_key_format.h"
#include "encoding/asn1.h"
#include "encoding/oid.h"
#include "ecc/eddsa.h"
#include "hash/sha1.h"
#include "debug.h"
Go to the source code of this file.
Macros | |
#define | TRACE_LEVEL CRYPTO_TRACE_LEVEL |
Functions | |
error_t | x509FormatSubjectPublicKeyInfo (const X509SubjectPublicKeyInfo *publicKeyInfo, const void *publicKey, uint8_t *keyId, uint8_t *output, size_t *written) |
Format SubjectPublicKeyInfo structure. More... | |
error_t | x509FormatAlgoId (const X509SubjectPublicKeyInfo *publicKeyInfo, const void *params, uint8_t *output, size_t *written) |
Format AlgorithmIdentifier structure. More... | |
error_t | x509FormatRsaPublicKey (const X509RsaPublicKey *rsaPublicKey, uint8_t *output, size_t *written) |
Format RSAPublicKey structure. More... | |
error_t | x509FormatDsaPublicKey (const X509DsaPublicKey *dsaPublicKey, uint8_t *output, size_t *written) |
Format DSAPublicKey structure. More... | |
error_t | x509FormatDsaParameters (const X509DsaParameters *dsaParams, uint8_t *output, size_t *written) |
Format DSA domain parameters. More... | |
error_t | x509FormatEcPublicKey (const X509EcPublicKey *ecPublicKey, uint8_t *output, size_t *written) |
Format ECPublicKey structure. More... | |
error_t | x509FormatEcParameters (const X509EcParameters *ecParams, uint8_t *output, size_t *written) |
Format ECParameters structure. More... | |
error_t | x509ExportRsaPublicKey (const RsaPublicKey *publicKey, uint8_t *output, size_t *written) |
Export an RSA public key to ASN.1 format. More... | |
error_t | x509ExportRsaPrivateKey (const RsaPrivateKey *privateKey, uint8_t *output, size_t *written) |
Export an RSA private key to ASN.1 format. More... | |
error_t | x509ExportDsaPublicKey (const DsaPublicKey *publicKey, uint8_t *output, size_t *written) |
Export a DSA public key to ASN.1 format. More... | |
error_t | x509ExportDsaPrivateKey (const DsaPrivateKey *privateKey, uint8_t *output, size_t *written) |
Export a DSA private key to ASN.1 format. More... | |
error_t | x509ExportDsaParameters (const DsaDomainParameters *params, uint8_t *output, size_t *written) |
Export DSA domain parameters to ASN.1 format. More... | |
error_t | x509ExportEcPublicKey (const X509SubjectPublicKeyInfo *publicKeyInfo, const EcPoint *publicKey, uint8_t *output, size_t *written) |
Export an EC public key to ASN.1 format. More... | |
error_t | x509ExportEddsaPublicKey (const EddsaPublicKey *publicKey, size_t publicKeyLen, uint8_t *output, size_t *written) |
Export an EdDSA public key to ASN.1 format. More... | |
error_t | x509ExportEddsaPrivateKey (const EddsaPrivateKey *privateKey, size_t privateKeyLen, uint8_t *output, size_t *written) |
Export an EdDSA private key to ASN.1 format. More... | |
Detailed Description
Formatting of ASN.1 encoded keys.
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 x509_key_format.c.
Macro Definition Documentation
◆ TRACE_LEVEL
#define TRACE_LEVEL CRYPTO_TRACE_LEVEL |
Definition at line 32 of file x509_key_format.c.
Function Documentation
◆ x509ExportDsaParameters()
error_t x509ExportDsaParameters | ( | const DsaDomainParameters * | params, |
uint8_t * | output, | ||
size_t * | written | ||
) |
Export DSA domain parameters to ASN.1 format.
- Parameters
-
[in] params Pointer to the DSA domain parameters [out] output Buffer where to store the ASN.1 structure [out] written Length of the resulting ASN.1 structure
- Returns
- Error code
Definition at line 994 of file x509_key_format.c.
◆ x509ExportDsaPrivateKey()
error_t x509ExportDsaPrivateKey | ( | const DsaPrivateKey * | privateKey, |
uint8_t * | output, | ||
size_t * | written | ||
) |
Export a DSA private key to ASN.1 format.
- Parameters
-
[in] privateKey Pointer to the DSA private key [out] output Buffer where to store the ASN.1 structure [out] written Length of the resulting ASN.1 structure
- Returns
- Error code
Definition at line 966 of file x509_key_format.c.
◆ x509ExportDsaPublicKey()
error_t x509ExportDsaPublicKey | ( | const DsaPublicKey * | publicKey, |
uint8_t * | output, | ||
size_t * | written | ||
) |
Export a DSA public key to ASN.1 format.
- Parameters
-
[in] publicKey Pointer to the DSA public key [out] output Buffer where to store the ASN.1 structure [out] written Length of the resulting ASN.1 structure
- Returns
- Error code
Definition at line 938 of file x509_key_format.c.
◆ x509ExportEcPublicKey()
error_t x509ExportEcPublicKey | ( | const X509SubjectPublicKeyInfo * | publicKeyInfo, |
const EcPoint * | publicKey, | ||
uint8_t * | output, | ||
size_t * | written | ||
) |
Export an EC public key to ASN.1 format.
- Parameters
-
[in] publicKeyInfo Public key information [in] publicKey Pointer to the EC public key [out] output Buffer where to store the ASN.1 structure [out] written Length of the resulting ASN.1 structure
- Returns
- Error code
Definition at line 1068 of file x509_key_format.c.
◆ x509ExportEddsaPrivateKey()
error_t x509ExportEddsaPrivateKey | ( | const EddsaPrivateKey * | privateKey, |
size_t | privateKeyLen, | ||
uint8_t * | output, | ||
size_t * | written | ||
) |
Export an EdDSA private key to ASN.1 format.
- Parameters
-
[in] privateKey Pointer to the EdDSA private key [in] privateKeyLen Length of the EdDSA private key, in bytes [out] output Buffer where to store the ASN.1 structure [out] written Length of the resulting ASN.1 structure
- Returns
- Error code
Definition at line 1152 of file x509_key_format.c.
◆ x509ExportEddsaPublicKey()
error_t x509ExportEddsaPublicKey | ( | const EddsaPublicKey * | publicKey, |
size_t | publicKeyLen, | ||
uint8_t * | output, | ||
size_t * | written | ||
) |
Export an EdDSA public key to ASN.1 format.
- Parameters
-
[in] publicKey Pointer to the EdDSA public key [in] publicKeyLen Length of the EdDSA public key, in bytes [out] output Buffer where to store the ASN.1 structure [out] written Length of the resulting ASN.1 structure
- Returns
- Error code
Definition at line 1123 of file x509_key_format.c.
◆ x509ExportRsaPrivateKey()
error_t x509ExportRsaPrivateKey | ( | const RsaPrivateKey * | privateKey, |
uint8_t * | output, | ||
size_t * | written | ||
) |
Export an RSA private key to ASN.1 format.
- Parameters
-
[in] privateKey Pointer to the RSA private key [out] output Buffer where to store the ASN.1 structure [out] written Length of the resulting ASN.1 structure
- Returns
- Error code
Definition at line 760 of file x509_key_format.c.
◆ x509ExportRsaPublicKey()
error_t x509ExportRsaPublicKey | ( | const RsaPublicKey * | publicKey, |
uint8_t * | output, | ||
size_t * | written | ||
) |
Export an RSA public key to ASN.1 format.
- Parameters
-
[in] publicKey Pointer to the RSA public key [out] output Buffer where to store the ASN.1 structure [out] written Length of the resulting ASN.1 structure
- Returns
- Error code
Definition at line 697 of file x509_key_format.c.
◆ x509FormatAlgoId()
error_t x509FormatAlgoId | ( | const X509SubjectPublicKeyInfo * | publicKeyInfo, |
const void * | params, | ||
uint8_t * | output, | ||
size_t * | written | ||
) |
Format AlgorithmIdentifier structure.
- Parameters
-
[in] publicKeyInfo Subject's public key information [in] params Pointer to the domain parameters (DSA or ECDSA) [out] output Buffer where to format the ASN.1 structure [out] written Length of the resulting ASN.1 structure
- Returns
- Error code
Definition at line 277 of file x509_key_format.c.
◆ x509FormatDsaParameters()
error_t x509FormatDsaParameters | ( | const X509DsaParameters * | dsaParams, |
uint8_t * | output, | ||
size_t * | written | ||
) |
Format DSA domain parameters.
- Parameters
-
[in] dsaParams Pointer to the DSA domain parameters [out] output Buffer where to format the ASN.1 structure [out] written Length of the resulting ASN.1 structure
- Returns
- Error code
Definition at line 543 of file x509_key_format.c.
◆ x509FormatDsaPublicKey()
error_t x509FormatDsaPublicKey | ( | const X509DsaPublicKey * | dsaPublicKey, |
uint8_t * | output, | ||
size_t * | written | ||
) |
Format DSAPublicKey structure.
- Parameters
-
[in] dsaPublicKey Pointer to the DSA public key [out] output Buffer where to format the DSAPublicKey structure [out] written Length of the DSAPublicKey structure
- Returns
- Error code
Definition at line 507 of file x509_key_format.c.
◆ x509FormatEcParameters()
error_t x509FormatEcParameters | ( | const X509EcParameters * | ecParams, |
uint8_t * | output, | ||
size_t * | written | ||
) |
Format ECParameters structure.
- Parameters
-
[in] ecParams Pointer to the EC parameters [out] output Buffer where to format the ECParameters structure [out] written Length of the ECParameters structure
- Returns
- Error code
Definition at line 659 of file x509_key_format.c.
◆ x509FormatEcPublicKey()
error_t x509FormatEcPublicKey | ( | const X509EcPublicKey * | ecPublicKey, |
uint8_t * | output, | ||
size_t * | written | ||
) |
Format ECPublicKey structure.
- Parameters
-
[in] ecPublicKey Pointer to the EC public key [out] output Buffer where to format the ASN.1 structure [out] written Length of the resulting ASN.1 structure
- Returns
- Error code
Definition at line 637 of file x509_key_format.c.
◆ x509FormatRsaPublicKey()
error_t x509FormatRsaPublicKey | ( | const X509RsaPublicKey * | rsaPublicKey, |
uint8_t * | output, | ||
size_t * | written | ||
) |
Format RSAPublicKey structure.
- Parameters
-
[in] rsaPublicKey Pointer to the RSA public key [out] output Buffer where to format the ASN.1 structure [out] written Length of the resulting ASN.1 structure
- Returns
- Error code
Definition at line 430 of file x509_key_format.c.
◆ x509FormatSubjectPublicKeyInfo()
error_t x509FormatSubjectPublicKeyInfo | ( | const X509SubjectPublicKeyInfo * | publicKeyInfo, |
const void * | publicKey, | ||
uint8_t * | keyId, | ||
uint8_t * | output, | ||
size_t * | written | ||
) |
Format SubjectPublicKeyInfo structure.
- Parameters
-
[in] publicKeyInfo Subject's public key information [in] publicKey Pointer to the public key (RSA, DSA, ECDSA or EdDSA) [out] keyId Subject's key identifier (optional parameter) [out] output Buffer where to format the ASN.1 structure [out] written Length of the resulting ASN.1 structure
- Returns
- Error code
Definition at line 57 of file x509_key_format.c.