CH341 MAC address derivation from serial and product string (#9226)

Updated MAC address derivation logic to include product string in hashing.
This commit is contained in:
Jonathan Bennett
2026-01-09 05:42:00 -06:00
committed by GitHub
parent 489de09375
commit b12acba44f

View File

@@ -419,9 +419,11 @@ void portduinoSetup()
ch341Hal->getProductString(product_string, 95);
std::cout << "CH341 Product " << product_string << std::endl;
if (strlen(serial) == 8 && portduino_config.mac_address.length() < 12) {
uint8_t hash[32] = {0};
std::cout << "Deriving MAC address from Serial and Product String" << std::endl;
uint8_t hash[104] = {0};
memcpy(hash, serial, 8);
crypto->hash(hash, 8);
memcpy(hash + 8, product_string, strlen(product_string));
crypto->hash(hash, 8 + strlen(product_string));
dmac[0] = (hash[0] << 4) | 2;
dmac[1] = hash[1];
dmac[2] = hash[2];