Fix builds for systems using glib 2.3.81 and above
[sipe-libnice.git] / stun / sha1.h
blob1383a6f912fcdb888ff5d78a2818961d6df486e6
1 /*
2 * SHA1 hash implementation and interface functions
3 * Copyright (c) 2003-2005, Jouni Malinen <j@w1.fi>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
9 * Alternatively, this software may be distributed under the terms of BSD
10 * license.
12 * See README and COPYING for more details.
15 #ifndef SHA1_H
16 #define SHA1_H
18 #include <stdint.h>
19 #include <stddef.h>
21 #define SHA1_MAC_LEN 20
23 struct SHA1Context {
24 uint32_t state[5];
25 uint32_t count[2];
26 unsigned char buffer[64];
29 typedef struct SHA1Context SHA1_CTX;
31 void SHA1Init(SHA1_CTX *context);
32 void SHA1Update(SHA1_CTX *context, const void *data, uint32_t len);
33 void SHA1Final(unsigned char digest[20], SHA1_CTX *context);
35 struct HMACContext {
36 SHA1_CTX context;
37 uint8_t key[64];
38 size_t key_len;
40 typedef struct HMACContext HMAC_CTX;
42 void HMACInit(HMAC_CTX *context, const uint8_t *key, size_t key_len);
43 void HMACUpdate(HMAC_CTX *context, const void *data, uint32_t len);
44 void HMACFinal(unsigned char digest[20], HMAC_CTX *context);
46 void sha1_vector(size_t num_elem, const uint8_t *addr[], const size_t *len,
47 uint8_t *mac);
48 void hmac_sha1_vector(const uint8_t *key, size_t key_len, size_t num_elem,
49 const uint8_t *addr[], const size_t *len, uint8_t *mac);
50 void hmac_sha1(const uint8_t *key, size_t key_len,
51 const uint8_t *data, size_t data_len, uint8_t *mac);
52 void sha1_prf(const uint8_t *key, size_t key_len, const char *label,
53 const uint8_t *data, size_t data_len, uint8_t *buf, size_t buf_len);
55 #endif /* SHA1_H */