From fcd50562767f67b86c4a122797747d82939551e5 Mon Sep 17 00:00:00 2001 From: bitfl0wer Date: Mon, 15 Apr 2024 14:45:27 +0200 Subject: [PATCH] remove tryfrom u32 for keyusage --- src/certs/capabilities/key_usage.rs | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/src/certs/capabilities/key_usage.rs b/src/certs/capabilities/key_usage.rs index 621769b..1b6fec2 100644 --- a/src/certs/capabilities/key_usage.rs +++ b/src/certs/capabilities/key_usage.rs @@ -57,34 +57,6 @@ pub enum KeyUsage { DecipherOnly, } -impl TryFrom for KeyUsage { - type Error = ConversionError; - - fn try_from(value: u32) -> Result { - if value > 256 { - return Err(ConversionError::InvalidInput(InvalidInput::Length { - min_length: 0, - max_length: 256, - actual_length: value.to_string(), - })); - } - match value { - x if x == KeyUsage::DigitalSignature as u32 => Ok(KeyUsage::DigitalSignature), - x if x == KeyUsage::ContentCommitment as u32 => Ok(KeyUsage::ContentCommitment), - x if x == KeyUsage::KeyEncipherment as u32 => Ok(KeyUsage::KeyEncipherment), - x if x == KeyUsage::DataEncipherment as u32 => Ok(KeyUsage::DataEncipherment), - x if x == KeyUsage::KeyAgreement as u32 => Ok(KeyUsage::KeyAgreement), - x if x == KeyUsage::KeyCertSign as u32 => Ok(KeyUsage::KeyCertSign), - x if x == KeyUsage::CrlSign as u32 => Ok(KeyUsage::CrlSign), - x if x == KeyUsage::EncipherOnly as u32 => Ok(KeyUsage::EncipherOnly), - x if x == KeyUsage::DecipherOnly as u32 => Ok(KeyUsage::DecipherOnly), - _ => Err(ConversionError::InvalidInput(InvalidInput::Malformed( - "Input cannot be matched to any of the KeyUsage variants".to_string(), - ))), - } - } -} - #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] /// The KeyUsages struct is a collection of KeyUsage variants. pub struct KeyUsages {