Repository navigation
feat: add client-side crypto and vault file indexing - #65
Merged
Merged
Conversation
Two independent client-side pieces that push/pull will build on: internal/client/vault scans a vault directory into a file index (relative path, size, mtime, SHA-256 content hash), and internal/client/crypto derives an AES-256 key from a passphrase via Argon2id and does AES-GCM encrypt/decrypt. vault.ScanVault: stats the root first so a bad/nonexistent path returns a clean error instead of panicking through WalkDir on a nil DirEntry, checks the walk callback's own error instead of ignoring it (an unreadable subdirectory now surfaces an error rather than silently vanishing from the index), and uses filepath.Rel so nested files with the same basename don't collide. Content hash streams the file through SHA-256 rather than buffering it whole. crypto.DeriveKey wraps argon2.IDKey (t=1, 2GiB memory, p=4, 32-byte key - OWASP's "uniformly safe" high-memory recommendation). Encrypt/Decrypt wrap AES-GCM, generating a random nonce per Encrypt call and prepending it to the ciphertext; Decrypt splits it back off before authenticating. A wrong key or a tampered/truncated ciphertext fails cleanly instead of returning garbage.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two independent client-side pieces that push/pull will build on: internal/client/vault scans a vault directory into a file index (relative path, size, mtime, SHA-256 content hash), and internal/client/crypto derives an AES-256 key from a passphrase via Argon2id and does AES-GCM encrypt/decrypt.
vault.ScanVault: stats the root first so a bad/nonexistent path returns a clean error instead of panicking through WalkDir on a nil DirEntry, checks the walk callback's own error instead of ignoring it (an unreadable subdirectory now surfaces an error rather than silently vanishing from the index), and uses filepath.Rel so nested files with the same basename don't collide. Content hash streams the file through SHA-256 rather than buffering it whole.
crypto.DeriveKey wraps argon2.IDKey (t=1, 2GiB memory, p=4, 32-byte key - OWASP's "uniformly safe" high-memory recommendation). Encrypt/Decrypt wrap AES-GCM, generating a random nonce per Encrypt call and prepending it to the ciphertext; Decrypt splits it back off before authenticating. A wrong key or a tampered/truncated ciphertext fails cleanly instead of returning garbage.