Distributed Publish & Subscribe for IoT
|
Key stores provide key data for protecting messages and the network. More...
Data Structures | |
struct | _DPS_Key |
Union of supported key types. More... | |
struct | _DPS_KeyCert |
Certificate key data. More... | |
struct | _DPS_KeyEC |
Elliptic curve key data. More... | |
struct | _DPS_KeyId |
An identifier of a key in a key store. More... | |
struct | _DPS_KeySymmetric |
Symmetric key data. More... | |
KeyStore | |
enum | DPS_KeyType { DPS_KEY_SYMMETRIC, DPS_KEY_EC, DPS_KEY_EC_CERT } |
A DPS key type. More... | |
enum | DPS_ECCurve { DPS_EC_CURVE_RESERVED = 0, DPS_EC_CURVE_P384 = 2, DPS_EC_CURVE_P521 = 3 } |
Allowed elliptic curves. More... | |
typedef struct _DPS_KeySymmetric | DPS_KeySymmetric |
Symmetric key data. More... | |
typedef struct _DPS_KeyEC | DPS_KeyEC |
Elliptic curve key data. More... | |
typedef struct _DPS_KeyCert | DPS_KeyCert |
Certificate key data. More... | |
typedef struct _DPS_Key | DPS_Key |
Union of supported key types. | |
typedef struct _DPS_KeyId | DPS_KeyId |
An identifier of a key in a key store. | |
typedef struct _DPS_KeyStore | DPS_KeyStore |
Opaque type for a key store. | |
typedef struct _DPS_KeyStoreRequest | DPS_KeyStoreRequest |
Opaque type for a key store request. | |
typedef DPS_Status(* | DPS_KeyAndIdHandler) (DPS_KeyStoreRequest *request) |
Function prototype for a key store handler called when a key and key identifier is requested. More... | |
typedef DPS_Status(* | DPS_KeyHandler) (DPS_KeyStoreRequest *request, const DPS_KeyId *keyId) |
Function prototype for a key store handler called when a key with the provided key identifier is requested. More... | |
typedef DPS_Status(* | DPS_EphemeralKeyHandler) (DPS_KeyStoreRequest *request, const DPS_Key *key) |
Function prototype for a key store handler called when an ephemeral key with the provided type is requested. More... | |
typedef DPS_Status(* | DPS_CAHandler) (DPS_KeyStoreRequest *request) |
Function prototype for a key store handler called when the trusted CA chain is requested. More... | |
DPS_Status | DPS_SetKeyAndId (DPS_KeyStoreRequest *request, const DPS_Key *key, const DPS_KeyId *keyId) |
Provide a key and key identifier to a key store request. More... | |
DPS_Status | DPS_SetKey (DPS_KeyStoreRequest *request, const DPS_Key *key) |
Provide a key to a key store request. More... | |
DPS_Status | DPS_SetCA (DPS_KeyStoreRequest *request, const char *ca) |
Provide a trusted CA chain to a key store request. More... | |
DPS_KeyStore * | DPS_KeyStoreHandle (DPS_KeyStoreRequest *request) |
Returns the DPS_KeyStore* of a key store request. More... | |
DPS_KeyStore * | DPS_CreateKeyStore (DPS_KeyAndIdHandler keyAndIdHandler, DPS_KeyHandler keyHandler, DPS_EphemeralKeyHandler ephemeralKeyHandler, DPS_CAHandler caHandler) |
Creates a key store. More... | |
void | DPS_DestroyKeyStore (DPS_KeyStore *keyStore) |
Destroys a previously created key store. More... | |
DPS_Status | DPS_SetKeyStoreData (DPS_KeyStore *keyStore, void *data) |
Store a pointer to application data in a key store. More... | |
void * | DPS_GetKeyStoreData (const DPS_KeyStore *keyStore) |
Get application data pointer previously set by DPS_SetKeyStoreData(). More... | |
#define | DPS_AES_256_KEY_LEN 32 |
AES 256 key length, in bytes. | |
In-memory Key Store | |
typedef struct _DPS_MemoryKeyStore | DPS_MemoryKeyStore |
Opaque type for an in-memory key store. | |
DPS_MemoryKeyStore * | DPS_CreateMemoryKeyStore (void) |
Creates an in-memory key store. More... | |
void | DPS_DestroyMemoryKeyStore (DPS_MemoryKeyStore *keyStore) |
Destroys a previously created in-memory key store. More... | |
DPS_Status | DPS_SetContentKey (DPS_MemoryKeyStore *keyStore, const DPS_KeyId *keyId, const DPS_Key *key) |
Create or replace a key with the specified key identifier in the key store. More... | |
DPS_Status | DPS_SetNetworkKey (DPS_MemoryKeyStore *keyStore, const DPS_KeyId *keyId, const DPS_Key *key) |
Create or replace the network key in the key store. More... | |
DPS_Status | DPS_SetTrustedCA (DPS_MemoryKeyStore *mks, const char *ca) |
Create or replace the trusted CA(s) in the key store. More... | |
DPS_Status | DPS_SetCertificate (DPS_MemoryKeyStore *mks, const char *cert, const char *key, const char *password) |
Create or replace a certificate in the key store. More... | |
DPS_KeyStore * | DPS_MemoryKeyStoreHandle (DPS_MemoryKeyStore *keyStore) |
Returns the DPS_KeyStore* of an in-memory key store. More... | |
Key stores provide key data for protecting messages and the network.
typedef DPS_Status(* DPS_CAHandler) (DPS_KeyStoreRequest *request) |
Function prototype for a key store handler called when the trusted CA chain is requested.
DPS_SetCA() should be called to provide the CA chain to the caller.
request | The request, only valid with the body of this callback function. |
typedef DPS_Status(* DPS_EphemeralKeyHandler) (DPS_KeyStoreRequest *request, const DPS_Key *key) |
Function prototype for a key store handler called when an ephemeral key with the provided type is requested.
DPS_SetKey() should be called to provide the ephemeral key to the caller.
request | The request, only valid with the body of this callback function. |
key | The requested key type and parameters (e.g. key->type is DPS_KEY_EC and key->ec.curve is DPS_EC_CURVE_P521). |
typedef DPS_Status(* DPS_KeyAndIdHandler) (DPS_KeyStoreRequest *request) |
Function prototype for a key store handler called when a key and key identifier is requested.
DPS_SetKeyAndId() should be called to provide the key and identifier to the caller.
request | The request, only valid with the body of this callback function. |
typedef struct _DPS_KeyCert DPS_KeyCert |
Certificate key data.
typedef struct _DPS_KeyEC DPS_KeyEC |
Elliptic curve key data.
Only x
and y
are needed for a public key. Similarly, only d
is needed for a private key.
typedef DPS_Status(* DPS_KeyHandler) (DPS_KeyStoreRequest *request, const DPS_KeyId *keyId) |
Function prototype for a key store handler called when a key with the provided key identifier is requested.
DPS_SetKey() should be called to provide the key to the caller.
request | The request, only valid with the body of this callback function. |
keyId | The identifier of the key to provide. |
typedef struct _DPS_KeySymmetric DPS_KeySymmetric |
Symmetric key data.
enum DPS_ECCurve |
enum DPS_KeyType |
DPS_KeyStore* DPS_CreateKeyStore | ( | DPS_KeyAndIdHandler | keyAndIdHandler, |
DPS_KeyHandler | keyHandler, | ||
DPS_EphemeralKeyHandler | ephemeralKeyHandler, | ||
DPS_CAHandler | caHandler | ||
) |
Creates a key store.
keyAndIdHandler | Optional handler for receiving key and key identifier requests |
keyHandler | Optional handler for receiving key requests |
ephemeralKeyHandler | Optional handler for receiving ephemeral key requests |
caHandler | Optional handler for receiving CA chain requests |
DPS_MemoryKeyStore* DPS_CreateMemoryKeyStore | ( | void | ) |
Creates an in-memory key store.
void DPS_DestroyKeyStore | ( | DPS_KeyStore * | keyStore | ) |
Destroys a previously created key store.
keyStore | The key store |
void DPS_DestroyMemoryKeyStore | ( | DPS_MemoryKeyStore * | keyStore | ) |
Destroys a previously created in-memory key store.
keyStore | An in-memory key store |
void* DPS_GetKeyStoreData | ( | const DPS_KeyStore * | keyStore | ) |
Get application data pointer previously set by DPS_SetKeyStoreData().
keyStore | The keyStore |
DPS_KeyStore* DPS_KeyStoreHandle | ( | DPS_KeyStoreRequest * | request | ) |
Returns the DPS_KeyStore*
of a key store request.
request | A key store request |
DPS_KeyStore* DPS_MemoryKeyStoreHandle | ( | DPS_MemoryKeyStore * | keyStore | ) |
Returns the DPS_KeyStore*
of an in-memory key store.
keyStore | An in-memory key store |
DPS_Status DPS_SetCA | ( | DPS_KeyStoreRequest * | request, |
const char * | ca | ||
) |
Provide a trusted CA chain to a key store request.
request | The request parameter of the handler |
ca | The CA chain in PEM format |
DPS_Status DPS_SetCertificate | ( | DPS_MemoryKeyStore * | mks, |
const char * | cert, | ||
const char * | key, | ||
const char * | password | ||
) |
Create or replace a certificate in the key store.
mks | An in-memory key store |
cert | The certificate in PEM format |
key | The optional private key in PEM format |
password | The optional password protecting the key, may be NULL |
DPS_Status DPS_SetContentKey | ( | DPS_MemoryKeyStore * | keyStore, |
const DPS_KeyId * | keyId, | ||
const DPS_Key * | key | ||
) |
Create or replace a key with the specified key identifier in the key store.
Specify a previously set key identifier and a NULL key to remove a key from the key store.
keyStore | An in-memory key store |
keyId | The identifier of the key to create, replace, or remove |
key | The key |
DPS_Status DPS_SetKey | ( | DPS_KeyStoreRequest * | request, |
const DPS_Key * | key | ||
) |
Provide a key to a key store request.
request | The request parameter of the handler |
key | The key |
DPS_Status DPS_SetKeyAndId | ( | DPS_KeyStoreRequest * | request, |
const DPS_Key * | key, | ||
const DPS_KeyId * | keyId | ||
) |
Provide a key and key identifier to a key store request.
request | The request parameter of the handler |
key | The key |
keyId | The identifier of the key to provide |
DPS_Status DPS_SetKeyStoreData | ( | DPS_KeyStore * | keyStore, |
void * | data | ||
) |
Store a pointer to application data in a key store.
keyStore | The key store |
data | The data pointer to store |
DPS_Status DPS_SetNetworkKey | ( | DPS_MemoryKeyStore * | keyStore, |
const DPS_KeyId * | keyId, | ||
const DPS_Key * | key | ||
) |
Create or replace the network key in the key store.
keyStore | An in-memory key store |
keyId | The identifier of the key to create |
key | The key |
DPS_Status DPS_SetTrustedCA | ( | DPS_MemoryKeyStore * | mks, |
const char * | ca | ||
) |
Create or replace the trusted CA(s) in the key store.
mks | An in-memory key store |
ca | The CA chain in PEM format |