Azure IoT common library
Dependents: STM32F746_iothub_client_sample_mqtt f767zi_mqtt iothub_client_sample_amqp iothub_client_sample_http ... more
hmacsha256.c
- Committer:
- AzureIoTClient
- Date:
- 2018-10-04
- Revision:
- 49:6bb8b9a66642
- Parent:
- 19:2e0811512ceb
File content as of revision 49:6bb8b9a66642:
// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. #include <stddef.h> #include "azure_c_shared_utility/hmacsha256.h" #include "azure_c_shared_utility/hmac.h" #include "azure_c_shared_utility/buffer_.h" HMACSHA256_RESULT HMACSHA256_ComputeHash(const unsigned char* key, size_t keyLen, const unsigned char* payload, size_t payloadLen, BUFFER_HANDLE hash) { HMACSHA256_RESULT result; if (key == NULL || keyLen == 0 || payload == NULL || payloadLen == 0 || hash == NULL) { result = HMACSHA256_INVALID_ARG; } else { if ((BUFFER_enlarge(hash, 32) != 0) || (hmac(SHA256, payload, (int)payloadLen, key, (int)keyLen, BUFFER_u_char(hash) ) != 0)) { result = HMACSHA256_ERROR; } else { result = HMACSHA256_OK; } } return result; }