c# wrapper implement of Naruto/simon-speck-c
simon and speck are lightweight block cipher algorithms, published by NSA.(iadgov/simon-speck)
support platforms are Desktop Platforms(Windows, macOS, Linux), Xamarin iOS and MonoAndroid.
- algorithms and block sizes, key sizes and modes
- speck ECB
- 128/128
- 128/192
- 128/256
- speck CTR
- 128/128
- 128/192
- 128/256
- speck ECB
- platforms, architectures
- windows x64
- macOS x64
- linux x64
- Xamarin iOS
- MonoAndroid
simple encrypt and decrypt code.
String plainText = "test text abcdefg.";
byte[] plainByte = System.Text.Encoding.ASCII.GetBytes(plainText);
// Speck ECB mode
using (SymmetricAlgorithm algo = new Speck())
{
algo.BlockSize = 128;
algo.KeySize = 128;
algo.GenerateKey();
using (ICryptoTransform encryptor = algo.CreateEncryptor() , decryptor = algo.CreateDecryptor())
{
byte[] plainEnc = encryptor.TransformFinalBlock(plainByte, 0, plainByte.Length);
byte[] plainDec = decryptor.TransformFinalBlock(plainEnc, 0, plainEnc.Length);
Console.WriteLine(System.Text.Encoding.ASCII.GetString(plainDec));
Console.WriteLine();
}
}
// Speck CTR mode
using (SymmetricAlgorithm algo = new SpeckCTR())
{
algo.BlockSize = 128;
algo.KeySize = 128;
algo.GenerateIV();
algo.GenerateKey();
using (ICryptoTransform encryptor = algo.CreateEncryptor() , decryptor = algo.CreateDecryptor())
{
byte[] plainEnc = encryptor.TransformFinalBlock(plainByte, 0, plainByte.Length);
byte[] plainDec = decryptor.TransformFinalBlock(plainEnc, 0, plainEnc.Length);
Console.WriteLine(System.Text.Encoding.ASCII.GetString(plainDec));
Console.WriteLine();
}
}
- mono
- Unity (if create unity package)
git clone --recursive git@github.com:Naruto/simon-speck-net.git
build simon-speck-net and nunit test.
cd /path/to/simon-speck-net
cd ./net
mono .nuget/nuget.exe restore
xbuild /p:TargetFrameworkVersion="v4.5" /p:Configuration=Release
mono ./packages/NUnit.ConsoleRunner.3.7.0/tools/nunit3-console.exe ./speckTest/bin/Release/speckTest.dll
or
cd /path/to/simon-speck-net
./scripts/build.sh
cd /path/to/simon-speck-net
./scripts/create_nuget.sh
SimonSpeckNet nuget package file is outputted to out/net
directory.
cd /path/to/simon-speck-net
./scripts/create_unitypackage.sh
SimonSpeckNet unitypackage file is outputted to out/unity
directory.
update simon-speck-c sumobule
git submodule update --init --recursive
export NDK_ROOT=/path/to/android-ndk-path
./scripts/plugins/deploy_android.sh
deploy each archtectures library files to net/plugins/Android/libs
./scripts/pluginsdeploy_ios.sh
deploy fat library file to net/plugins/iOS
./scripts/plugins/deploy_linux.sh
deploy .so file to net/plugins/x64
./scripts/plugins/deploy_mac.sh
deploy .dylib and .bundle files to net/plugins/x64
T.B.D