x509_key_format.h File Reference

Formatting of ASN.1 encoded keys. More...

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

Go to the source code of this file.

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

Detailed Description

Formatting of ASN.1 encoded keys.

License

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.

Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
1.9.6

Definition in file x509_key_format.h.

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]paramsPointer to the DSA domain parameters
[out]outputBuffer where to store the ASN.1 structure
[out]writtenLength of the resulting ASN.1 structure
Returns
Error code

Definition at line 1338 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]privateKeyPointer to the DSA private key
[out]outputBuffer where to store the ASN.1 structure
[out]writtenLength of the resulting ASN.1 structure
Returns
Error code

Definition at line 1310 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]publicKeyPointer to the DSA public key
[out]outputBuffer where to store the ASN.1 structure
[out]writtenLength of the resulting ASN.1 structure
Returns
Error code

Definition at line 1282 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]publicKeyInfoPublic key information
[in]publicKeyPointer to the EC public key
[out]outputBuffer where to store the ASN.1 structure
[out]writtenLength of the resulting ASN.1 structure
Returns
Error code

Definition at line 1412 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]privateKeyPointer to the EdDSA private key
[in]privateKeyLenLength of the EdDSA private key, in bytes
[out]outputBuffer where to store the ASN.1 structure
[out]writtenLength of the resulting ASN.1 structure
Returns
Error code

Definition at line 1496 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]publicKeyPointer to the EdDSA public key
[in]publicKeyLenLength of the EdDSA public key, in bytes
[out]outputBuffer where to store the ASN.1 structure
[out]writtenLength of the resulting ASN.1 structure
Returns
Error code

Definition at line 1467 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]privateKeyPointer to the RSA private key
[out]outputBuffer where to store the ASN.1 structure
[out]writtenLength of the resulting ASN.1 structure
Returns
Error code

Definition at line 1104 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]publicKeyPointer to the RSA public key
[out]outputBuffer where to store the ASN.1 structure
[out]writtenLength of the resulting ASN.1 structure
Returns
Error code

Definition at line 1041 of file x509_key_format.c.

◆ x509FormatAlgorithmIdentifier()

error_t x509FormatAlgorithmIdentifier ( const X509SubjectPublicKeyInfo publicKeyInfo,
const void *  params,
uint8_t *  output,
size_t *  written 
)

Format AlgorithmIdentifier structure.

Parameters
[in]publicKeyInfoSubject's public key information
[in]paramsPointer to the domain parameters (DSA or ECDSA)
[out]outputBuffer where to format the ASN.1 structure
[out]writtenLength of the resulting ASN.1 structure
Returns
Error code

Definition at line 279 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]dsaParamsPointer to the DSA domain parameters
[out]outputBuffer where to format the ASN.1 structure
[out]writtenLength of the resulting ASN.1 structure
Returns
Error code

Definition at line 882 of file x509_key_format.c.

◆ x509FormatDsaPublicKey()

error_t x509FormatDsaPublicKey ( const X509DsaPublicKey dsaPublicKey,
uint8_t *  output,
size_t *  written 
)

Format DSAPublicKey structure.

Parameters
[in]dsaPublicKeyPointer to the DSA public key
[out]outputBuffer where to format the DSAPublicKey structure
[out]writtenLength of the DSAPublicKey structure
Returns
Error code

Definition at line 846 of file x509_key_format.c.

◆ x509FormatEcParameters()

error_t x509FormatEcParameters ( const X509EcParameters ecParams,
uint8_t *  output,
size_t *  written 
)

Format ECParameters structure.

Parameters
[in]ecParamsPointer to the EC parameters
[out]outputBuffer where to format the ECParameters structure
[out]writtenLength of the ECParameters structure
Returns
Error code

Definition at line 1003 of file x509_key_format.c.

◆ x509FormatEcPublicKey()

error_t x509FormatEcPublicKey ( const X509EcPublicKey ecPublicKey,
uint8_t *  output,
size_t *  written 
)

Format ECPublicKey structure.

Parameters
[in]ecPublicKeyPointer to the EC public key
[out]outputBuffer where to format the ASN.1 structure
[out]writtenLength of the resulting ASN.1 structure
Returns
Error code

Definition at line 976 of file x509_key_format.c.

◆ x509FormatRsaPssHashAlgo()

error_t x509FormatRsaPssHashAlgo ( const X509RsaPssParameters rsaPssParams,
uint8_t *  output,
size_t *  written 
)

Format RSASSA-PSS hash algorithm.

Parameters
[in]rsaPssParamsPointer to the RSA-PSS parameters
[out]outputBuffer where to format the ASN.1 structure
[out]writtenLength of the resulting ASN.1 structure
Returns
Error code

Definition at line 582 of file x509_key_format.c.

◆ x509FormatRsaPssMaskGenAlgo()

error_t x509FormatRsaPssMaskGenAlgo ( const X509RsaPssParameters rsaPssParams,
uint8_t *  output,
size_t *  written 
)

Format RSASSA-PSS mask generation algorithm.

Parameters
[in]rsaPssParamsPointer to the RSA-PSS parameters
[out]outputBuffer where to format the ASN.1 structure
[out]writtenLength of the resulting ASN.1 structure
Returns
Error code

Definition at line 651 of file x509_key_format.c.

◆ x509FormatRsaPssMaskGenHashAlgo()

error_t x509FormatRsaPssMaskGenHashAlgo ( const X509RsaPssParameters rsaPssParams,
uint8_t *  output,
size_t *  written 
)

Format RSASSA-PSS mask generation hash algorithm.

Parameters
[in]rsaPssParamsPointer to the RSA-PSS parameters
[out]outputBuffer where to format the ASN.1 structure
[out]writtenLength of the resulting ASN.1 structure
Returns
Error code

Definition at line 739 of file x509_key_format.c.

◆ x509FormatRsaPssParameters()

error_t x509FormatRsaPssParameters ( const X509RsaPssParameters rsaPssParams,
uint8_t *  output,
size_t *  written 
)

Format RSASSA-PSS parameters.

Parameters
[in]rsaPssParamsPointer to the RSA-PSS parameters
[out]outputBuffer where to format the ASN.1 structure
[out]writtenLength of the resulting ASN.1 structure
Returns
Error code

Definition at line 509 of file x509_key_format.c.

◆ x509FormatRsaPssSaltLength()

error_t x509FormatRsaPssSaltLength ( const X509RsaPssParameters rsaPssParams,
uint8_t *  output,
size_t *  written 
)

Format RSASSA-PSS salt length.

Parameters
[in]rsaPssParamsPointer to the RSA-PSS parameters
[out]outputBuffer where to format the ASN.1 structure
[out]writtenLength of the resulting ASN.1 structure
Returns
Error code

Definition at line 797 of file x509_key_format.c.

◆ x509FormatRsaPublicKey()

error_t x509FormatRsaPublicKey ( const X509RsaPublicKey rsaPublicKey,
uint8_t *  output,
size_t *  written 
)

Format RSAPublicKey structure.

Parameters
[in]rsaPublicKeyPointer to the RSA public key
[out]outputBuffer where to format the ASN.1 structure
[out]writtenLength of the resulting ASN.1 structure
Returns
Error code

Definition at line 432 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]publicKeyInfoSubject's public key information
[in]publicKeyPointer to the public key (RSA, DSA, ECDSA or EdDSA)
[out]keyIdSubject's key identifier (optional parameter)
[out]outputBuffer where to format the ASN.1 structure
[out]writtenLength of the resulting ASN.1 structure
Returns
Error code

Definition at line 58 of file x509_key_format.c.