12 #ifndef _ASTARTE_CREDENTIALS_H_
13 #define _ASTARTE_CREDENTIALS_H_
20 #define CERT_LENGTH 4096
23 #define ASTARTE_CREDENTIALS_DEFAULT_NVS_PARTITION NULL
25 enum credential_type_t
27 ASTARTE_CREDENTIALS_CSR = 1,
28 ASTARTE_CREDENTIALS_KEY,
29 ASTARTE_CREDENTIALS_CERTIFICATE
30 } __attribute__((deprecated(
"Please use the typedef credential_type_t")));
32 #pragma GCC diagnostic push
33 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
34 typedef enum credential_type_t credential_type_t;
35 #pragma GCC diagnostic pop
38 void *opaque, credential_type_t cred_type,
const void *credential,
size_t length);
40 void *opaque, credential_type_t cred_type,
char *out,
size_t length);
41 typedef bool (*astarte_credentials_exists_t)(
void *opaque, credential_type_t cred_type);
42 typedef astarte_err_t (*astarte_credentials_remove_t)(
void *opaque, credential_type_t cred_type);
46 astarte_credentials_store_t astarte_credentials_store;
47 astarte_credentials_fetch_t astarte_credentials_fetch;
48 astarte_credentials_exists_t astarte_credentials_exists;
49 astarte_credentials_remove_t astarte_credentials_remove;
175 const char *cert_pem,
char *out,
size_t length);
252 void *opaque, credential_type_t cred_type,
const void *credential,
size_t length);
260 void *opaque, credential_type_t cred_type,
char *out,
size_t length);
267 bool astarte_credentials_exists(
void *opaque, credential_type_t cred_type);
274 astarte_err_t astarte_credentials_remove(
void *opaque, credential_type_t cred_type);
282 void *opaque, credential_type_t cred_type,
const void *credential,
size_t length);
290 void *opaque, credential_type_t cred_type,
char *out,
size_t length);
297 bool astarte_credentials_nvs_exists(
void *opaque, credential_type_t cred_type);
304 astarte_err_t astarte_credentials_nvs_remove(
void *opaque, credential_type_t cred_type);
Astarte types and defines.
astarte_err_t
Astarte return codes.
Definition: astarte.h:28
astarte_err_t astarte_credentials_get_csr(char *out, size_t length)
get the saved CSR
bool astarte_credentials_has_certificate()
check if the certificate exists
astarte_err_t astarte_credentials_create_key()
create Astarte private key.
astarte_err_t astarte_credentials_get_key(char *out, size_t length)
get the private key to connect with the Astarte MQTT v1 protocol
astarte_err_t astarte_credentials_create_csr()
create Astarte CSR to be sent to Pairing API.
bool astarte_credentials_has_key()
check if the private key exists
astarte_err_t astarte_credentials_set_storage_context(astarte_credentials_context_t *creds_context)
replace credentials context.
astarte_err_t astarte_credentials_get_stored_credentials_secret(char *out, size_t length)
get the stored credentials_secret
bool astarte_credentials_has_csr()
check if the CSR exists
astarte_err_t astarte_credentials_set_stored_credentials_secret(const char *credentials_secret)
save the credentials_secret in the NVS
astarte_err_t astarte_credentials_delete_certificate()
delets the saved certificate used to connect with the Astarte MQTT v1 protocol
astarte_err_t astarte_credentials_save_certificate(const char *cert_pem)
save the certificate to connect with the Astarte MQTT v1 protocol
astarte_err_t astarte_credentials_init()
initialize Astarte credentials.
astarte_err_t astarte_credentials_get_certificate(char *out, size_t length)
get the certificate to connect with the Astarte MQTT v1 protocol
astarte_err_t astarte_credentials_erase_stored_credentials_secret()
delete the credentials_secret from the NVS
astarte_err_t astarte_credentials_use_nvs_storage(const char *partition_label)
use a NVS partition as credentials context.
astarte_err_t astarte_credentials_get_certificate_common_name(const char *cert_pem, char *out, size_t length)
get the certificate Common Name
bool astarte_credentials_is_initialized()
check if Astarte credentials are initialized.
Definition: astarte_credentials.h:53
Definition: astarte_credentials.h:45