4 years agoMerge pull request #13 from jpetso/build_ci
Jakob Petsovits [Mon, 18 Jan 2016 18:04:14 +0000 (13:04 -0500)]
Merge pull request #13 from jpetso/build_ci

Build with Travis CI.

4 years agoBuild with Travis CI. 13/head
Jakob Petsovits [Sun, 17 Jan 2016 23:58:14 +0000 (18:58 -0500)]
Build with Travis CI.

Fixes #9

4 years agoFix buffer overflow for null-terminated padded strings.
Jakob Petsovits [Mon, 18 Jan 2016 17:55:14 +0000 (12:55 -0500)]
Fix buffer overflow for null-terminated padded strings.

4 years agoRemove some items from TODO.md that I've added as GitHub issues.
Jakob Petsovits [Sun, 17 Jan 2016 18:47:10 +0000 (13:47 -0500)]
Remove some items from TODO.md that I've added as GitHub issues.

4 years agoAdd tests for hex codecs, and a few extra tests for base64.
Jakob Petsovits [Sat, 16 Jan 2016 22:30:51 +0000 (17:30 -0500)]
Add tests for hex codecs, and a few extra tests for base64.

Fixes #2

4 years agoAlso add case insensitivity test for base32_rfc4648.
Jakob Petsovits [Sat, 16 Jan 2016 22:01:42 +0000 (17:01 -0500)]
Also add case insensitivity test for base32_rfc4648.

4 years agoAdd tests for base32_rfc4648.
Jakob Petsovits [Sat, 16 Jan 2016 21:52:04 +0000 (16:52 -0500)]
Add tests for base32_rfc4648.

Fixes #1

4 years agoRefactoring: Move codec variants into their respective includes.
Jakob Petsovits [Sat, 16 Jan 2016 20:31:18 +0000 (15:31 -0500)]
Refactoring: Move codec variants into their respective includes.

Two advantages here:
1. No need to parse unused code when including only one variant.
2. Might make it easier for people to add new codec variants.

4 years agoDon't name an unused parameter. Avoids a VC14 compiler warning.
Jakob Petsovits [Fri, 15 Jan 2016 20:24:55 +0000 (15:24 -0500)]
Don't name an unused parameter. Avoids a VC14 compiler warning.

Fixes #6

4 years agoClang doesn't like non-lvalue ostringstreams. Fix that build error.
Jakob Petsovits [Thu, 14 Jan 2016 23:26:54 +0000 (18:26 -0500)]
Clang doesn't like non-lvalue ostringstreams. Fix that build error.

4 years agoIgnore Crockford base32 dashes as specified.
Jakob Petsovits [Thu, 14 Jan 2016 23:21:57 +0000 (18:21 -0500)]
Ignore Crockford base32 dashes as specified.

4 years agoIn README.md, mention exceptions for all overloads.
Jakob Petsovits [Mon, 4 Jan 2016 21:30:23 +0000 (16:30 -0500)]
In README.md, mention exceptions for all overloads.

Also tune some wordings a bit.

4 years agoUse -Wall -pedantic to make sure we'll work well within other projects.
Jakob Petsovits [Mon, 4 Jan 2016 21:21:40 +0000 (16:21 -0500)]
Use -Wall -pedantic to make sure we'll work well within other projects.

4 years agoPut base32 bit operations inside parentheses. Avoids some warnings.
Jakob Petsovits [Mon, 4 Jan 2016 21:10:00 +0000 (16:10 -0500)]
Put base32 bit operations inside parentheses. Avoids some warnings.

4 years agoAdd .gitignore.
Jakob Petsovits [Mon, 4 Jan 2016 18:08:11 +0000 (13:08 -0500)]
Add .gitignore.

4 years agoUpdate TODO and README to reflect the current feature status.
Jakob Petsovits [Mon, 28 Dec 2015 00:39:44 +0000 (19:39 -0500)]
Update TODO and README to reflect the current feature status.

4 years agoFix API documentation: default decoded type is std::vector<uint8_t>.
Jakob Petsovits [Mon, 28 Dec 2015 00:29:03 +0000 (19:29 -0500)]
Fix API documentation: default decoded type is std::vector<uint8_t>.

