1#[derive(Debug, Clone, Copy, PartialEq, Eq)]
10pub struct Profile {
11 pub name: Option<&'static str>,
13 pub envelope_format: u32,
15 pub label: &'static str,
18 pub shard_prefix: &'static str,
20 pub claim_salt: &'static [u8],
22 pub dark_shard_label: &'static str,
24}
25
26impl Profile {
27 pub const WEIRDNET: Profile = Profile {
28 name: Some("weirdnet/keys/v1"),
29 envelope_format: 2,
30 label: "weirdnet/keys/v1",
31 shard_prefix: "weirdnet-shard-v1",
32 claim_salt: b"weirdnet/keys/v1/shard-claim",
33 dark_shard_label: "weirdnet/keys/v1/dark-shard",
34 };
35
36 pub fn service_info(&self, version: u32) -> String {
37 format!("{}/service/v{version}", self.label)
38 }
39 pub fn kek_info(&self) -> String {
40 format!("{}/kek", self.label)
41 }
42 pub fn dek_aad(&self) -> Vec<u8> {
43 format!("{}/dek", self.label).into_bytes()
44 }
45 pub fn service_key_aad(&self, db_id: &str, version: u32) -> Vec<u8> {
46 format!("{}/service-key/{db_id}/v{version}", self.label).into_bytes()
47 }
48 pub fn dark_shard_aad(&self, set: &str, index: u32) -> Vec<u8> {
49 format!("{}|{set}|{index}", self.dark_shard_label).into_bytes()
50 }
51}
52
53impl Default for Profile {
54 fn default() -> Self {
55 Profile::WEIRDNET
56 }
57}