ndn-lite
key-storage.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 Zhiyi Zhang, Tianyuan Yu
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v3.0. See the file LICENSE in the top level
6  * directory for more details.
7  *
8  * See AUTHORS.md for complete list of NDN IOT PKG authors and contributors.
9  */
10 #ifndef NDN_ENCODE_KEY_STORAGE_H
11 #define NDN_ENCODE_KEY_STORAGE_H
12 
13 #include "data.h"
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
22 typedef struct ndn_key_storage {
34  uint8_t is_bootstrapped;
46 
53 
60 
66 int
67 ndn_key_storage_set_anchor(const ndn_data_t* trust_anchor);
68 
73 void
75 
81 void
83 
88 void
90 
95 void
96 ndn_key_storage_delete_hmac_key(uint32_t key_id);
97 
102 void
103 ndn_key_storage_delete_ecc_key(uint32_t key_id);
104 
109 void
110 ndn_key_storage_delete_aes_key(uint32_t key_id);
111 
117 void
118 ndn_key_storage_get_hmac_key(uint32_t key_id, ndn_hmac_key_t** hmac);
119 
125 void
126 ndn_key_storage_get_ecc_key(uint32_t key_id, ndn_ecc_pub_t** pub, ndn_ecc_prv_t** prv);
127 
133 void
134 ndn_key_storage_get_aes_key(uint32_t key_id, ndn_aes_key_t** aes);
135 
136 #ifdef __cplusplus
137 }
138 #endif
139 
140 #endif // NDN_ENCODE_KEY_STORAGE_H
void ndn_key_storage_delete_hmac_key(uint32_t key_id)
Delete a HMAC key by searching corresponding unique key id.
Definition: key-storage.c:91
void ndn_key_storage_get_empty_aes_key(ndn_aes_key_t **aes)
Get an empty AES-128 key pointer from key storage structure.
Definition: key-storage.c:79
ndn_ecc_prv_t ecc_prv_keys[NDN_SEC_SIGNING_KEYS_SIZE]
Definition: key-storage.h:39
The structure to keep a HMAC key.
Definition: ndn-lite-hmac.h:65
The structure to represent an NDN Data packet The best practice of using ndn_data_t is to first decla...
Definition: data.h:30
uint8_t is_bootstrapped
Boolean indicating whether the device is bootstrapped.
Definition: key-storage.h:34
void ndn_key_storage_get_hmac_key(uint32_t key_id, ndn_hmac_key_t **hmac)
Get an empty HMAC key pointer from key storage structure.
Definition: key-storage.c:132
The structure to keep an ECC private key.
Definition: ndn-lite-ecc.h:86
int ndn_key_storage_set_anchor(const ndn_data_t *trust_anchor)
Set trust anchor for the key storage structure.
Definition: key-storage.c:37
ndn_hmac_key_t hmac_keys[NDN_SEC_SIGNING_KEYS_SIZE]
Definition: key-storage.h:40
#define NDN_SEC_ENCRYPTION_KEYS_SIZE
Definition: ndn-constants.h:111
The structure to keep an AES-128 key.
Definition: ndn-lite-aes.h:56
ndn_ecc_pub_t ecc_pub_keys[NDN_SEC_SIGNING_KEYS_SIZE]
The self signing key storage.
Definition: key-storage.h:38
void ndn_key_storage_get_ecc_key(uint32_t key_id, ndn_ecc_pub_t **pub, ndn_ecc_prv_t **prv)
Get an empty ECC key pointer from key storage structure.
Definition: key-storage.c:147
ndn_aes_key_t aes_keys[NDN_SEC_ENCRYPTION_KEYS_SIZE]
The self encryption/decryption key storage.
Definition: key-storage.h:44
ndn_key_storage_t * ndn_key_storage_init(void)
Init an in-library key storage structure.
Definition: key-storage.c:16
ndn_data_t trust_anchor
The trust anchor storage.
Definition: key-storage.h:26
#define NDN_SEC_SIGNING_KEYS_SIZE
Definition: ndn-constants.h:110
ndn_ecc_pub_t trust_anchor_key
The trust anchor public key.
Definition: key-storage.h:30
struct ndn_key_storage ndn_key_storage_t
The structure to implement keys storage and management.
void ndn_key_storage_get_empty_ecc_key(ndn_ecc_pub_t **pub, ndn_ecc_prv_t **prv)
Get an empty ECC key pointer from key storage structure.
Definition: key-storage.c:64
void ndn_key_storage_delete_ecc_key(uint32_t key_id)
Delete a ECC key by searching corresponding unique key id.
Definition: key-storage.c:104
void ndn_key_storage_get_empty_hmac_key(ndn_hmac_key_t **hmac)
Get an empty HMAC key pointer from key storage structure.
Definition: key-storage.c:51
The structure to implement keys storage and management.
Definition: key-storage.h:22
ndn_key_storage_t * ndn_key_storage_get_instance(void)
Get a running instance of key storage structure.
Definition: key-storage.c:31
void ndn_key_storage_get_aes_key(uint32_t key_id, ndn_aes_key_t **aes)
Get an empty AES-128 key pointer from key storage structure.
Definition: key-storage.c:164
The structure to keep an ECC public key.
Definition: ndn-lite-ecc.h:71
void ndn_key_storage_delete_aes_key(uint32_t key_id)
Delete a AES-128 key by searching corresponding unique key id.
Definition: key-storage.c:118