1// Copyright 2017 The Fuchsia Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#include <stdio.h> 6#include <string.h> 7 8#include "device_id.h" 9#include "eff_short_wordlist_1.h" 10 11#define APPEND_WORD(NUM, SEP) \ 12 word = dictionary[(NUM) % DICEWARE_DICTIONARY_SIZE]; \ 13 memcpy(dest, word, strlen(word)); \ 14 dest += strlen(word); \ 15 *dest = SEP; \ 16 dest++; 17 18void device_id_get(unsigned char mac[6], char out[DEVICE_ID_MAX]) { 19 const char* word; 20 char* dest = out; 21 APPEND_WORD(mac[0] | ((mac[4] << 8) & 0xF00), '-'); 22 APPEND_WORD(mac[1] | ((mac[5] << 8) & 0xF00), '-'); 23 APPEND_WORD(mac[2] | ((mac[4] << 4) & 0xF00), '-'); 24 APPEND_WORD(mac[3] | ((mac[5] << 4) & 0xF00), 0); 25} 26