Skip to content

Commit 364ff2f

Browse files
atlas-formclaude
andcommitted
feat: implement enhanced KeyStore with Key trait integration
* Add comprehensive EnhancedKeyStore implementation with PKI-specific metadata * Extend Key trait with as_any() method for safe type downcasting * Support all key types: Ed25519, P256, RSA with PKCS#8 serialization * Implement hybrid metadata persistence (cache + attribute storage) * Add PKI-specific features: usage restrictions, validity periods, certificate associations * Include comprehensive test coverage for all supported key algorithms * Bridge gap between raw key storage and high-level PKI operations 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 6cee34d commit 364ff2f

File tree

6 files changed

+440
-8
lines changed

6 files changed

+440
-8
lines changed

crates/capsula-key/src/key/curve25519.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,10 @@ impl Key for Curve25519 {
201201
fn capabilities(&self) -> KeyCapabilities {
202202
KeyCapabilities::SIGNING.union(KeyCapabilities::KEY_AGREEMENT)
203203
}
204+
205+
fn as_any(&self) -> &dyn std::any::Any {
206+
self
207+
}
204208
}
205209

206210
impl KeySign for Curve25519 {

crates/capsula-key/src/key/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ pub trait Key: Send + Sync {
5353
fn fingerprint_hex(&self) -> String {
5454
hex::encode(self.fingerprint_sha256_spki())
5555
}
56+
57+
/// 获取Any trait object引用,用于安全的向下转换
58+
fn as_any(&self) -> &dyn std::any::Any;
5659
}
5760

5861
// ============================================================================

crates/capsula-key/src/key/p256.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ impl Key for P256Key {
119119
fn capabilities(&self) -> KeyCapabilities {
120120
KeyCapabilities::SIGNING.union(KeyCapabilities::KEY_AGREEMENT)
121121
}
122+
123+
fn as_any(&self) -> &dyn std::any::Any {
124+
self
125+
}
122126
}
123127

124128
// ============================================================================

crates/capsula-key/src/key/rsa.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ impl Key for RsaKey {
116116
fn capabilities(&self) -> KeyCapabilities {
117117
KeyCapabilities::SIGNING.union(KeyCapabilities::ENCRYPTION)
118118
}
119+
120+
fn as_any(&self) -> &dyn std::any::Any {
121+
self
122+
}
119123
}
120124

121125
// ============================================================================

0 commit comments

Comments
 (0)