device: refact. error handling
device trusted: Initial commit