Git Product home page Git Product logo

randen's Introduction

Overview

What if we could default to attack-resistant random generators without excessive CPU cost? We introduce 'Randen', a new generator with security guarantees; it outperforms MT19937, pcg64_c32, Philox, ISAAC and ChaCha8 in real-world benchmarks. This is made possible by AES hardware acceleration and a large Feistel permutation.

Related work

AES-CTR (encrypting a counter) is a well-known and easy to implement generator. It has two known weaknesses:

  • A known-key distinguisher on 10-round, 128-bit AES [https://goo.gl/3xReB9].

  • No forward security/backtracking resistance: compromising the current state lets attackers distinguish prior outputs from random.

NIST 800-90a r1 [https://goo.gl/68Fwmv] is a standardized generator that ensures backtracking resistance, but is not fast enough for a general-purpose generator (5-10x slower than AES).

Algorithm

The Randen generator is based upon three existing components:

  1. Reverie [https://eprint.iacr.org/2016/886.pdf] is a sponge-like generator that requires a cryptographic permutation. It improves upon "Provably Robust Sponge-Based PRNGs and KDFs" by achieving backtracking resistance with only a single permutation per buffer.

  2. Simpira v2 [https://eprint.iacr.org/2016/122.pdf] constructs up to 1024-bit permutations using an improved Generalized Feistel network with 2-round AES-128 functions. This Feistel block shuffle achieves diffusion sooner and is less vulnerable to sliced-biclique attacks than a Type-2 cyclic shuffle.

  3. "New criterion for diffusion property" [https://goo.gl/mLXH4f] shows that the same kind of improved Feistel block shuffle can be extended to 16 branches, which enables a more efficient 2048-bit permutation.

We combine these by plugging the larger Simpira-like permutation into Reverie.

Performance

The implementation targets x86 (Westmere), POWER 8 and ARM64.

x86 microbenchmark: generating random bits in a tight loop (cpb=cycles per byte, MAD=median absolute deviation):

RNG cpb MAD
Randen 1.54 0.002
pcg64_c32 0.78 0.003
mt19937_64 1.79 0.001
ChaCha8 3.02 0.003
ISAAC 4.08 0.006
Philox 4.70 0.003
/dev/urandom (ChaCha20) 15.27 0.018
BCryptGenRandom (CTR-DRBG) 16.80 0.009

x86 real-world benchmark (reservoir sampling):

RNG cpb MAD
Randen 2.60 0.008
pcg64_c32 3.03 0.009
mt19937_64 2.82 0.009
ChaCha8 3.75 0.008
ISAAC 4.46 0.014
Philox 4.95 0.009
/dev/urandom (ChaCha20) 13.46 0.017
BCryptGenRandom (CTR-DRBG) 16.41 0.015

Security

Randen is indistinguishable from random and backtracking-resistant. For more details and benchmarks, please see "Randen - fast backtracking-resistant random generator with AES+Feistel+Reverie".

Usage

make && bin/randen_benchmark

Note that the code relies on compiler optimizations. Cycles per byte may increase by factors of 1.6 when compiled with GCC 7.3, and 1.3 with Clang 4.0.1. This can be mitigated by manually unrolling the loops.

Third-party implementations / bindings

Thanks to Frank Denis for making us aware of these third-party implementations or bindings. Note that the algorithm is still under review and subject to change, but please feel free to get in touch or raise an issue and we'll add yours as well.

By Language URL
Frank Denis C https://github.com/jedisct1/randen-rng

This is not an official Google product.

randen's People

Contributors

bhswl avatar jan-wassenberg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

randen's Issues

SSE-based Mersenne Twister?

From what I can understand, you used the standard 64-bit version of the Mersenne Twister. Considering that your code use specialized AES instructions, you should at least compare with the SFMT (SIMD-friendly Fast Mersenne Twister), which is almost twice as fast.

If you are not using the SSE2 version, I don't think the comparison you have currently on display is fair.

Mention backtracking resistance in the project summary?

My first thought was "why aren't other fast stream ciphers (e.g. Salsa) sufficient"?

Looks like the main qualitative motivation is backtracking resistance, which takes a dive into the README to understand. I think it would be nice to highlight at the top of the project to distinguish its goals!

Illegal instruction (core dumped)

./randen_benchmark
Illegal instruction (core dumped)

/opt/gcc-9.1.0/bin/g++ -c -I. -I../ -std=c++11 -Wall -O3 -fno-pic -mavx2 -maes -g3

backstack:
(gdb) bt
#0 0x000000000040162a in __fill_a<unsigned int*, unsigned int> (__value=@0xad2c60: 56, __last=0x7ffd509ee138, __first=0x7ffd509eddc0) at /opt/gcc-9.1.0/include/c++/9.1.0/bits/stl_algobase.h:1029
#1 fill<unsigned int*, unsigned int> (__value=@0xad2c60: 56, __last=0x7ffd509ee138, __first=0x7ffd509eddc0) at /opt/gcc-9.1.0/include/c++/9.1.0/bits/stl_algobase.h:749
#2 void randen::(anonymous namespace)::robust_statistics::CountingSort(unsigned int*, unsigned long) [clone .constprop.0] () at nanobenchmark.cc:430
#3 0x000000000040174e in Mode (num_values=256, values=0x7ffd509eddc0) at nanobenchmark.cc:538
#4 Mode<unsigned int, 256> (values=...) at nanobenchmark.cc:489
#5 randen::(anonymous namespace)::TimerResolution () at nanobenchmark.cc:538
#6 0x0000000000401869 in __static_initialization_and_destruction_0 (__priority=65535, __initialize_p=1) at nanobenchmark.cc:795
#7 _GLOBAL__sub_I__ZN6randen8platform14PinThreadToCPUEi () at nanobenchmark.cc:795
#8 0x000000000040beed in __libc_csu_init ()
#9 0x00007ff45a50eb95 in __libc_start_main () from /lib64/libc.so.6
#10 0x000000000040189d in _start () at /opt/gcc-9.1.0/include/c++/9.1.0/bits/stl_algobase.h:1029

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.