Last change
on this file since 473 was 453, checked in by coas-nagasima, 4 years ago |
ファイルを追加
|
-
Property svn:eol-style
set to
native
-
Property svn:mime-type
set to
text/x-csrc;charset=UTF-8
|
File size:
981 bytes
|
Line | |
---|
1 | // Copyright (c) Microsoft. All rights reserved.
|
---|
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
---|
3 |
|
---|
4 | #include <stddef.h>
|
---|
5 | #include "azure_c_shared_utility/hmacsha256.h"
|
---|
6 | #include "azure_c_shared_utility/hmac.h"
|
---|
7 | #include "azure_c_shared_utility/buffer_.h"
|
---|
8 |
|
---|
9 | HMACSHA256_RESULT HMACSHA256_ComputeHash(const unsigned char* key, size_t keyLen, const unsigned char* payload, size_t payloadLen, BUFFER_HANDLE hash)
|
---|
10 | {
|
---|
11 | HMACSHA256_RESULT result;
|
---|
12 |
|
---|
13 | if (key == NULL ||
|
---|
14 | keyLen == 0 ||
|
---|
15 | payload == NULL ||
|
---|
16 | payloadLen == 0 ||
|
---|
17 | hash == NULL)
|
---|
18 | {
|
---|
19 | result = HMACSHA256_INVALID_ARG;
|
---|
20 | }
|
---|
21 | else
|
---|
22 | {
|
---|
23 | if ((BUFFER_enlarge(hash, 32) != 0) ||
|
---|
24 | (hmac(SHA256, payload, (int)payloadLen, key, (int)keyLen, BUFFER_u_char(hash) ) != 0))
|
---|
25 | {
|
---|
26 | result = HMACSHA256_ERROR;
|
---|
27 | }
|
---|
28 | else
|
---|
29 | {
|
---|
30 | result = HMACSHA256_OK;
|
---|
31 | }
|
---|
32 | }
|
---|
33 |
|
---|
34 | return result;
|
---|
35 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.