https://github.com/aegis-dev/specknet
C# implementation of Speck cipher
https://github.com/aegis-dev/specknet
cipher cipher-algorithms ciphers crypto crypto-library cryptography cryptography-algorithms cryptography-library cyber-security cybersecurity encryption encryption-algorithm encryption-algorithms encryption-decryption library nsa speck speck-128 speck-64
Last synced: 6 months ago
JSON representation
C# implementation of Speck cipher
- Host: GitHub
- URL: https://github.com/aegis-dev/specknet
- Owner: aegis-dev
- License: mit
- Created: 2021-03-31T17:03:13.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-03-16T20:42:48.000Z (almost 4 years ago)
- Last Synced: 2025-04-12T11:13:17.953Z (8 months ago)
- Topics: cipher, cipher-algorithms, ciphers, crypto, crypto-library, cryptography, cryptography-algorithms, cryptography-library, cyber-security, cybersecurity, encryption, encryption-algorithm, encryption-algorithms, encryption-decryption, library, nsa, speck, speck-128, speck-64
- Language: C#
- Homepage:
- Size: 13.7 KB
- Stars: 7
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SpeckNet
.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](https://nsacyber.github.io/simon-speck/implementations/ImplementationGuide1.1.pdf) and tested with their test vectors.
## Supported block and key sizes
* 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
## Supported modes of operation
* ECB (Electronic codebook) - default mode
* CBC (Cipher block chaining)
## Supported padding
* PKCS#7
## Supported .Net versions
Currently implementation is writen for .Net 5.0 but if there is a need I can happily downgrade it to .Net standard 2.0.
## Sample
```cs
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);
```