Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor storage into a separate crate #90

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
52 changes: 13 additions & 39 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace]
members = ["askar-bbs", "askar-crypto"]
members = ["askar-bbs", "askar-crypto", "askar-storage"]

[package]
name = "aries-askar"
Expand All @@ -26,65 +26,39 @@ rustdoc-args = ["--cfg", "docsrs"]

[features]
default = ["all_backends", "ffi", "logger", "migration"]
all_backends = ["any", "postgres", "sqlite"]
any = []
ffi = ["any", "ffi-support", "logger"]
all_backends = ["postgres", "sqlite"]
ffi = ["ffi-support", "logger"]
jemalloc = ["jemallocator"]
logger = ["env_logger", "log"]
postgres = ["sqlx", "sqlx/postgres", "sqlx/tls"]
sqlite = ["num_cpus", "sqlx", "sqlx/sqlite"]
pg_test = ["postgres"]
migration = ["rmp", "rmp-serde"]

[dev-dependencies]
hex-literal = "0.3"
logger = ["env_logger", "log", "askar-storage/log"]
postgres = ["askar-storage/postgres"]
sqlite = ["askar-storage/sqlite"]
pg_test = ["askar-storage/pg_test"]
migration = ["askar-storage/migration"]

[dependencies]
arc-swap = "1.6"
async-lock = "2.5"
async-stream = "0.3"
bs58 = "0.4"
chrono = "0.4"
digest = "0.10"
env_logger = { version = "0.9", optional = true }
ffi-support = { version = "0.4", optional = true }
futures-lite = "1.11"
hex = "0.4"
hmac = "0.12"
itertools = "0.10"
jemallocator = { version = "0.5", optional = true }
log = { version = "0.4", optional = true }
num_cpus = { version = "1.0", optional = true }
once_cell = "1.5"
percent-encoding = "2.0"
rand = { version = "0.8", default-features = false }
rmp = { version = "0.8.11", optional = true }
rmp-serde = { version = "1.1.1", optional = true }
serde = { version = "1.0", features = ["derive"] }
serde_bytes = "0.11"
serde_cbor = "0.11"
serde_json = "1.0"
sha2 = "0.10"
tokio = { version = "1.5", features = ["time"] }
url = { version = "2.1", default-features = false }
uuid = { version = "1.2", features = ["v4"] }
zeroize = "1.4"
zeroize = "1.5"

[dependencies.askar-crypto]
version = "0.2.5"
path = "./askar-crypto"
features = ["all_keys", "any_key", "argon2", "crypto_box", "std"]

[dependencies.sqlx]
version = "0.6.2"
[dependencies.askar-storage]
version = "0.1.0"
path = "./askar-storage"
default-features = false
features = ["chrono", "runtime-tokio-rustls", "macros"]
optional = true
features = ["any"]

[profile.release]
codegen-units = 1
lto = true
panic = "abort"

[[test]]
name = "backends"
2 changes: 1 addition & 1 deletion askar-bbs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ subtle = "2.4"
criterion = "0.3"
# override transitive dependency from criterion to support rust versions older than 1.60
csv = "=1.1"
hex-literal = "0.3"
hex-literal = "0.4"
serde-json-core = { version = "0.4", default-features = false, features = ["std"] }


Expand Down
8 changes: 4 additions & 4 deletions askar-crypto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ std_rng = ["getrandom", "rand/std", "rand/std_rng"]
[dev-dependencies]
base64 = { version = "0.13", default-features = false, features = ["alloc"] }
criterion = "0.4"
hex-literal = "0.3"
hex-literal = "0.4"
serde_cbor = "0.11"
serde-json-core = { version = "0.5", default-features = false, features = ["std"] }

