mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-03-17 23:20:33 +01:00
util: increase SHA1_DIGEST_LENGTH to 32 (BLAKE3_KEY_LEN)
The last 12 bytes are always 0 for now. With this, all SHA1 functions can be internally implemented as BLAKE3, so that we can switch everything to BLAKE3 by only changing the implementation of the sha1 utility. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39110>
This commit is contained in:
parent
524a536b7b
commit
492a176cbb
4 changed files with 13 additions and 7 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,10 +11,12 @@
|
|||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#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" {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue