Last change
on this file since 389 was 389, checked in by coas-nagasima, 5 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
|
Rev | Line | |
---|
[388] | 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.