From 7c69b4c124979cd453a0a2df72cee90ae3a45dd0 Mon Sep 17 00:00:00 2001 From: mii Date: Mon, 8 Apr 2024 17:01:28 +0900 Subject: [PATCH] update ring --- Cargo.toml | 2 +- src/lib.rs | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 43c66ef..d4b30de 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" edition = "2018" [dependencies] -ring = "0.16.15" +ring = "0.17.8" [package.metadata.release] sign-commit = true diff --git a/src/lib.rs b/src/lib.rs index e127194..6668630 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -84,7 +84,7 @@ impl PublicKey { /// Returns `None` if it couldn't parse the provided data pub fn from_vec(vec: Vec, algorithm: &'static Algorithm) -> Option { let size = vec.len(); - let hash_output_size = algorithm.output_len; + let hash_output_size = algorithm.output_len(); if size != (hash_output_size * hash_output_size * 8 * 2) { return None; } @@ -134,7 +134,7 @@ impl PublicKey { /// Verifies that the signature of the data is correctly signed with the given key pub fn verify_signature(&self, signature: &[Vec], data: &[u8]) -> bool { - if signature.len() != self.algorithm.output_len * 8 { + if signature.len() != self.algorithm.output_len() * 8 { return false; } @@ -176,8 +176,8 @@ impl PrivateKey { let generate_bit_hash_values = || -> Vec> { let rng = SystemRandom::new(); - let buffer_byte = vec![0u8; algorithm.output_len]; - let mut buffer = vec![buffer_byte; algorithm.output_len * 8]; + let buffer_byte = vec![0u8; algorithm.output_len()]; + let mut buffer = vec![buffer_byte; algorithm.output_len() * 8]; for hash in &mut buffer { rng.fill(hash) @@ -201,10 +201,10 @@ impl PrivateKey { /// Returns the public key associated with this private key pub fn public_key(&self) -> PublicKey { let hash_values = |x: &Vec>| -> Vec> { - let buffer_byte = vec![0u8; self.algorithm.output_len]; - let mut buffer = vec![buffer_byte; self.algorithm.output_len * 8]; + let buffer_byte = vec![0u8; self.algorithm.output_len()]; + let mut buffer = vec![buffer_byte; self.algorithm.output_len() * 8]; - for i in 0..self.algorithm.output_len * 8 { + for i in 0..self.algorithm.output_len() * 8 { let mut context = Context::new(self.algorithm); context.update(x[i].as_slice()); buffer[i] = Vec::from(context.finish().as_ref());