est_client.h File Reference

EST client. More...

#include "est_config.h"
#include "core/net.h"
#include "http/http_client.h"

Go to the source code of this file.

Data Structures

struct  _EstClientContext
 EST client context. More...
 

Macros

#define CYCLONE_EST_VERSION_STRING   "2.5.4"
 
#define CYCLONE_EST_MAJOR_VERSION   2
 
#define CYCLONE_EST_MINOR_VERSION   5
 
#define CYCLONE_EST_REV_NUMBER   4
 
#define EST_CLIENT_SUPPORT   DISABLED
 
#define EST_CLIENT_RSA_SUPPORT   ENABLED
 
#define EST_CLIENT_ECDSA_SUPPORT   ENABLED
 
#define EST_CLIENT_DEFAULT_TIMEOUT   20000
 
#define EST_CLIENT_BUFFER_SIZE   4096
 
#define EST_CLIENT_MAX_HOST_LEN   64
 
#define EST_CLIENT_MAX_URI_LEN   64
 
#define EST_CLIENT_MAX_CONTENT_TYPE_LEN   40
 
#define EST_CLIENT_MAX_CSR_LEN   1024
 
#define EST_CLIENT_MAX_CERT_LEN   2048
 
#define EST_CLIENT_MAX_CA_CERTS_LEN   4096
 
#define EST_CLIENT_PRIVATE_CONTEXT
 
#define EstClientContext   struct _EstClientContext
 

Typedefs

typedef error_t(* EstClientTlsInitCallback) (EstClientContext *context, TlsContext *tlsContext)
 TLS initialization callback function. More...
 
typedef error_t(* EstClientCsrGenCallback) (EstClientContext *context, const char_t *challengePwd, uint8_t *buffer, size_t size, size_t *length)
 CSR generation callback function. More...
 

Enumerations

enum  EstClientState {
  EST_CLIENT_STATE_DISCONNECTED = 0, EST_CLIENT_STATE_CONNECTING = 1, EST_CLIENT_STATE_CONNECTED = 2, EST_CLIENT_STATE_GET_CA = 3,
  EST_CLIENT_STATE_CSR_GEN = 4, EST_CLIENT_STATE_ENROLL = 5, EST_CLIENT_STATE_REENROLL = 6, EST_CLIENT_STATE_DISCONNECTING = 7
}
 EST client states. More...
 
enum  EstRequestState {
  EST_REQ_STATE_INIT = 0, EST_REQ_STATE_FORMAT_HEADER = 1, EST_REQ_STATE_SEND_HEADER = 2, EST_REQ_STATE_FORMAT_BODY = 3,
  EST_REQ_STATE_SEND_BODY = 4, EST_REQ_STATE_RECEIVE_HEADER = 5, EST_REQ_STATE_PARSE_HEADER = 6, EST_REQ_STATE_RECEIVE_BODY = 7,
  EST_REQ_STATE_CLOSE_BODY = 8, EST_REQ_STATE_COMPLETE = 9
}
 HTTP request states. More...
 

Functions

error_t estClientInit (EstClientContext *context)
 EST client initialization. More...
 
error_t estClientRegisterTlsInitCallback (EstClientContext *context, EstClientTlsInitCallback callback)
 Register TLS initialization callback function. More...
 
error_t estClientRegisterCsrGenCallback (EstClientContext *context, EstClientCsrGenCallback callback)
 Register CSR generation callback function. More...
 
error_t estClientSetPrng (EstClientContext *context, const PrngAlgo *prngAlgo, void *prngContext)
 Set the pseudo-random number generator to be used. More...
 
error_t estClientSetTimeout (EstClientContext *context, systime_t timeout)
 Set communication timeout. More...
 
error_t estClientSetHost (EstClientContext *context, const char_t *host)
 Set the domain name of the EST server. More...
 
error_t estClientSetPathPrefix (EstClientContext *context, const char_t *pathPrefix)
 Set path prefix. More...
 
error_t estClientSetAllowedAuthModes (EstClientContext *context, uint_t allowedAuthModes)
 Set allowed HTTP authentication modes. More...
 
error_t estClientSetAuthInfo (EstClientContext *context, const char_t *username, const char_t *password)
 Set authentication information. More...
 
error_t estClientBindToInterface (EstClientContext *context, NetInterface *interface)
 Bind the EST client to a particular network interface. More...
 
error_t estClientConnect (EstClientContext *context, const IpAddr *serverIpAddr, uint16_t serverPort)
 Specify the address of the EST server. More...
 
