mirror of
https://github.com/bitwarden/server.git
synced 2025-12-10 00:42:07 -06:00
Add config struct for AKD config
This commit is contained in:
parent
72fd4956ba
commit
895e720e58
33
.vscode/tasks.json
vendored
33
.vscode/tasks.json
vendored
@ -89,6 +89,9 @@
|
||||
"/property:GenerateFullPaths=true",
|
||||
"/consoleloggerparameters:NoSummary"
|
||||
],
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
{
|
||||
@ -102,6 +105,9 @@
|
||||
"/property:GenerateFullPaths=true",
|
||||
"/consoleloggerparameters:NoSummary"
|
||||
],
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
{
|
||||
@ -115,6 +121,9 @@
|
||||
"/property:GenerateFullPaths=true",
|
||||
"/consoleloggerparameters:NoSummary"
|
||||
],
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
{
|
||||
@ -128,6 +137,9 @@
|
||||
"/property:GenerateFullPaths=true",
|
||||
"/consoleloggerparameters:NoSummary"
|
||||
],
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
{
|
||||
@ -141,6 +153,9 @@
|
||||
"/property:GenerateFullPaths=true",
|
||||
"/consoleloggerparameters:NoSummary"
|
||||
],
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
{
|
||||
@ -154,6 +169,9 @@
|
||||
"/property:GenerateFullPaths=true",
|
||||
"/consoleloggerparameters:NoSummary"
|
||||
],
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
{
|
||||
@ -167,6 +185,9 @@
|
||||
"/property:GenerateFullPaths=true",
|
||||
"/consoleloggerparameters:NoSummary"
|
||||
],
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
{
|
||||
@ -180,6 +201,9 @@
|
||||
"/property:GenerateFullPaths=true",
|
||||
"/consoleloggerparameters:NoSummary"
|
||||
],
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
"problemMatcher": "$msCompile",
|
||||
"group": {
|
||||
"kind": "build",
|
||||
@ -197,6 +221,9 @@
|
||||
"/property:GenerateFullPaths=true",
|
||||
"/consoleloggerparameters:NoSummary"
|
||||
],
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
"problemMatcher": "$msCompile",
|
||||
"group": {
|
||||
"kind": "build",
|
||||
@ -214,6 +241,9 @@
|
||||
"/property:GenerateFullPaths=true",
|
||||
"/consoleloggerparameters:NoSummary"
|
||||
],
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
"problemMatcher": "$msCompile",
|
||||
"group": {
|
||||
"kind": "build",
|
||||
@ -224,6 +254,9 @@
|
||||
"label": "test",
|
||||
"type": "shell",
|
||||
"command": "dotnet test",
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
"group": {
|
||||
"kind": "test",
|
||||
"isDefault": true
|
||||
|
||||
3
akd/Cargo.lock
generated
3
akd/Cargo.lock
generated
@ -418,6 +418,8 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"akd",
|
||||
"blake3",
|
||||
"config",
|
||||
"serde",
|
||||
"uuid",
|
||||
]
|
||||
|
||||
@ -2635,6 +2637,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2f87b8aa10b915a06587d0dec516c282ff295b475d94abf425d62b57710070a2"
|
||||
dependencies = [
|
||||
"js-sys",
|
||||
"serde",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
|
||||
@ -7,9 +7,15 @@ license-file.workspace = true
|
||||
keywords.workspace = true
|
||||
|
||||
[dependencies]
|
||||
akd = { workspace = true }
|
||||
akd.workspace = true
|
||||
blake3 = "1.8.2"
|
||||
uuid = "1.18.1"
|
||||
config = { workspace = true, optional = true }
|
||||
serde = { workspace = true, optional = true }
|
||||
uuid = { version = "1.18.1", features = ["serde"] }
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[features]
|
||||
config = ["dep:config", "dep:serde"]
|
||||
default = ["config"]
|
||||
|
||||
19
akd/crates/bitwarden-akd-configuration/src/config.rs
Normal file
19
akd/crates/bitwarden-akd-configuration/src/config.rs
Normal file
@ -0,0 +1,19 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::INSTALLATION_CONTEXT;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct BitwardenAkdConfiguration {
|
||||
pub installation_id: uuid::Uuid,
|
||||
}
|
||||
|
||||
impl BitwardenAkdConfiguration {
|
||||
/// Initialize the global installation context for Bitwarden AKD.
|
||||
/// Must be called once before any use.
|
||||
///
|
||||
/// # Errors
|
||||
/// Returns an error like [`OnceLock<Vec<u8>>`](std::sync::OnceLock) if called more than once.
|
||||
pub fn init(&self) -> Result<(), Vec<u8>> {
|
||||
INSTALLATION_CONTEXT.set(self.installation_id.into_bytes().into())
|
||||
}
|
||||
}
|
||||
@ -29,13 +29,14 @@
|
||||
|
||||
//! Define the Bitwarden V1 configuration
|
||||
|
||||
#[cfg(feature = "config")]
|
||||
pub mod config;
|
||||
|
||||
use akd::configuration::Configuration;
|
||||
use akd::hash::{Digest, DIGEST_BYTES};
|
||||
use akd::{
|
||||
AkdLabel, AkdValue, AzksValue, AzksValueWithEpoch, NodeLabel, VersionFreshness,
|
||||
};
|
||||
use uuid::Uuid;
|
||||
use akd::{AkdLabel, AkdValue, AzksValue, AzksValueWithEpoch, NodeLabel, VersionFreshness};
|
||||
use std::sync::OnceLock;
|
||||
use uuid::Uuid;
|
||||
|
||||
/// Bitwarden installation ID for instance separation
|
||||
static INSTALLATION_CONTEXT: OnceLock<Vec<u8>> = OnceLock::new();
|
||||
@ -99,11 +100,7 @@ impl Configuration for BitwardenV1Configuration {
|
||||
AzksValue([0u8; 32])
|
||||
}
|
||||
|
||||
fn hash_leaf_with_value(
|
||||
value: &akd::AkdValue,
|
||||
epoch: u64,
|
||||
nonce: &[u8],
|
||||
) -> AzksValueWithEpoch {
|
||||
fn hash_leaf_with_value(value: &akd::AkdValue, epoch: u64, nonce: &[u8]) -> AzksValueWithEpoch {
|
||||
let commitment = Self::generate_commitment_from_nonce_client(value, nonce);
|
||||
Self::hash_leaf_with_commitment(commitment, epoch)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user