credman.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2019 HAW Hamburg
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
27 #ifndef NET_CREDMAN_H
28 #define NET_CREDMAN_H
29 
30 #include <unistd.h>
31 #include <stdint.h>
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
45 #ifndef CONFIG_CREDMAN_MAX_CREDENTIALS
46 #define CONFIG_CREDMAN_MAX_CREDENTIALS (2)
47 #endif
48 
53 typedef struct {
54  const void *s;
55  size_t len;
57 
61 typedef struct {
65 } psk_params_t;
66 
70 typedef struct {
71  const void *x;
72  const void *y;
74 
78 typedef struct {
79  const void *private_key;
84 
88 typedef uint16_t credman_tag_t;
89 
93 #define CREDMAN_TAG_EMPTY (0)
94 
98 typedef enum {
108 
112 typedef struct {
115  union {
118  } params;
120 
124 enum {
132 };
133 
153 int credman_add(const credman_credential_t *credential);
154 
166 int credman_get(credman_credential_t *credential, credman_tag_t tag,
167  credman_type_t type);
168 
178 
186 int credman_get_used_count(void);
187 
188 #ifdef TEST_SUITES
189 
192 void credman_reset(void);
193 #endif /*TEST_SUITES */
194 
195 #ifdef __cplusplus
196 }
197 #endif
198 
199 #endif /* NET_CREDMAN_H */
200 
credman_delete
void credman_delete(credman_tag_t tag, credman_type_t type)
Delete a credential from the credential pool.
credman_credential_t::ecdsa
ecdsa_params_t ecdsa
ECDSA credential parameters.
Definition: credman.h:117
credman_buffer_t::s
const void * s
Pointer to the buffer.
Definition: credman.h:54
credman_buffer_t
Buffer of the credential.
Definition: credman.h:53
psk_params_t
PSK parameters.
Definition: credman.h:61
psk_params_t::hint
credman_buffer_t hint
Hint buffer.
Definition: credman.h:64
credman_get
int credman_get(credman_credential_t *credential, credman_tag_t tag, credman_type_t type)
Gets a credential from credential pool.
credman_credential_t
Credential information.
Definition: credman.h:112
CREDMAN_OK
@ CREDMAN_OK
No error.
Definition: credman.h:125
CREDMAN_INVALID
@ CREDMAN_INVALID
Invalid input parameter(s)
Definition: credman.h:129
CREDMAN_NO_SPACE
@ CREDMAN_NO_SPACE
No space in system pool for new credential.
Definition: credman.h:127
CREDMAN_TYPE_PSK
@ CREDMAN_TYPE_PSK
PSK credential type.
Definition: credman.h:105
psk_params_t::key
credman_buffer_t key
Key buffer.
Definition: credman.h:62
credman_credential_t::psk
psk_params_t psk
PSK credential parameters.
Definition: credman.h:116
ecdsa_params_t::client_keys
ecdsa_public_key_t * client_keys
Array of clients public keys.
Definition: credman.h:81
ecdsa_params_t::public_key
ecdsa_public_key_t public_key
Public key.
Definition: credman.h:80
ecdsa_public_key_t
ECDSA public keys.
Definition: credman.h:70
credman_add
int credman_add(const credman_credential_t *credential)
Adds a credential to the credential pool.
ecdsa_public_key_t::y
const void * y
Y part of the public key.
Definition: credman.h:72
CREDMAN_TYPE_UNKNOWN
@ CREDMAN_TYPE_UNKNOWN
Unknown credential type.
Definition: credman.h:130
CREDMAN_ERROR
@ CREDMAN_ERROR
Other errors.
Definition: credman.h:131
credman_type_t
credman_type_t
Credential types.
Definition: credman.h:98
CREDMAN_TYPE_ECDSA
@ CREDMAN_TYPE_ECDSA
ECDSA credential type.
Definition: credman.h:106
credman_tag_t
uint16_t credman_tag_t
Tag of the credential.
Definition: credman.h:88
credman_buffer_t::len
size_t len
Length of credman_buffer_t::s.
Definition: credman.h:55
credman_get_used_count
int credman_get_used_count(void)
Gets the number of credentials currently in the credential pool.
ecdsa_public_key_t::x
const void * x
X part of the public key.
Definition: credman.h:71
credman_reset
void credman_reset(void)
Empties the credential pool.
ecdsa_params_t::client_keys_size
size_t client_keys_size
Size of ecdsa_params_t::clients_keys.
Definition: credman.h:82
ecdsa_params_t::private_key
const void * private_key
Pointer to the private key.
Definition: credman.h:79
psk_params_t::id
credman_buffer_t id
ID buffer.
Definition: credman.h:63
ecdsa_params_t
ECDSA parameters.
Definition: credman.h:78
CREDMAN_EXIST
@ CREDMAN_EXIST
Credential already exist in system pool.
Definition: credman.h:126
CREDMAN_NOT_FOUND
@ CREDMAN_NOT_FOUND
Credential not found in the system pool.
Definition: credman.h:128
CREDMAN_TYPE_EMPTY
@ CREDMAN_TYPE_EMPTY
Empty type.
Definition: credman.h:104
credman_credential_t::type
credman_type_t type
Type of the credential.
Definition: credman.h:113
credman_credential_t::tag
credman_tag_t tag
Tag of the credential.
Definition: credman.h:114