MCPcopy Create free account
hub / github.com/DNSCrypt/encrypted-dns-server / derive_shared_key

Function derive_shared_key

src/pq.rs:135–151  ·  view source on GitHub ↗

Derive ` ` for a query that carries a ciphertext.

(
    kem_ss: &[u8; 32],
    es_version: &[u8; 2],
    client_magic: &[u8; 8],
    cert_ctx: &[u8],
    client_kex: &[u8],
)

Source from the content-addressed store, hash-verified

133
134/// Derive `<shared-key>` for a query that carries a ciphertext.
135pub fn derive_shared_key(
136 kem_ss: &[u8; 32],
137 es_version: &[u8; 2],
138 client_magic: &[u8; 8],
139 cert_ctx: &[u8],
140 client_kex: &[u8],
141) -> SharedKey {
142 let mut salt = [0u8; 10];
143 salt[0..2].copy_from_slice(es_version);
144 salt[2..10].copy_from_slice(client_magic);
145 let mut info = Vec::with_capacity(cert_ctx.len() + client_kex.len());
146 info.extend_from_slice(cert_ctx);
147 info.extend_from_slice(client_kex);
148 let mut key = [0u8; 32];
149 hkdf_sha256(&salt, kem_ss, &info, &mut key);
150 SharedKey::from_bytes(key)
151}
152
153/// The resumption secret shared between client and resolver after a query that
154/// carried a ciphertext.

Callers 2

appendix3_vectorsFunction · 0.85
decrypt_pq_ciphertextFunction · 0.85

Calls 1

hkdf_sha256Function · 0.85

Tested by 1

appendix3_vectorsFunction · 0.68