Debian Codegraph @

ref10/crypto_rng/rng.c

raw symbols SCIP
1 #include <string.h>
2 #include "crypto_stream_salsa20.h"
3 #include "crypto_rng.h"
4
5 #define crypto_stream crypto_stream_salsa20
6 #define KEYBYTES crypto_stream_salsa20_KEYBYTES
7 #define NONCEBYTES crypto_stream_salsa20_NONCEBYTES
8 #define OUTPUTBYTES crypto_rng_OUTPUTBYTES
9
10 #if KEYBYTES != crypto_rng_KEYBYTES
11 KEYBYTES mismatch!
12 #endif
13
14 static const unsigned char nonce[NONCEBYTES] = {0};
15
16 int crypto_rng(
17 unsigned char *r, /* random output */
18 unsigned char *n, /* new key */
19 const unsigned char *g /* old key */
20 )
21 {
22 unsigned char x[KEYBYTES + OUTPUTBYTES];
23 crypto_stream(x,sizeof x,nonce,g);
24 memcpy(n,x,KEYBYTES);
25 memcpy(r,x + KEYBYTES,OUTPUTBYTES);
26 return 0;
27 }