|
| AESNIEngine (result_type s=0) |
|
template<typename SeedSeq > |
| AESNIEngine (SeedSeq &seq, typename cxx11::enable_if< internal::is_seed_seq< SeedSeq, result_type, key_type, AESNIEngine< ResultType, KeySeq, KeySeqInit, Rounds, Blocks > >::value >::type *=nullptr) |
|
| AESNIEngine (const key_type &k) |
|
template<std::size_t B> |
ctr_type | ctr () const |
|
void | ctr (const ctr_type &c) |
|
ctr_block_type | ctr_block () const |
|
void | discard (result_type nskip) |
|
key_type | key () const |
|
void | key (const key_type &k) |
|
key_seq_type | key_seq () const |
|
result_type | operator() () |
|
buffer_type | operator() (const ctr_type &c) const |
| Generate a buffer of random bits given a counter using the current key. More...
|
|
buffer_type | operator() (const ctr_block_type &cb) const |
| Generate a buffer of random bits given a block of counters using the current key. More...
|
|
void | operator() (const ctr_type &c, buffer_type &buf) const |
| Generate random bits in a pre-allocated buffer given a counter using the current key. More...
|
|
void | operator() (const ctr_block_type &cb, buffer_type &buf) const |
| Generate ranodm bits in a pre-allocated buffer given a block of counters using the current key. More...
|
|
void | seed (result_type s) |
|
template<typename SeedSeq > |
void | seed (SeedSeq &seq, typename cxx11::enable_if< internal::is_seed_seq< SeedSeq, result_type, key_type >::value >::type *=nullptr) |
|
void | seed (const key_type &k) |
|
|
bool | operator!= (const AESNIEngine< ResultType, KeySeq, KeySeqInit, Rounds, Blocks > &eng1, const AESNIEngine< ResultType, KeySeq, KeySeqInit, Rounds, Blocks > &eng2) |
|
template<typename CharT , typename Traits > |
std::basic_ostream< CharT, Traits > & | operator<< (std::basic_ostream< CharT, Traits > &os, const AESNIEngine< ResultType, KeySeq, KeySeqInit, Rounds, Blocks > &eng) |
|
bool | operator== (const AESNIEngine< ResultType, KeySeq, KeySeqInit, Rounds, Blocks > &eng1, const AESNIEngine< ResultType, KeySeq, KeySeqInit, Rounds, Blocks > &eng2) |
|
template<typename CharT , typename Traits > |
std::basic_istream< CharT, Traits > & | operator>> (std::basic_istream< CharT, Traits > &is, AESNIEngine< ResultType, KeySeq, KeySeqInit, Rounds, Blocks > &eng) |
|
template<typename ResultType, typename KeySeq, bool KeySeqInit, std::size_t Rounds, std::size_t Blocks>
class vsmc::AESNIEngine< ResultType, KeySeq, KeySeqInit, Rounds, Blocks >
RNG engine using AES-NI instructions.
Two dervied class AES128Engine and ARSEngine behave exactly the same as AES and ARS RNG engines as described in Parallel Random Numbers: As Easy as 1, 2, 3 and implemented in Random123, when used with uint32_t
as ResultType. The first \(2^{32}\) iterations will be exactly the same as r123::Engine<r123:AESNI4x32>
and r123::Engine<r123:ARS4x32_R<10> >
. (Note, they could be simple template alias in C++11, but to support C++98 we had to derive from it. Since the derived classes contains nothing and does nothing, there is no performance cost).
This implementation is more flexible than the original. First, it allows using any unsigned integers as output. Second, it allows user defined key schedule (the second template argument). The two derived classed merely use two special key schedule to reproduce the original behavior.
The terminology used in this engine is slightly different than that in Random123. In the later, there is a distinction between key_type
and ukey_type
. They are key_type
and key_seq_type
in this class, respectively. In other Random123 engines, key_type
and ukey_type
are usually the same. And in ThreefryEngine and PhiloxEngine, vSMC does not define ukey_type
. In this engine, the term key
(ukey
, short for unique key, in Rnadom123) usually refer to the 128-, 192-, or 256-bits input key in the context of the AES algorithm. And key_seq
(key
in Random123) refers to the key schedule in the same context. In the context of C++11, key_seq
is also sort of like the seed_seq
for other RNG (basically both expand a single input value into a sequence such that the sequence provides extra entropy even the inputs are not random at all). Therefore vSMC's terminology shall be both familiar to people familiar with block ciphers (of which AES is one), and people familiar with C++11, but at the risk of confusing people already familiar with [Random123r123lib. Of course, if only used as a standard C++11 engine, then none of these matters since users only provides seeds or a seed sequence.
- Template Parameters
-
ResultType | The output type of operator() |
KeySeq | Using other key schedule can lead to other rng. The KeySeq template parameter needs to has a member function of the form, which is similar to that of C++11 seed_seq . Given a unique key, a sequence of round keys shall be generated and filled into key_seq . The KeySeq type also needs to have a member type key_type . |
KeySeqInit | The key sequence can be computed when the engine is constructed or seeded, or computed each time it is needed. Prepare the key when seeding increase the size of the engine considerably. But in some cases such as AES128Engine, etc, it increase the throughput significantly. |
Rounds | The third template argument is the rounds of the algorithm. AES requires 10 rounds when using a 128-bits key. With reduced strength, any number of round below 10 can be used. |
Blocks | The fourth template argument specifies how many blocks shall be used. The AES-NI instructions have noticeable latency but can be started every two cycles. By allowing generating multiple blocks at once, and interleaving the instructions, the throughput can be increased at the cost of space. |
Definition at line 213 of file aes_ni.hpp.