diff --git a/src/amd/common/ac_surface_modifier_test.c b/src/amd/common/ac_surface_modifier_test.c index 3b4b4379fa3..8f18233669d 100644 --- a/src/amd/common/ac_surface_modifier_test.c +++ b/src/amd/common/ac_surface_modifier_test.c @@ -31,17 +31,17 @@ struct test_entry { enum pipe_format format; /* debug info */ - const char *name; uint8_t pipes; uint8_t rb; uint8_t banks_or_pkrs; uint8_t se; + const char *name; /* value to determine uniqueness */ unsigned char hash[SHA1_DIGEST_LENGTH]; /* u_vector requires power of two sizing */ - char padding[sizeof(void*) == 8 ? 8 : 16]; + char padding[sizeof(void*) == 8 ? 0 : 4]; }; static uint64_t diff --git a/src/util/sha1/sha1.c b/src/util/sha1/sha1.c index ed043fe39de..10db80a2375 100644 --- a/src/util/sha1/sha1.c +++ b/src/util/sha1/sha1.c @@ -169,9 +169,14 @@ SHA1Final(uint8_t digest[SHA1_DIGEST_LENGTH], SHA1_CTX *context) uint32_t i; SHA1Pad(context); - for (i = 0; i < SHA1_DIGEST_LENGTH; i++) { + for (i = 0; i < SHA1_DIGEST_LENGTH_INTERNAL; i++) { digest[i] = (uint8_t) ((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255); } + + /* Fill the rest of the hash with zeros. */ + memset(digest + SHA1_DIGEST_LENGTH_INTERNAL, 0, + SHA1_DIGEST_LENGTH - SHA1_DIGEST_LENGTH_INTERNAL); + memset(context, 0, sizeof(*context)); } diff --git a/src/util/sha1/sha1.h b/src/util/sha1/sha1.h index df534b508e4..3157a8acb1f 100644 --- a/src/util/sha1/sha1.h +++ b/src/util/sha1/sha1.h @@ -11,10 +11,12 @@ #include #include +#include "util/mesa-blake3.h" #define SHA1_BLOCK_LENGTH 64 -#define SHA1_DIGEST_LENGTH 20 -#define SHA1_DIGEST_STRING_LENGTH (SHA1_DIGEST_LENGTH * 2 + 1) +#define SHA1_DIGEST_LENGTH_INTERNAL 20 +#define SHA1_DIGEST_LENGTH BLAKE3_KEY_LEN +#define SHA1_DIGEST_STRING_LENGTH BLAKE3_HEX_LEN #ifdef __cplusplus extern "C" { diff --git a/src/vulkan/runtime/vk_shader.c b/src/vulkan/runtime/vk_shader.c index 812d6496de1..80431a5c046 100644 --- a/src/vulkan/runtime/vk_shader.c +++ b/src/vulkan/runtime/vk_shader.c @@ -315,10 +315,9 @@ struct vk_shader_bin_header { uint32_t version; uint64_t size; uint8_t sha1[SHA1_DIGEST_LENGTH]; - uint32_t _pad; }; PRAGMA_DIAGNOSTIC_POP -static_assert(sizeof(struct vk_shader_bin_header) == 72, +static_assert(sizeof(struct vk_shader_bin_header) == 80, "This struct has no holes"); static void