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 "hash/sha1.h"
#include "ecc/ed25519.h"
#include "ecc/ed448.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 | x509FormatAlgorithmIdentifier (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 | x509FormatRsaPssParameters (const X509RsaPssParameters *rsaPssParams, uint8_t *output, size_t *written) |
Format RSASSA-PSS parameters. More... | |
error_t | x509FormatRsaPssHashAlgo (const X509RsaPssParameters *rsaPssParams, uint8_t *output, size_t *written) |
Format RSASSA-PSS hash algorithm. More... | |
error_t | x509FormatRsaPssMaskGenAlgo (const X509RsaPssParameters *rsaPssParams, uint8_t *output, size_t *written) |
Format RSASSA-PSS mask generation algorithm. More... | |
error_t | x509FormatRsaPssMaskGenHashAlgo (const X509RsaPssParameters *rsaPssParams, uint8_t *output, size_t *written) |
Format RSASSA-PSS mask generation hash algorithm. More... | |
error_t | x509FormatRsaPssSaltLength (const X509RsaPssParameters *rsaPssParams, uint8_t *output, size_t *written) |
Format RSASSA-PSS salt length. 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... | |
Formatting of ASN.1 encoded keys.
SPDX-License-Identifier: GPL-2.0-or-later
Copyright (C) 2010-2019 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.
Definition in file x509_key_format.c.
#define TRACE_LEVEL CRYPTO_TRACE_LEVEL |
Definition at line 32 of file x509_key_format.c.
error_t x509ExportDsaParameters | ( | const DsaDomainParameters * | params, |
uint8_t * | output, | ||
size_t * | written | ||
) |
Export DSA domain parameters to ASN.1 format.
[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 |
Definition at line 1338 of file x509_key_format.c.
error_t x509ExportDsaPrivateKey | ( | const DsaPrivateKey * | privateKey, |
uint8_t * | output, | ||
size_t * | written | ||
) |
Export a DSA private key to ASN.1 format.
[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 |
Definition at line 1310 of file x509_key_format.c.
error_t x509ExportDsaPublicKey | ( | const DsaPublicKey * | publicKey, |
uint8_t * | output, | ||
size_t * | written | ||
) |
Export a DSA public key to ASN.1 format.
[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 |
Definition at line 1282 of file x509_key_format.c.
error_t x509ExportEcPublicKey | ( | const X509SubjectPublicKeyInfo * | publicKeyInfo, |
const EcPoint * | publicKey, | ||
uint8_t * | output, | ||
size_t * | written | ||
) |
Export an EC public key to ASN.1 format.
[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 |
Definition at line 1412 of file x509_key_format.c.
error_t x509ExportEddsaPrivateKey | ( | const EddsaPrivateKey * | privateKey, |
size_t | privateKeyLen, | ||
uint8_t * | output, | ||
size_t * | written | ||
) |
Export an EdDSA private key to ASN.1 format.
[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 |
Definition at line 1496 of file x509_key_format.c.
error_t x509ExportEddsaPublicKey | ( | const EddsaPublicKey * | publicKey, |
size_t | publicKeyLen, | ||
uint8_t * | output, | ||
size_t * | written | ||
) |
Export an EdDSA public key to ASN.1 format.
[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 |
Definition at line 1467 of file x509_key_format.c.
error_t x509ExportRsaPrivateKey | ( | const RsaPrivateKey * | privateKey, |
uint8_t * | output, | ||
size_t * | written | ||
) |
Export an RSA private key to ASN.1 format.
[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 |
Definition at line 1104 of file x509_key_format.c.
error_t x509ExportRsaPublicKey | ( | const RsaPublicKey * | publicKey, |
uint8_t * | output, | ||
size_t * | written | ||
) |
Export an RSA public key to ASN.1 format.
[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 |
Definition at line 1041 of file x509_key_format.c.
error_t x509FormatAlgorithmIdentifier | ( | const X509SubjectPublicKeyInfo * | publicKeyInfo, |
const void * | params, | ||
uint8_t * | output, | ||
size_t * | written | ||
) |
Format AlgorithmIdentifier structure.
[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 |
Definition at line 279 of file x509_key_format.c.
error_t x509FormatDsaParameters | ( | const X509DsaParameters * | dsaParams, |
uint8_t * | output, | ||
size_t * | written | ||
) |
Format DSA domain 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 |
Definition at line 882 of file x509_key_format.c.
error_t x509FormatDsaPublicKey | ( | const X509DsaPublicKey * | dsaPublicKey, |
uint8_t * | output, | ||
size_t * | written | ||
) |
Format DSAPublicKey structure.
[in] | dsaPublicKey | Pointer to the DSA public key |
[out] | output | Buffer where to format the DSAPublicKey structure |
[out] | written | Length of the DSAPublicKey structure |
Definition at line 846 of file x509_key_format.c.
error_t x509FormatEcParameters | ( | const X509EcParameters * | ecParams, |
uint8_t * | output, | ||
size_t * | written | ||
) |
Format ECParameters structure.
[in] | ecParams | Pointer to the EC parameters |
[out] | output | Buffer where to format the ECParameters structure |
[out] | written | Length of the ECParameters structure |
Definition at line 1003 of file x509_key_format.c.
error_t x509FormatEcPublicKey | ( | const X509EcPublicKey * | ecPublicKey, |
uint8_t * | output, | ||
size_t * | written | ||
) |
Format ECPublicKey structure.
[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 |
Definition at line 976 of file x509_key_format.c.
error_t x509FormatRsaPssHashAlgo | ( | const X509RsaPssParameters * | rsaPssParams, |
uint8_t * | output, | ||
size_t * | written | ||
) |
Format RSASSA-PSS hash algorithm.
[in] | rsaPssParams | Pointer to the RSA-PSS parameters |
[out] | output | Buffer where to format the ASN.1 structure |
[out] | written | Length of the resulting ASN.1 structure |
Definition at line 582 of file x509_key_format.c.
error_t x509FormatRsaPssMaskGenAlgo | ( | const X509RsaPssParameters * | rsaPssParams, |
uint8_t * | output, | ||
size_t * | written | ||
) |
Format RSASSA-PSS mask generation algorithm.
[in] | rsaPssParams | Pointer to the RSA-PSS parameters |
[out] | output | Buffer where to format the ASN.1 structure |
[out] | written | Length of the resulting ASN.1 structure |
Definition at line 651 of file x509_key_format.c.
error_t x509FormatRsaPssMaskGenHashAlgo | ( | const X509RsaPssParameters * | rsaPssParams, |
uint8_t * | output, | ||
size_t * | written | ||
) |
Format RSASSA-PSS mask generation hash algorithm.
[in] | rsaPssParams | Pointer to the RSA-PSS parameters |
[out] | output | Buffer where to format the ASN.1 structure |
[out] | written | Length of the resulting ASN.1 structure |
Definition at line 739 of file x509_key_format.c.
error_t x509FormatRsaPssParameters | ( | const X509RsaPssParameters * | rsaPssParams, |
uint8_t * | output, | ||
size_t * | written | ||
) |
Format RSASSA-PSS parameters.
[in] | rsaPssParams | Pointer to the RSA-PSS parameters |
[out] | output | Buffer where to format the ASN.1 structure |
[out] | written | Length of the resulting ASN.1 structure |
Definition at line 509 of file x509_key_format.c.
error_t x509FormatRsaPssSaltLength | ( | const X509RsaPssParameters * | rsaPssParams, |
uint8_t * | output, | ||
size_t * | written | ||
) |
Format RSASSA-PSS salt length.
[in] | rsaPssParams | Pointer to the RSA-PSS parameters |
[out] | output | Buffer where to format the ASN.1 structure |
[out] | written | Length of the resulting ASN.1 structure |
Definition at line 797 of file x509_key_format.c.
error_t x509FormatRsaPublicKey | ( | const X509RsaPublicKey * | rsaPublicKey, |
uint8_t * | output, | ||
size_t * | written | ||
) |
Format RSAPublicKey structure.
[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 |
Definition at line 432 of file x509_key_format.c.
error_t x509FormatSubjectPublicKeyInfo | ( | const X509SubjectPublicKeyInfo * | publicKeyInfo, |
const void * | publicKey, | ||
uint8_t * | keyId, | ||
uint8_t * | output, | ||
size_t * | written | ||
) |
Format SubjectPublicKeyInfo structure.
[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 |
Definition at line 58 of file x509_key_format.c.