knx/examples/knx-linux/fdsk.h
nanosonde 96884f768e
Add support for KNX data secure (#66)
* initial comic

* save work

* Handle SystemBroadcast and Broadcast for TP and IP

* Rework

* Fix comment

* save work

* save work

* save work

* save work

* save work

* Restore old broadcast structure

* Readd systembroadcast methods

* Make sure that services from SystemBroadcast are also available from Broadcast on closed media

* save work

* Save work

* save work

* Save work

* save work

* save work

* save work

* save work

* save work

* Change maximum number of elements for the key tables, etc.

* save work

* First working seqno sync with ETS

* save work

* save work

* save work

* save work

* save work

* save work

* Remove magic value and add comment

* save work

* Extend restart and masterreset for factory reset

* save work

* First working secure broadcast mode with IA programming

* Add FunctionPropertyExt* AL services

* Fix FunctionPropertyExt*. Working T_DATA_CONNECTED with FunctionPropertyExt*.

* Add PropertyValueExt* AL services. Handle master reset in AL service RESTART.

* Fix FunctionPropertyExtStateRead, fix restart. MILESTONE: Working physical programming of IA and toolkey with confirmed restart. Reading deviceinfos working.

* Handle PDT_CONTROL in FunctionPropertyExt*

* Fix FunctionPropertyExt* and FunctionProperty for PDT_CONTROL

* Change comment.

* save work

* save work

* Add group object security handling

* Move map to own file

* use simple_map

* Include simple_map.h in CmakeFile

* Move code from header to source file

* Remove obsolete code

* MILESTONE: working programming of secure device with IA and tables

* cleanup

* bugfix

* flashSize must be big enough. Security IF object contains a lot more data.

* Merge master into feat_datasecure

* Revert "Merge master into feat_datasecure"

This reverts commit 0c8358692a.

* Revert "Revert "Merge master into feat_datasecure""

This reverts commit aa59253785.

* Bugfixes

* cleanup

* cleanup

* Add printing of uint64_t

* Don't compile secapplayer if data secure not enabled

* pin platform for ESP8266 to specific version

* SecIfObject: save/restore required for persisting STATE. Bugfix: use correct PID for group key table

* Cleanup comment and debug output

* Further cleanup.

* Refactor master reset

* Remove unused IP data link layer test code

* Only reset TOOL kkey to FDSK on factory reset

* Modify .gitignore and remove vscode config file

* Correct comment

* Handle SBC flag (systembroadcast) in SCF field. Couplers between open and closed media need this.

* Remove code that slipped in.
2020-07-06 19:16:54 +02:00

38 lines
860 B
C++

#pragma once
#include <stdint.h>
class FdskCalculator
{
public:
int snprintFdsk(char* str, int strSize, uint8_t* serialNumber, uint8_t* key);
private:
char* generateFdskString(uint8_t* serialNumber, uint8_t* key);
int toBase32(uint8_t* in, long length, uint8_t*& out, bool usePadding);
int fromBase32(uint8_t* in, long length, uint8_t*& out);
uint8_t crc4Array(uint8_t* data, uint8_t len) {
uint8_t start = 0;
for (uint8_t i = 0; i <len; i++)
{
start = crc4(start, data[i]);
}
return start;
}
uint8_t crc4(uint8_t c, uint8_t x) {
uint8_t low4Bits = x & 0x0F;
uint8_t high4Bits = x >> 4;
c = crc4_tab[c ^ high4Bits];
c = crc4_tab[c ^ low4Bits];
return c;
}
int ceil(float num);
static const uint8_t crc4_tab[16];
};