error_t estClientLoadKeyPair (EstClientContext *context, const char_t *publicKey, size_t publicKeyLen, const char_t *privateKey, size_t privateKeyLen, const char_t *password)
 Load public/private key pair. More...
 
void estClientUnloadKeyPair (EstClientContext *context)
 Unload public/private key pair. More...
 
error_t estClientLoadCert (EstClientContext *context, const char_t *input, size_t length)
 Load client's certificate. More...
 
error_t estClientStoreCert (EstClientContext *context, char_t *output, size_t *written)
 Store client's certificate. More...
 
error_t estClientLoadCaCerts (EstClientContext *context, const char_t *input, size_t length)
 Load implicit TA database. More...
 
error_t estClientStoreCaCerts (EstClientContext *context, char_t *output, size_t *written)
 Store CA certificates. More...
 
error_t estClientGetCaCerts (EstClientContext *context)
 Get CA certificates. More...
 
error_t estClientEnroll (EstClientContext *context)
 Certificate enrollment. More...
 
error_t estClientReEnroll (EstClientContext *context)
 Certificate re-enrollment. More...
 
error_t estClientDisconnect (EstClientContext *context)
 Gracefully disconnect from the EST server. More...
 
error_t estClientClose (EstClientContext *context)
 Close the connection with the EST server. More...
 
void estClientDeinit (EstClientContext *context)
 Release EST client context. More...
 

Detailed Description

EST client.

License

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

Copyright (C) 2024-2025 Oryx Embedded SARL. All rights reserved.

This file is part of CycloneEST 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.5.4

Definition in file est_client.h.

Macro Definition Documentation

◆ CYCLONE_EST_MAJOR_VERSION

#define CYCLONE_EST_MAJOR_VERSION   2

Definition at line 69 of file est_client.h.

◆ CYCLONE_EST_MINOR_VERSION

#define CYCLONE_EST_MINOR_VERSION   5

Definition at line 71 of file est_client.h.

◆ CYCLONE_EST_REV_NUMBER

#define CYCLONE_EST_REV_NUMBER   4

Definition at line 73 of file est_client.h.

◆ CYCLONE_EST_VERSION_STRING

#define CYCLONE_EST_VERSION_STRING   "2.5.4"

Definition at line 67 of file est_client.h.

◆ EST_CLIENT_BUFFER_SIZE

#define EST_CLIENT_BUFFER_SIZE   4096

Definition at line 105 of file est_client.h.

◆ EST_CLIENT_DEFAULT_TIMEOUT

#define EST_CLIENT_DEFAULT_TIMEOUT   20000

Definition at line 98 of file est_client.h.

◆ EST_CLIENT_ECDSA_SUPPORT

#define EST_CLIENT_ECDSA_SUPPORT   ENABLED

Definition at line 91 of file est_client.h.

◆ EST_CLIENT_MAX_CA_CERTS_LEN

#define EST_CLIENT_MAX_CA_CERTS_LEN   4096

Definition at line 147 of file est_client.h.

◆ EST_CLIENT_MAX_CERT_LEN

#define EST_CLIENT_MAX_CERT_LEN   2048

Definition at line 140 of file est_client.h.

◆ EST_CLIENT_MAX_CONTENT_TYPE_LEN

#define EST_CLIENT_MAX_CONTENT_TYPE_LEN   40

Definition at line 126 of file est_client.h.

◆ EST_CLIENT_MAX_CSR_LEN

#define EST_CLIENT_MAX_CSR_LEN   1024

Definition at line 133 of file est_client.h.

◆ EST_CLIENT_MAX_HOST_LEN

#define EST_CLIENT_MAX_HOST_LEN   64

Definition at line 112 of file est_client.h.

◆ EST_CLIENT_MAX_URI_LEN

#define EST_CLIENT_MAX_URI_LEN   64

Definition at line 119 of file est_client.h.

◆ EST_CLIENT_PRIVATE_CONTEXT

#define EST_CLIENT_PRIVATE_CONTEXT

Definition at line 154 of file est_client.h.

◆ EST_CLIENT_RSA_SUPPORT

#define EST_CLIENT_RSA_SUPPORT   ENABLED

Definition at line 84 of file est_client.h.

◆ EST_CLIENT_SUPPORT

#define EST_CLIENT_SUPPORT   DISABLED

Definition at line 77 of file est_client.h.

◆ EstClientContext

#define EstClientContext   struct _EstClientContext

Definition at line 159 of file est_client.h.

Typedef Documentation

◆ EstClientCsrGenCallback

