.Net 5.0 implementation of Speck cipher in C#.
Speck is a family of lightweight block ciphers publicly released by the National Security Agency (NSA) in June 2013. Speck has been optimized for performance in software implementations.
Implemented by following official NSA implementation guide and tested with their test vectors.
- 64 bit block 96 bit key
- 64 bit block 128 bit key
- 128 bit block 128 bit key
- 128 bit block 192 bit key
- 128 bit block 256 bit key
- ECB (Electronic codebook) - default mode
- CBC (Cipher block chaining)
- PKCS#7
Currently implementation is writen for .Net 5.0 but if there is a need I can happily downgrade it to .Net standard 2.0.
byte[] payload = new byte[]
{
0x20, 0x6d, 0x61, 0x64, 0x65, 0x20, 0x69, 0x74,
0x20, 0x65, 0x71, 0x75, 0x69, 0x76, 0x61, 0x6c
};
byte[] keyBytes = new byte[]
{
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f
};
Speck speck = SpeckProvider.NewInstance(EncryptionType.Speck_128_128, keyBytes);
byte[] encrypted = speck.Encrypt(payload, EncryptionMode.CBC, Padding.PKCS7);
byte[] decrypted = speck.Decrypt(encrypted, EncryptionMode.CBC, Padding.PKCS7);