1 // SPDX-License-Identifier: BSD-2-Clause 2 /* 3 * Copyright (c) 2016, Linaro Limited 4 * All rights reserved. 5 */ 6 7 #include <string.h> 8 #include <tee/uuid.h> 9 #include <util.h> 10 11 void tee_uuid_to_octets(uint8_t *d, const TEE_UUID *s) 12 { 13 d[0] = s->timeLow >> 24; 14 d[1] = s->timeLow >> 16; 15 d[2] = s->timeLow >> 8; 16 d[3] = s->timeLow; 17 d[4] = s->timeMid >> 8; 18 d[5] = s->timeMid; 19 d[6] = s->timeHiAndVersion >> 8; 20 d[7] = s->timeHiAndVersion; 21 memcpy(d + 8, s->clockSeqAndNode, sizeof(s->clockSeqAndNode)); 22 } 23 24 void tee_uuid_from_octets(TEE_UUID *d, const uint8_t *s) 25 { 26 d->timeLow = SHIFT_U32(s[0], 24) | SHIFT_U32(s[1], 16) | 27 SHIFT_U32(s[2], 8) | s[3]; 28 d->timeMid = SHIFT_U32(s[4], 8) | s[5]; 29 d->timeHiAndVersion = SHIFT_U32(s[6], 8) | s[7]; 30 memcpy(d->clockSeqAndNode, s + 8, sizeof(d->clockSeqAndNode)); 31 } 32