Embeddable Speck is an implementation of NSA's block cipher Speck. The goal of Embeddable Speck is to make the cipher more suitble for PSK scheme adaptation for embedded systems.
- The key scheduler is not included, resulting in a lighter-weight implementation
- Asynchronous execution with callback interfaces
- Hightly cooperative polling, non-blocking encryption and decryption
- Optional concurrency with multiple instances
- No CPU hogging
- 128-bit block with 128-bit key mode only
- Static (and precomputed) key schedule matrix must be present
- Commercial usage is highly discouraged, personal usage only
- The algorithm was designed by NSA.
- PSK nature of the library, with a static key, and without a key-exchange mechanism whatsoever, make the device adopting this library susceptible to key-recovery attacks by reverse engineering.
- At best, the library can be used for your DIY remote-controlled door locker, assuming that you do not use it to lock anything NSA or the US government would care about.
- Safer alternatives available. (Try Embeddable SPARX instead; different algorithm, same API)
No need, the code is hardware and platform agnostic. It will run everywhere as long as C language works. You can even run the test on your PC.
However, at the very least, 32-bit processor like Arm Cortex-M0 is recommended.
See the test for an example.
Declare the key schedule matrix
static const uint64_t key_schedule[EMBEDDABLE_SPECK__ROUND] = ...;
Declare the configuration of an instance including the callback function
static void encrypted_handler(uint8_t *result);
static const EmbeddableSpeck_Config encryption_config = {
.key_schedule = (uint64_t *)key_schedule,
.finished = &encrypted_handler,
};
Declare state in RAM and reset the memory on application start
static EmbeddableSpeck_State encryption_state;
embeddable_speck__init(&encryption_state);
Start by feeding the input data to an instance
embeddable_speck__start(&encryption_state, plain_text);
And keep polling for the encryption
embeddable_speck__encryption_poll(&encryption_config, &encryption_state);
The only difference from the encryption part is the polling function operate on an instance.
Keeping everything else the same.
embeddable_speck__decryption_poll(&decryption_config, &decryption_state);
If the explanation is not clear you can always see an actual usage in the test.
Both embeddable_speck__encryption_poll
and embeddable_speck__decryption_poll
operations are safe to be called periodically.
Just make sure each of them does not operate on the same instance.
If there is nothing to be done the function would return right away; costing only about a couple of address jump on the hardware running the program.
Just clone the repository with submodules and make run
.
Please note that non-NSA-designed algorithm is available with the exact same API. See Embeddable SPARX.
Embeddable Speck is released under the BSD 3-Clause License. 🎉