#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Profile {
pub name: Option<&'static str>,
pub envelope_format: u32,
pub label: &'static str,
pub shard_prefix: &'static str,
pub claim_salt: &'static [u8],
pub dark_shard_label: &'static str,
}
impl Profile {
pub const WEIRDNET: Profile = Profile {
name: Some("weirdnet/keys/v1"),
envelope_format: 2,
label: "weirdnet/keys/v1",
shard_prefix: "weirdnet-shard-v1",
claim_salt: b"weirdnet/keys/v1/shard-claim",
dark_shard_label: "weirdnet/keys/v1/dark-shard",
};
pub fn service_info(&self, version: u32) -> String {
format!("{}/service/v{version}", self.label)
}
pub fn kek_info(&self) -> String {
format!("{}/kek", self.label)
}
pub fn dek_aad(&self) -> Vec<u8> {
format!("{}/dek", self.label).into_bytes()
}
pub fn service_key_aad(&self, db_id: &str, version: u32) -> Vec<u8> {
format!("{}/service-key/{db_id}/v{version}", self.label).into_bytes()
}
pub fn dark_shard_aad(&self, set: &str, index: u32) -> Vec<u8> {
format!("{}|{set}|{index}", self.dark_shard_label).into_bytes()
}
}
impl Default for Profile {
fn default() -> Self {
Profile::WEIRDNET
}
}