1
0
mirror of https://github.com/bitwarden/server synced 2026-02-05 19:23:25 +00:00

re-export akd_storage vrf configuration

This commit is contained in:
Matt Gibson
2025-12-18 10:30:43 -08:00
parent bf3a280b9b
commit 7eda815adb
5 changed files with 2 additions and 64 deletions

View File

@@ -15,7 +15,7 @@ use crate::ms_sql::MsSql;
pub mod akd_storage_config;
pub mod db_config;
pub mod ms_sql;
mod vrf_key_config;
pub mod vrf_key_config;
pub mod vrf_key_database;
/// Enum to represent different database types supported by the storage layer.

View File

@@ -1,10 +1,9 @@
use thiserror::Error;
mod storage_manager_config;
mod vrf_config;
pub use akd_storage::vrf_key_config::VrfKeyConfig;
pub use storage_manager_config::*;
pub use vrf_config::*;
#[derive(Error, Debug)]
pub enum ConfigError {

View File

@@ -1,34 +0,0 @@
use serde::{Deserialize, Serialize};
use crate::config::ConfigError;
use crate::VrfStorageType;
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "type")]
pub enum VrfConfig {
HardCodedAkdVRF,
ConstantConfigurableVRF { key_material: String },
}
impl TryFrom<&VrfConfig> for VrfStorageType {
type Error = ConfigError;
fn try_from(config: &VrfConfig) -> Result<Self, ConfigError> {
match config {
VrfConfig::HardCodedAkdVRF => Ok(VrfStorageType::HardCodedAkdVRF),
VrfConfig::ConstantConfigurableVRF { key_material } => {
let key_material =
hex::decode(key_material).map_err(ConfigError::InvalidVrfKeyMaterialHex)?;
if key_material.len() != 32 {
return Err(ConfigError::VrfKeyMaterialInvalidLength {
actual: key_material.len(),
});
}
Ok(VrfStorageType::ConstantConfigurableVRF {
key_material: key_material.clone(),
})
}
}
}
}

View File

@@ -1,4 +1 @@
pub mod config;
mod vrf_type;
pub use vrf_type::VrfStorageType;

View File

@@ -1,24 +0,0 @@
use akd::ecvrf::{HardCodedAkdVRF, VRFKeyStorage, VrfError};
use async_trait::async_trait;
#[derive(Debug, Clone)]
pub enum VrfStorageType {
/// **WARNING**: Do not use this in production systems. This is only for testing and debugging.
/// This is a version of VRFKeyStorage for testing purposes, which uses the example from the VRF crate.
///
/// const KEY_MATERIAL: &str = "c9afa9d845ba75166b5c215767b1d6934e50c3db36e89b127b8a622b120f6721";
HardCodedAkdVRF,
ConstantConfigurableVRF {
key_material: Vec<u8>,
},
}
#[async_trait]
impl VRFKeyStorage for VrfStorageType {
async fn retrieve(&self) -> Result<Vec<u8>, VrfError> {
match self {
VrfStorageType::HardCodedAkdVRF => HardCodedAkdVRF.retrieve().await,
VrfStorageType::ConstantConfigurableVRF { key_material } => Ok(key_material.clone()),
}
}
}