4 years agoAdd base64url tests, and adapt base64 tests to also use "/".
Jakob Petsovits [Mon, 28 Dec 2015 00:21:51 +0000 (19:21 -0500)]
Add base64url tests, and adapt base64 tests to also use "/".

4 years agoTest for some error conditions & refine exception types.
Jakob Petsovits [Sun, 27 Dec 2015 23:53:42 +0000 (18:53 -0500)]
Test for some error conditions & refine exception types.

4 years agoAdd tests for standard base64.
Jakob Petsovits [Sun, 27 Dec 2015 22:17:01 +0000 (17:17 -0500)]
Add tests for standard base64.

4 years agoAdd test framework and a set of tests for base32_crockford.
Jakob Petsovits [Sun, 27 Dec 2015 21:19:16 +0000 (16:19 -0500)]
Add test framework and a set of tests for base32_crockford.

4 years agoFix decoded_max_size() for unpadded stream codecs.
Jakob Petsovits [Sun, 27 Dec 2015 21:14:48 +0000 (16:14 -0500)]
Fix decoded_max_size() for unpadded stream codecs.

The previous version produced sizes that are too big in some cases.
The new version always yields the exact size for cases when the
input data contains only non-whitespace symbols.

4 years agoIn encode(), don't decrease src_end unless a full block is present.
Jakob Petsovits [Sun, 27 Dec 2015 21:11:14 +0000 (16:11 -0500)]
In encode(), don't decrease src_end unless a full block is present.

This prevents us from running into overflow issues when
src_size == 0 and src == 0x0.

4 years agoFix templates/accessors to make all overloads work.
Jakob Petsovits [Sun, 27 Dec 2015 17:36:44 +0000 (12:36 -0500)]
Fix templates/accessors to make all overloads work.

4 years agoAdd TODO item about improving the command line tools.
Jakob Petsovits [Thu, 24 Dec 2015 08:50:24 +0000 (03:50 -0500)]
Add TODO item about improving the command line tools.

4 years agoMake the Hello World example from README.md actually work.
Jakob Petsovits [Thu, 24 Dec 2015 08:20:05 +0000 (03:20 -0500)]
Make the Hello World example from README.md actually work.

Since it passes a string literal (a.k.a. constexpr char array),
we have to make sure to support that for size() and char_data().

Along the way I picked up another piece of template magic too,
to make put() not fail in one instance. As a nice side effect,
this allows us to get rid of the function_traits file.
I'm still only beginning to understand how it could possibly work,
but it seems to be more robust than the previous one.

4 years agoRename non_char_array to non_char_ptr.
Jakob Petsovits [Thu, 24 Dec 2015 08:16:59 +0000 (03:16 -0500)]
Rename non_char_array to non_char_ptr.

That's what it really is, and that's what out SFINAE is
protecting against to avoid the wrong overload from being called.

We're actually sort of fine with actual char arrays.
See next commit.

4 years agoFix decode_tail() logic for base32 and base64.
Jakob Petsovits [Thu, 24 Dec 2015 08:10:54 +0000 (03:10 -0500)]
Fix decode_tail() logic for base32 and base64.

Now, we'll rightfully complain and output the right data if
someone gives us an incorrect number of symbols in the last,
incomplete block.

It also looks much nicer this way.

4 years agoSwitch from `unsigned char` to `uint8_t` everywhere.
Jakob Petsovits [Thu, 24 Dec 2015 04:02:25 +0000 (23:02 -0500)]
Switch from `unsigned char` to `uint8_t` everywhere.

It's shorter, more expressive, better specified, and otherwise
defined to unsigned char on all platforms I'm aware of.

4 years agoRemove unnecessary includes.
Jakob Petsovits [Thu, 24 Dec 2015 03:50:21 +0000 (22:50 -0500)]
Remove unnecessary includes.

4 years agoAdd a TODO file until we're on GitHub and I can switch to issues.
Jakob Petsovits [Thu, 24 Dec 2015 03:42:29 +0000 (22:42 -0500)]
Add a TODO file until we're on GitHub and I can switch to issues.

4 years agoImplement hex via stream_codec, i.e. decode "0F" but not "F".
Jakob Petsovits [Thu, 24 Dec 2015 03:37:37 +0000 (22:37 -0500)]
Implement hex via stream_codec, i.e. decode "0F" but not "F".

