[go: up one dir, main page]

File: hmac.h

package info (click to toggle)
cctools 1%3A7.15.9-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 40,008 kB
  • sloc: ansic: 117,215; python: 30,569; cpp: 20,301; sh: 13,834; perl: 4,056; xml: 3,688; makefile: 1,502
file content (53 lines) | stat: -rw-r--r-- 2,216 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
Copyright (C) 2022 The University of Notre Dame
This software is distributed under the GNU General Public License.
See the file COPYING for details.
*/

#ifndef HMAC_H_
#define HMAC_H_

#include <stdlib.h>

/** @file hmac.h
Routines for computing Hash-based Message Authentication Codes.
*/

#include "sha1.h"
#include "md5.h"


/** Generate HMAC
@param buffer Pointer to a memory buffer.
@param buffer_length Length of the buffer in bytes.
@param key Pointer to a buffer containing the key for hashing.
@param key_length The length of the key in bytes.
@param digest Pointer to a buffer to store the digest.
@param digest_len The length of the digest buffer.
@param block_size The size of the block used by the hash function in bytes.
@param hash_func A function pointer to the hash function to be used.
*/
int hmac(const void *buffer, size_t buffer_length, const void *key, size_t key_length, unsigned char *digest, size_t digest_len, size_t block_size, void (*hash_func) (const void *, size_t, unsigned char *));

/** Generate HMAC using md5 hash function
Note that this function produces a digest in binary form which must be converted to a human readable form with md5_to_string.
@param buffer Pointer to a memory buffer.
@param buffer_length Length of the buffer in bytes.
@param key Pointer to a buffer containing the key for hashing.
@param key_length The length of the key in bytes.
@param digest Pointer to a buffer of size MD5_DIGEST_LENGTH to store the digest.
*/
int hmac_md5(const void *buffer, size_t buffer_length, const void *key, size_t key_length, unsigned char digest[MD5_DIGEST_LENGTH]);

/** Generate HMAC using sha1 hash function
Note that this function produces a digest in binary form which must be converted to a human readable form with sha1_string.
@param buffer Pointer to a memory buffer.
@param buffer_length Length of the buffer in bytes.
@param key Pointer to a buffer containing the key for hashing.
@param key_length The length of the key in bytes.
@param digest Pointer to a buffer of size SHA1_DIGEST_LENGTH to store the digest.
*/
int hmac_sha1(const void *buffer, size_t buffer_length, const void *key, size_t key_length, unsigned char digest[SHA1_DIGEST_LENGTH]);


#endif