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

Method compute_shared_key

src/crypto.rs:148–159  ·  view source on GitHub ↗
(&self, pk: &[u8])

Source from the content-addressed store, hash-verified

146 }
147
148 pub fn compute_shared_key(&self, pk: &[u8]) -> Result<SharedKey, Error> {
149 let mut shared_key = SharedKey::default();
150 let res = unsafe {
151 crypto_box_curve25519xchacha20poly1305_beforenm(
152 shared_key.0.as_mut_ptr(),
153 pk.as_ptr(),
154 self.sk.0.as_ptr(),
155 )
156 };
157 ensure!(res == 0, "Weak public key");
158 Ok(shared_key)
159 }
160}
161
162#[derive(Debug, Clone, Default)]

Callers 1

decryptFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected