common: improve base64/32hex interface and error codes

Change-Id: I777d3986ac9197ec438b0b7c00b2098ba60d9437