* Get a key based on hardware parameters. * @param[out] key the output key */
| 25 | * @param[out] key the output key |
| 26 | */ |
| 27 | static void get_hardware_key(uint8_t key[32]) { |
| 28 | uint8_t mac[8]; |
| 29 | // MAC can be 6 or 8 bytes |
| 30 | size_t mac_length = esp_mac_addr_len_get(ESP_MAC_EFUSE_FACTORY); |
| 31 | LOGGER.info("Using MAC with length {}", mac_length); |
| 32 | check(mac_length <= 8); |
| 33 | ESP_ERROR_CHECK(esp_read_mac(mac, ESP_MAC_EFUSE_FACTORY)); |
| 34 | |
| 35 | // Fill buffer with repeating MAC |
| 36 | for (size_t i = 0; i < 32; ++i) { |
| 37 | key[i] = mac[i % mac_length]; |
| 38 | } |
| 39 | } |
| 40 | #endif |
| 41 | |
| 42 | #ifdef ESP_PLATFORM |