Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wine-mirror
GitHub Repository: wine-mirror/wine
Path: blob/master/libs/tomcrypt/src/headers/tomcrypt_misc.h
5971 views
1
/* LibTomCrypt, modular cryptographic library -- Tom St Denis
2
*
3
* LibTomCrypt is a library that provides various cryptographic
4
* algorithms in a highly modular and flexible manner.
5
*
6
* The library is free for all purposes without any express
7
* guarantee it works.
8
*/
9
10
/* ---- LTC_BASE64 Routines ---- */
11
#ifdef LTC_BASE64
12
int base64_encode(const unsigned char *in, unsigned long len,
13
unsigned char *out, unsigned long *outlen);
14
15
int base64_decode(const unsigned char *in, unsigned long len,
16
unsigned char *out, unsigned long *outlen);
17
int base64_strict_decode(const unsigned char *in, unsigned long len,
18
unsigned char *out, unsigned long *outlen);
19
#endif
20
21
#ifdef LTC_BASE64_URL
22
int base64url_encode(const unsigned char *in, unsigned long len,
23
unsigned char *out, unsigned long *outlen);
24
int base64url_strict_encode(const unsigned char *in, unsigned long inlen,
25
unsigned char *out, unsigned long *outlen);
26
27
int base64url_decode(const unsigned char *in, unsigned long len,
28
unsigned char *out, unsigned long *outlen);
29
int base64url_strict_decode(const unsigned char *in, unsigned long len,
30
unsigned char *out, unsigned long *outlen);
31
#endif
32
33
/* ===> LTC_HKDF -- RFC5869 HMAC-based Key Derivation Function <=== */
34
#ifdef LTC_HKDF
35
36
int hkdf_test(void);
37
38
int hkdf_extract(int hash_idx,
39
const unsigned char *salt, unsigned long saltlen,
40
const unsigned char *in, unsigned long inlen,
41
unsigned char *out, unsigned long *outlen);
42
43
int hkdf_expand(int hash_idx,
44
const unsigned char *info, unsigned long infolen,
45
const unsigned char *in, unsigned long inlen,
46
unsigned char *out, unsigned long outlen);
47
48
int hkdf(int hash_idx,
49
const unsigned char *salt, unsigned long saltlen,
50
const unsigned char *info, unsigned long infolen,
51
const unsigned char *in, unsigned long inlen,
52
unsigned char *out, unsigned long outlen);
53
54
#endif /* LTC_HKDF */
55
56
/* ---- MEM routines ---- */
57
int mem_neq(const void *a, const void *b, size_t len);
58
void zeromem(volatile void *dst, size_t len);
59
void burn_stack(unsigned long len);
60
61
const char *error_to_string(int err);
62
63
extern const char *crypt_build_settings;
64
65
/* ---- HMM ---- */
66
int crypt_fsa(void *mp, ...);
67
68
/* ---- Dynamic language support ---- */
69
int crypt_get_constant(const char* namein, int *valueout);
70
int crypt_list_all_constants(char *names_list, unsigned int *names_list_size);
71
72
int crypt_get_size(const char* namein, unsigned int *sizeout);
73
int crypt_list_all_sizes(char *names_list, unsigned int *names_list_size);
74
75
#ifdef LTM_DESC
76
void init_LTM(void);
77
#endif
78
#ifdef TFM_DESC
79
void init_TFM(void);
80
#endif
81
#ifdef GMP_DESC
82
void init_GMP(void);
83
#endif
84
85
#ifdef LTC_ADLER32
86
typedef struct adler32_state_s
87
{
88
unsigned short s[2];
89
} adler32_state;
90
91
void adler32_init(adler32_state *ctx);
92
void adler32_update(adler32_state *ctx, const unsigned char *input, unsigned long length);
93
void adler32_finish(adler32_state *ctx, void *hash, unsigned long size);
94
int adler32_test(void);
95
#endif
96
97
#ifdef LTC_CRC32
98
typedef struct crc32_state_s
99
{
100
ulong32 crc;
101
} crc32_state;
102
103
void crc32_init(crc32_state *ctx);
104
void crc32_update(crc32_state *ctx, const unsigned char *input, unsigned long length);
105
void crc32_finish(crc32_state *ctx, void *hash, unsigned long size);
106
int crc32_test(void);
107
#endif
108
109
int compare_testvector(const void* is, const unsigned long is_len, const void* should, const unsigned long should_len, const char* what, int which);
110
111