blob: a71dbf96b87761144ce619fcb07e9613ae3127d0 [file] [log] [blame]
Mateusz Zalega612a0332021-11-17 20:04:52 +01001// Copyright 2020 The Monogon Project Authors.
2//
3// SPDX-License-Identifier: Apache-2.0
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
16
17package efivarfs
18
19import (
20 "github.com/google/uuid"
21)
22
23// MarshalEFIGUID returns src represented in the EFI GUID format, as defined in
24// UEFI specification, version 2.9, appendix A:
25// https://uefi.org/sites/default/files/resources/UEFI_Spec_2_9_2021_03_18.pdf
26func MarshalEFIGUID(src uuid.UUID) []byte {
27 efi := make([]byte, 16)
28 transform := []int{3, 2, 1, 0, 5, 4, 7, 6, 8, 9, 10, 11, 12, 13, 14, 15}
29 for dest, from := range transform {
30 efi[dest] = src[from]
31 }
32 return efi
33}