1 /* aich.h */
2 #ifndef AICH_H
3 #define AICH_H
4 #include "sha1.h"
5 
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 
10 /* algorithm context */
11 typedef struct aich_ctx
12 {
13 	sha1_ctx sha1_context; /* context used to hash tree leaves */
14 #if defined(USE_OPENSSL) || defined(OPENSSL_RUNTIME)
15 	unsigned long reserved; /* need more space for openssl sha1 context */
16 	void (*sha_init)(void*);
17 	void (*sha_update)(void*, const void*, size_t size);
18 	void (*sha_final)(void*, unsigned char*);
19 #endif
20 	unsigned index;        /* algorithm position in the current ed2k chunk */
21 	unsigned char (*block_hashes)[sha1_hash_size];
22 
23 	void** chunk_table;    /* table of chunk hashes */
24 	size_t allocated;      /* allocated size of the chunk_table */
25 	size_t chunks_number;  /* number of ed2k chunks hashed */
26 	int error;             /* non-zero if a memory error occurred, 0 otherwise */
27 } aich_ctx;
28 
29 /* hash functions */
30 
31 void rhash_aich_init(aich_ctx* ctx);
32 void rhash_aich_update(aich_ctx* ctx, const unsigned char* msg, size_t size);
33 void rhash_aich_final(aich_ctx* ctx, unsigned char result[20]);
34 
35 /* Clean up context by freeing allocated memory.
36  * The function is called automatically by rhash_aich_final.
37  * Shall be called when aborting hash calculations. */
38 void rhash_aich_cleanup(aich_ctx* ctx);
39 
40 #ifdef __cplusplus
41 } /* extern "C" */
42 #endif /* __cplusplus */
43 
44 #endif /* AICH_H */
45