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

Update dependencies #89

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
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: "Aries-Askar"

env:
RUST_VERSION: "1.58.0"
RUST_VERSION: "1.60.0"
CROSS_VERSION: "0.2.4"

on:
Expand Down
10 changes: 6 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ members = ["askar-bbs", "askar-crypto"]
name = "aries-askar"
version = "0.2.8-dev.3"
authors = ["Hyperledger Aries Contributors <aries@lists.hyperledger.org>"]
edition = "2018"
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.60"

[lib]
name = "aries_askar"
Expand Down Expand Up @@ -50,7 +51,7 @@ futures-lite = "1.11"
hex = "0.4"
hmac = "0.12"
itertools = "0.10"
jemallocator = { version = "0.3", optional = true }
jemallocator = { version = "0.5", optional = true }
log = { version = "0.4", optional = true }
num_cpus = { version = "1.0", optional = true }
once_cell = "1.5"
Expand All @@ -63,7 +64,7 @@ serde_json = "1.0"
sha2 = "0.10"
tokio = { version = "1.5", features = ["time"] }
url = { version = "2.1", default-features = false }
uuid = { version = "0.8", features = ["v4"] }
uuid = { version = "1.2", features = ["v4"] }
zeroize = "1.4"

[dependencies.askar-crypto]
Expand All @@ -72,14 +73,15 @@ path = "./askar-crypto"
features = ["all_keys", "any_key", "argon2", "crypto_box", "std"]

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

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason behind abort?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It removes the panic unwinding, because a panic can't cross the FFI boundary and it potentially leaves things in an invalid state. This makes the binary smaller as well.


[[test]]
name = "backends"
11 changes: 5 additions & 6 deletions askar-crypto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
name = "askar-crypto"
version = "0.2.5"
authors = ["Hyperledger Aries Contributors <aries@lists.hyperledger.org>"]
edition = "2018"
edition = "2021"
description = "Hyperledger Aries Askar cryptography"
license = "MIT OR Apache-2.0"
readme = "README.md"
repository = "https://github.com/hyperledger/aries-askar/"
categories = ["cryptography", "no-std"]
keywords = ["hyperledger", "aries", "didcomm", "ssi"]
rust-version = "1.60"

[package.metadata.docs.rs]
features = ["argon2", "std"]
Expand All @@ -31,12 +32,10 @@ std_rng = ["getrandom", "rand/std", "rand/std_rng"]

[dev-dependencies]
base64 = { version = "0.13", default-features = false, features = ["alloc"] }
criterion = "0.3"
# override transitive dependency from criterion to support rust versions older than 1.60
csv = "=1.1"
criterion = "0.4"
hex-literal = "0.3"
serde_cbor = "0.11"
serde-json-core = { version = "0.4", default-features = false, features = ["std"] }
serde-json-core = { version = "0.5", default-features = false, features = ["std"] }

