[package]
name = "sd-crypto"
version = "0.0.0"
authors = ["Jake Robinson <jake@spacedrive.com>"]
readme = "README.md"
description = "A library to handle cryptographic functions within Spacedrive"
rust-version = "1.67.0"
license = { workspace = true }
repository = { workspace = true }
edition = { workspace = true }

[features]
rspc = ["dep:rspc", "dep:specta"]
specta = ["dep:specta"]
serde = ["dep:serde", "dep:serde_json", "dep:serde-big-array", "uuid/serde"]
keymanager = ["dep:dashmap", "os-keyrings"]
os-keyrings = ["dep:secret-service", "dep:security-framework"]

[dependencies]
# rng
rand = "0.8.5"
rand_chacha = "0.3.1"

# hashing
argon2 = "0.5.0"
balloon-hash = "0.4.0"
blake3 = { version = "1.3.3", features = ["traits-preview"] }

# aeads
aes-gcm = "0.10.1"
chacha20poly1305 = "0.10.1"
aead = { version = "0.5.1", features = ["stream"] }

# cryptographic hygiene
zeroize = "1.5.7"

# error handling
thiserror = "1.0.37"

# metadata de/serialization
serde = { version = "1.0", features = ["derive"], optional = true }
serde_json = { version = "1.0", optional = true }
serde-big-array = { version = "0.5.1", optional = true }

# for storedkey organisation and handling
uuid = { version = "1.1.2", features = ["v4"] }

# better concurrency for the keymanager
dashmap = { version = "5.4.0", optional = true }

# optional, for support with rspc
rspc = { workspace = true, features = [], optional = true }
specta = { workspace = true, features = ["uuid"], optional = true }

# for asynchronous crypto
tokio = { workspace = true, features = ["io-util", "rt-multi-thread", "sync"] }

hex = "0.4.3"

# linux OS keyring - using `v2.0.2` as newer versions broke a lot due to async/lifetimes
[target.'cfg(target_os = "linux")'.dependencies]
secret-service = { version = "2.0.2", optional = true }

# macos/ios OS keyring
[target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies]
security-framework = { version = "2.8.1", optional = true }

[dev-dependencies]
tokio = { workspace = true, features = [
	"fs",
	"macros",
] } # features needed for examples
