wire_ctx: refactor to reduce duplication and UB
It was using misaligned pointers which causes undefined behavior, at least theoretically.
API change: data in wire_ctx_read() is now passed as void* instead of uint8_t*, and it zeroes the data on error.