AES128ESP32 Library
Loading...
Searching...
No Matches
pass2Key Class Reference

Create suitable keys for key generation (the masterkey) and encryption/decryption (newkey). More...

#include <pbkdf2.h>

Public Member Functions

 pass2Key ()
 ~pass2Key ()
bool getMasterKey (MasterKeyData &mkd)
bool setMasterKey (MasterKeyData &mkd)
bool makeMasterKey ()
bool deriveNewKeyfromText (String text)

Detailed Description

Create suitable keys for key generation (the masterkey) and encryption/decryption (newkey).

pass2Key is used to generate a new crypto key suitable for use with AES128 encryption. It uses the PSA library which on the esp32 uses a hardware device (i think). The idea is to create and store a masterkey. The master key can be stored, but it should never be distributed. It can never be used for encryption. Instead after the masterkey has been created or reloaded you use a plain text password to generate a newkey. The newkey should never be saved. The newkey can be used to for AES128 encryption.

Definition at line 31 of file pbkdf2.h.

Constructor & Destructor Documentation

◆ pass2Key()

pass2Key::pass2Key ( )

class constructor: initialize the psa cypto library

Definition at line 6 of file pbkdf2.cpp.

◆ ~pass2Key()

pass2Key::~pass2Key ( )

class destruction: unloads the masterkey and the newkey if they exist.

Definition at line 14 of file pbkdf2.cpp.

Member Function Documentation

◆ deriveNewKeyfromText()

bool pass2Key::deriveNewKeyfromText ( String text)

the masterkey id must already have a value. If the masterkey is not available it will assert (reboot esp32). using the masterkey derive a new key from the masterkey and the supplied text. before calling this function the following must be setup i) a masterkey must exist. optional setup i) edit the MSTRKEYSALT #define value in pbkdf2.h

return true if the newkey was generated. return false if it failed.

errors: AES128_ERROR6: masterkey has not been set. all other errors will be psa errors

note: If DEBUGLEVEL is defined and an error happens, it will freeze forever and display a message on the serial port.

Definition at line 154 of file pbkdf2.cpp.

◆ getMasterKey()

bool pass2Key::getMasterKey ( MasterKeyData & mkd)

provides access to the masterkey data, you can save this data for future use. The masterkey data is only available after a call to makeMasterKey().

returns true if successful or false if not.

errors: AES128_ERROR3: masterkey is not valid AES128_ERROR4: masterkey invalid size all other errors will be psa errors

note: If DEBUGLEVEL is defined and an error happens, it will freeze forever and display a message on the serial port.

Definition at line 40 of file pbkdf2.cpp.

◆ makeMasterKey()

bool pass2Key::makeMasterKey ( )

creates a new masterkey. Use getMasterKey() and save the data. Without it your screwed.

errors: AES128_ERROR5: masterkey has already been created all other errors will be from psa

note: If DEBUGLEVEL is defined and an error happens, it will freeze forever and display a message on the serial port.

Definition at line 117 of file pbkdf2.cpp.

◆ setMasterKey()

bool pass2Key::setMasterKey ( MasterKeyData & mkd)

sets the masterkey data and creates the internal masterkey id.

errors: all errors will be psa errors

note: If DEBUGLEVEL is defined and an error happens, it will freeze forever and display a message on the serial port.

Definition at line 69 of file pbkdf2.cpp.


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