Expand All @@ -55,8 +55,8 @@ base64 = { version = "0.13", default-features = false }
blake2 = { version = "0.10", default-features = false }
block-modes = { version = "0.8", default-features = false, optional = true }
bls12_381 = { version = "0.6", default-features = false, features = ["groups", "zeroize"], optional = true }
chacha20 = { version = "0.7" } # should match chacha20poly1305
chacha20poly1305 = { version = "0.8", default-features = false, optional = true }
chacha20 = { version = "0.8" } # should match dependency of chacha20poly1305
chacha20poly1305 = { version = "0.9", default-features = false, optional = true }
crypto_box_rs = { package = "crypto_box", version = "0.6", default-features = false, features = ["u64_backend"], optional = true }
curve25519-dalek = { version = "3.1", default-features = false, features = ["u64_backend"], optional = true }
ed25519-dalek = { version = "1.0", default-features = false, features = ["u64_backend"], optional = true }
Expand All @@ -73,4 +73,4 @@ serde-json-core = { version = "0.5", default-features = false }
subtle = "2.4"
sha2 = { version = "0.10", default-features = false }
x25519-dalek = { version = "=1.1", default-features = false, features = ["u64_backend"], optional = true }
zeroize = { version = "1.4", features = ["zeroize_derive"] }
zeroize = { version = "1.5", features = ["zeroize_derive"] }
2 changes: 1 addition & 1 deletion askar-crypto/src/buffer/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ impl<L: ArrayLength<u8>> From<GenericArray<u8, L>> for ArrayKey<L> {
impl<L: ArrayLength<u8>> Debug for ArrayKey<L> {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
if cfg!(test) {
f.debug_tuple("ArrayKey").field(&*self).finish()
f.debug_tuple("ArrayKey").field(&self.0).finish()
} else {
f.debug_tuple("ArrayKey").field(&"<secret>").finish()
}
Expand Down
2 changes: 1 addition & 1 deletion askar-crypto/src/jwk/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ pub fn write_jwk_thumbprint<K: ToJwk + ?Sized>(
buf.finalize()?;
let hash = hasher.finalize();
let mut buf = [0u8; 43];
let len = base64::encode_config_slice(&hash, base64::URL_SAFE_NO_PAD, &mut buf);
let len = base64::encode_config_slice(hash, base64::URL_SAFE_NO_PAD, &mut buf);
output.buffer_write(&buf[..len])?;
Ok(())
}
Expand Down
70 changes: 70 additions & 0 deletions askar-storage/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
[package]
name = "askar-storage"
version = "0.1.0"
authors = ["Hyperledger Aries Contributors <aries@lists.hyperledger.org>"]
edition = "2021"
description = "Hyperledger Aries Askar secure storage"
license = "MIT OR Apache-2.0"
readme = "README.md"
repository = "https://github.com/hyperledger/aries-askar/"
categories = ["cryptography", "database"]
keywords = ["hyperledger", "aries", "ssi", "verifiable", "credentials"]
rust-version = "1.58"

[package.metadata.docs.rs]
features = ["all_backends"]
no-default-features = true
rustdoc-args = ["--cfg", "docsrs"]

[features]
default = ["all_backends", "log"]
all_backends = ["any", "postgres", "sqlite"]
any = []
berendsliedrecht marked this conversation as resolved.
Show resolved Hide resolved
migration = ["rmp-serde", "sqlx/macros"]
postgres = ["sqlx", "sqlx/postgres", "sqlx/tls"]
sqlite = ["sqlx", "sqlx/sqlite"]
pg_test = ["postgres"]

[dependencies]
arc-swap = "1.6"
async-lock = "2.5"
async-stream = "0.3"
bs58 = "0.4"
chrono = "0.4"
digest = "0.10"
futures-lite = "1.11"
hex = "0.4"
hmac = "0.12"
itertools = "0.10"
log = { version = "0.4", optional = true }
once_cell = "1.5"
percent-encoding = "2.0"
rmp-serde = { version= "1.1", optional = true }
serde = { version = "1.0", features = ["derive"] }
serde_cbor = "0.11"
serde_json = "1.0"
sha2 = "0.10"
tokio = { version = "1.5", features = ["time"] }
url = { version = "2.1", default-features = false }
uuid = { version = "1.2", features = ["v4"] }
zeroize = "1.5"

[dependencies.askar-crypto]
version = "0.2.5"
path = "../askar-crypto"
default-features = false
features = ["alloc", "argon2", "chacha", "std_rng"]

[dependencies.sqlx]
version = "0.6.2"
default-features = false
features = ["chrono", "runtime-tokio-rustls"]
optional = true

[dev-dependencies]
env_logger = "0.9"
hex-literal = "0.4"
rand = { version = "0.8" }

[[test]]
name = "backends"
Loading