feat: v1.2.2, digest type
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "swift-secure-enclave-tool-rs"
|
name = "swift-secure-enclave-tool-rs"
|
||||||
version = "1.2.1"
|
version = "1.2.2"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
authors = ["Hatter Jiang"]
|
authors = ["Hatter Jiang"]
|
||||||
repository = "https://git.hatter.ink/hatter/swift-secure-enclave-tool-rs"
|
repository = "https://git.hatter.ink/hatter/swift-secure-enclave-tool-rs"
|
||||||
|
|||||||
21
src/lib.rs
21
src/lib.rs
@@ -40,7 +40,7 @@ pub enum DigestType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl DigestType {
|
impl DigestType {
|
||||||
fn to_str(&self) -> &'static str {
|
pub fn to_str(&self) -> &'static str {
|
||||||
match self {
|
match self {
|
||||||
DigestType::Raw => "raw",
|
DigestType::Raw => "raw",
|
||||||
DigestType::Sha256 => "sha256",
|
DigestType::Sha256 => "sha256",
|
||||||
@@ -48,6 +48,25 @@ impl DigestType {
|
|||||||
DigestType::Sha512 => "sha512",
|
DigestType::Sha512 => "sha512",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn bytes(&self) -> Option<u32> {
|
||||||
|
match self {
|
||||||
|
DigestType::Raw => None,
|
||||||
|
DigestType::Sha256 => Some(256 / 8),
|
||||||
|
DigestType::Sha384 => Some(384 / 8),
|
||||||
|
DigestType::Sha512 => Some(512 / 8),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn parse(t: Option<&str>) -> XResult<DigestType> {
|
||||||
|
Ok(match t {
|
||||||
|
None | Some("") | Some("raw") => DigestType::Raw,
|
||||||
|
Some("sha256") => DigestType::Sha256,
|
||||||
|
Some("sha384") => DigestType::Sha384,
|
||||||
|
Some("sha512") => DigestType::Sha512,
|
||||||
|
Some(other_digest_type) => return simple_error!("Invalid digest type: {}", other_digest_type),
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|||||||
Reference in New Issue
Block a user