Skip to content

Commit caf80cf

Browse files
committed
stating changes for hmac.c
1 parent 8ad6ecb commit caf80cf

1 file changed

Lines changed: 40 additions & 4 deletions

File tree

src/hmac.c

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,39 @@
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+
137
// HMAC_SHA1 implementation
238
//
339
// Copyright 2010 Google Inc.
@@ -16,10 +52,10 @@
1652
// limitations under the License.
1753

1854
#include <string.h>
55+
#include <strings.h>
1956

2057
#include "hmac.h"
2158
#include "sha1.h"
22-
#include "util.h"
2359

2460
void hmac_sha1(const uint8_t *key, int keyLength,
2561
const uint8_t *data, int dataLength,
@@ -74,7 +110,7 @@ void hmac_sha1(const uint8_t *key, int keyLength,
74110
memcpy(result, sha, resultLength);
75111

76112
// 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));
80116
}

0 commit comments

Comments
 (0)