Skip to content

Commit

Permalink
Add macro to set alignment of sha256 context (#28426)
Browse files Browse the repository at this point in the history
  • Loading branch information
wy-hh authored and pull[bot] committed Feb 26, 2024
1 parent e850f55 commit 5609592
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/crypto/CHIPCryptoPAL.h
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ CHIP_ERROR Hash_SHA1(const uint8_t * data, size_t data_length, uint8_t * out_buf
* All implementations must check for std::is_trivially_copyable.
**/

struct alignas(size_t) HashSHA256OpaqueContext
struct alignas(CHIP_CONFIG_SHA256_CONTEXT_ALIGN) HashSHA256OpaqueContext
{
uint8_t mOpaque[kMAX_Hash_SHA256_Context_Size];
};
Expand Down
9 changes: 9 additions & 0 deletions src/lib/core/CHIPConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,15 @@
#define CHIP_CONFIG_SHA256_CONTEXT_SIZE ((sizeof(unsigned int) * (8 + 2 + 16 + 2)) + sizeof(uint64_t))
#endif // CHIP_CONFIG_SHA256_CONTEXT_SIZE

/**
* @def CHIP_CONFIG_SHA256_CONTEXT_ALIGN
*
* @brief The alignment of SHA256 context buffer.
*/
#ifndef CHIP_CONFIG_SHA256_CONTEXT_ALIGN
#define CHIP_CONFIG_SHA256_CONTEXT_ALIGN size_t
#endif // CHIP_CONFIG_SHA256_CONTEXT_ALIGN

/**
* @def CHIP_CONFIG_MAX_UNSOLICITED_MESSAGE_HANDLERS
*
Expand Down

0 comments on commit 5609592

Please sign in to comment.