Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
[target.'cfg(target_arch = "aarch64")']
rustflags = ["--cfg", "aes_armv8"]

# getrandom 0.3 (through turso_core) needs this cfg to pick its Web Crypto
# backend on wasm32-unknown-unknown. Only a backend selection, never a URL.
[target.wasm32-unknown-unknown]
rustflags = ["--cfg", 'getrandom_backend="wasm_js"']

[target.wasm32-wasip1]
runner = "wasmtime run --dir=."
45 changes: 41 additions & 4 deletions .github/workflows/cryptex.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: Cryptex CI

permissions:
contents: read

on:
push:
branches: main
Expand Down Expand Up @@ -46,7 +49,7 @@ jobs:
- name: Install native dependencies for encrypted-vfs and YubiHSM
run: sudo apt-get install -y libclang-dev libusb-1.0-0-dev
- run: cargo clippy --no-default-features --features encrypted-vfs -- -D warnings
- run: cargo clippy --all-targets --all-features -- -D warnings
- run: cargo clippy --all-targets --features "file,serde,encrypted-vfs,memory,turso,turso-encrypted-io,yubihsm-usb,yubihsm-http" -- -D warnings

clippy-macos:
runs-on: macos-latest
Expand Down Expand Up @@ -82,6 +85,39 @@ jobs:
- run: cargo clippy --no-default-features --features "windows-credentials,file" -- -D warnings
- run: cargo clippy --no-default-features --features encrypted-vfs -- -D warnings

wasm:
runs-on: ubuntu-latest
env:
# The workflow-level RUSTFLAGS override the per-target flags in
# .cargo/config.toml, so the getrandom backend is repeated here.
RUSTFLAGS: '-D warnings --cfg getrandom_backend="wasm_js"'
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
components: clippy
targets: wasm32-unknown-unknown,wasm32-wasip1,wasm32-wasip2
# WASI takes getrandom's WASI backend, so its checks drop the wasm_js cfg.
- name: Check browser and WASI backends
run: |
cargo clippy --target wasm32-unknown-unknown --no-default-features --features turso -- -D warnings
cargo clippy --target wasm32-unknown-unknown --no-default-features --features "turso,turso-encrypted-io" -- -D warnings
cargo clippy --target wasm32-unknown-unknown --no-default-features --features memory -- -D warnings
cargo clippy --target wasm32-unknown-unknown --no-default-features --features "turso,turso-opfs,indexeddb,web-storage,js" -- -D warnings
RUSTFLAGS="-D warnings" cargo check --target wasm32-wasip1 --no-default-features --features "turso,memory"
RUSTFLAGS="-D warnings" cargo check --target wasm32-wasip2 --no-default-features --features "turso,memory"
- name: Install wasm-pack
# Pinned and built from the registry: piping an unpinned installer
# script into a shell runs whatever that URL serves today.
run: cargo install wasm-pack --locked --version 0.13.1
- name: Build the JavaScript package
run: wasm-pack build --target web --no-default-features --features js
# The runner image ships Chrome with a matching ChromeDriver; a separately
# installed driver tracks a newer Chrome and refuses the image's browser.
- name: Run the browser tests
run: wasm-pack test --headless --chrome --chromedriver "$CHROMEWEBDRIVER/chromedriver" --no-default-features --features js --test wasm

rustfmt-linux:
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -123,7 +159,7 @@ jobs:
- name: Install native dependencies for encrypted-vfs and YubiHSM
run: sudo apt-get install -y libclang-dev libusb-1.0-0-dev
- run: cargo doc --no-default-features --features encrypted-vfs
- run: cargo doc --no-deps --all-features
- run: cargo doc --no-deps --features "file,serde,encrypted-vfs,memory,turso,turso-encrypted-io,yubihsm-usb,yubihsm-http"

doc-macos:
runs-on: macos-latest
Expand Down Expand Up @@ -191,7 +227,7 @@ jobs:
run: cargo test --test default_argon2_params --no-default-features --features "file,encrypted-vfs"
- name: Test all features
if: matrix.cache-key == 'encrypted-vfs'
run: cargo test --all-features
run: cargo test --features "file,serde,encrypted-vfs,memory,turso,turso-encrypted-io,yubihsm-usb,yubihsm-http"

macos:
runs-on: macos-latest
Expand Down Expand Up @@ -289,7 +325,8 @@ jobs:
toolchain: nightly
- uses: cargo-bins/cargo-binstall@main
- run: cargo binstall --no-confirm cargo-outdated
- run: cargo outdated --root-deps-only --exit-code=1
# bindgen must match sqlite-plugin's 0.72 to turn on its `runtime` feature.
- run: cargo outdated --root-deps-only --exit-code=1 --ignore bindgen

pants:
runs-on: ubuntu-latest
Expand Down
108 changes: 96 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,22 @@ keywords = ["secrets", "vault", "keyring"]
license = "MIT/Apache-2.0"
repository = "https://github.com/mikelodder7/cryptex"
readme = "README.md"
version = "2.4.0"
version = "2.5.0"

# `all-features` is not used: the browser-only features (web-storage,
# indexeddb, opfs, js) are rejected on non-wasm targets on purpose.
[package.metadata.docs.rs]
all-features = true
no-default-features = true
features = [
"serde",
"file",
"encrypted-vfs",
"memory",
"turso",
"turso-encrypted-io",
"yubihsm-usb",
"yubihsm-http",
]
rustdoc-args = ["--cfg", "docsrs"]

