update ring

This commit is contained in:
mii
2024-04-08 17:01:28 +09:00
parent f32dae2923
commit 7c69b4c124
2 changed files with 8 additions and 8 deletions

View File

@ -13,7 +13,7 @@ readme = "README.md"
edition = "2018" edition = "2018"
[dependencies] [dependencies]
ring = "0.16.15" ring = "0.17.8"
[package.metadata.release] [package.metadata.release]
sign-commit = true sign-commit = true

View File

@ -84,7 +84,7 @@ impl PublicKey {
/// Returns `None` if it couldn't parse the provided data /// Returns `None` if it couldn't parse the provided data
pub fn from_vec(vec: Vec<u8>, algorithm: &'static Algorithm) -> Option<PublicKey> { pub fn from_vec(vec: Vec<u8>, algorithm: &'static Algorithm) -> Option<PublicKey> {
let size = vec.len(); 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) { if size != (hash_output_size * hash_output_size * 8 * 2) {
return None; return None;
} }
@ -134,7 +134,7 @@ impl PublicKey {
/// Verifies that the signature of the data is correctly signed with the given key /// Verifies that the signature of the data is correctly signed with the given key
pub fn verify_signature(&self, signature: &[Vec<u8>], data: &[u8]) -> bool { pub fn verify_signature(&self, signature: &[Vec<u8>], data: &[u8]) -> bool {
if signature.len() != self.algorithm.output_len * 8 { if signature.len() != self.algorithm.output_len() * 8 {
return false; return false;
} }
@ -176,8 +176,8 @@ impl PrivateKey {
let generate_bit_hash_values = || -> Vec<Vec<u8>> { let generate_bit_hash_values = || -> Vec<Vec<u8>> {
let rng = SystemRandom::new(); let rng = SystemRandom::new();
let buffer_byte = vec![0u8; algorithm.output_len]; let buffer_byte = vec![0u8; algorithm.output_len()];
let mut buffer = vec![buffer_byte; algorithm.output_len * 8]; let mut buffer = vec![buffer_byte; algorithm.output_len() * 8];
for hash in &mut buffer { for hash in &mut buffer {
rng.fill(hash) rng.fill(hash)
@ -201,10 +201,10 @@ impl PrivateKey {
/// Returns the public key associated with this private key /// Returns the public key associated with this private key
pub fn public_key(&self) -> PublicKey { pub fn public_key(&self) -> PublicKey {
let hash_values = |x: &Vec<Vec<u8>>| -> Vec<Vec<u8>> { let hash_values = |x: &Vec<Vec<u8>>| -> Vec<Vec<u8>> {
let buffer_byte = vec![0u8; self.algorithm.output_len]; let buffer_byte = vec![0u8; self.algorithm.output_len()];
let mut buffer = vec![buffer_byte; self.algorithm.output_len * 8]; 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); let mut context = Context::new(self.algorithm);
context.update(x[i].as_slice()); context.update(x[i].as_slice());
buffer[i] = Vec::from(context.finish().as_ref()); buffer[i] = Vec::from(context.finish().as_ref());