5 Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
7 Copyright (C) 1997 - 2001 Pekka Riikonen
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program 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.
27 This is the HMAC object to create keyed hash values for message
28 authentication. These routines uses already implemented hash functions.
29 HMAC's can be created using any hash function implemented in SILC. These
30 routines were created according to RFC2104. Following short description
41 Length of the MAC the HMAC is to produce (bytes).
48 The hash object to tell what hash function to use with this HMAC.
52 TRUE if the `hash' was allocated and FALSE if it is static and
58 The key and its length used to make the HMAC. This is set
59 with silc_hmac_set_key function.
62 typedef struct SilcHmacStruct *SilcHmac;
69 struct SilcHmacStruct {
77 /* Marks for all hmacs. This can be used in silc_hmac_unregister
78 to unregister all hmacs at once. */
79 #define SILC_ALL_HMACS ((SilcHmacObject *)1)
81 /* Default hmacs for silc_hmac_register_default(). */
82 extern SilcHmacObject silc_default_hmacs[];
85 bool silc_hmac_register(SilcHmacObject *hmac);
86 bool silc_hmac_unregister(SilcHmacObject *hmac);
87 bool silc_hmac_register_default(void);
88 bool silc_hmac_alloc(char *name, SilcHash hash, SilcHmac *new_hmac);
89 void silc_hmac_free(SilcHmac hmac);
90 bool silc_hmac_is_supported(const char *name);
91 char *silc_hmac_get_supported(void);
92 uint32 silc_hmac_len(SilcHmac hmac);
93 void silc_hmac_set_key(SilcHmac hmac, const unsigned char *key,
95 void silc_hmac_make(SilcHmac hmac, unsigned char *data,
96 uint32 data_len, unsigned char *return_hash,
98 void silc_hmac_make_with_key(SilcHmac hmac, unsigned char *data,
100 unsigned char *key, uint32 key_len,
101 unsigned char *return_hash,
103 void silc_hmac_make_truncated(SilcHmac hmac,
106 uint32 truncated_len,
107 unsigned char *return_hash);