typedef error_t(* EstClientCsrGenCallback) (EstClientContext *context, const char_t *challengePwd, uint8_t *buffer, size_t size, size_t *length)

CSR generation callback function.

Definition at line 215 of file est_client.h.

◆ EstClientTlsInitCallback

typedef error_t(* EstClientTlsInitCallback) (EstClientContext *context, TlsContext *tlsContext)

TLS initialization callback function.

Definition at line 207 of file est_client.h.

Enumeration Type Documentation

◆ EstClientState

EST client states.

Enumerator
EST_CLIENT_STATE_DISCONNECTED 
EST_CLIENT_STATE_CONNECTING 
EST_CLIENT_STATE_CONNECTED 
EST_CLIENT_STATE_GET_CA 
EST_CLIENT_STATE_CSR_GEN 
EST_CLIENT_STATE_ENROLL 
EST_CLIENT_STATE_REENROLL 
EST_CLIENT_STATE_DISCONNECTING 

Definition at line 171 of file est_client.h.

◆ EstRequestState

HTTP request states.

Enumerator
EST_REQ_STATE_INIT 
EST_REQ_STATE_FORMAT_HEADER 
EST_REQ_STATE_SEND_HEADER 
EST_REQ_STATE_FORMAT_BODY 
EST_REQ_STATE_SEND_BODY 
EST_REQ_STATE_RECEIVE_HEADER 
EST_REQ_STATE_PARSE_HEADER 
EST_REQ_STATE_RECEIVE_BODY 
EST_REQ_STATE_CLOSE_BODY 
EST_REQ_STATE_COMPLETE 

Definition at line 188 of file est_client.h.

Function Documentation

◆ estClientBindToInterface()

error_t estClientBindToInterface ( EstClientContext context,
NetInterface interface 
)

Bind the EST client to a particular network interface.

Parameters
[in]contextPointer to the EST client context
[in]interfaceNetwork interface to be used
Returns
Error code

Definition at line 290 of file est_client.c.

◆ estClientClose()

error_t estClientClose ( EstClientContext context)

Close the connection with the EST server.

Parameters
[in]contextPointer to the EST client context
Returns
Error code

Definition at line 1069 of file est_client.c.

◆ estClientConnect()

error_t estClientConnect ( EstClientContext context,
const IpAddr serverIpAddr,
uint16_t  serverPort 
)

Specify the address of the EST server.

Parameters
[in]contextPointer to the EST client context
[in]serverIpAddrIP address of the EST server to connect to
[in]serverPortUDP port number
Returns
Error code

Definition at line 313 of file est_client.c.

◆ estClientDeinit()

void estClientDeinit ( EstClientContext context)

Release EST client context.

Parameters
[in]contextPointer to the EST client context

Definition at line 1090 of file est_client.c.

◆ estClientDisconnect()

error_t estClientDisconnect ( EstClientContext context)

Gracefully disconnect from the EST server.

Parameters
[in]contextPointer to the EST client context
Returns
Error code

Definition at line 1003 of file est_client.c.

◆ estClientEnroll()

error_t estClientEnroll ( EstClientContext context)

Certificate enrollment.

Parameters
[in]contextPointer to the EST client context
Returns
Error code

Definition at line 821 of file est_client.c.

◆ estClientGetCaCerts()

error_t estClientGetCaCerts ( EstClientContext context)

Get CA certificates.

Parameters
[in]contextPointer to the EST client context
Returns
Error code

Definition at line 762 of file est_client.c.

◆ estClientInit()

error_t estClientInit ( EstClientContext context)

EST client initialization.

Parameters
[in]contextPointer to the EST client context
Returns
Error code

Definition at line 62 of file est_client.c.

◆ estClientLoadCaCerts()

error_t estClientLoadCaCerts ( EstClientContext context,
const char_t input,
size_t  length 
)

Load implicit TA database.

Parameters
[in]contextPointer to the EST client context
[out]inputPointer to the PEM-encoded CA certificates
[out]lengthLength of the PEM-encoded CA certificates
Returns
Error code

Definition at line 659 of file est_client.c.

◆ estClientLoadCert()

error_t estClientLoadCert ( EstClientContext context,
const char_t input,
size_t  length 
)

Load client's certificate.

Parameters
[in]contextPointer to the EST client context
[out]inputPointer to the PEM-encoded certificate
[out]lengthLength of the PEM-encoded certificate
Returns
Error code

Definition at line 563 of file est_client.c.

◆ estClientLoadKeyPair()

error_t estClientLoadKeyPair ( EstClientContext context,
const char_t publicKey,
size_t  publicKeyLen,
const char_t privateKey,
size_t  privateKeyLen,
const char_t password 
)

