Bluenet
5.7.0
Bluenet, firmware for nRF52 smart home devices
|
Class to get keys based on access level, and to check access levels. More...
#include <cs_KeysAndAccess.h>
Public Member Functions | |
void | init () |
Init the class: reads from State. More... | |
bool | allowAccess (EncryptionAccessLevel minimum, EncryptionAccessLevel provided) |
Verify if the access level provided is sufficient. More... | |
bool | getKey (EncryptionAccessLevel accessLevel, buffer_ptr_t outBuf, cs_buffer_size_t outBufSize) |
Get key of given access level. More... | |
cs_data_t | getSetupKey () |
Get a pointer to the setup key. More... | |
void | generateSetupKey () |
Generate a new setup key. More... | |
cs_ret_code_t | setSetupKey (cs_data_t data) |
Set the setup key. More... | |
void | invalidateSetupKey () |
Invalidate the setup key. More... | |
Static Public Member Functions | |
static KeysAndAccess & | getInstance () |
Use static variant of singleton, no dynamic memory allocation. More... | |
Private Member Functions | |
KeysAndAccess () | |
KeysAndAccess (KeysAndAccess const &) | |
void | operator= (KeysAndAccess const &) |
Private Attributes | |
OperationMode | _operationMode = OperationMode::OPERATION_MODE_UNINITIALIZED |
Cached operation mode. More... | |
bool | _encryptionEnabled = true |
Cache of whether encryption is enabled. More... | |
uint8_t | _setupKey [ENCRYPTION_KEY_LENGTH] |
Current setup key. More... | |
bool | _setupKeyValid = false |
Whether the setup key is valid. More... | |
Class to get keys based on access level, and to check access levels.
|
private |
|
private |
bool KeysAndAccess::allowAccess | ( | EncryptionAccessLevel | minimum, |
EncryptionAccessLevel | provided | ||
) |
Verify if the access level provided is sufficient.
[in] | minimum | Minimum required access level. |
[in] | provided | Provided access level. |
void KeysAndAccess::generateSetupKey | ( | ) |
Generate a new setup key.
Will only do so if operation mode is setup.
|
inlinestatic |
Use static variant of singleton, no dynamic memory allocation.
bool KeysAndAccess::getKey | ( | EncryptionAccessLevel | accessLevel, |
buffer_ptr_t | outBuf, | ||
cs_buffer_size_t | outBufSize | ||
) |
Get key of given access level.
[in] | accessLevel | Access level of which to get the key. |
[out] | outBuf | Buffer to write the key to. |
[in] | outBufSize | Size of the buffer. |
cs_data_t KeysAndAccess::getSetupKey | ( | ) |
Get a pointer to the setup key.
void KeysAndAccess::init | ( | ) |
Init the class: reads from State.
void KeysAndAccess::invalidateSetupKey | ( | ) |
Invalidate the setup key.
|
private |
cs_ret_code_t KeysAndAccess::setSetupKey | ( | cs_data_t | data | ) |
Set the setup key.
To be used when connecting to another crownstone.
[in] | data | The key that has been read. |
|
private |
Cache of whether encryption is enabled.
|
private |
Cached operation mode.
|
private |
Current setup key.
|
private |
Whether the setup key is valid.