4 years agoRefine base32 accepted characters, rename crockstr to crockford.
Jakob Petsovits [Thu, 24 Dec 2015 02:53:25 +0000 (21:53 -0500)]
Refine base32 accepted characters, rename crockstr to crockford.

For naming, I decided to let place-based single number codecs
have the original octet-streaming name plus "_num" appended.
Because they're an edge case, they'll perform worse, and they
people shouldn't be encouraged to use them. A slightly
inconvenient suffix will do that and make the rest of the names
easier to read and come up with.

As for accepted characters, Crockford base32 was missing special
treatment for 'OoIiLl' and RFC 4648 base32 was not accepting
lower-case characters, although it should. Both are now fixed.

README.txt got a bit of a rewrite for codec variants so all of
the codecs are now listed and with hopefully better explanations.

4 years agoActually implement the size_t return value as stated in README.md.
Jakob Petsovits [Wed, 23 Dec 2015 22:53:46 +0000 (17:53 -0500)]
Actually implement the size_t return value as stated in README.md.

This also shows that some encode()/decode() overloads have not
been exercised yet. Need to add testing soon.

4 years agoAdd base64 codec with variants base64_rfc4648 and base64_url.
Jakob Petsovits [Wed, 23 Dec 2015 22:38:11 +0000 (17:38 -0500)]
Add base64 codec with variants base64_rfc4648 and base64_url.

4 years agoReadability: Only access a single variable after block processing.
Jakob Petsovits [Wed, 23 Dec 2015 22:30:34 +0000 (17:30 -0500)]
Readability: Only access a single variable after block processing.

It behaves the same way, but if you only have to deal with a
single variable then that's less confusing.

4 years agoMake index lookups and alphabet arrays safer.
Jakob Petsovits [Wed, 23 Dec 2015 22:27:51 +0000 (17:27 -0500)]
Make index lookups and alphabet arrays safer.

4 years agoFix header guard name (was ...BASE4648 instead of ...RFC4648).
Jakob Petsovits [Wed, 23 Dec 2015 22:26:47 +0000 (17:26 -0500)]
Fix header guard name (was ...BASE4648 instead of ...RFC4648).

4 years agoWrite the print output lines a bit more compactly.
Jakob Petsovits [Wed, 23 Dec 2015 22:26:11 +0000 (17:26 -0500)]
Write the print output lines a bit more compactly.

4 years agoFactor out the codec framework into a stream_codec class.
Jakob Petsovits [Wed, 23 Dec 2015 19:33:36 +0000 (14:33 -0500)]
Factor out the codec framework into a stream_codec class.

This way, the actual codec only has to provide codec variants
plus the {encode,decode}_{block,tail}() and pad() functions.
Encoded/decoded sizes and loops are implemented based on
the codec's binary and encoded block sizes.

This should make it very easy to support other stream codecs
as well, base64 being the obvious example.

4 years agoAdd standard base32 from RFC 4648, introducing base32 variants.
Jakob Petsovits [Wed, 23 Dec 2015 08:12:14 +0000 (03:12 -0500)]
Add standard base32 from RFC 4648, introducing base32 variants.

We now handle (via templates) alphabets including padding and
ignored whitespace characters, as well as a variant option to
generate/require padding characters. Left-padding variants
(a.k.a. place-based single number encoding systems) are still
not supported at this time.

Sharing virtually the entire encoding/decoding logic between the
base32 variants greatly increases confidence that Crockford base32
(concatenative iterative stream interpretation) might actually
be correct. Plus it matches agnoster/base32-js on GitHub. Yay.

4 years agoAlso accept decoded sizes smaller than the max size, not only equal.
Jakob Petsovits [Wed, 23 Dec 2015 07:46:28 +0000 (02:46 -0500)]
Also accept decoded sizes smaller than the max size, not only equal.

4 years agoInitial commit of cppcodec.
Jakob Petsovits [Tue, 22 Dec 2015 19:46:50 +0000 (14:46 -0500)]
Initial commit of cppcodec.

It's starting out with a README.md that contains a pretty
comprehensive documentation of the API and design choices,
plus a first crack at implementing Crockford base32 within
that framework.

The base32 implementation might be incorrect and will have to
be verified/tested, however it exercises all the infrastructure
to go from app to (templated) interface to codec. So adding more
codecs should be fairly straightforward without too much effort.