# Speck (cipher)

General 3 rounds of Speck with key schedule Ray Beaulieu, Douglas Shors, Jason Smith, Stefan Treatman-Clark, Bryan Weeks, Louis Wingers NSA 2013 Simon, Threefish 64, 72, 96, 128, 144, 192 or 256 bits 32, 48, 64, 96 or 128 bits ARX 22, 23, 26, 27, 28, 29, 32, 33 or 34 (depending on block and key size) 2.6 cpb on Intel Xeon 5640 (Speck128/128) Differential cryptanalysis can break 17 rounds of Speck128/128 with 2113 data, 222 bytes memory and time complexity of 2113.[1] Rectangle attack can break 18 rounds of Speck128/192,256 with 2121.9 data, 2125.9 bytes memory and time complexity of 2182.7.[2]

Speck is a family of lightweight block ciphers publicly released by the NSA in June 2013.[3] Speck has been optimized for performance in software implementations, while its sister algorithm, Simon, has been optimized for hardware implementations. Speck is an Add-Rotate-Xor (ARX) cipher.

Speck supports the following combinations of block sizes, key sizes and number of rounds:[4]

Block size (bits) Key size (bits) Rounds
32 64 22
48 72 22
96 23
64 96 26
128 27
96 96 28
144 29
128 128 32
192 33
256 34

## Reference code

Reference code of encryption of Speck variant with 128 bit block size and key.

#include <stdint.h>

#define ROR(x, r) ((x >> r) | (x << (64 - r)))
#define ROL(x, r) ((x << r) | (x >> (64 - r)))
#define R(x, y, k) (x = ROR(x, 8), x += y, x ^= k, y = ROL(y, 3), y ^= x)

void encrypt(uint64_t *pt, uint64_t *ct, uint64_t *K)
{
uint64_t i, B = K[1], A = K[0];
ct[0] = pt[0]; ct[1] = pt[1];

for(i = 0; i < 32; i++)
{
R(ct[1], ct[0], A);
R(B, A, i);
}
}