-
Notifications
You must be signed in to change notification settings - Fork 715
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
digest/hmac: Clarify error handling.
Computing an HMAC can only fail if the input is too long. The other `FinishError` condition, where we failed to meet the precondition for `BlockContext::try_finish()`, is obviously, using information local to the function, unreachable. Similarly, when there is only a single slice of bytes as input, then the `InputTooLongError` should be the `usize` type, not `u64`. The case where the u64 -> usize condition fails is not interesting, so we use a saturating conversion instead of giving ourselves the future work of proving that it is unreachable. Finally, remove the `From<FinishError> for error::Unspecified` implementation, in favor of `error::erase`, following the new convention.
- Loading branch information
1 parent
826598e
commit fa0c22b
Showing
2 changed files
with
58 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters