comparison hmac_file.c @ 143:5d99163f7e32 libtomcrypt-orig

import of libtomcrypt 0.99
author Matt Johnston <matt@ucc.asn.au>
date Sun, 19 Dec 2004 11:34:45 +0000
parents 7faae8f46238
children
comparison
equal deleted inserted replaced
15:6362d3854bb4 143:5d99163f7e32
10 */ 10 */
11 /* Submited by Dobes Vandermeer ([email protected]) */ 11 /* Submited by Dobes Vandermeer ([email protected]) */
12 12
13 #include "mycrypt.h" 13 #include "mycrypt.h"
14 14
15 /*
16 (1) append zeros to the end of K to create a B byte string
17 (e.g., if K is of length 20 bytes and B=64, then K will be
18 appended with 44 zero bytes 0x00)
19 (2) XOR (bitwise exclusive-OR) the B byte string computed in step
20 (1) with ipad (ipad = the byte 0x36 repeated B times)
21 (3) append the stream of data 'text' to the B byte string resulting
22 from step (2)
23 (4) apply H to the stream generated in step (3)
24 (5) XOR (bitwise exclusive-OR) the B byte string computed in
25 step (1) with opad (opad = the byte 0x5C repeated B times.)
26 (6) append the H result from step (4) to the B byte string
27 resulting from step (5)
28 (7) apply H to the stream generated in step (6) and output
29 the result
30 */
31
32 #ifdef HMAC 15 #ifdef HMAC
33
34 #define HMAC_BLOCKSIZE hash_descriptor[hash].blocksize
35 16
36 /* hmac_file added by Tom St Denis */ 17 /* hmac_file added by Tom St Denis */
37 int hmac_file(int hash, const char *fname, 18 int hmac_file(int hash, const char *fname,
38 const unsigned char *key, unsigned long keylen, 19 const unsigned char *key, unsigned long keylen,
39 unsigned char *dst, unsigned long *dstlen) 20 unsigned char *dst, unsigned long *dstlen)