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.
Dependencies: EthernetInterface NTPClient iothub_amqp_transport iothub_client mbed-rtos mbed
Fork of iothub_client_sample_amqp by
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 <stdlib.h> 00005 #ifdef _CRTDBG_MAP_ALLOC 00006 #include <crtdbg.h> 00007 #endif 00008 #include "azure_c_shared_utility/gballoc.h" 00009 00010 #include "azure_c_shared_utility/hmacsha256.h" 00011 #include "azure_c_shared_utility/hmac.h" 00012 #include "azure_c_shared_utility/strings.h" 00013 00014 HMACSHA256_RESULT HMACSHA256_ComputeHash(const unsigned char* key, size_t keyLen, const unsigned char* payload, size_t payloadLen, BUFFER_HANDLE hash) 00015 { 00016 HMACSHA256_RESULT result; 00017 00018 if (key == NULL || 00019 keyLen == 0 || 00020 payload == NULL || 00021 payloadLen == 0 || 00022 hash == NULL) 00023 { 00024 result = HMACSHA256_INVALID_ARG; 00025 } 00026 else 00027 { 00028 if ((BUFFER_enlarge(hash, 32) != 0) || 00029 (hmac(SHA256, payload, (int)payloadLen, key, (int)keyLen, BUFFER_u_char(hash) ) != 0)) 00030 { 00031 result = HMACSHA256_ERROR; 00032 } 00033 else 00034 { 00035 result = HMACSHA256_OK; 00036 } 00037 } 00038 00039 return result; 00040 }
Generated on Tue Jul 12 2022 12:43:19 by
