diff --git a/src/pkcs1v15/signature.rs b/src/pkcs1v15/signature.rs index 0d274d5..3200b0a 100644 --- a/src/pkcs1v15/signature.rs +++ b/src/pkcs1v15/signature.rs @@ -35,8 +35,12 @@ impl TryFrom<&[u8]> for Signature { fn try_from(bytes: &[u8]) -> signature::Result { let len = bytes.len(); - let inner = BoxedUint::from_be_slice(bytes, len as u32 * 8) + let inner = BoxedUint::from_be_slice(bytes, len as u32 * 8); + #[cfg(feature = "std")] + let inner = inner .map_err(|e| Box::new(e) as Box)?; + #[cfg(not(feature = "std"))] + let inner = inner.map_err(|_| signature::Error::new())?; Ok(Self { inner }) } diff --git a/src/pss/signature.rs b/src/pss/signature.rs index 5e986cd..a95ecfb 100644 --- a/src/pss/signature.rs +++ b/src/pss/signature.rs @@ -35,8 +35,13 @@ impl TryFrom<&[u8]> for Signature { fn try_from(bytes: &[u8]) -> signature::Result { let len = bytes.len(); - let inner = BoxedUint::from_be_slice(bytes, len as u32 * 8) + let inner = BoxedUint::from_be_slice(bytes, len as u32 * 8); + + #[cfg(feature = "std")] + let inner = inner .map_err(|e| Box::new(e) as Box)?; + #[cfg(not(feature = "std"))] + let inner = inner.map_err(|_| signature::Error::new())?; Ok(Self { inner }) }