|
| 1 | +/* |
| 2 | + * MIT License |
| 3 | + * |
| 4 | + * Copyright (c) 2018 Davidson Francis <davidsondfgl@gmail.com> |
| 5 | + * |
| 6 | + * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | + * of this software and associated documentation files (the "Software"), to deal |
| 8 | + * in the Software without restriction, including without limitation the rights |
| 9 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 10 | + * copies of the Software, and to permit persons to whom the Software is |
| 11 | + * furnished to do so, subject to the following conditions: |
| 12 | + * |
| 13 | + * The above copyright notice and this permission notice shall be included in all |
| 14 | + * copies or substantial portions of the Software. |
| 15 | + * |
| 16 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 22 | + * SOFTWARE. |
| 23 | + * |
| 24 | + * |
| 25 | + * |
| 26 | + * This file previously have made use of the function 'explicit_bzero', provided |
| 27 | + * from the file util.c/util.h in order to avoid GCC optimizations in the |
| 28 | + * function. |
| 29 | + * |
| 30 | + * Since util.c makes use of a header not present in the original project |
| 31 | + * (config.h), I've intentionally excluded the use of util.h and replaced the |
| 32 | + * function for the original 'bzero', present in the default C library. |
| 33 | + * |
| 34 | + * The previous authors terms are included below: |
| 35 | + */ |
| 36 | + |
1 | 37 | // HMAC_SHA1 implementation |
2 | 38 | // |
3 | 39 | // Copyright 2010 Google Inc. |
|
16 | 52 | // limitations under the License. |
17 | 53 |
|
18 | 54 | #include <string.h> |
| 55 | +#include <strings.h> |
19 | 56 |
|
20 | 57 | #include "hmac.h" |
21 | 58 | #include "sha1.h" |
22 | | -#include "util.h" |
23 | 59 |
|
24 | 60 | void hmac_sha1(const uint8_t *key, int keyLength, |
25 | 61 | const uint8_t *data, int dataLength, |
@@ -74,7 +110,7 @@ void hmac_sha1(const uint8_t *key, int keyLength, |
74 | 110 | memcpy(result, sha, resultLength); |
75 | 111 |
|
76 | 112 | // Zero out all internal data structures |
77 | | - explicit_bzero(hashed_key, sizeof(hashed_key)); |
78 | | - explicit_bzero(sha, sizeof(sha)); |
79 | | - explicit_bzero(tmp_key, sizeof(tmp_key)); |
| 113 | + bzero(hashed_key, sizeof(hashed_key)); |
| 114 | + bzero(sha, sizeof(sha)); |
| 115 | + bzero(tmp_key, sizeof(tmp_key)); |
80 | 116 | } |
0 commit comments