MCPcopy Create free account
hub / github.com/cosdata/cosdata / generate_token_key

Function generate_token_key

src/models/crypto.rs:114–121  ·  view source on GitHub ↗

Generates time-based token key from master key

(master_key: &MasterKey, timestamp: u64)

Source from the content-addressed store, hash-verified

112
113// Generates time-based token key from master key
114pub fn generate_token_key(master_key: &MasterKey, timestamp: u64) -> hmac::Key {
115 // Create HMAC key from master key
116 let key = hmac::Key::new(hmac::HMAC_SHA256, &master_key.0);
117
118 // Convert timestamp to bytes and sign with master key
119 let ts_bytes = timestamp.to_be_bytes();
120 hmac::Key::new(hmac::HMAC_SHA256, hmac::sign(&key, &ts_bytes).as_ref())
121}
122
123// Retrieves current Unix timestamp for token generation
124pub fn get_current_timestamp() -> u64 {

Callers 1

create_sessionFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected