Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: STM32F746_iothub_client_sample_mqtt f767zi_mqtt iothub_client_sample_amqp iothub_client_sample_http ... more
hmacsha256.c
00001 // Copyright (c) Microsoft. All rights reserved. 00002 // Licensed under the MIT license. See LICENSE file in the project root for full license information. 00003 00004 #include <stddef.h> 00005 #include "azure_c_shared_utility/hmacsha256.h" 00006 #include "azure_c_shared_utility/hmac.h" 00007 #include "azure_c_shared_utility/buffer_.h" 00008 00009 HMACSHA256_RESULT HMACSHA256_ComputeHash(const unsigned char* key, size_t keyLen, const unsigned char* payload, size_t payloadLen, BUFFER_HANDLE hash) 00010 { 00011 HMACSHA256_RESULT result; 00012 00013 if (key == NULL || 00014 keyLen == 0 || 00015 payload == NULL || 00016 payloadLen == 0 || 00017 hash == NULL) 00018 { 00019 result = HMACSHA256_INVALID_ARG; 00020 } 00021 else 00022 { 00023 if ((BUFFER_enlarge(hash, 32) != 0) || 00024 (hmac(SHA256, payload, (int)payloadLen, key, (int)keyLen, BUFFER_u_char(hash) ) != 0)) 00025 { 00026 result = HMACSHA256_ERROR; 00027 } 00028 else 00029 { 00030 result = HMACSHA256_OK; 00031 } 00032 } 00033 00034 return result; 00035 }
Generated on Wed Jul 13 2022 23:38:02 by
1.7.2
