[dependencies]
ring = { version = "0.17", default-features = false, features = ["alloc"], optional = true }
-bitcoin_hashes = { version = "0.13", default-features = false, optional = true }
+bitcoin_hashes = { version = "0.14", default-features = false, optional = true }
hex_lit = { version = "0.1", default-features = false, features = ["rust_v_1_46"], optional = true }
tokio_crate = { package = "tokio", version = "1.0", default-features = false, optional = true }
use bitcoin_hashes::HashEngine as _;
use bitcoin_hashes::sha1::Hash as Sha1;
use bitcoin_hashes::sha256::Hash as Sha256;
+use bitcoin_hashes::sha384::Hash as Sha384;
use bitcoin_hashes::sha512::Hash as Sha512;
pub(crate) enum Hasher {
Sha1(<Sha1 as Hash>::Engine),
Sha256(<Sha256 as Hash>::Engine),
+ Sha384(<Sha384 as Hash>::Engine),
#[allow(unused)]
Sha512(<Sha512 as Hash>::Engine),
}
pub(crate) enum HashResult {
Sha1(Sha1),
Sha256(Sha256),
+ Sha384(Sha384),
Sha512(Sha512),
}
match self {
HashResult::Sha1(hash) => hash.as_ref(),
HashResult::Sha256(hash) => hash.as_ref(),
+ HashResult::Sha384(hash) => hash.as_ref(),
HashResult::Sha512(hash) => hash.as_ref(),
}
}
impl Hasher {
pub(crate) fn sha1() -> Hasher { Hasher::Sha1(Sha1::engine()) }
pub(crate) fn sha256() -> Hasher { Hasher::Sha256(Sha256::engine()) }
+ pub(crate) fn sha384() -> Hasher { Hasher::Sha384(Sha384::engine()) }
#[allow(unused)]
pub(crate) fn sha512() -> Hasher { Hasher::Sha512(Sha512::engine()) }
match self {
Hasher::Sha1(hasher) => hasher.input(buf),
Hasher::Sha256(hasher) => hasher.input(buf),
+ Hasher::Sha384(hasher) => hasher.input(buf),
Hasher::Sha512(hasher) => hasher.input(buf),
}
}
match self {
Hasher::Sha1(hasher) => HashResult::Sha1(Sha1::from_engine(hasher)),
Hasher::Sha256(hasher) => HashResult::Sha256(Sha256::from_engine(hasher)),
+ Hasher::Sha384(hasher) => HashResult::Sha384(Sha384::from_engine(hasher)),
Hasher::Sha512(hasher) => HashResult::Sha512(Sha512::from_engine(hasher)),
}
}
let mut ctx = match ds.digest_type {
1 if trust_sha1 => crypto::hash::Hasher::sha1(),
2 => crypto::hash::Hasher::sha256(),
- // TODO: 4 => crypto::hash::Hasher::sha384(),
+ 4 => crypto::hash::Hasher::sha384(),
_ => continue,
};
write_name(&mut ctx, &dnskey.name);