diff options
| author | Caleb Connolly <[email protected]> | 2024-08-30 13:34:32 +0100 |
|---|---|---|
| committer | Heinrich Schuchardt <[email protected]> | 2024-09-12 17:35:37 +0200 |
| commit | 4c5e1ff31bf3d816412232ed7b4a2a581a50b262 (patch) | |
| tree | c0e74acd94291681619b32afaab0dbcadb1c9207 /include | |
| parent | 3cc3bc08f4669e5952e3dc649dcd13a19ca2a038 (diff) | |
lib: uuid: add UUID v5 support
Add support for generating version 5 UUIDs, these are determistic and work
by hashing a "namespace" UUID together with some unique data. One intended
usecase is to allow for dynamically generate payload UUIDs for UEFI
capsule updates, so that supported boards can have their own UUIDs
without needing to hardcode them.
In addition, move the common bit twiddling code from gen_ran_uuid into a
separate function and rewrite it not to use clrsetbits (which is not
available when building as part of host tools).
Tests for this are added in an upcoming patch.
Reviewed-by: Ilias Apalodimas <[email protected]>
Signed-off-by: Caleb Connolly <[email protected]>
Diffstat (limited to 'include')
| -rw-r--r-- | include/uuid.h | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/include/uuid.h b/include/uuid.h index f5a941250f4..1f4fa103b5e 100644 --- a/include/uuid.h +++ b/include/uuid.h @@ -11,6 +11,7 @@ #define __UUID_H__ #include <linux/bitops.h> +#include <linux/kconfig.h> /* * UUID - Universally Unique IDentifier - 128 bits unique number. @@ -46,8 +47,8 @@ * When converting to a binary UUID, le means the field should be converted * to little endian and be means it should be converted to big endian. * - * UUID is also used as GUID (Globally Unique Identifier) with the same binary - * format but it differs in string format like below. + * UUID is also used as GUID (Globally Unique Identifier) with the same format + * but with some fields stored in little endian. * * GUID: * 0 9 14 19 24 @@ -143,6 +144,18 @@ void gen_rand_uuid(unsigned char *uuid_bin); */ void gen_rand_uuid_str(char *uuid_str, int str_format); +struct efi_guid; + +/** + * gen_v5_guid() - generate little endian v5 GUID from namespace and other seed data. + * + * @namespace: pointer to UUID namespace salt + * @guid: pointer to allocated GUID output + * @...: NULL terminated list of seed data as pairs of pointers + * to data and their lengths + */ +void gen_v5_guid(const struct uuid *namespace, struct efi_guid *guid, ...); + /** * uuid_str_to_le_bin() - Convert string UUID to little endian binary data. * @uuid_str: pointer to UUID string |
