Skip to content

armgit / ente

Public Imported from GitHub
0

💚 End-to-end encrypted cloud for everything.

rust/core: harden crypto primitives

Prateek Sunalc79eac423b10
diff --git a/rust/core/src/crypto/impl_pure/kdf.rs b/rust/core/src/crypto/impl_pure/kdf.rs
index 282bb7d7a0..d74a8405c4 100644
--- a/rust/core/src/crypto/impl_pure/kdf.rs
+++ b/rust/core/src/crypto/impl_pure/kdf.rs
@@ -56,6 +56,13 @@ pub fn derive_subkey(
});
}
+ if key.len() != KEY_BYTES {
+ return Err(crate::crypto::CryptoError::InvalidKeyLength {
+ expected: KEY_BYTES,
+ actual: key.len(),
+ });
+ }
+
// Build salt: subkey_id (8 bytes LE) || zeros (8 bytes)
let mut salt = [0u8; 16];
salt[0..8].copy_from_slice(&subkey_id.to_le_bytes());
@@ -216,6 +223,20 @@ mod tests {
assert_eq!(subkey.len(), 32);
}
+ #[test]
+ fn test_invalid_master_key_length() {
+ let bad_key = vec![0x42u8; 31];
+ let result = derive_subkey(&bad_key, 32, 1, b"context");
+
+ assert!(matches!(
+ result,
+ Err(crate::crypto::CryptoError::InvalidKeyLength {
+ expected: KEY_BYTES,
+ actual: 31
+ })
+ ));
+ }
+
#[test]
fn test_derive_login_key() {
let master_key = vec![0x42u8; 32];
diff --git a/rust/core/src/crypto/impl_pure/secretbox.rs b/rust/core/src/crypto/impl_pure/secretbox.rs
index bf4b725064..46365ed945 100644
--- a/rust/core/src/crypto/impl_pure/secretbox.rs
+++ b/rust/core/src/crypto/impl_pure/secretbox.rs
@@ -19,8 +19,6 @@ pub struct EncryptedData {
pub encrypted_data: Vec<u8>,
/// The nonce used for encryption (24 bytes).
pub nonce: Vec<u8>,
- /// The key used for encryption (32 bytes).
- pub key: Vec<u8>,
}
/// Result of SecretBox encryption with a separate nonce.
@@ -30,8 +28,6 @@ pub struct SecretBoxCiphertext {
pub ciphertext: Vec<u8>,
/// The nonce used for encryption (24 bytes).
pub nonce: Vec<u8>,
- /// The key used for encryption (32 bytes).
- pub key: Vec<u8>,
}
/// Size of a SecretBox key in bytes.
@@ -65,7 +61,6 @@ pub fn encrypt(plaintext: &[u8], key: &[u8]) -> Result<EncryptedData> {
Ok(EncryptedData {
encrypted_data: result,
nonce,
- key: key.to_vec(),
})
}
@@ -84,11 +79,7 @@ pub fn encrypt_with_key(plaintext: &[u8], key: &[u8]) -> Result<SecretBoxCiphert
let nonce = keys::generate_secretbox_nonce();
let ciphertext = encrypt_with_nonce(plaintext, &nonce, key)?;
- Ok(SecretBoxCiphertext {
- ciphertext,
- nonce,
- key: key.to_vec(),
- })
+ Ok(SecretBoxCiphertext { ciphertext, nonce })
}
/// Encrypt plaintext with a provided nonce.
@@ -235,6 +226,23 @@ pub fn decrypt_with_key(ciphertext: &[u8], key: &[u8], nonce: &[u8]) -> Result<V
mod tests {
use super::*;
+ #[test]
+ fn test_encrypt_result_structs_do_not_store_key() {
+ let key = keys::generate_key();
+
+ let encrypted = encrypt(b"test", &key).unwrap();
+ let EncryptedData {
+ encrypted_data: _,
+ nonce: _,
+ } = encrypted;
+
+ let encrypted = encrypt_with_key(b"test", &key).unwrap();
+ let SecretBoxCiphertext {
+ ciphertext: _,
+ nonce: _,
+ } = encrypted;
+ }
+
#[test]
fn test_encrypt_decrypt() {
let key = keys::generate_key();
@@ -267,10 +275,8 @@ mod tests {
let encrypted = encrypt_with_key(plaintext, &key).unwrap();
assert_eq!(encrypted.ciphertext.len(), MAC_BYTES + plaintext.len());
assert_eq!(encrypted.nonce.len(), NONCE_BYTES);
- assert_eq!(encrypted.key, key);
- let decrypted =
- decrypt_with_key(&encrypted.ciphertext, &encrypted.key, &encrypted.nonce).unwrap();
+ let decrypted = decrypt_with_key(&encrypted.ciphertext, &key, &encrypted.nonce).unwrap();
assert_eq!(decrypted, plaintext);
}
diff --git a/rust/core/src/crypto/impl_pure/stream.rs b/rust/core/src/crypto/impl_pure/stream.rs
index a28df20191..ff4d870d9a 100644
--- a/rust/core/src/crypto/impl_pure/stream.rs
+++ b/rust/core/src/crypto/impl_pure/stream.rs
@@ -317,34 +317,31 @@ pub fn decrypt_stream(encrypted: &EncryptedStream, key: &[u8]) -> Result<Vec<u8>
/// Estimate encrypted size for chunked secretstream encryption.
///
-/// This estimates the ciphertext size when data is encrypted using
-/// [`StreamingEncryptor`] or [`encrypt_file`], which split data into
-/// `ENCRYPTION_CHUNK_SIZE` chunks with MESSAGE tags, plus a FINAL chunk.
+/// Estimate ciphertext size (excluding header) for chunked secretstream encryption.
///
-/// **Note**: This does NOT include the header (24 bytes). For total output
-/// size including header, add `HEADER_BYTES` to the result.
-///
-/// For the simple [`encrypt`] function (single-chunk encryption), the
-/// size is simply `plaintext_len + ABYTES`.
-///
-/// # Examples
-/// - Empty (0 bytes): Returns `ABYTES` (empty FINAL chunk)
-/// - 100 bytes: Returns `100 + ABYTES` (single FINAL chunk)
-/// - Exact `ENCRYPTION_CHUNK_SIZE`: Returns `DECRYPTION_CHUNK_SIZE + ABYTES`
-/// (one MESSAGE chunk + empty FINAL chunk)
+/// The stream is split into `ENCRYPTION_CHUNK_SIZE` chunks. The last chunk is
+/// tagged FINAL; if the plaintext is empty, a single empty FINAL chunk is
+/// emitted.
///
/// If the calculation overflows `usize`, this returns `usize::MAX`.
#[inline]
pub fn estimate_encrypted_size(plaintext_len: usize) -> usize {
+ if plaintext_len == 0 {
+ return ABYTES;
+ }
+
let full_chunks = plaintext_len / ENCRYPTION_CHUNK_SIZE;
let last_chunk_size = plaintext_len % ENCRYPTION_CHUNK_SIZE;
- // Full MESSAGE chunks (each adds ABYTES overhead)
- // + FINAL chunk (even if empty, always emitted with ABYTES overhead)
let full_bytes = match full_chunks.checked_mul(DECRYPTION_CHUNK_SIZE) {
Some(value) => value,
None => return usize::MAX,
};
+
+ if last_chunk_size == 0 {
+ return full_bytes;
+ }
+
let with_last = match full_bytes.checked_add(last_chunk_size) {
Some(value) => value,
None => return usize::MAX,
@@ -372,22 +369,16 @@ pub fn validate_sizes(plaintext_len: usize, ciphertext_len: usize) -> bool {
/// Streaming file encryptor that writes encrypted chunks to a writer.
///
-/// # Algorithmic Complexity
-///
-/// The `write()` method is O(n) where n is the input size:
-/// - Full chunks are processed directly from the input slice (no buffering)
-/// - Only remainder bytes (< chunk size) are buffered
-/// - No compaction/shifting of internal buffer after each chunk
-///
-/// This avoids O(n²) behavior that would occur if we buffered all input
-/// first and then shifted the buffer after processing each chunk.
+/// Keeps the last full plaintext chunk in memory so it can be tagged FINAL
+/// without emitting an extra empty FINAL chunk on exact chunk boundaries.
pub struct StreamingEncryptor<W: Write> {
encryptor: StreamEncryptor,
writer: W,
- /// Buffer for remainder bytes (< chunk size). Never exceeds ENCRYPTION_CHUNK_SIZE.
+ /// Remainder bytes (< chunk size).
buffer: Vec<u8>,
- /// Reusable buffer for encrypting chunks from input slice (avoids allocation per chunk)
- chunk_buffer: Vec<u8>,
+ /// Pending full chunk (exactly `ENCRYPTION_CHUNK_SIZE` bytes) that is not
+ /// written until we know whether it's the final chunk.
+ pending: Vec<u8>,
}
impl<W: Write> StreamingEncryptor<W> {
@@ -398,54 +389,58 @@ impl<W: Write> StreamingEncryptor<W> {
Ok(Self {
encryptor,
writer,
- // Buffer only needs to hold remainder (< chunk size) + ABYTES for encryption
buffer: Vec::with_capacity(ENCRYPTION_CHUNK_SIZE + ABYTES),
- chunk_buffer: Vec::with_capacity(ENCRYPTION_CHUNK_SIZE + ABYTES),
+ pending: Vec::with_capacity(ENCRYPTION_CHUNK_SIZE + ABYTES),
})
}
- /// Write plaintext data. Data is buffered and encrypted in chunks.
- ///
- /// # Algorithm
- ///
- /// 1. If there's buffered data, complete it to a full chunk from input
- /// 2. Process full chunks directly from input slice (no intermediate buffering)
- /// 3. Buffer only the remainder (< chunk size)
- ///
- /// This ensures O(n) complexity regardless of input size.
+ fn flush_pending(&mut self, is_final: bool) -> Result<()> {
+ if self.pending.is_empty() {
+ return Ok(());
+ }
+
+ self.encryptor
+ .push_in_place(&mut self.pending, &[], is_final)?;
+ self.writer.write_all(&self.pending)?;
+ self.pending.clear();
+ Ok(())
+ }
+
+ fn push_full_chunk(&mut self) -> Result<()> {
+ if !self.pending.is_empty() {
+ self.flush_pending(false)?;
+ }
+
+ std::mem::swap(&mut self.pending, &mut self.buffer);
+ self.buffer.clear();
+ Ok(())
+ }
+
+ /// Write plaintext data to the stream.
pub fn write(&mut self, data: &[u8]) -> Result<()> {
let mut input_pos = 0;
- // Step 1: If buffer has partial data, try to complete it to a full chunk
if !self.buffer.is_empty() {
let space_in_buffer = ENCRYPTION_CHUNK_SIZE - self.buffer.len();
let bytes_to_add = std::cmp::min(space_in_buffer, data.len());
self.buffer.extend_from_slice(&data[..bytes_to_add]);
input_pos = bytes_to_add;
- // If buffer is now a full chunk, encrypt and write it
if self.buffer.len() == ENCRYPTION_CHUNK_SIZE {
- self.encryptor.push_in_place(&mut self.buffer, &[], false)?;
- self.writer.write_all(&self.buffer)?;
- self.buffer.clear();
+ self.push_full_chunk()?;
} else {
- // Not enough data to complete the chunk, done for now
return Ok(());
}
}
- // Step 2: Process full chunks directly from input slice (zero intermediate buffering)
while input_pos + ENCRYPTION_CHUNK_SIZE <= data.len() {
- self.chunk_buffer.clear();
- self.chunk_buffer
+ self.buffer.clear();
+ self.buffer
.extend_from_slice(&data[input_pos..input_pos + ENCRYPTION_CHUNK_SIZE]);
- self.encryptor
- .push_in_place(&mut self.chunk_buffer, &[], false)?;
- self.writer.write_all(&self.chunk_buffer)?;
input_pos += ENCRYPTION_CHUNK_SIZE;
+ self.push_full_chunk()?;
}
- // Step 3: Buffer the remainder (< chunk size)
if input_pos < data.len() {
self.buffer.extend_from_slice(&data[input_pos..]);
}
@@ -453,13 +448,17 @@ impl<W: Write> StreamingEncryptor<W> {
Ok(())
}
- /// Finish encryption and write the final chunk.
- ///
- /// Uses `self.buffer` directly since `self` is consumed, avoiding
- /// an extra copy to `chunk_buffer`.
+ /// Finish encryption, writing the final chunk.
pub fn finish(mut self) -> Result<W> {
- // Encrypt buffer in-place (adds ABYTES bytes)
- // No need to copy to chunk_buffer since we're consuming self
+ if !self.pending.is_empty() {
+ if !self.buffer.is_empty() {
+ self.flush_pending(false)?;
+ } else {
+ self.flush_pending(true)?;
+ return Ok(self.writer);
+ }
+ }
+
self.encryptor.push_in_place(&mut self.buffer, &[], true)?;
self.writer.write_all(&self.buffer)?;
Ok(self.writer)
@@ -608,12 +607,14 @@ impl<R: Read> StreamingDecryptor<R> {
}
}
+type EncryptFileResult = Result<(Vec<u8>, Vec<u8>, Option<Vec<u8>>)>;
+
fn encrypt_file_internal<R: Read, W: Write>(
reader: &mut R,
writer: &mut W,
key: Option<&[u8]>,
mut md5_state: Option<Md5>,
-) -> Result<(Vec<u8>, Vec<u8>, Option<Vec<u8>>)> {
+) -> EncryptFileResult {
use crate::crypto::keys::generate_stream_key;
let key = match key {
@@ -624,39 +625,46 @@ fn encrypt_file_internal<R: Read, W: Write>(
let mut encryptor = StreamEncryptor::new(&key)?;
let header = encryptor.header.clone();
- // Reusable read buffer for plaintext
- let mut read_buffer = vec![0u8; ENCRYPTION_CHUNK_SIZE];
- // Reusable buffer for in-place encryption (avoids per-chunk allocation)
- let mut encrypt_buffer = Vec::with_capacity(ENCRYPTION_CHUNK_SIZE + ABYTES);
-
- loop {
+ let mut read_chunk = |buf: &mut [u8]| -> Result<usize> {
let mut total_read = 0;
-
- // Read up to ENCRYPTION_CHUNK_SIZE bytes
while total_read < ENCRYPTION_CHUNK_SIZE {
- match reader.read(&mut read_buffer[total_read..]) {
- Ok(0) => break, // EOF
+ match reader.read(&mut buf[total_read..]) {
+ Ok(0) => break,
Ok(n) => total_read += n,
Err(e) if e.kind() == std::io::ErrorKind::Interrupted => continue,
Err(e) => return Err(e.into()),
}
}
+ Ok(total_read)
+ };
- if total_read == 0 {
- // No more data - write final empty chunk to match StreamingEncryptor semantics
- encrypt_buffer.clear();
- encryptor.push_in_place(&mut encrypt_buffer, &[], true)?;
- if let Some(state) = md5_state.as_mut() {
- state.update(&encrypt_buffer);
- }
- writer.write_all(&encrypt_buffer)?;
- break;
+ // Reusable buffers for plaintext chunks
+ let mut curr = vec![0u8; ENCRYPTION_CHUNK_SIZE];
+ let mut next = vec![0u8; ENCRYPTION_CHUNK_SIZE];
+
+ // Reusable buffer for in-place encryption (avoids per-chunk allocation)
+ let mut encrypt_buffer = Vec::with_capacity(ENCRYPTION_CHUNK_SIZE + ABYTES);
+
+ let mut curr_len = read_chunk(&mut curr)?;
+
+ if curr_len == 0 {
+ // Empty file: single empty FINAL chunk
+ encrypt_buffer.clear();
+ encryptor.push_in_place(&mut encrypt_buffer, &[], true)?;
+ if let Some(state) = md5_state.as_mut() {
+ state.update(&encrypt_buffer);
}
+ writer.write_all(&encrypt_buffer)?;
+
+ let md5 = md5_state.map(|state| state.finalize().as_slice().to_vec());
+ return Ok((key, header, md5));
+ }
- // If we read less than full chunk, it's the last chunk with data
- if total_read < ENCRYPTION_CHUNK_SIZE {
+ loop {
+ if curr_len < ENCRYPTION_CHUNK_SIZE {
+ // Last chunk is partial
encrypt_buffer.clear();
- encrypt_buffer.extend_from_slice(&read_buffer[..total_read]);
+ encrypt_buffer.extend_from_slice(&curr[..curr_len]);
encryptor.push_in_place(&mut encrypt_buffer, &[], true)?;
if let Some(state) = md5_state.as_mut() {
state.update(&encrypt_buffer);
@@ -665,15 +673,23 @@ fn encrypt_file_internal<R: Read, W: Write>(
break;
}
- // Full chunk - write with MESSAGE tag (not FINAL)
- // The FINAL tag will be on the next chunk (which may be empty)
+ let next_len = read_chunk(&mut next)?;
+ let is_final = next_len == 0;
+
encrypt_buffer.clear();
- encrypt_buffer.extend_from_slice(&read_buffer[..total_read]);
- encryptor.push_in_place(&mut encrypt_buffer, &[], false)?;
+ encrypt_buffer.extend_from_slice(&curr[..curr_len]);
+ encryptor.push_in_place(&mut encrypt_buffer, &[], is_final)?;
if let Some(state) = md5_state.as_mut() {
state.update(&encrypt_buffer);
}
writer.write_all(&encrypt_buffer)?;
+
+ if is_final {
+ break;
+ }
+
+ std::mem::swap(&mut curr, &mut next);
+ curr_len = next_len;
}
let md5 = md5_state.map(|state| state.finalize().as_slice().to_vec());
@@ -690,7 +706,7 @@ fn encrypt_file_internal<R: Read, W: Write>(
///
/// This function produces output consistent with [`StreamingEncryptor`]:
/// - Full chunks are encrypted with MESSAGE tags
-/// - A FINAL chunk is always emitted (may be empty if plaintext is exact multiple of chunk size)
+/// - The last chunk is tagged FINAL (empty FINAL chunk only for empty plaintext)
///
/// Use [`estimate_encrypted_size`] to predict the ciphertext size (excluding header).
///
@@ -1296,10 +1312,10 @@ mod tests {
// Small data: data + ABYTES
assert_eq!(estimate_encrypted_size(100), 100 + ABYTES);
- // Exact chunk size: chunk + ABYTES (MESSAGE) + empty FINAL with ABYTES
+ // Exact chunk size: one FINAL chunk
assert_eq!(
estimate_encrypted_size(ENCRYPTION_CHUNK_SIZE),
- DECRYPTION_CHUNK_SIZE + ABYTES
+ DECRYPTION_CHUNK_SIZE
);
// Multiple chunks
@@ -1312,10 +1328,7 @@ mod tests {
fn test_validate_sizes() {
assert!(validate_sizes(0, ABYTES));
assert!(validate_sizes(100, 100 + ABYTES));
- assert!(validate_sizes(
- ENCRYPTION_CHUNK_SIZE,
- DECRYPTION_CHUNK_SIZE + ABYTES
- ));
+ assert!(validate_sizes(ENCRYPTION_CHUNK_SIZE, DECRYPTION_CHUNK_SIZE));
assert!(!validate_sizes(100, 100)); // Missing ABYTES
assert!(!validate_sizes(100, 200)); // Wrong size
}
@@ -1455,9 +1468,8 @@ mod tests {
#[test]
fn test_file_encrypt_decrypt_exact_chunk_boundary() {
- // Edge case: plaintext exactly at chunk boundary
- // When plaintext is exact multiple of ENCRYPTION_CHUNK_SIZE, encrypt_file
- // emits an empty FINAL chunk to match StreamingEncryptor semantics.
+ // Edge case: plaintext exactly at chunk boundary.
+ // The last full chunk must be tagged FINAL (no extra empty FINAL chunk).
let key = generate_test_key();
let plaintext: Vec<u8> = (0..ENCRYPTION_CHUNK_SIZE)
@@ -1469,8 +1481,7 @@ mod tests {
let (_, header) =
encrypt_file(&mut reader, &mut encrypted, Some(&key)).expect("encrypt_file failed");
- // Should be one MESSAGE chunk + empty FINAL chunk
- assert_eq!(encrypted.len(), DECRYPTION_CHUNK_SIZE + ABYTES);
+ assert_eq!(encrypted.len(), DECRYPTION_CHUNK_SIZE);
// Should match estimate
assert_eq!(encrypted.len(), estimate_encrypted_size(plaintext.len()));
@@ -1824,8 +1835,8 @@ mod tests {
#[test]
fn test_encrypt_file_size_matches_estimate_exact_chunk() {
- // Exact chunk size: encrypt_file output should match estimate
- // This is the key edge case - should emit MESSAGE chunk + empty FINAL
+ // Exact chunk size: encrypt_file output should match estimate.
+ // The last full chunk should be tagged FINAL.
let key = generate_test_key();
let plaintext: Vec<u8> = (0..ENCRYPTION_CHUNK_SIZE)
.map(|i| (i % 256) as u8)
@@ -1843,8 +1854,7 @@ mod tests {
encrypted.len(),
expected
);
- // One MESSAGE chunk + empty FINAL chunk
- assert_eq!(encrypted.len(), DECRYPTION_CHUNK_SIZE + ABYTES);
+ assert_eq!(encrypted.len(), DECRYPTION_CHUNK_SIZE);
}
#[test]
@@ -1867,8 +1877,7 @@ mod tests {
encrypted.len(),
expected
);
- // Two MESSAGE chunks + empty FINAL chunk
- assert_eq!(encrypted.len(), 2 * DECRYPTION_CHUNK_SIZE + ABYTES);
+ assert_eq!(encrypted.len(), 2 * DECRYPTION_CHUNK_SIZE);
}
#[test]
diff --git a/web/packages/wasm/Cargo.lock b/web/packages/wasm/Cargo.lock
index 19e46825be..80fabb4abb 100644
--- a/web/packages/wasm/Cargo.lock
+++ b/web/packages/wasm/Cargo.lock
@@ -2,6 +2,40 @@
# It is not intended for manual editing.
version = 4
+[[package]]
+name = "aead"
+version = "0.5.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0"
+dependencies = [
+ "crypto-common",
+ "generic-array",
+]
+
+[[package]]
+name = "argon2"
+version = "0.5.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3c3610892ee6e0cbce8ae2700349fcf8f98adb0dbfbee85aec3c9179d29cc072"
+dependencies = [
+ "base64ct",
+ "blake2",
+ "cpufeatures",
+ "password-hash",
+]
+
+[[package]]
+name = "arrayref"
+version = "0.3.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb"
+
+[[package]]
+name = "arrayvec"
+version = "0.7.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50"
+
[[package]]
name = "atomic-waker"
version = "1.1.2"
@@ -14,12 +48,56 @@ version = "0.22.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
+[[package]]
+name = "base64ct"
+version = "1.8.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2af50177e190e07a26ab74f8b1efbfe2ef87da2116221318cb1c2e82baf7de06"
+
[[package]]
name = "bitflags"
version = "2.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3"
+[[package]]
+name = "blake2"
+version = "0.10.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe"
+dependencies = [
+ "digest",
+]
+
+[[package]]
+name = "blake2b_simd"
+version = "1.0.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b79834656f71332577234b50bfc009996f7449e0c056884e6a02492ded0ca2f3"
+dependencies = [
+ "arrayref",
+ "arrayvec",
+ "constant_time_eq",
+]
+
+[[package]]
+name = "block-buffer"
+version = "0.10.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71"
+dependencies = [
+ "generic-array",
+]
+
+[[package]]
+name = "block-padding"
+version = "0.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a8894febbff9f758034a5b8e12d87918f56dfc64a8e1fe757d65e29041538d93"
+dependencies = [
+ "generic-array",
+]
+
[[package]]
name = "bumpalo"
version = "3.19.0"
@@ -54,6 +132,34 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"
+[[package]]
+name = "chacha20"
+version = "0.9.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c3613f74bd2eac03dad61bd53dbe620703d4371614fe0bc3b9f04dd36fe4e818"
+dependencies = [
+ "cfg-if",
+ "cipher",
+ "cpufeatures",
+]
+
+[[package]]
+name = "cipher"
+version = "0.4.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad"
+dependencies = [
+ "crypto-common",
+ "inout",
+ "zeroize",
+]
+
+[[package]]
+name = "constant_time_eq"
+version = "0.4.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3d52eff69cd5e647efe296129160853a42795992097e8af39800e1060caeea9b"
+
[[package]]
name = "core-foundation"
version = "0.9.4"
@@ -80,6 +186,77 @@ version = "0.8.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
+[[package]]
+name = "cpufeatures"
+version = "0.2.17"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280"
+dependencies = [
+ "libc",
+]
+
+[[package]]
+name = "crypto-common"
+version = "0.1.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a"
+dependencies = [
+ "generic-array",
+ "rand_core 0.6.4",
+ "typenum",
+]
+
+[[package]]
+name = "crypto_secretstream"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9a6419214057ad50a13efccb3ad7714b86b848e3a5aa7b6cf5a3ff07edf387eb"
+dependencies = [
+ "aead",
+ "chacha20",
+ "getrandom 0.2.16",
+ "poly1305",
+ "rand_core 0.6.4",
+ "subtle",
+]
+
+[[package]]
+name = "curve25519-dalek"
+version = "4.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be"
+dependencies = [
+ "cfg-if",
+ "cpufeatures",
+ "curve25519-dalek-derive",
+ "fiat-crypto",
+ "rustc_version",
+ "subtle",
+ "zeroize",
+]
+
+[[package]]
+name = "curve25519-dalek-derive"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "digest"
+version = "0.10.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
+dependencies = [
+ "block-buffer",
+ "crypto-common",
+ "subtle",
+]
+
[[package]]
name = "displaydoc"
version = "0.2.5"
@@ -104,10 +281,22 @@ dependencies = [
name = "ente-core"
version = "0.0.1"
dependencies = [
+ "argon2",
+ "base64",
+ "blake2b_simd",
+ "crypto_secretstream",
+ "hex",
+ "md-5",
+ "rand_core 0.6.4",
"reqwest",
+ "salsa20",
"serde",
"serde_json",
+ "subtle",
"thiserror",
+ "x25519-dalek",
+ "xsalsa20poly1305",
+ "zeroize",
]
[[package]]
@@ -125,6 +314,12 @@ version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
+[[package]]
+name = "fiat-crypto"
+version = "0.2.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d"
+
[[package]]
name = "find-msvc-tools"
version = "0.1.5"
@@ -185,6 +380,16 @@ dependencies = [
"pin-utils",
]
+[[package]]
+name = "generic-array"
+version = "0.14.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a"
+dependencies = [
+ "typenum",
+ "version_check",
+]
+
[[package]]
name = "getrandom"
version = "0.2.16"
@@ -237,6 +442,12 @@ version = "0.16.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100"
+[[package]]
+name = "hex"
+version = "0.4.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
+
[[package]]
name = "http"
version = "1.4.0"
@@ -453,6 +664,16 @@ dependencies = [
"hashbrown",
]
+[[package]]
+name = "inout"
+version = "0.1.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01"
+dependencies = [
+ "block-padding",
+ "generic-array",
+]
+
[[package]]
name = "ipnet"
version = "2.11.0"
@@ -509,6 +730,16 @@ version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "112b39cec0b298b6c1999fee3e31427f74f676e4cb9879ed1a121b43661a4154"
+[[package]]
+name = "md-5"
+version = "0.10.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf"
+dependencies = [
+ "cfg-if",
+ "digest",
+]
+
[[package]]
name = "memchr"
version = "2.7.6"
@@ -538,12 +769,29 @@ version = "1.21.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
+[[package]]
+name = "opaque-debug"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381"
+
[[package]]
name = "openssl-probe"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e"
+[[package]]
+name = "password-hash"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "346f04948ba92c43e8469c1ee6736c7563d71012b17d40745260fe106aac2166"
+dependencies = [
+ "base64ct",
+ "rand_core 0.6.4",
+ "subtle",
+]
+
[[package]]
name = "percent-encoding"
version = "2.3.2"
@@ -562,6 +810,17 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
+[[package]]
+name = "poly1305"
+version = "0.8.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8159bd90725d2df49889a078b54f4f79e87f1f8a8444194cdca81d38f5393abf"
+dependencies = [
+ "cpufeatures",
+ "opaque-debug",
+ "universal-hash",
+]
+
[[package]]
name = "potential_utf"
version = "0.1.4"
@@ -641,7 +900,7 @@ dependencies = [
"once_cell",
"socket2",
"tracing",
- "windows-sys 0.52.0",
+ "windows-sys 0.60.2",
]
[[package]]
@@ -666,7 +925,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1"
dependencies = [
"rand_chacha",
- "rand_core",
+ "rand_core 0.9.3",
]
[[package]]
@@ -676,7 +935,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb"
dependencies = [
"ppv-lite86",
- "rand_core",
+ "rand_core 0.9.3",
+]
+
+[[package]]
+name = "rand_core"
+version = "0.6.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
+dependencies = [
+ "getrandom 0.2.16",
]
[[package]]
@@ -749,6 +1017,15 @@ version = "2.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d"
+[[package]]
+name = "rustc_version"
+version = "0.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92"
+dependencies = [
+ "semver",
+]
+
[[package]]
name = "rustls"
version = "0.23.35"
@@ -808,6 +1085,15 @@ version = "1.0.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f"
+[[package]]
+name = "salsa20"
+version = "0.10.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "97a22f5af31f73a954c10289c93e8a50cc23d971e80ee446f1f6f7137a088213"
+dependencies = [
+ "cipher",
+]
+
[[package]]
name = "schannel"
version = "0.1.28"
@@ -840,6 +1126,12 @@ dependencies = [
"libc",
]
+[[package]]
+name = "semver"
+version = "1.0.27"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2"
+
[[package]]
name = "serde"
version = "1.0.228"
@@ -1139,12 +1431,28 @@ version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"
+[[package]]
+name = "typenum"
+version = "1.19.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "562d481066bde0658276a35467c4af00bdc6ee726305698a55b86e61d7ad82bb"
+
[[package]]
name = "unicode-ident"
version = "1.0.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5"
+[[package]]
+name = "universal-hash"
+version = "0.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fc1de2c688dc15305988b563c3854064043356019f97a4b46276fe734c4f07ea"
+dependencies = [
+ "crypto-common",
+ "subtle",
+]
+
[[package]]
name = "untrusted"
version = "0.9.0"
@@ -1169,6 +1477,12 @@ version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be"
+[[package]]
+name = "version_check"
+version = "0.9.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
+
[[package]]
name = "want"
version = "0.3.1"
@@ -1474,6 +1788,31 @@ version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9edde0db4769d2dc68579893f2306b26c6ecfbe0ef499b013d731b7b9247e0b9"
+[[package]]
+name = "x25519-dalek"
+version = "2.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c7e468321c81fb07fa7f4c636c3972b9100f0346e5b6a9f2bd0603a52f7ed277"
+dependencies = [
+ "curve25519-dalek",
+ "rand_core 0.6.4",
+ "serde",
+ "zeroize",
+]
+
+[[package]]
+name = "xsalsa20poly1305"
+version = "0.9.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "02a6dad357567f81cd78ee75f7c61f1b30bb2fe4390be8fb7c69e2ac8dffb6c7"
+dependencies = [
+ "aead",
+ "poly1305",
+ "salsa20",
+ "subtle",
+ "zeroize",
+]
+
[[package]]
name = "yoke"
version = "0.8.1"
@@ -1543,6 +1882,20 @@ name = "zeroize"
version = "1.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0"
+dependencies = [
+ "zeroize_derive",
+]
+
+[[package]]
+name = "zeroize_derive"
+version = "1.4.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "85a5b4158499876c763cb03bc4e49185d3cccbabb15b33c627f7884f43db852e"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
[[package]]
name = "zerotrie"