All Projects → Naruto → Simon Speck C

Naruto / Simon Speck C

Licence: mit
example C language implementation of SIMON and SPECK lightweight block ciphers.

Projects that are alternatives of or similar to Simon Speck C

Forge
A native implementation of TLS in Javascript and tools to write crypto-based and network-heavy webapps
Stars: ✭ 4,204 (+46611.11%)
Mutual labels:  cryptography, crypto, cipher
Simon Speck
The SIMON and SPECK families of lightweight block ciphers. #nsacyber
Stars: ✭ 146 (+1522.22%)
Mutual labels:  cryptography, crypto, cipher
Libsodium Php
The PHP extension for libsodium.
Stars: ✭ 507 (+5533.33%)
Mutual labels:  cryptography, crypto
Securefs
Filesystem in userspace (FUSE) with transparent authenticated encryption
Stars: ✭ 518 (+5655.56%)
Mutual labels:  cryptography, crypto
Aeternity
æternity: solving scalability problems by making sense of state-channels
Stars: ✭ 923 (+10155.56%)
Mutual labels:  cryptography, crypto
Swifty
🔑 Free Offline Password Manager
Stars: ✭ 496 (+5411.11%)
Mutual labels:  cryptography, cipher
Securitydriven.inferno
✅ .NET crypto done right. Professionally audited.
Stars: ✭ 501 (+5466.67%)
Mutual labels:  cryptography, crypto
Cryptomator
Multi-platform transparent client-side encryption of your files in the cloud
Stars: ✭ 6,623 (+73488.89%)
Mutual labels:  cryptography, crypto
S2n Tls
s2n : an implementation of the TLS/SSL protocols
Stars: ✭ 4,029 (+44666.67%)
Mutual labels:  cryptography, crypto
Maskbook
The portal to the new, open internet. ([I:b])
Stars: ✭ 691 (+7577.78%)
Mutual labels:  cryptography, crypto
Libsodium.js
libsodium compiled to Webassembly and pure JavaScript, with convenient wrappers.
Stars: ✭ 665 (+7288.89%)
Mutual labels:  cryptography, crypto
Acra
Database security suite. Database proxy with field-level encryption, search through encrypted data, SQL injections prevention, intrusion detection, honeypots. Supports client-side and proxy-side ("transparent") encryption. SQL, NoSQL.
Stars: ✭ 726 (+7966.67%)
Mutual labels:  cryptography, crypto
Rsa And Lll Attacks
attacking RSA via lattice reductions (LLL)
Stars: ✭ 482 (+5255.56%)
Mutual labels:  cryptography, crypto
Capillary
Capillary is a library to simplify the sending of end-to-end encrypted push messages from Java-based application servers to Android clients.
Stars: ✭ 445 (+4844.44%)
Mutual labels:  cryptography, crypto
Iotex Core
Official implementation of IoTeX blockchain protocol in Go.
Stars: ✭ 505 (+5511.11%)
Mutual labels:  cryptography, crypto
Snow
A Rust implementation of the Noise Protocol Framework
Stars: ✭ 436 (+4744.44%)
Mutual labels:  cryptography, crypto
Diffie Hellman backdoor
How to backdoor Diffie-Hellman
Stars: ✭ 559 (+6111.11%)
Mutual labels:  cryptography, crypto
Awesome Cryptography
A curated list of cryptography resources and links.
Stars: ✭ 3,475 (+38511.11%)
Mutual labels:  cryptography, crypto
Virgil Crypto Php
Virgil PHP Crypto Library is a high-level cryptographic library that allows you to perform all necessary operations for secure storing and transferring data and everything required to become HIPAA and GDPR compliant.
Stars: ✭ 22 (+144.44%)
Mutual labels:  cryptography, crypto
Rando.js
The world's easiest, most powerful random function.
Stars: ✭ 659 (+7222.22%)
Mutual labels:  cryptography, crypto

Build Status Windows build status Coverity Scan Build Status FOSSA Status

simon-speck-c

simon and speck are lightweight block cipher algorithms, published by NSA.(iadgov/simon-speck)

this is one reference implementation example by C language.

support platforms are linux, iOS, Android ndk, macOS and Windows.