Load public/private key pair.

Parameters
[in]contextPointer to the EST client context
[in]publicKeyPublic key (PEM format)
[in]publicKeyLenLength of the public key
[in]privateKeyPrivate key (PEM format)
[in]privateKeyLenLength of the private key
[in]passwordNULL-terminated string containing the password. This parameter is required if the private key is encrypted
Returns
Error code

Definition at line 429 of file est_client.c.

◆ estClientReEnroll()

error_t estClientReEnroll ( EstClientContext context)

Certificate re-enrollment.

Parameters
[in]contextPointer to the EST client context
Returns
Error code

Definition at line 910 of file est_client.c.

◆ estClientRegisterCsrGenCallback()

error_t estClientRegisterCsrGenCallback ( EstClientContext context,
EstClientCsrGenCallback  callback 
)

Register CSR generation callback function.

Parameters
[in]contextPointer to the EST client context
[in]callbackCSR generation callback function
Returns
Error code

Definition at line 131 of file est_client.c.

◆ estClientRegisterTlsInitCallback()

error_t estClientRegisterTlsInitCallback ( EstClientContext context,
EstClientTlsInitCallback  callback 
)

Register TLS initialization callback function.

Parameters
[in]contextPointer to the EST client context
[in]callbackTLS initialization callback function
Returns
Error code

Definition at line 109 of file est_client.c.

◆ estClientSetAllowedAuthModes()

error_t estClientSetAllowedAuthModes ( EstClientContext context,
uint_t  allowedAuthModes 
)

Set allowed HTTP authentication modes.

Parameters
[in]contextPointer to the EST client context
[in]allowedAuthModesLogic OR of allowed HTTP authentication schemes
Returns
Error code

Definition at line 250 of file est_client.c.

◆ estClientSetAuthInfo()

error_t estClientSetAuthInfo ( EstClientContext context,
const char_t username,
const char_t password 
)

Set authentication information.

Parameters
[in]contextPointer to the EST client context
[in]usernameNULL-terminated string containing the user name to be used
[in]passwordNULL-terminated string containing the password to be used
Returns
Error code

Definition at line 273 of file est_client.c.

◆ estClientSetHost()

error_t estClientSetHost ( EstClientContext context,
const char_t host 
)

Set the domain name of the EST server.

Parameters
[in]contextPointer to the EST client context
[in]hostNULL-terminated string containing the host name
Returns
Error code

Definition at line 199 of file est_client.c.

◆ estClientSetPathPrefix()

error_t estClientSetPathPrefix ( EstClientContext context,
const char_t pathPrefix 
)

Set path prefix.

Parameters
[in]contextPointer to the EST client context
[in]uriNULL-terminated string that contains the path prefix
Returns
Error code

Definition at line 224 of file est_client.c.

◆ estClientSetPrng()

error_t estClientSetPrng ( EstClientContext context,
const PrngAlgo prngAlgo,
void *  prngContext 
)

Set the pseudo-random number generator to be used.

Parameters
[in]contextPointer to the EST client context
[in]prngAlgoPRNG algorithm
[in]prngContextPointer to the PRNG context
Returns
Error code

Definition at line 154 of file est_client.c.

◆ estClientSetTimeout()

error_t estClientSetTimeout ( EstClientContext context,
systime_t  timeout 
)

Set communication timeout.

Parameters
[in]contextPointer to the EST client context
[in]timeoutTimeout value, in milliseconds
Returns
Error code

Definition at line 178 of file est_client.c.

◆ estClientStoreCaCerts()

error_t estClientStoreCaCerts ( EstClientContext context,
char_t output,
size_t *  written 
)

Store CA certificates.

Parameters
[in]contextPointer to the EST client context
[out]outputPointer to the buffer where to store the PEM-encoded CA certificates (optional parameter)
[out]writtenLength of the resulting PEM string
Returns
Error code

Definition at line 717 of file est_client.c.

◆ estClientStoreCert()

error_t estClientStoreCert ( EstClientContext context,
char_t output,
size_t *  written 
)

Store client's certificate.

Parameters
[in]contextPointer to the EST client context
[out]outputPointer to the buffer where to store the PEM-encoded certificate (optional parameter)
[out]writtenLength of the resulting PEM string
Returns
Error code

Definition at line 624 of file est_client.c.

◆ estClientUnloadKeyPair()

void estClientUnloadKeyPair ( EstClientContext context)

Unload public/private key pair.

Parameters
[in]contextPointer to the EST client context

Definition at line 522 of file est_client.c.