lib: add base64 decoder

Hardware / Coreboot - Vadim Bendebury [chromium.org] - 22 April 2015 01:50 UTC

It became necessary to decode base64 data retrieved from VPD and convert it into binary for inclusion in the device tree.

The patch introduces the decoder function based on the description found in http://en.wikipedia.org/wiki/Base64.

An open source implementation from http://base64.sourceforge.net was considered, in the end the only thing borrowed from it is the table to translate base64 ascii characters into numbers in 0..63 range.

BRANCH=none BUG=chromium:450169

TEST=created a test harness generating random contents of random size (in 8 to 32766 bytes range), then converting the contents into base64 using the Linux utility, and then converting it back to binary using this function and comparing the results.

It succeeded 1700 iterations before it was stopped.

Change-Id: I502f2c9494c99ba95ece37a7220c0c70c4755be2

243c614 lib: add base64 decoder
src/include/b64_decode.h | 35 +++++++++++
src/lib/Makefile.inc | 1 +
src/lib/b64_decode.c | 146 ++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 182 insertions(+)

Upstream: review.coreboot.org


  • Share