Use a 960-byte constant-time Ed25519 base table, compact hash/scalar code and unused-library trims while retaining Reader, BLE P-256 and the 8 KiB stack. RAK4631 Full saves 57,496 flash bytes and 3,152 static RAM bytes versus preview3. Support complete chapters and verse ranges with bounded app continuation replies and cooperative terminal output. Use nonblocking TCP writes under reader backpressure. Add scalar/signature comparisons and a linked ARM crypto/stack CI gate. Validated clean RAK4631, T1000-E, T096 and V4 Full builds, host regressions, and physical RAK chapter/reconnect and signing comparisons. Physical signing averages 35.9 ms versus 14.4 ms with the original table.
35 lines
875 B
C++
35 lines
875 B
C++
#pragma once
|
|
#include <cstdarg>
|
|
#include <cstdint>
|
|
#include <cstdio>
|
|
#include <cstring>
|
|
#include <string>
|
|
|
|
// Models Adafruit's bounded printf so a long verse sent via printf is caught.
|
|
class Stream {
|
|
public:
|
|
std::string text;
|
|
size_t max_write = 65535;
|
|
size_t credit = 65535;
|
|
size_t writes = 0;
|
|
size_t write(const uint8_t* value, size_t size) {
|
|
++writes;
|
|
if (size > max_write) size = max_write;
|
|
if (size > credit) size = credit;
|
|
credit -= size;
|
|
text.append(reinterpret_cast<const char*>(value), size);
|
|
return size;
|
|
}
|
|
size_t print(const char* value) {
|
|
return write(reinterpret_cast<const uint8_t*>(value), std::strlen(value));
|
|
}
|
|
size_t printf(const char* format, ...) {
|
|
char buf[256];
|
|
va_list args;
|
|
va_start(args, format);
|
|
vsnprintf(buf, sizeof(buf), format, args);
|
|
va_end(args);
|
|
return print(buf);
|
|
}
|
|
};
|