mirror of
https://github.com/MercuryWorkshop/epoxy-tls.git
synced 2025-05-12 14:00:01 -04:00
sha512 -> sha256
This commit is contained in:
parent
1a8773f801
commit
fe250c32c3
3 changed files with 14 additions and 14 deletions
|
@ -1,7 +1,7 @@
|
||||||
use std::{path::PathBuf, sync::Arc};
|
use std::{path::PathBuf, sync::Arc};
|
||||||
|
|
||||||
use ed25519_dalek::{pkcs8::DecodePublicKey, VerifyingKey};
|
use ed25519_dalek::{pkcs8::DecodePublicKey, VerifyingKey};
|
||||||
use sha2::{Digest, Sha512};
|
use sha2::{Digest, Sha256};
|
||||||
use wisp_mux::extensions::cert::VerifyKey;
|
use wisp_mux::extensions::cert::VerifyKey;
|
||||||
|
|
||||||
pub async fn get_certificates_from_paths(paths: Vec<PathBuf>) -> anyhow::Result<Vec<VerifyKey>> {
|
pub async fn get_certificates_from_paths(paths: Vec<PathBuf>) -> anyhow::Result<Vec<VerifyKey>> {
|
||||||
|
@ -11,9 +11,9 @@ pub async fn get_certificates_from_paths(paths: Vec<PathBuf>) -> anyhow::Result<
|
||||||
let verifier = VerifyingKey::from_public_key_pem(&data)?;
|
let verifier = VerifyingKey::from_public_key_pem(&data)?;
|
||||||
let binary_key = verifier.to_bytes();
|
let binary_key = verifier.to_bytes();
|
||||||
|
|
||||||
let mut hasher = Sha512::new();
|
let mut hasher = Sha256::new();
|
||||||
hasher.update(binary_key);
|
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));
|
out.push(VerifyKey::new_ed25519(Arc::new(verifier), hash));
|
||||||
}
|
}
|
||||||
Ok(out)
|
Ok(out)
|
||||||
|
|
|
@ -11,7 +11,7 @@ use hyper::{
|
||||||
Request, Uri,
|
Request, Uri,
|
||||||
};
|
};
|
||||||
use hyper_util::rt::TokioIo;
|
use hyper_util::rt::TokioIo;
|
||||||
use sha2::{Digest, Sha512};
|
use sha2::{Digest, Sha256};
|
||||||
use simple_moving_average::{SingleSumSMA, SMA};
|
use simple_moving_average::{SingleSumSMA, SMA};
|
||||||
use std::{
|
use std::{
|
||||||
error::Error,
|
error::Error,
|
||||||
|
@ -113,9 +113,9 @@ async fn get_cert(path: PathBuf) -> Result<SigningKey, Box<dyn Error + Sync + Se
|
||||||
let signer = ed25519_dalek::SigningKey::from_pkcs8_pem(&data)?;
|
let signer = ed25519_dalek::SigningKey::from_pkcs8_pem(&data)?;
|
||||||
let binary_key = signer.verifying_key().to_bytes();
|
let binary_key = signer.verifying_key().to_bytes();
|
||||||
|
|
||||||
let mut hasher = Sha512::new();
|
let mut hasher = Sha256::new();
|
||||||
hasher.update(binary_key);
|
hasher.update(binary_key);
|
||||||
let hash: [u8; 64] = hasher.finalize().into();
|
let hash: [u8; 32] = hasher.finalize().into();
|
||||||
Ok(SigningKey::new_ed25519(Arc::new(signer), hash))
|
Ok(SigningKey::new_ed25519(Arc::new(signer), hash))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,8 +66,8 @@ bitflags::bitflags! {
|
||||||
pub struct VerifyKey {
|
pub struct VerifyKey {
|
||||||
/// Certificate type of the keypair.
|
/// Certificate type of the keypair.
|
||||||
pub cert_type: SupportedCertificateTypes,
|
pub cert_type: SupportedCertificateTypes,
|
||||||
/// SHA-512 hash of the public key.
|
/// SHA-256 hash of the public key.
|
||||||
pub hash: [u8; 64],
|
pub hash: [u8; 32],
|
||||||
/// Verifier.
|
/// Verifier.
|
||||||
pub verifier: Arc<dyn Verifier<Signature> + Sync + Send>,
|
pub verifier: Arc<dyn Verifier<Signature> + Sync + Send>,
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ impl VerifyKey {
|
||||||
/// Create a new ED25519 verification key.
|
/// Create a new ED25519 verification key.
|
||||||
pub fn new_ed25519(
|
pub fn new_ed25519(
|
||||||
verifier: Arc<dyn Verifier<Signature> + Sync + Send>,
|
verifier: Arc<dyn Verifier<Signature> + Sync + Send>,
|
||||||
hash: [u8; 64],
|
hash: [u8; 32],
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
cert_type: SupportedCertificateTypes::Ed25519,
|
cert_type: SupportedCertificateTypes::Ed25519,
|
||||||
|
@ -91,14 +91,14 @@ impl VerifyKey {
|
||||||
pub struct SigningKey {
|
pub struct SigningKey {
|
||||||
/// Certificate type of the keypair.
|
/// Certificate type of the keypair.
|
||||||
pub cert_type: SupportedCertificateTypes,
|
pub cert_type: SupportedCertificateTypes,
|
||||||
/// SHA-512 hash of the public key.
|
/// SHA-256 hash of the public key.
|
||||||
pub hash: [u8; 64],
|
pub hash: [u8; 32],
|
||||||
/// Signer.
|
/// Signer.
|
||||||
pub signer: Arc<dyn Signer<Signature> + Sync + Send>,
|
pub signer: Arc<dyn Signer<Signature> + Sync + Send>,
|
||||||
}
|
}
|
||||||
impl SigningKey {
|
impl SigningKey {
|
||||||
/// Create a new ED25519 signing key.
|
/// Create a new ED25519 signing key.
|
||||||
pub fn new_ed25519(signer: Arc<dyn Signer<Signature> + Sync + Send>, hash: [u8; 64]) -> Self {
|
pub fn new_ed25519(signer: Arc<dyn Signer<Signature> + Sync + Send>, hash: [u8; 32]) -> Self {
|
||||||
Self {
|
Self {
|
||||||
cert_type: SupportedCertificateTypes::Ed25519,
|
cert_type: SupportedCertificateTypes::Ed25519,
|
||||||
hash,
|
hash,
|
||||||
|
@ -123,8 +123,8 @@ pub enum CertAuthProtocolExtension {
|
||||||
Client {
|
Client {
|
||||||
/// Chosen certificate type.
|
/// Chosen certificate type.
|
||||||
cert_type: SupportedCertificateTypes,
|
cert_type: SupportedCertificateTypes,
|
||||||
/// Hash of public key.
|
/// SHA-256 hash of public key.
|
||||||
hash: [u8; 64],
|
hash: [u8; 32],
|
||||||
/// Signature of challenge.
|
/// Signature of challenge.
|
||||||
signature: Bytes,
|
signature: Bytes,
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue