-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add Debug and Error impls for block-modes error types. fixes #44
- Loading branch information
Showing
5 changed files
with
45 additions
and
12 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use core::fmt; | ||
#[cfg(feature = "std")] | ||
use std::error; | ||
|
||
/// Block mode error. | ||
#[derive(Clone, Copy, Debug)] | ||
pub struct BlockModeError; | ||
|
||
/// Invalid key or IV length error. | ||
#[derive(Clone, Copy, Debug)] | ||
pub struct InvalidKeyIvLength; | ||
|
||
impl fmt::Display for BlockModeError { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { | ||
f.write_str("BlockModeError") | ||
} | ||
} | ||
|
||
#[cfg(feature = "std")] | ||
impl error::Error for BlockModeError { | ||
fn description(&self) -> &str { | ||
"block mode error" | ||
} | ||
} | ||
|
||
impl fmt::Display for InvalidKeyIvLength { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { | ||
f.write_str("InvalidKeyIvLength") | ||
} | ||
} | ||
|
||
#[cfg(feature = "std")] | ||
impl error::Error for InvalidKeyIvLength { | ||
fn description(&self) -> &str { | ||
"invalid key or IV length during block cipher mode initialization" | ||
} | ||
} |
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