Skip to content

jellytera/simon-speck.rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

simon-speck

Production-ready implementation in Rust for SIMON and SPECK block ciphers.

All implementation passed the tests with vectors served in the official guide.

SPECK SIMON Block Key
[x] [x] 64 96
[x] [x] 64 128
[x] [x] 128 128
[x] [x] 128 192
[x] [x] 128 256
// Key schedule.
let rk: SpeckRkB64K128 = speck_b64_k128_key_schedule(k[0], k[1], k[2], k[3]);
// Encrypt block.
let ct: u64 = speck_b64_k128_encrypt(&rk, pt);
// Decrypt block.
let pt: u64 = speck_b64_k128_decrypt(&rk, ct);
// Key schedule.
let rk: SpeckRkB{BLOCK}K{KEY} = speck_b{BLOCK}_k{KEY} _key_schedule({KEYS..});
// Encrypt block.
let ct: u{BLOCK} = speck_b{BLOCK}_k{KEY}_encrypt(&rk, pt);
// Decrypt block.
let pt: u{BLOCK} = speck_b{BLOCK}_k{KEY}_decrypt(&rk, ct);

Database serial obfuscation

For cases in API that you want to hide scale of the table rows.

create table row_t (
    _id bigserial primary key,
    ...
);
// Key schedule.
let rk: SpeckRkB64K128 = speck_b64_k128_key_schedule(k[0], k[1], k[2], k[3]);
// Query row.
let row = query!(...);
// Obfuscation.
let id: u64 = speck_b64_k128_encrypt(&rk, row._id);

What are SIMON and SPECK?

SIMON and SPECK are families of lightweight block ciphers publicly released by the National Security Agency (NSA) in June 2013.

  • SPECK, add–rotate–xor (ARX) cipher, has been optimized for performance in software implementations.
  • SIMON, Feistel cipher, has been optimized for hardware implementations.

This implementation replicates the reference code in the Implementation Guide v1.1 by NSA Cyber-security, using macros to derive common patterns and crypto functions.

SPECK is simple, took about 100 lines in total. SIMON is designed for hardware, has more variants in different cases.

All implementation passed the tests with vectors served in the guide.

Legal information about the cipher

Advisory

SIMON and SPECK cipher is NOT adopted as an ISO standard. Using it may not meet certain security compliance requirements in global.

Even while NSA is eating its own dog food, using SIMON and SPECK in their devices, the ciphers have been controversial due to history of NSA promoting ciphers which has backdoor design inside.

You decide whether to adopt this at your own discretion. Given that all the institutions and enterprises that once promoted it, like Linux kernel and Google's Adiantum cipher, have suffered setbacks in the court of public opinion.

The NSA began working on the SIMON and SPECK ciphers in 2011. The agency anticipated some agencies in the US federal government would need a cipher that would operate well on a diverse collection of Internet of Things devices while maintaining an acceptable level of security.

Cited from Wikipedia

A report about NSA's attempts to promote SIMON/SPECK cipher as ISO standard: Reuters, 2017: Distrustful U.S. allies force spy agency to back down in encryption fight

In view of the fact that this cipher having targeted analysis for a long time and has no attacked cases, running fast on low-level device, it is still valuable.

For myself, the motivation to implement it, is: obfuscation for database auto-increase serial ID

About

Production ready SIMON and SPECK block cipher implementation. Passed tests served with official vectors.

Topics

Resources

License

Stars

2 stars

Watchers

0 watching

Forks

Contributors

Languages