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

Method open_raw

src/crypto.rs:194–213  ·  view source on GitHub ↗
(&self, nonce: &[u8], encrypted: &[u8])

Source from the content-addressed store, hash-verified

192 }
193
194 pub fn open_raw(&self, nonce: &[u8], encrypted: &[u8]) -> Result<Vec<u8>, Error> {
195 let encrypted_len = encrypted.len();
196 ensure!(
197 encrypted_len >= crypto_box_curve25519xchacha20poly1305_MACBYTES as usize,
198 "Unable to decrypt"
199 );
200 let mut decrypted =
201 vec![0u8; encrypted_len - crypto_box_curve25519xchacha20poly1305_MACBYTES as usize];
202 let res = unsafe {
203 crypto_box_curve25519xchacha20poly1305_open_easy_afternm(
204 decrypted.as_mut_ptr(),
205 encrypted.as_ptr(),
206 encrypted_len as _,
207 nonce.as_ptr(),
208 self.0.as_ptr(),
209 )
210 };
211 ensure!(res == 0, "Unable to decrypt");
212 Ok(decrypted)
213 }
214
215 pub fn decrypt(&self, nonce: &[u8], encrypted: &[u8]) -> Result<Vec<u8>, Error> {
216 let encrypted_len = encrypted.len();

Callers 1

open_ticketFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected