Mercurial > hg > octave-kai > gnulib-hg
comparison lib/hmac-sha1.c @ 6410:30ac46875fed
* hmac-md5.c (hmac_md5): Add comments, suggested by Bruno Haible
<bruno@clisp.org>.
* hmac-sha1.c (hmac_sha1): Likewise.
author | Simon Josefsson <simon@josefsson.org> |
---|---|
date | Fri, 21 Oct 2005 12:49:28 +0000 |
parents | 6777a0214f5d |
children | a88f85e4728f |
comparison
equal
deleted
inserted
replaced
6409:faf42a2c7a24 | 6410:30ac46875fed |
---|---|
39 struct sha1_ctx outer; | 39 struct sha1_ctx outer; |
40 char optkeybuf[20]; | 40 char optkeybuf[20]; |
41 char block[64]; | 41 char block[64]; |
42 char innerhash[20]; | 42 char innerhash[20]; |
43 | 43 |
44 /* Reduce the key's size, so that it becomes <= 64 bytes large. */ | |
45 | |
44 if (keylen > 64) | 46 if (keylen > 64) |
45 { | 47 { |
46 struct sha1_ctx keyhash; | 48 struct sha1_ctx keyhash; |
47 | 49 |
48 sha1_init_ctx (&keyhash); | 50 sha1_init_ctx (&keyhash); |
51 | 53 |
52 key = optkeybuf; | 54 key = optkeybuf; |
53 keylen = 20; | 55 keylen = 20; |
54 } | 56 } |
55 | 57 |
58 /* Compute INNERHASH from KEY and IN. */ | |
59 | |
56 sha1_init_ctx (&inner); | 60 sha1_init_ctx (&inner); |
57 | 61 |
58 memset (block, IPAD, sizeof (block)); | 62 memset (block, IPAD, sizeof (block)); |
59 memxor (block, key, keylen); | 63 memxor (block, key, keylen); |
60 | 64 |
61 sha1_process_block (block, 64, &inner); | 65 sha1_process_block (block, 64, &inner); |
62 sha1_process_bytes (in, inlen, &inner); | 66 sha1_process_bytes (in, inlen, &inner); |
63 | 67 |
64 sha1_finish_ctx (&inner, innerhash); | 68 sha1_finish_ctx (&inner, innerhash); |
69 | |
70 /* Compute result from KEY and INNERHASH. */ | |
65 | 71 |
66 sha1_init_ctx (&outer); | 72 sha1_init_ctx (&outer); |
67 | 73 |
68 memset (block, OPAD, sizeof (block)); | 74 memset (block, OPAD, sizeof (block)); |
69 memxor (block, key, keylen); | 75 memxor (block, key, keylen); |