| 1 | #cxx . . $ `<file>/ref10/fastrandombytes/fastrandombytes.c`/include <string.h> |
| 2 | #include "kernelrandombytes.h"cxx . . $ `<file>/ref10/kernelrandombytes/kernelrandombytes.h`/ |
| 3 | #include "crypto_rng.h"cxx . . $ `<file>/ref10/crypto_rng/crypto_rng.h`/ |
| 4 | #include "randombytes.h"cxx . . $ `<file>/ref10/fastrandombytes/randombytes.h`/ |
| 5 | |
| 6 | unsigned long long randombytes_callscxx . . $ randombytes_calls. = 0; |
| 7 | unsigned long long randombytes_bytescxx . . $ randombytes_bytes. = 0; |
| 8 | |
| 9 | static unsigned int initcxx . . $ init. = 0; |
| 10 | |
| 11 | static unsigned char gcxx . . $ g.[crypto_rng_KEYBYTEScxx . . $ `ref10/crypto_rng/crypto_rng.h:7:9`!]; |
| 12 | static unsigned char rcxx . . $ r.[crypto_rng_OUTPUTBYTEScxx . . $ `ref10/crypto_rng/crypto_rng.h:8:9`!]; |
| 13 | unsigned long long poscxx . . $ pos. = crypto_rng_OUTPUTBYTEScxx . . $ `ref10/crypto_rng/crypto_rng.h:8:9`!; |
| 14 | |
| 15 | void randombytescxx . . $ randombytes(3053ec783434178a).(unsigned char *x,unsigned long long xlen) |
| 16 | { |
| 17 | randombytes_callscxx . . $ randombytes_calls. += 1; |
| 18 | randombytes_bytescxx . . $ randombytes_bytes. += xlen; |
| 19 | |
| 20 | if (!initcxx . . $ init.) { |
| 21 | kernelrandombytescxx . . $ kernelrandombytes(3053ec783434178a).(gcxx . . $ g.,sizeof gcxx . . $ g.); |
| 22 | initcxx . . $ init. = 1; |
| 23 | } |
| 24 | |
| 25 | #ifdef SIMPLE |
| 26 | |
| 27 | while (xlen > 0) { |
| 28 | if (pos == crypto_rng_OUTPUTBYTES) { |
| 29 | crypto_rng(r,g,g); |
| 30 | pos = 0; |
| 31 | } |
| 32 | *x++ = r[pos]; xlen -= 1; |
| 33 | r[pos++] = 0; |
| 34 | } |
| 35 | |
| 36 | #else /* same output but optimizing copies */ |
| 37 | |
| 38 | while (xlen > 0) { |
| 39 | unsigned long long ready; |
| 40 | |
| 41 | if (poscxx . . $ pos. == crypto_rng_OUTPUTBYTEScxx . . $ `ref10/crypto_rng/crypto_rng.h:8:9`!) { |
| 42 | while (xlen > crypto_rng_OUTPUTBYTEScxx . . $ `ref10/crypto_rng/crypto_rng.h:8:9`!) { |
| 43 | crypto_rngcxx . . $ `ref10/crypto_rng/crypto_rng.h:6:9`!(x,gcxx . . $ g.,gcxx . . $ g.); |
| 44 | x += crypto_rng_OUTPUTBYTEScxx . . $ `ref10/crypto_rng/crypto_rng.h:8:9`!; |
| 45 | xlen -= crypto_rng_OUTPUTBYTEScxx . . $ `ref10/crypto_rng/crypto_rng.h:8:9`!; |
| 46 | } |
| 47 | if (xlen == 0) return; |
| 48 | |
| 49 | crypto_rngcxx . . $ `ref10/crypto_rng/crypto_rng.h:6:9`!(rcxx . . $ r.,gcxx . . $ g.,gcxx . . $ g.); |
| 50 | poscxx . . $ pos. = 0; |
| 51 | } |
| 52 | |
| 53 | ready = crypto_rng_OUTPUTBYTEScxx . . $ `ref10/crypto_rng/crypto_rng.h:8:9`! - poscxx . . $ pos.; |
| 54 | if (xlen <= ready) ready = xlen; |
| 55 | memcpycxx . . $ memcpy(cc817cb175f282d).(x,rcxx . . $ r. + poscxx . . $ pos.,ready); |
| 56 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(rcxx . . $ r. + poscxx . . $ pos.,0,ready); |
| 57 | x += ready; |
| 58 | xlen -= ready; |
| 59 | poscxx . . $ pos. += ready; |
| 60 | } |
| 61 | |
| 62 | #endif |
| 63 | |
| 64 | } |