Supports

  • algorithms and block sizes, key sizes
    • speck
      • 128/128
      • 128/192
      • 128/256
  • block cipher mode
    • ECB
    • CTR
  • platforms, architectures
    • linux
      • x86_64(enable AVX2)
      • arm(enable NEON)
      • aarch64(enable NEON)
    • iOS
      • armv7(enable NEON)
      • armv7s(enable NEON)
      • arm64(enable NEON)
      • x86 (simulator)
      • x86_64 (simulator)
    • android
      • armeabi
      • armeabi-v7a(enable NEON)
      • x86
      • x86_64
      • arm64-v8a(enable NEON)
    • macOS
      • x86_64(enable AVX2)
    • windows
      • x86
      • x86_64(enable AVX2)

Samples

#include <speck/speck.h>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <random>

int main() {
    uint8_t key[16]; // when use 128/192, key size is 24. when use 128/256, key size is 32.
    uint8_t original_iv[16];
    uint8_t plain_text[16];
    uint8_t crypted_text[16];
    uint8_t decrypted_text[16];

    // generate key and iv
    std::random_device rd;
    std::mt19937 gen(rd());
    std::uniform_int_distribution<> dis;

    for(int i=0; i<sizeof(key); i++) {
        key[i] = static_cast<uint8_t>(dis(gen));
    }
    for(int i=0; i<sizeof(original_iv); i++) {
        original_iv[i] = static_cast<uint8_t>(dis(gen));
    }
    snprintf(reinterpret_cast<char *>(plain_text), sizeof(plain_text), "hello world!!!!");

    speck_ctx_t *ctx = speck_init(SPECK_ENCRYPT_TYPE_128_128, key, sizeof(key));
    // ECB test
    speck_ecb_encrypt(ctx, plain_text, crypted_text, sizeof(plain_text));
    speck_ecb_decrypt(ctx, crypted_text, decrypted_text, sizeof(crypted_text));
    printf("speck 128/128 ecb\n");
    printf("  plain:     %s\n", plain_text);
    printf("  decrypted: %s\n", decrypted_text);

    // CTR test
    uint8_t iv[16];
    memcpy(iv, original_iv, sizeof(iv));
    speck_ctr_encrypt(ctx, plain_text, crypted_text, sizeof(plain_text), iv, sizeof(iv));
    memcpy(iv, original_iv, sizeof(iv));
    speck_ctr_decrypt(ctx, crypted_text, decrypted_text, sizeof(crypted_text), iv, sizeof(iv));
    printf("speck 128/128 ctr\n");
    printf("  plain:     %s\n", plain_text);
    printf("  decrypted: %s\n", decrypted_text);
}

bindings

development

Requirements

common

  • cmake 3.7 higher

platforms

  • linux
    • gcc
  • iOS & macOS
    • xcode
  • android
    • Android NDK r10e higher
  • windows
    • Visual Studio 2015 higher

build

develop build

on macOS or Linux.

rm -rf build
mkdir build
cd build
cmake -DENABLE_TESTING=ON -DCMAKE_BUILD_TYPE=Debug ..
cmake --build . --clean-first
ctest

release build

linux

./scripts/speck/build_linux.sh

shared library is outputted to libs/linux directory.

iOS

./scripts/speck/build_ios.sh

fat library(simulator, device) is outputted to libs/ios directory.

android

./scripts/speck/build_android.sh

shared librares of each architectures are outputted to libs/android.

macOS

./scripts/speck/build_mac.sh

bundle file is outputted to libs/mac directory.

windows

scripts\speck\build_win.bat

dll library is outputted to libs/windows directory.

benchmark

example enable avx2 benchmark on macOS or Linux.

rm -rf build
mkdir build
pushd build
cmake -DENABLE_TESTING=ON -DENABLE_BENCHMARK=ON -DENABLE_AVX2=ON -DCMAKE_BUILD_TYPE=Release ..
cmake --build . --clean-first
ctest .
./test/speck/speck128128/speck128128benchmark
./test/speck/speck128192/speck128192benchmark
./test/speck/speck128256/speck128256benchmark

benchmark program usage

./test/speck/speck128128/speck128128benchmark [test byte length] [test count]

# e.g.: test encrypt 8096 byte data by speck and speck ctr 128/128 at 50 times.
./test/speck/speck128128/speck128128benchmark 8096 50

License

FOSSA Status

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].