I combined ideas from the pull requests #15 and #16 and updated the examples accordingly.
I tested the code on Arduino Leonardo and Raspberry Pi 1B+
Summary of changes:
The length of the plain data must be calculates without the trailing \0 added by string assignments
Note that the function sizeof() includes the \0, so -1 needs to be subtracted for the correct plain data length in case of string input. The function strlen() doesn't count the \0.
The "-1" was incorrectly in the function calc_size_n_pad, instead the input length in the example code has been corrected.
If the length of the plain data is a multiple of N_BLOCK, a full block of padding must be added (instead of none)
I combined ideas from the pull requests #15 and #16 and updated the examples accordingly. I tested the code on Arduino Leonardo and Raspberry Pi 1B+
Summary of changes:
sizeof()
includes the \0, so -1 needs to be subtracted for the correct plain data length in case of string input. The functionstrlen()
doesn't count the \0.calc_size_n_pad
, instead the input length in the example code has been corrected.