confium_openssl_provider/
lib.rs1#![forbid(unsafe_code)]
25#![allow(missing_docs)] use serde::{Deserialize, Serialize};
28
29#[derive(Debug, Clone, Serialize, Deserialize)]
31pub struct ProviderInfo {
32 pub name: String,
34 pub version: String,
36 pub description: String,
38 pub buildinfo: String,
40}
41
42impl ProviderInfo {
43 pub fn default_confium() -> Self {
45 Self {
46 name: "confium".into(),
47 version: env!("CARGO_PKG_VERSION").into(),
48 description: "Confium threshold cryptography provider for OpenSSL 3.0".into(),
49 buildinfo: "Confium OpenSSL Provider".into(),
50 }
51 }
52}
53
54#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
56#[serde(rename_all = "snake_case")]
57pub enum Operation {
58 Signer,
60 Verifier,
62 Digester,
64 KeyGenerator,
66 KeyEncoder,
68 StoreLoader,
70}
71
72impl Operation {
73 pub fn all() -> &'static [Operation] {
75 &[
76 Operation::Signer,
77 Operation::Verifier,
78 Operation::Digester,
79 Operation::KeyGenerator,
80 Operation::KeyEncoder,
81 Operation::StoreLoader,
82 ]
83 }
84}
85
86#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
88#[serde(rename_all = "snake_case")]
89pub enum Algorithm {
90 Ed25519,
92 EcdsaP256,
94 EcdsaP384,
96 MlDsa65,
98 CompositeEd25519MlDsa65,
100}
101
102impl Algorithm {
103 pub fn openssl_name(&self) -> &'static str {
105 match self {
106 Algorithm::Ed25519 => "Ed25519",
107 Algorithm::EcdsaP256 => "ECDSA",
108 Algorithm::EcdsaP384 => "ECDSA",
109 Algorithm::MlDsa65 => "ML-DSA-65",
110 Algorithm::CompositeEd25519MlDsa65 => "composite-MLDSA65-Ed25519",
111 }
112 }
113}
114
115#[derive(Debug, Clone, Serialize, Deserialize)]
117pub struct ProviderConfig {
118 pub daemon_socket: String,
120 pub default_quorum: String,
122}
123
124#[cfg(test)]
125mod tests {
126 use super::*;
127
128 #[test]
129 fn default_provider_info() {
130 let info = ProviderInfo::default_confium();
131 assert_eq!(info.name, "confium");
132 }
133
134 #[test]
135 fn all_operations_non_empty() {
136 assert!(!Operation::all().is_empty());
137 }
138
139 #[test]
140 fn ed25519_openssl_name() {
141 assert_eq!(Algorithm::Ed25519.openssl_name(), "Ed25519");
142 }
143}