Uniot Core
0.8.1
Loading...
Searching...
No Matches
uniot::Credentials Class Reference

Manages device identity and cryptographic credentials for Uniot devices. More...

#include <Credentials.h>

Inheritance diagram for uniot::Credentials:
[legend]

Public Member Functions

 Credentials ()
 Constructor that initializes device credentials.
 
virtual bool store () override
 Stores credentials to persistent storage.
 
virtual bool restore () override
 Restores credentials from persistent storage.
 
void setOwnerId (const String &id)
 Sets the owner ID of the device.
 
const String & getOwnerId () const
 Gets the current owner ID.
 
bool isOwnerChanged () const
 
void resetOwnerChanged ()
 
const String & getCreatorId () const
 Gets the creator ID.
 
const String & getDeviceId () const
 Gets the unique device ID.
 
const String & getPublicKey () const
 Gets the device's public key as a hexadecimal string.
 
uint32_t getShortDeviceId () const
 Gets a shorter unique identifier for the device.
 
virtual Bytes keyId () const override
 Implements ICOSESigner interface to provide key ID.
 
virtual Bytes sign (const Bytes &data) const override
 Implements ICOSESigner interface to sign data.
 
virtual COSEAlgorithm signerAlgorithm () const override
 Implements ICOSESigner interface to specify the signing algorithm.
 
- Public Member Functions inherited from uniot::CBORStorage
 CBORStorage (const String &path)
 Constructs a new CBORStorage object.
 
virtual ~CBORStorage ()
 Virtual destructor.
 
CBORObjectobject ()
 Get access to the underlying CBORObject.
 
virtual bool clean () override
 Clean the CBOR object and remove the storage file.
 
- Public Member Functions inherited from uniot::Storage
 Storage (const String &path)
 Constructs a Storage object for a specific file.
 
virtual ~Storage ()
 Destructor.
 
- Public Member Functions inherited from uniot::ICOSESigner
virtual ~ICOSESigner ()
 Virtual destructor to ensure proper cleanup of derived classes.
 

Additional Inherited Members

- Static Public Member Functions inherited from uniot::Storage
static void unmount ()
 Explicitly unmounts the filesystem.
 
- Protected Member Functions inherited from uniot::Storage
void setPath (const String &path)
 Sets the file path, ensuring it starts with "/".
 
- Protected Attributes inherited from uniot::CBORStorage
CBORObject mCbor
 The CBOR object used for data serialization/deserialization.
 
- Protected Attributes inherited from uniot::Storage
Bytes mData
 The byte array containing the data to be stored or the loaded data.
 
String mPath
 The file path where data is stored.
 

Detailed Description

Manages device identity and cryptographic credentials for Uniot devices.

The Credentials class is responsible for:

  • Generating and storing device private keys
  • Deriving public keys from private keys
  • Signing data using the device's private key
  • Managing device and owner identifiers
  • Providing persistent storage of credentials

It inherits from CBORStorage for serialization/deserialization and from ICOSESigner to implement COSE signing capabilities.

Constructor & Destructor Documentation

◆ Credentials()

uniot::Credentials::Credentials ( )
inline

Constructor that initializes device credentials.

On first instantiation, it generates a new Ed25519 key pair for the device. On subsequent instantiations, it loads existing credentials from persistent storage.

Member Function Documentation

◆ getCreatorId()

const String & uniot::Credentials::getCreatorId ( ) const
inline

Gets the creator ID.

Return values
creatorId&The creator ID.

◆ getDeviceId()

const String & uniot::Credentials::getDeviceId ( ) const
inline

Gets the unique device ID.

Return values
deviceId&The device ID.

◆ getOwnerId()

const String & uniot::Credentials::getOwnerId ( ) const
inline

Gets the current owner ID.

Return values
ownerId&The owner ID.

◆ getPublicKey()

const String & uniot::Credentials::getPublicKey ( ) const
inline

Gets the device's public key as a hexadecimal string.

Return values
publicKey&The public key in hexadecimal format.

◆ getShortDeviceId()

uint32_t uniot::Credentials::getShortDeviceId ( ) const
inline

Gets a shorter unique identifier for the device.

Uses ESP-specific functions to obtain a chip ID.

Return values
uint32_tThe short device ID.

◆ isOwnerChanged()

bool uniot::Credentials::isOwnerChanged ( ) const
inline

◆ keyId()

virtual Bytes uniot::Credentials::keyId ( ) const
inlineoverridevirtual

Implements ICOSESigner interface to provide key ID.

Return values
BytesThe raw public key bytes.

Implements uniot::ICOSESigner.

◆ resetOwnerChanged()

void uniot::Credentials::resetOwnerChanged ( )
inline

◆ restore()

virtual bool uniot::Credentials::restore ( )
inlineoverridevirtual

Restores credentials from persistent storage.

Loads the owner ID and private key from CBOR storage.

Return values
trueCredentials were successfully restored.
falseCredentials could not be restored.

Reimplemented from uniot::CBORStorage.

◆ setOwnerId()

void uniot::Credentials::setOwnerId ( const String & id)
inline

Sets the owner ID of the device.

Parameters
idThe new owner ID to set.

◆ sign()

virtual Bytes uniot::Credentials::sign ( const Bytes & data) const
inlineoverridevirtual

Implements ICOSESigner interface to sign data.

Signs the provided data using the device's Ed25519 private key.

Parameters
dataThe data to sign.
Return values
BytesThe signature of the data.

Implements uniot::ICOSESigner.

◆ signerAlgorithm()

virtual COSEAlgorithm uniot::Credentials::signerAlgorithm ( ) const
inlineoverridevirtual

Implements ICOSESigner interface to specify the signing algorithm.

Return values
COSEAlgorithm::EdDSAThe algorithm used for signing.

Implements uniot::ICOSESigner.

◆ store()

virtual bool uniot::Credentials::store ( )
inlineoverridevirtual

Stores credentials to persistent storage.

Saves the owner ID and private key to the CBOR storage.

Return values
trueStorage operation was successful.
falseStorage operation failed.

Reimplemented from uniot::CBORStorage.


The documentation for this class was generated from the following file: