mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-22 18:52:30 +00:00
clean up the crypto api
This commit is contained in:
@@ -10,9 +10,6 @@ class CrossPlatformCryptoEngine : public CryptoEngine
|
||||
|
||||
CTRCommon *ctr = NULL;
|
||||
|
||||
/// How many bytes in our key
|
||||
uint8_t keySize = 0;
|
||||
|
||||
public:
|
||||
CrossPlatformCryptoEngine() {}
|
||||
|
||||
@@ -27,9 +24,9 @@ class CrossPlatformCryptoEngine : public CryptoEngine
|
||||
* @param bytes a _static_ buffer that will remain valid for the life of this crypto instance (i.e. this class will cache the
|
||||
* provided pointer)
|
||||
*/
|
||||
virtual void setKey(size_t numBytes, uint8_t *bytes)
|
||||
virtual void setKey(const CryptoKey &k)
|
||||
{
|
||||
keySize = numBytes;
|
||||
CryptoEngine::setKey(k);
|
||||
DEBUG_MSG("Installing AES%d key!\n", numBytes * 8);
|
||||
if (ctr) {
|
||||
delete ctr;
|
||||
@@ -41,7 +38,7 @@ class CrossPlatformCryptoEngine : public CryptoEngine
|
||||
else
|
||||
ctr = new CTR<AES256>();
|
||||
|
||||
ctr->setKey(bytes, numBytes);
|
||||
ctr->setKey(key.bytes, key.length);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +49,7 @@ class CrossPlatformCryptoEngine : public CryptoEngine
|
||||
*/
|
||||
virtual void encrypt(uint32_t fromNode, uint64_t packetNum, size_t numBytes, uint8_t *bytes)
|
||||
{
|
||||
if (keySize != 0) {
|
||||
if (key.length > 0) {
|
||||
uint8_t stream_block[16];
|
||||
static uint8_t scratch[MAX_BLOCKSIZE];
|
||||
size_t nc_off = 0;
|
||||
|
||||
Reference in New Issue
Block a user