line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#include "ed25519.h" |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
#ifndef ED25519_NO_SEED |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
#ifdef _WIN32 |
6
|
|
|
|
|
|
|
#include |
7
|
|
|
|
|
|
|
#include |
8
|
|
|
|
|
|
|
#else |
9
|
|
|
|
|
|
|
#include |
10
|
|
|
|
|
|
|
#endif |
11
|
|
|
|
|
|
|
|
12
|
1024
|
|
|
|
|
|
int ed25519_create_seed(unsigned char *seed) { |
13
|
|
|
|
|
|
|
#ifdef _WIN32 |
14
|
|
|
|
|
|
|
HCRYPTPROV prov; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
if (!CryptAcquireContext(&prov, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) { |
17
|
|
|
|
|
|
|
return 1; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
if (!CryptGenRandom(prov, 32, seed)) { |
21
|
|
|
|
|
|
|
CryptReleaseContext(prov, 0); |
22
|
|
|
|
|
|
|
return 1; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
CryptReleaseContext(prov, 0); |
26
|
|
|
|
|
|
|
#else |
27
|
1024
|
|
|
|
|
|
FILE *f = fopen("/dev/urandom", "rb"); |
28
|
|
|
|
|
|
|
|
29
|
1024
|
50
|
|
|
|
|
if (f == NULL) { |
30
|
0
|
|
|
|
|
|
return 1; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
1024
|
|
|
|
|
|
fread(seed, 1, 32, f); |
34
|
1024
|
|
|
|
|
|
fclose(f); |
35
|
|
|
|
|
|
|
#endif |
36
|
|
|
|
|
|
|
|
37
|
1024
|
|
|
|
|
|
return 0; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
#endif |