diff options
Diffstat (limited to 'toxencryptsave/crypto_pwhash_scryptsalsa208sha256/crypto_hash_sha256.h')
-rw-r--r-- | toxencryptsave/crypto_pwhash_scryptsalsa208sha256/crypto_hash_sha256.h | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/crypto_hash_sha256.h b/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/crypto_hash_sha256.h new file mode 100644 index 00000000..cc6e3df1 --- /dev/null +++ b/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/crypto_hash_sha256.h | |||
@@ -0,0 +1,61 @@ | |||
1 | #ifdef HAVE_CONFIG_H | ||
2 | #include "config.h" | ||
3 | #endif | ||
4 | #ifdef VANILLA_NACL /* toxcore only uses this when libsodium is unavailable */ | ||
5 | |||
6 | #ifndef crypto_hash_sha256_H | ||
7 | #define crypto_hash_sha256_H | ||
8 | |||
9 | /* | ||
10 | * WARNING: Unless you absolutely need to use SHA256 for interoperatibility, | ||
11 | * purposes, you might want to consider crypto_generichash() instead. | ||
12 | * Unlike SHA256, crypto_generichash() is not vulnerable to length | ||
13 | * extension attacks. | ||
14 | */ | ||
15 | |||
16 | #include <stddef.h> | ||
17 | #include <stdint.h> | ||
18 | #include <stdlib.h> | ||
19 | |||
20 | #include "export.h" | ||
21 | |||
22 | #ifdef __cplusplus | ||
23 | # if __GNUC__ | ||
24 | # pragma GCC diagnostic ignored "-Wlong-long" | ||
25 | # endif | ||
26 | extern "C" { | ||
27 | #endif | ||
28 | |||
29 | typedef struct crypto_hash_sha256_state { | ||
30 | uint32_t state[8]; | ||
31 | uint32_t count[2]; | ||
32 | unsigned char buf[64]; | ||
33 | } crypto_hash_sha256_state; | ||
34 | |||
35 | #define crypto_hash_sha256_BYTES 32U | ||
36 | SODIUM_EXPORT | ||
37 | size_t crypto_hash_sha256_bytes(void); | ||
38 | |||
39 | SODIUM_EXPORT | ||
40 | int crypto_hash_sha256(unsigned char *out, const unsigned char *in, | ||
41 | unsigned long long inlen); | ||
42 | |||
43 | SODIUM_EXPORT | ||
44 | int crypto_hash_sha256_init(crypto_hash_sha256_state *state); | ||
45 | |||
46 | SODIUM_EXPORT | ||
47 | int crypto_hash_sha256_update(crypto_hash_sha256_state *state, | ||
48 | const unsigned char *in, | ||
49 | unsigned long long inlen); | ||
50 | |||
51 | SODIUM_EXPORT | ||
52 | int crypto_hash_sha256_final(crypto_hash_sha256_state *state, | ||
53 | unsigned char *out); | ||
54 | |||
55 | #ifdef __cplusplus | ||
56 | } | ||
57 | #endif | ||
58 | |||
59 | #endif | ||
60 | |||
61 | #endif | ||