From 59c36b0ebe46e613a23ba95bd642f39226f0a29b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodolphe=20Br=C3=A9ard?= Date: Sun, 25 Feb 2024 11:46:08 +0100 Subject: [PATCH] Rename the parsing errors using the module name --- src/error.rs | 8 ++++---- src/ikm.rs | 2 +- src/scheme.rs | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/error.rs b/src/error.rs index 7be3f39..ee413dd 100644 --- a/src/error.rs +++ b/src/error.rs @@ -10,14 +10,14 @@ pub enum Error { IkmNotFound(u32), #[error("parsing error: invalid base64-urlsafe-nopadding data: {0}")] ParsingBase64Error(base64ct::Error), - #[error("parsing error: invalid data length: {0} bytes")] - ParsingInvalidLength(usize), - #[error("parsing error: {0}: unknown scheme")] - ParsingUnknownScheme(u32), #[error("parsing error: encoded data: invalid IKM id: {0:?}")] ParsingEncodedDataInvalidIkmId(Vec), #[error("parsing error: encoded data: invalid number of parts: got {1} instead of {0}")] ParsingEncodedDataInvalidPartLen(usize, usize), + #[error("parsing error: ikm: invalid data length: {0} bytes")] + ParsingIkmInvalidLength(usize), + #[error("parsing error: scheme: {0}: unknown scheme")] + ParsingSchemeUnknownScheme(u32), #[error("unable to generate random values: {0}")] RandomSourceError(getrandom::Error), #[error("system time error: {0}")] diff --git a/src/ikm.rs b/src/ikm.rs index 1e24bc6..2ecd9ff 100644 --- a/src/ikm.rs +++ b/src/ikm.rs @@ -109,7 +109,7 @@ impl InputKeyMaterialList { pub fn import(s: &str) -> Result { let data = Base64UrlUnpadded::decode_vec(s)?; if data.len() % IKM_STRUCT_SIZE != 4 { - return Err(Error::ParsingInvalidLength(data.len())); + return Err(Error::ParsingIkmInvalidLength(data.len())); } let mut ikm_lst = Vec::with_capacity(data.len() / IKM_STRUCT_SIZE); for ikm_slice in data[4..].chunks_exact(IKM_STRUCT_SIZE) { diff --git a/src/scheme.rs b/src/scheme.rs index b541551..4afea4e 100644 --- a/src/scheme.rs +++ b/src/scheme.rs @@ -29,7 +29,7 @@ impl TryFrom for Scheme { fn try_from(value: u32) -> Result { match value { 1 => Ok(Scheme::XChaCha20Poly1305WithBlake3), - _ => Err(Error::ParsingUnknownScheme(value)), + _ => Err(Error::ParsingSchemeUnknownScheme(value)), } } }