[package.metadata.cargo-udeps.ignore]
Expand All @@ -31,8 +43,35 @@ name = "cryptex"
[features]
default = ["linux-secret-service", "macos-keychain", "windows-credentials"]
file = ["dep:argon2", "dep:dirs", "dep:rusqlite", "rusqlite/bundled-sqlcipher-vendored-openssl"]
memory = ["dep:argon2", "dep:chacha20poly1305", "dep:aes-gcm", "dep:getrandom"]
web-storage = [
"memory",
"dep:web-sys",
"dep:wasm-bindgen",
"dep:wasm-bindgen-futures",
"dep:js-sys",
]
indexeddb = ["memory", "dep:web-sys", "dep:wasm-bindgen", "dep:wasm-bindgen-futures", "dep:js-sys"]
turso-opfs = [
"turso",
"dep:web-sys",
"dep:wasm-bindgen",
"dep:wasm-bindgen-futures",
"dep:js-sys",
]
js = [
"memory",
"web-storage",
"indexeddb",
"turso-opfs",
"turso",
"dep:web-sys",
"dep:wasm-bindgen",
"dep:wasm-bindgen-futures",
"dep:js-sys",
]
encrypted-vfs = ["dep:argon2", "dep:dirs", "dep:rusqlite", "rusqlite/bundled", "dep:chacha20poly1305", "dep:aes-gcm", "dep:sqlite-plugin", "dep:getrandom"]
turso = ["dep:argon2", "dep:dirs", "dep:turso", "dep:bindgen"]
turso = ["dep:argon2", "dep:dirs", "dep:turso", "dep:bindgen", "dep:js-sys", "dep:wasm-bindgen"]
turso-encrypted-io = ["dep:argon2", "dep:dirs", "dep:turso", "dep:bindgen", "dep:chacha20poly1305", "dep:aes-gcm", "dep:getrandom"]
linux-secret-service = ["secret-service", "uzers"]
macos-keychain = ["security-framework", "security-framework-sys", "core-foundation", "core-foundation-sys", "uzers"]
Expand All @@ -42,30 +81,75 @@ yubihsm-usb = ["dep:yubihsm", "yubihsm/usb", "yubihsm/passwords", "dep:aes-gcm",
yubihsm-http = ["dep:yubihsm", "yubihsm/http", "yubihsm/passwords", "dep:aes-gcm", "dep:sha2", "dep:getrandom", "dep:dirs"]

[dependencies]
aes-gcm = { version = "0.11", optional = true }
argon2 = { version = "0.5", optional = true }
chacha20poly1305 = { version = "0.11", optional = true }
aes-gcm = { version = "0.11", features = ["zeroize"], optional = true }
argon2 = { version = "0.6", optional = true }
chacha20poly1305 = { version = "0.11", features = ["zeroize"], optional = true }
clap = "4.6.1"
colored = "3.0"
dirs = { version = "6.0", optional = true }
dirs = { version = "7.0", optional = true }
getrandom = { version = "0.4.3", optional = true }
hex = "0.4"
postcard = { version = "1", default-features = false, features = ["use-std"], optional = true }
rpassword = "7.5.4"
rusqlite = { version = "0.40.1", default-features = false, optional = true }
rusqlite = { version = "0.43", default-features = false, optional = true }
serde = { version = "1", optional = true }
sha2 = { version = "0.11", optional = true }
sqlite-plugin = { version = "0.10", optional = true }
sqlite-plugin = { version = "0.11", optional = true }
subtle = "2"
# Pre-release pinned exactly: page encryption and custom IO are only exposed here.
turso = { version = "=0.9.0-pre.1", default-features = false, optional = true }
turso = { version = "=0.9.0-pre.6", default-features = false, optional = true }
whoami = "2.1.2"
yubihsm = { version = "0.42", default-features = false, optional = true }
zeroize = { version = "1.9.0", features = ["zeroize_derive"] }

[dev-dependencies]
[target.'cfg(not(target_family = "wasm"))'.dependencies]
rpassword = "7.5.4"

# Criterion pulls in Rayon, which does not build for wasm.
[target.'cfg(not(target_family = "wasm"))'.dev-dependencies]
criterion = { version = "0.8", features = ["html_reports"] }

[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dependencies]
getrandom = { version = "0.4.3", features = ["wasm_js"], optional = true }
js-sys = { version = "0.3", optional = true }
wasm-bindgen = { version = "0.2.130", optional = true }
wasm-bindgen-futures = { version = "0.4", optional = true }
web-sys = { version = "0.3", optional = true, features = [
"Window",
"Storage",
"Performance",
"WorkerGlobalScope",
"WorkerNavigator",
"StorageManager",
"LockManager",
"LockManagerSnapshot",
"Lock",
"IdbFactory",
"IdbDatabase",
"IdbOpenDbRequest",
"IdbObjectStore",
"IdbTransaction",
"IdbTransactionMode",
"DomException",
"IdbRequest",
"FileSystemDirectoryHandle",
"FileSystemGetDirectoryOptions",
"FileSystemFileHandle",
"FileSystemGetFileOptions",
"FileSystemSyncAccessHandle",
"FileSystemReadWriteOptions",
] }

# Turso's native page encryption on wasm must use its pure-Rust ciphers;
# the native `aegis` build links C.
[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dependencies.turso]
version = "=0.9.0-pre.6"
default-features = false
features = ["pure-rust-crypto"]
optional = true

[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dev-dependencies]
wasm-bindgen-test = "0.3"

[[bench]]
name = "cipher_bench"
harness = false
Expand Down
Loading
Loading