Next major iteration on Cipher interface #23
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request represents the next iteration on the Cipher interface that I mentioned during the last meeting. It will require minor changes to all code that called the old cipher.Crypt method, to invoke the new cipher.Message or cipher.Partial methods instead. Partial is equivalent to the old cipher.Crypt(..., abstract.More{}), getting rid of the somewhat clunky use of variable-length options arguments to the workhorse message-processing methods.
The other significant API change is that the new Cipher interface no longer has a need for the "Direction" option-arguments (which was insufficient anyway as it didn't quite provide a proper stream-cipher mode of operation): instead, both the Message and Partial methods now take a third byte-slice argument, 'key', in which the caller explicitly specifies what - if any - input should be absorbed into the Cipher's state to key (or re-key) it for the next message (or hash/MAC output or whatever).
I've rewritten and greatly expanded the documentation for the Cipher interface, to include a bunch of examples of how to use it in various ways; please see that documentation for details on how to use it.
Currently some tests fail merely because the bits have changed in various test-cases; this will be fixed before merging this branch (and possibly after adding some more extensive Cipher tests; see the work-item I'll be posting shortly).