[IOT-2097][IOT-2098] Cleanup of base64 code 87/19187/13
authorGeorge Nash <george.nash@intel.com>
Fri, 21 Apr 2017 05:48:41 +0000 (22:48 -0700)
committerRick Bell <richard.s.bell@intel.com>
Mon, 19 Jun 2017 18:23:30 +0000 (18:23 +0000)
commit807bbea871f1c9a3c292fa3097faec35a7480eba
treeca2a9b132de289fb21ca59f1b3794a6281e298d5
parent1cbb91880618c40ce557672c9c98bd5cfe501b3e
[IOT-2097][IOT-2098] Cleanup of base64 code

[IOT-2097] According to RFC4648 Base64 can accept empty data.
Fixed error for input containing no data for b64Encode and
b64Decode.

[IOT-2098] Add error checking to b64Decode. The original code
would decode any string even if it contained characters that are
invalid for base 64 encoding. Code now checks that all
characters found in the encoded string are [A-Z][a-z][0-9]+/=

The padding character '=' is checked to only be at the end of
the encoded string.

Unit tests improved. They now include test vectors from RFC4648
Unit tests now cover failure cases. Not just pass cases.

Improved documentation
 - Add file documentation for base64.h file
 - Add reference to RFC4648.
 - Documented all B64Result enum values
 - Add [in],[out] markup for b64Encode function
 - Add code example for b64Encode function
 - Add [in],[out] markup for b64Decode function
 - Add code example for b64Decode function

Bug: https://jira.iotivity.org/browse/IOT-2097
Bug: https://jira.iotivity.org/browse/IOT-2098

Change-Id: I3d6167c85a766ae8200339f00ef5c978f0ec55b7
Signed-off-by: George Nash <george.nash@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/19187
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Phil Coval <philippe.coval@osg.samsung.com>
Reviewed-by: Pawel Winogrodzki <pawelwi@microsoft.com>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
Reviewed-by: Rick Bell <richard.s.bell@intel.com>
resource/csdk/security/include/base64.h
resource/csdk/security/src/base64.c
resource/csdk/security/unittest/base64tests.cpp