1 | //hash.h: |
---|
2 | |
---|
3 | /* |
---|
4 | * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2011 |
---|
5 | * |
---|
6 | * This file is part of libroar a part of RoarAudio, |
---|
7 | * a cross-platform sound system for both, home and professional use. |
---|
8 | * See README for details. |
---|
9 | * |
---|
10 | * This file is free software; you can redistribute it and/or modify |
---|
11 | * it under the terms of the GNU General Public License version 3 |
---|
12 | * as published by the Free Software Foundation. |
---|
13 | * |
---|
14 | * libroar is distributed in the hope that it will be useful, |
---|
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 | * GNU General Public License for more details. |
---|
18 | * |
---|
19 | * You should have received a copy of the GNU General Public License |
---|
20 | * along with this software; see the file COPYING. If not, write to |
---|
21 | * the Free Software Foundation, 51 Franklin Street, Fifth Floor, |
---|
22 | * Boston, MA 02110-1301, USA. |
---|
23 | * |
---|
24 | * NOTE for everyone want's to change something and send patches: |
---|
25 | * read README and HACKING! There a addition information on |
---|
26 | * the license of this document you need to read before you send |
---|
27 | * any patches. |
---|
28 | * |
---|
29 | * NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc |
---|
30 | * or libpulse*: |
---|
31 | * The libs libroaresd, libroararts and libroarpulse link this lib |
---|
32 | * and are therefore GPL. Because of this it may be illigal to use |
---|
33 | * them with any software that uses libesd, libartsc or libpulse*. |
---|
34 | */ |
---|
35 | |
---|
36 | #ifndef _LIBROARHASH_H_ |
---|
37 | #define _LIBROARHASH_H_ |
---|
38 | |
---|
39 | #include "libroar.h" |
---|
40 | |
---|
41 | typedef uint_least32_t roar_hash_t; |
---|
42 | |
---|
43 | // the hashtypes: |
---|
44 | #define ROAR_HT_NONE ((roar_hash_t)0UL) |
---|
45 | #define ROAR_HT_MD5 ((roar_hash_t)1UL) |
---|
46 | #define ROAR_HT_SHA1 ((roar_hash_t)2UL) |
---|
47 | #define ROAR_HT_RIPEMD160 ((roar_hash_t)3UL) |
---|
48 | #define ROAR_HT_MD2 ((roar_hash_t)5UL) |
---|
49 | #define ROAR_HT_TIGER ((roar_hash_t)6UL) |
---|
50 | #define ROAR_HT_HAVAL ((roar_hash_t)7UL) |
---|
51 | #define ROAR_HT_SHA256 ((roar_hash_t)8UL) |
---|
52 | #define ROAR_HT_SHA384 ((roar_hash_t)9UL) |
---|
53 | #define ROAR_HT_SHA512 ((roar_hash_t)10UL) |
---|
54 | #define ROAR_HT_SHA224 ((roar_hash_t)11UL) |
---|
55 | #define ROAR_HT_MD4 ((roar_hash_t)301UL) |
---|
56 | #define ROAR_HT_CRC32 ((roar_hash_t)302UL) |
---|
57 | #define ROAR_HT_RFC1510 ((roar_hash_t)303UL) |
---|
58 | #define ROAR_HT_RFC2440 ((roar_hash_t)304UL) |
---|
59 | #define ROAR_HT_WHIRLPOOL ((roar_hash_t)305UL) |
---|
60 | #define ROAR_HT_UUID ((roar_hash_t)70000UL) |
---|
61 | #define ROAR_HT_GTN8 ((roar_hash_t)70001UL) |
---|
62 | #define ROAR_HT_GTN16 ((roar_hash_t)70002UL) |
---|
63 | #define ROAR_HT_GTN32 ((roar_hash_t)70004UL) |
---|
64 | #define ROAR_HT_GTN64 ((roar_hash_t)70008UL) |
---|
65 | #define ROAR_HT_CLIENTID ((roar_hash_t)71001UL) |
---|
66 | #define ROAR_HT_STREAMID ((roar_hash_t)71002UL) |
---|
67 | #define ROAR_HT_SOURCEID ((roar_hash_t)71003UL) |
---|
68 | #define ROAR_HT_SAMPLEID ((roar_hash_t)71004UL) |
---|
69 | #define ROAR_HT_MIXERID ((roar_hash_t)71005UL) |
---|
70 | #define ROAR_HT_BRIDGEID ((roar_hash_t)71006UL) |
---|
71 | #define ROAR_HT_LISTENID ((roar_hash_t)71007UL) |
---|
72 | #define ROAR_HT_ACTIONID ((roar_hash_t)71008UL) |
---|
73 | #define ROAR_HT_MSGQUEUEID ((roar_hash_t)71009UL) |
---|
74 | #define ROAR_HT_MSGBUSID ((roar_hash_t)71010UL) |
---|
75 | #define ROAR_HT_GTIN8 ((roar_hash_t)72001UL) |
---|
76 | #define ROAR_HT_GTIN13 ((roar_hash_t)72002UL) |
---|
77 | #define ROAR_HT_ISBN10 ((roar_hash_t)72003UL) |
---|
78 | #define ROAR_HT_ISBN13 ROAR_HT_GTIN13 |
---|
79 | #define ROAR_HT_ADLER32 ((roar_hash_t)73001UL) |
---|
80 | |
---|
81 | struct roar_hash_cmds { |
---|
82 | roar_hash_t algo; |
---|
83 | ssize_t statelen; |
---|
84 | ssize_t blocksize; |
---|
85 | int (*init)(void * state); |
---|
86 | int (*uninit)(void * state); |
---|
87 | int (*digest)(void * state, void * digest, size_t * len); |
---|
88 | int (*proc_block)(void * state, const void * block); |
---|
89 | int (*proc)(void * state, const void * data, size_t len); |
---|
90 | }; |
---|
91 | |
---|
92 | const char * roar_ht2str (const roar_hash_t ht); |
---|
93 | roar_hash_t roar_str2ht (const char * ht); |
---|
94 | |
---|
95 | ssize_t roar_ht_digestlen (const roar_hash_t ht); |
---|
96 | |
---|
97 | ssize_t roar_hash_digest2str(char * out, size_t outlen, void * digest, size_t digestlen, roar_hash_t ht); |
---|
98 | |
---|
99 | int roar_ht_is_supported(const roar_hash_t ht); |
---|
100 | |
---|
101 | struct roar_hash_state; |
---|
102 | |
---|
103 | struct roar_hash_state * roar_hash_new(roar_hash_t algo); |
---|
104 | int roar_hash_free(struct roar_hash_state * state); |
---|
105 | int roar_hash_digest(struct roar_hash_state * state, void * digest, size_t * len); |
---|
106 | int roar_hash_proc(struct roar_hash_state * state, const void * data, size_t len); |
---|
107 | |
---|
108 | int roar_hash_buffer(void * digest, const void * data, size_t datalen, roar_hash_t algo); |
---|
109 | int roar_hash_salted_buffer(void * digest, const void * data, size_t datalen, roar_hash_t algo, const void * salt, size_t saltlen); |
---|
110 | |
---|
111 | #endif |
---|
112 | |
---|
113 | //ll |
---|