mirror of
https://github.com/zerotier/identity.git
synced 2026-05-22 16:29:03 -07:00
Add a 384-bit hash to V1 identity.
This commit is contained in:
+14
-1
@@ -20,7 +20,7 @@ use zerotier_common_utils::blob::Blob;
|
||||
use zerotier_common_utils::error::InvalidParameterError;
|
||||
use zerotier_common_utils::hex;
|
||||
use zerotier_common_utils::tofrombytes::ToFromBytes;
|
||||
use zerotier_crypto_glue::hash::SHA512;
|
||||
use zerotier_crypto_glue::hash::{SHA384, SHA512};
|
||||
use zerotier_crypto_glue::salsa::Salsa;
|
||||
use zerotier_crypto_glue::x25519::*;
|
||||
|
||||
@@ -175,6 +175,19 @@ impl Identity {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
/// Get a SHA384 hash of all this identity's elements but with the address overwriting the first 5 bytes.
|
||||
/// This is for use with CAMP and modern federated root backplanes that require all identity types to
|
||||
/// have a full length 384-bit address.
|
||||
pub fn address384(&self) -> [u8; 48] {
|
||||
let mut a384 = SHA384::new();
|
||||
a384.update(&self.address.0);
|
||||
a384.update(&self.ecdh);
|
||||
a384.update(&self.eddsa);
|
||||
let mut a384 = a384.finish();
|
||||
a384[..5].copy_from_slice(&self.address.0);
|
||||
a384
|
||||
}
|
||||
}
|
||||
|
||||
impl ToString for Identity {
|
||||
|
||||
Reference in New Issue
Block a user