Mercurial > masqmail
comparison src/md5/hmac_md5.c @ 367:b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
Now we use:
/*
** comment
*/
This makes the indent style simpler, too.
author | markus schnalke <meillo@marmaro.de> |
---|---|
date | Thu, 20 Oct 2011 10:20:59 +0200 |
parents | 41958685480d |
children |
comparison
equal
deleted
inserted
replaced
366:41958685480d | 367:b27f66555ba8 |
---|---|
1 /* | 1 /* |
2 hmac_md5 -- implements RFC 2104 | 2 ** hmac_md5 -- implements RFC 2104 |
3 | 3 ** |
4 Copyright 2010, markus schnalke <meillo@marmaro.de> | 4 ** Copyright 2010, markus schnalke <meillo@marmaro.de> |
5 | 5 ** |
6 Permission to use, copy, modify, and/or distribute this software for any | 6 ** Permission to use, copy, modify, and/or distribute this software for any |
7 purpose with or without fee is hereby granted, provided that the above | 7 ** purpose with or without fee is hereby granted, provided that the above |
8 copyright notice and this permission notice appear in all copies. | 8 ** copyright notice and this permission notice appear in all copies. |
9 | 9 ** |
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | 10 ** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | 11 ** WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | 12 ** MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
13 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | 13 ** ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | 14 ** WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | 15 ** ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 16 ** OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
17 | 17 ** |
18 | 18 ** |
19 My motivation to write this code was the lack of a nicely licensed | 19 ** My motivation to write this code was the lack of a nicely licensed |
20 hmac_md5 function in C. I programmed it following the RFC's text. | 20 ** hmac_md5 function in C. I programmed it following the RFC's text. |
21 Obviously this code is highly similar to the sample code of the RFC. | 21 ** Obviously this code is highly similar to the sample code of the RFC. |
22 The code is tested against the test vectors of the RFC. Wikipedia's | 22 ** The code is tested against the test vectors of the RFC. Wikipedia's |
23 HMAC page helped me to understand the algorithm better. | 23 ** HMAC page helped me to understand the algorithm better. |
24 | 24 ** |
25 This hmac_md5 function requires an OpenSSL-compatible MD5 | 25 ** This hmac_md5 function requires an OpenSSL-compatible MD5 |
26 implementation. There are Public Domain MD5 implementations by Colin | 26 ** implementation. There are Public Domain MD5 implementations by Colin |
27 Plumb and by Solar Designer. You probably want to use one of these. | 27 ** Plumb and by Solar Designer. You probably want to use one of these. |
28 */ | 28 */ |
29 | 29 |
30 #include <string.h> | 30 #include <string.h> |
31 #include "md5.h" | 31 #include "md5.h" |
32 | 32 |
34 const int blocksize = 64; | 34 const int blocksize = 64; |
35 const int hashsize = 16; | 35 const int hashsize = 16; |
36 | 36 |
37 | 37 |
38 /* | 38 /* |
39 The computed HMAC will be written to `digest'. | 39 ** The computed HMAC will be written to `digest'. |
40 Ensure digest points to hashsize bytes of allocated memory. | 40 ** Ensure digest points to hashsize bytes of allocated memory. |
41 */ | 41 */ |
42 void | 42 void |
43 hmac_md5(unsigned char *text, int textlen, unsigned char *key, int keylen, unsigned char *digest) | 43 hmac_md5(unsigned char *text, int textlen, unsigned char *key, int keylen, |
44 unsigned char *digest) | |
44 { | 45 { |
45 int i; | 46 int i; |
46 MD5_CTX context; | 47 MD5_CTX context; |
47 unsigned char ipad[blocksize]; | 48 unsigned char ipad[blocksize]; |
48 unsigned char opad[blocksize]; | 49 unsigned char opad[blocksize]; |