[[bench]]
name = "enc"
Expand Down Expand Up @@ -70,7 +69,7 @@ k256 = { version = "0.10", default-features = false, features = ["arithmetic", "
p256 = { version = "0.10", default-features = false, features = ["arithmetic", "ecdsa", "ecdh"], optional = true }
rand = { version = "0.8", default-features = false }
serde = { version = "1.0", default-features = false, features = ["derive"] }
serde-json-core = { version = "0.4", default-features = false }
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 }
Expand Down
38 changes: 19 additions & 19 deletions askar-crypto/benches/enc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,96 +21,96 @@ fn criterion_benchmark(c: &mut Criterion) {

let mut message = vec![0u8; MSG_SIZE];
fill_random(&mut message[..]);
let message = &message[..];
let message = message.as_slice();

c.bench_function(&format!("random nonce"), move |b| {
b.iter(|| AesKey::<A128Gcm>::random_nonce())
c.bench_function("random nonce", move |b| {
b.iter(AesKey::<A128Gcm>::random_nonce)
});
c.bench_function(&format!("aes128gcm encrypt"), move |b| {
c.bench_function("aes128gcm encrypt", move |b| {
let key = AesKey::<A128Gcm>::random().unwrap();
let nonce = AesKey::<A128Gcm>::random_nonce();
let mut buffer = Vec::with_capacity(ALLOC_SIZE);
b.iter(|| {
buffer.clear();
buffer.extend_from_slice(black_box(&message[..]));
buffer.extend_from_slice(black_box(message));
key.encrypt_in_place(&mut buffer, &nonce, &[]).unwrap();
})
});
c.bench_function(&format!("aes256gcm encrypt"), move |b| {
c.bench_function("aes256gcm encrypt", move |b| {
let key = AesKey::<A256Gcm>::random().unwrap();
let nonce = AesKey::<A256Gcm>::random_nonce();
let mut buffer = Vec::with_capacity(ALLOC_SIZE);
b.iter(|| {
buffer.clear();
buffer.extend_from_slice(black_box(&message[..]));
buffer.extend_from_slice(black_box(message));
key.encrypt_in_place(&mut buffer, &nonce, &[]).unwrap();
})
});

c.bench_function(&format!("aes128cbc-hs256 encrypt"), move |b| {
c.bench_function("aes128cbc-hs256 encrypt", move |b| {
let key = AesKey::<A128CbcHs256>::random().unwrap();
let nonce = AesKey::<A128CbcHs256>::random_nonce();
let mut buffer = Vec::with_capacity(ALLOC_SIZE);
b.iter(|| {
buffer.clear();
buffer.extend_from_slice(black_box(&message[..]));
buffer.extend_from_slice(black_box(message));
key.encrypt_in_place(&mut buffer, &nonce, &[]).unwrap();
})
});
c.bench_function(&format!("aes256cbc-hs512 encrypt"), move |b| {
c.bench_function("aes256cbc-hs512 encrypt", move |b| {
let key = AesKey::<A256CbcHs512>::random().unwrap();
let nonce = AesKey::<A256CbcHs512>::random_nonce();
let mut buffer = Vec::with_capacity(ALLOC_SIZE);
b.iter(|| {
buffer.clear();
buffer.extend_from_slice(black_box(&message[..]));
buffer.extend_from_slice(black_box(message));
key.encrypt_in_place(&mut buffer, &nonce, &[]).unwrap();
})
});

c.bench_function(&format!("chacha20-poly1305 encrypt"), move |b| {
c.bench_function("chacha20-poly1305 encrypt", move |b| {
let key = Chacha20Key::<C20P>::random().unwrap();
let nonce = Chacha20Key::<C20P>::random_nonce();
let mut buffer = Vec::with_capacity(ALLOC_SIZE);
b.iter(|| {
buffer.clear();
buffer.extend_from_slice(black_box(&message[..]));
buffer.extend_from_slice(black_box(message));
key.encrypt_in_place(&mut buffer, &nonce, &[]).unwrap();
})
});
c.bench_function(&format!("xchacha20-poly1305 encrypt"), move |b| {
c.bench_function("xchacha20-poly1305 encrypt", move |b| {
let key = Chacha20Key::<XC20P>::random().unwrap();
let nonce = Chacha20Key::<XC20P>::random_nonce();
let mut buffer = Vec::with_capacity(ALLOC_SIZE);
b.iter(|| {
buffer.clear();
buffer.extend_from_slice(black_box(&message[..]));
buffer.extend_from_slice(black_box(message));
key.encrypt_in_place(&mut buffer, &nonce, &[]).unwrap();
})
});

// test overhead of SecretBytes
c.bench_function(&format!("chacha20-poly1305 encrypt alloc"), move |b| {
c.bench_function("chacha20-poly1305 encrypt alloc", move |b| {
let key = Chacha20Key::<C20P>::random().unwrap();
let nonce = Chacha20Key::<C20P>::random_nonce();
let mut buffer = SecretBytes::with_capacity(ALLOC_SIZE);
b.iter(|| {
buffer.clear();
buffer.buffer_write(black_box(&message[..])).unwrap();
buffer.buffer_write(black_box(message)).unwrap();
key.encrypt_in_place(&mut buffer, &nonce, &[]).unwrap();
})
});

// test overhead of AnyKey
c.bench_function(&format!("chacha20-poly1305 encrypt as any"), move |b| {
c.bench_function("chacha20-poly1305 encrypt as any", move |b| {
let key = Box::<AnyKey>::random(KeyAlg::Chacha20(Chacha20Types::C20P)).unwrap();
let mut nonce = [0u8; 255];
let nonce_len = key.aead_params().nonce_length;
fill_random(&mut nonce[..nonce_len]);
let mut buffer = Vec::with_capacity(ALLOC_SIZE);
b.iter(|| {
buffer.clear();
buffer.extend_from_slice(black_box(&message[..]));
buffer.extend_from_slice(black_box(message));
key.encrypt_in_place(&mut buffer, &nonce[..nonce_len], &[])
.unwrap();
})
Expand Down
2 changes: 1 addition & 1 deletion askar-crypto/benches/kdf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fn criterion_benchmark(c: &mut Criterion) {
prv_info: &[],
};

c.bench_function(&format!("concat kdf sha256"), move |b| {
c.bench_function("concat kdf sha256", move |b| {
b.iter(|| {
let mut output = [0u8; 32];
ConcatKDF::<Sha256>::derive_key(black_box(message), black_box(params), &mut output)
Expand Down
10 changes: 5 additions & 5 deletions askar-crypto/src/alg/aes/key_wrap.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! AES key wrap

use core::{convert::TryInto, marker::PhantomData};
use core::marker::PhantomData;

use aes_core::{Aes128, Aes256};
use block_modes::cipher::{BlockCipher, BlockDecrypt, BlockEncrypt, NewBlockCipher};
Expand Down Expand Up @@ -64,10 +64,10 @@ where
nonce: &[u8],
aad: &[u8],
) -> Result<usize, Error> {
if nonce.len() != 0 {
if !nonce.is_empty() {
return Err(err_msg!(Unsupported, "Custom nonce not supported"));
}
if aad.len() != 0 {
if !aad.is_empty() {
return Err(err_msg!(Unsupported, "AAD not supported"));
}
let mut buf_len = buffer.as_ref().len();
Expand Down Expand Up @@ -108,10 +108,10 @@ where
nonce: &[u8],
aad: &[u8],
) -> Result<(), Error> {
if nonce.len() != 0 {
if !nonce.is_empty() {
return Err(err_msg!(Unsupported, "Custom nonce not supported"));
}
if aad.len() != 0 {
if !aad.is_empty() {
return Err(err_msg!(Unsupported, "AAD not supported"));
}
if buffer.as_ref().len() % 8 != 0 {
Expand Down
2 changes: 1 addition & 1 deletion askar-crypto/src/alg/aes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ mod key_wrap;
pub use key_wrap::{A128Kw, A256Kw};

/// The 'kty' value of a symmetric key JWK
pub static JWK_KEY_TYPE: &'static str = "oct";
pub static JWK_KEY_TYPE: &str = "oct";

/// Trait implemented by supported AES authenticated encryption algorithms
pub trait AesType: 'static {
Expand Down
64 changes: 25 additions & 39 deletions askar-crypto/src/alg/any.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use alloc::{boxed::Box, sync::Arc};
#[cfg(feature = "ed25519")]
use core::convert::TryFrom;
use core::{
any::{Any, TypeId},
fmt::Debug,
Expand Down Expand Up @@ -230,12 +228,10 @@ fn generate_any<R: AllocKey>(alg: KeyAlg, rng: impl KeyMaterial) -> Result<R, Er
#[cfg(feature = "p256")]
KeyAlg::EcCurve(EcCurves::Secp256r1) => P256KeyPair::generate(rng).map(R::alloc_key),
#[allow(unreachable_patterns)]
_ => {
return Err(err_msg!(
Unsupported,
"Unsupported algorithm for key generation"
))
}
_ => Err(err_msg!(
Unsupported,
"Unsupported algorithm for key generation"
)),
}
}

Expand Down Expand Up @@ -267,12 +263,10 @@ fn from_public_bytes_any<R: AllocKey>(alg: KeyAlg, public: &[u8]) -> Result<R, E
P256KeyPair::from_public_bytes(public).map(R::alloc_key)
}
#[allow(unreachable_patterns)]
_ => {
return Err(err_msg!(
Unsupported,
"Unsupported algorithm for public key import"
))
}
_ => Err(err_msg!(
Unsupported,
"Unsupported algorithm for public key import"
)),
}
}

Expand Down Expand Up @@ -336,12 +330,10 @@ fn from_secret_bytes_any<R: AllocKey>(alg: KeyAlg, secret: &[u8]) -> Result<R, E
P256KeyPair::from_secret_bytes(secret).map(R::alloc_key)
}
#[allow(unreachable_patterns)]
_ => {
return Err(err_msg!(
Unsupported,
"Unsupported algorithm for secret key import"
))
}
_ => Err(err_msg!(
Unsupported,
"Unsupported algorithm for secret key import"
)),
}
}

Expand Down Expand Up @@ -387,12 +379,10 @@ where
Chacha20Key::<XC20P>::from_key_exchange(secret, public).map(R::alloc_key)
}
#[allow(unreachable_patterns)]
_ => {
return Err(err_msg!(
Unsupported,
"Unsupported algorithm for key exchange"
));
}
_ => Err(err_msg!(
Unsupported,
"Unsupported algorithm for key exchange"
)),
}
}

Expand Down Expand Up @@ -449,12 +439,10 @@ fn from_key_derivation_any<R: AllocKey>(
Chacha20Key::<XC20P>::from_key_derivation(derive).map(R::alloc_key)
}
#[allow(unreachable_patterns)]
_ => {
return Err(err_msg!(
Unsupported,
"Unsupported algorithm for key derivation"
));
}
_ => Err(err_msg!(
Unsupported,
"Unsupported algorithm for key derivation"
)),
}
}

Expand Down Expand Up @@ -486,12 +474,10 @@ fn convert_key_any<R: AllocKey>(key: &AnyKey, alg: KeyAlg) -> Result<R, Error> {
)
.map(R::alloc_key)?),
#[allow(unreachable_patterns)]
_ => {
return Err(err_msg!(
Unsupported,
"Unsupported key conversion operation"
))
}
_ => Err(err_msg!(
Unsupported,
"Unsupported key conversion operation"
)),
}
}

Expand Down Expand Up @@ -714,7 +700,7 @@ impl KeyExchange for AnyKey {
#[allow(unreachable_patterns)]
_ => {
let _ = out;
return Err(err_msg!(Unsupported, "Unsupported key exchange"));
Err(err_msg!(Unsupported, "Unsupported key exchange"))
}
}
}
Expand Down
Loading