From fe250c32c331a08e35d19f7b509819cd981720d3 Mon Sep 17 00:00:00 2001 From: Toshit Chawda Date: Fri, 25 Oct 2024 22:44:40 -0700 Subject: [PATCH] sha512 -> sha256 --- server/src/handle/wisp/utils.rs | 6 +++--- simple-wisp-client/src/main.rs | 6 +++--- wisp/src/extensions/cert.rs | 16 ++++++++-------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/server/src/handle/wisp/utils.rs b/server/src/handle/wisp/utils.rs index b098cab..f763dda 100644 --- a/server/src/handle/wisp/utils.rs +++ b/server/src/handle/wisp/utils.rs @@ -1,7 +1,7 @@ use std::{path::PathBuf, sync::Arc}; use ed25519_dalek::{pkcs8::DecodePublicKey, VerifyingKey}; -use sha2::{Digest, Sha512}; +use sha2::{Digest, Sha256}; use wisp_mux::extensions::cert::VerifyKey; pub async fn get_certificates_from_paths(paths: Vec) -> anyhow::Result> { @@ -11,9 +11,9 @@ pub async fn get_certificates_from_paths(paths: Vec) -> anyhow::Result< let verifier = VerifyingKey::from_public_key_pem(&data)?; let binary_key = verifier.to_bytes(); - let mut hasher = Sha512::new(); + let mut hasher = Sha256::new(); hasher.update(binary_key); - let hash: [u8; 64] = hasher.finalize().into(); + let hash: [u8; 32] = hasher.finalize().into(); out.push(VerifyKey::new_ed25519(Arc::new(verifier), hash)); } Ok(out) diff --git a/simple-wisp-client/src/main.rs b/simple-wisp-client/src/main.rs index c03f86f..d89a0ab 100644 --- a/simple-wisp-client/src/main.rs +++ b/simple-wisp-client/src/main.rs @@ -11,7 +11,7 @@ use hyper::{ Request, Uri, }; use hyper_util::rt::TokioIo; -use sha2::{Digest, Sha512}; +use sha2::{Digest, Sha256}; use simple_moving_average::{SingleSumSMA, SMA}; use std::{ error::Error, @@ -113,9 +113,9 @@ async fn get_cert(path: PathBuf) -> Result + Sync + Send>, } @@ -76,7 +76,7 @@ impl VerifyKey { /// Create a new ED25519 verification key. pub fn new_ed25519( verifier: Arc + Sync + Send>, - hash: [u8; 64], + hash: [u8; 32], ) -> Self { Self { cert_type: SupportedCertificateTypes::Ed25519, @@ -91,14 +91,14 @@ impl VerifyKey { pub struct SigningKey { /// Certificate type of the keypair. pub cert_type: SupportedCertificateTypes, - /// SHA-512 hash of the public key. - pub hash: [u8; 64], + /// SHA-256 hash of the public key. + pub hash: [u8; 32], /// Signer. pub signer: Arc + Sync + Send>, } impl SigningKey { /// Create a new ED25519 signing key. - pub fn new_ed25519(signer: Arc + Sync + Send>, hash: [u8; 64]) -> Self { + pub fn new_ed25519(signer: Arc + Sync + Send>, hash: [u8; 32]) -> Self { Self { cert_type: SupportedCertificateTypes::Ed25519, hash, @@ -123,8 +123,8 @@ pub enum CertAuthProtocolExtension { Client { /// Chosen certificate type. cert_type: SupportedCertificateTypes, - /// Hash of public key. - hash: [u8; 64], + /// SHA-256 hash of public key. + hash: [u8; 32], /// Signature of challenge. signature: Bytes, },