~ubuntu-branches/ubuntu/vivid/cctools/vivid

« back to all changes in this revision

Viewing changes to dttools/src/hmac.h

  • Committer: Bazaar Package Importer
  • Author(s): Michael Hanke
  • Date: 2011-05-07 09:05:00 UTC
  • Revision ID: james.westby@ubuntu.com-20110507090500-lqpmdtwndor6e7os
Tags: upstream-3.3.2
ImportĀ upstreamĀ versionĀ 3.3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
Copyright (C) 2010- The University of Notre Dame
 
3
This software is distributed under the GNU General Public License.
 
4
See the file COPYING for details.
 
5
*/
 
6
 
 
7
#ifndef HMAC_H_
 
8
#define HMAC_H_
 
9
 
 
10
/** @file hmac.h
 
11
Routines for computing Hash-based Message Authentication Codes.
 
12
*/
 
13
 
 
14
#include "sha1.h"
 
15
#include "md5.h"
 
16
 
 
17
 
 
18
/** Generate HMAC
 
19
@param buffer Pointer to a memory buffer.
 
20
@param buffer_length Length of the buffer in bytes.
 
21
@param key Pointer to a buffer containing the key for hashing.
 
22
@param key_length The length of the key in bytes.
 
23
@param digest Pointer to a buffer to store the digest.
 
24
@param digest_len The length of the digest buffer.
 
25
@param block_size The size of the block used by the hash function in bytes.
 
26
@param hash_func A function pointer to the hash function to be used.
 
27
*/
 
28
int hmac( const char* buffer, int buffer_length, const char* key, int key_length, unsigned char *digest, int digest_len, int block_size, void (*hash_func)(const char*, int, unsigned char*));
 
29
 
 
30
/** Generate HMAC using md5 hash function
 
31
Note that this function produces a digest in binary form which must be converted to a human readable form with md5_string.
 
32
@param buffer Pointer to a memory buffer.
 
33
@param buffer_length Length of the buffer in bytes.
 
34
@param key Pointer to a buffer containing the key for hashing.
 
35
@param key_length The length of the key in bytes.
 
36
@param digest Pointer to a buffer of size MD5_DIGEST_LENGTH to store the digest.
 
37
*/
 
38
int hmac_md5( const char* buffer, int buffer_length, const char* key, int key_length, unsigned char digest[MD5_DIGEST_LENGTH]);
 
39
 
 
40
/** Generate HMAC using sha1 hash function
 
41
Note that this function produces a digest in binary form which must be converted to a human readable form with sha1_string.
 
42
@param buffer Pointer to a memory buffer.
 
43
@param buffer_length Length of the buffer in bytes.
 
44
@param key Pointer to a buffer containing the key for hashing.
 
45
@param key_length The length of the key in bytes.
 
46
@param digest Pointer to a buffer of size SHA1_DIGEST_LENGTH to store the digest.
 
47
*/
 
48
int hmac_sha1( const char* buffer, int buffer_length, const char* key, int key_length, unsigned char digest[SHA1_DIGEST_LENGTH]);
 
49
 
 
50
 
 
51
#endif
 
52