(D)TLS Credential Manager

Credentials management module for (D)TLS. More...

Detailed Description

Credentials management module for (D)TLS.

Files

file  credman.h
 (D)TLS credentials management module definitions
 

Data Structures

struct  credman_buffer_t
 Buffer of the credential. More...
 
struct  psk_params_t
 PSK parameters. More...
 
struct  ecdsa_public_key_t
 ECDSA public keys. More...
 
struct  ecdsa_params_t
 ECDSA parameters. More...
 
struct  credman_credential_t
 Credential information. More...
 

Macros

#define CREDMAN_MAX_CREDENTIALS   (2)
 Maximum number of credentials in credential pool.
 
#define CREDMAN_TAG_EMPTY   (0)
 Used to signal empty/no tag.
 

Typedefs

typedef uint16_t credman_tag_t
 Tag of the credential.
 

Enumerations

enum  credman_type_t { CREDMAN_TYPE_EMPTY = 0, CREDMAN_TYPE_PSK = 1, CREDMAN_TYPE_ECDSA = 2 }
 Credential types. More...
 
enum  {
  CREDMAN_OK = 0, CREDMAN_EXIST = -1, CREDMAN_NO_SPACE = -2, CREDMAN_NOT_FOUND = -3,
  CREDMAN_INVALID = -4, CREDMAN_TYPE_UNKNOWN = -5, CREDMAN_ERROR = -6
}
 Return values. More...
 

Functions

int credman_add (const credman_credential_t *credential)
 Adds a credential to the credential pool. More...
 
int credman_get (credman_credential_t *credential, credman_tag_t tag, credman_type_t type)
 Gets a credential from credential pool. More...
 
void credman_delete (credman_tag_t tag, credman_type_t type)
 Delete a credential from the credential pool. More...
 
int credman_get_used_count (void)
 Gets the number of credentials currently in the credential pool. More...
 
void credman_reset (void)
 Empties the credential pool.
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Return values.

Enumerator
CREDMAN_OK 

No error.

CREDMAN_EXIST 

Credential already exist in system pool.

CREDMAN_NO_SPACE 

No space in system pool for new credential.

CREDMAN_NOT_FOUND 

Credential not found in the system pool.

CREDMAN_INVALID 

Invalid input parameter(s)

CREDMAN_TYPE_UNKNOWN 

Unknown credential type.

CREDMAN_ERROR 

Other errors.

Definition at line 118 of file credman.h.

◆ credman_type_t

Credential types.

Enumerator
CREDMAN_TYPE_EMPTY 

Empty type.

Used to detect uninitialized credman_credential_t internally.

CREDMAN_TYPE_PSK 

PSK credential type.

CREDMAN_TYPE_ECDSA 

ECDSA credential type.

Definition at line 92 of file credman.h.

Function Documentation

◆ credman_add()

int credman_add ( const credman_credential_t credential)

Adds a credential to the credential pool.

Parameters
[in]credentialCredential to add.
Returns
CREDMAN_OK on success
CREDMAN_EXIST if credential of tag and type already exist
CREDMAN_NO_SPACE if credential pool is full
CREDMAN_TYPE_UNKNOWN if credential has unknown credman_credential_t::type
CREDMAN_INVALID if credential has
CREDMAN_INVALID credman_credential_t::tag with the value of CREDMAN_TAG_EMPTY
CREDMAN_INVALID credman_credential_t::type with the value of CREDMAN_TYPE_EMPTY
CREDMAN_INVALID credman_credential_t::params with invalid credential parameters i.e. the key points to NULL or has a length of 0
CREDMAN_ERROR on other errors

◆ credman_delete()

void credman_delete ( credman_tag_t  tag,
credman_type_t  type 
)

Delete a credential from the credential pool.

Does nothing if credential with credman_credential_t::tag tag and credman_credential_t::type type is not found.

Parameters
[in]tagTag of the credential
[in]typeType of the credential

◆ credman_get()

int credman_get ( credman_credential_t credential,
credman_tag_t  tag,
credman_type_t  type 
)

Gets a credential from credential pool.

Parameters
[out]credentialFound credential
[in]tagTag of credential to get
[in]typeType of credential to get
Returns
CREDMAN_OK on success
CREDMAN_NOT_FOUND if no credential with tag and type found
CREDMAN_ERROR on other errors

◆ credman_get_used_count()

int credman_get_used_count ( void  )

Gets the number of credentials currently in the credential pool.

Maximum number of allowed credentials is defined by CREDMAN_MAX_CREDENTIALS

Returns
number of credentials currently in the credential pool