kat.h (2541B)
1 /* 2 Copyright 2010-2011, D. E. Shaw Research. 3 All rights reserved. 4 5 Redistribution and use in source and binary forms, with or without 6 modification, are permitted provided that the following conditions are 7 met: 8 9 * Redistributions of source code must retain the above copyright 10 notice, this list of conditions, and the following disclaimer. 11 12 * Redistributions in binary form must reproduce the above copyright 13 notice, this list of conditions, and the following disclaimer in the 14 documentation and/or other materials provided with the distribution. 15 16 * Neither the name of D. E. Shaw Research nor the names of its 17 contributors may be used to endorse or promote products derived from 18 this software without specific prior written permission. 19 20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 */ 32 #ifndef __katdoth__ 33 #define __katdoth__ 34 35 #include <Random123/philox.h> 36 #include <Random123/threefry.h> 37 #include <Random123/ars.h> 38 #include <Random123/aes.h> 39 40 enum method_e{ 41 #define RNGNxW_TPL(base, N, W) base##N##x##W##_e, 42 #include "rngNxW.h" 43 #undef RNGNxW_TPL 44 last 45 }; 46 47 #define RNGNxW_TPL(base, N, W) \ 48 typedef struct { \ 49 base##N##x##W##_ctr_t ctr; \ 50 base##N##x##W##_ukey_t ukey; \ 51 base##N##x##W##_ctr_t expected; \ 52 base##N##x##W##_ctr_t computed; \ 53 } base##N##x##W##_kat; 54 #include "rngNxW.h" 55 #undef RNGNxW_TPL 56 57 typedef struct{ 58 enum method_e method; 59 unsigned nrounds; 60 union{ 61 #define RNGNxW_TPL(base, N, W) base##N##x##W##_kat base##N##x##W##_data; 62 #include "rngNxW.h" 63 #undef RNGNxW_TPL 64 /* Sigh... For those platforms that lack uint64_t, carve 65 out 128 bytes for the counter, key, expected, and computed. */ 66 char justbytes[128]; 67 }u; 68 } kat_instance; 69 70 #endif