mirror of
https://github.com/meshcore-dev/meshcore_py.git
synced 2026-04-20 22:13:49 +00:00
Add private key export support
- Add PRIVATE_KEY and DISABLED event types - Add packet parsing for private key export responses - Add export_private_key() method to DeviceCommands - Add comprehensive unit tests - Add BLE private key export example - Update documentation with security notes
This commit is contained in:
parent
c697c960a6
commit
e0f71482c6
6 changed files with 305 additions and 0 deletions
|
|
@ -569,6 +569,20 @@ class MessageReader:
|
|||
Event(EventType.PATH_RESPONSE, res, attributes)
|
||||
)
|
||||
|
||||
elif packet_type_value == PacketType.PRIVATE_KEY.value:
|
||||
logger.debug(f"Received private key response: {data.hex()}")
|
||||
if len(data) >= 65: # 1 byte response code + 64 bytes private key
|
||||
private_key = data[1:65] # Extract 64-byte private key
|
||||
res = {"private_key": private_key}
|
||||
await self.dispatcher.dispatch(Event(EventType.PRIVATE_KEY, res))
|
||||
else:
|
||||
logger.error(f"Invalid private key response length: {len(data)}")
|
||||
|
||||
elif packet_type_value == PacketType.DISABLED.value:
|
||||
logger.debug("Received disabled response")
|
||||
res = {"reason": "private_key_export_disabled"}
|
||||
await self.dispatcher.dispatch(Event(EventType.DISABLED, res))
|
||||
|
||||
else:
|
||||
logger.debug(f"Unhandled data received {data}")
|
||||
logger.debug(f"Unhandled packet type: {packet_type_value}")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue