Skip to content
This repository has been archived by the owner on Mar 11, 2024. It is now read-only.

Commit

Permalink
[version]: Bump trivial dependencies
Browse files Browse the repository at this point in the history
Signed-off-by: Aleksandr Petrosyan <[email protected]>
  • Loading branch information
appetrosyan committed Feb 20, 2023
1 parent cb56546 commit 0ee4c27
Show file tree
Hide file tree
Showing 8 changed files with 532 additions and 440 deletions.
786 changes: 444 additions & 342 deletions libursa/Cargo.lock

Large diffs are not rendered by default.

56 changes: 28 additions & 28 deletions libursa/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -113,50 +113,50 @@ aes = { version = "0.6", optional = true }
aes-gcm = { version = "0.8", optional = true }
amcl = { version = "0.2", optional = true, default-features = false, features = ["bn254"]}
amcl_wrapper = {version = "0.4.0", features = ["bls381"], optional = true }
arrayref = { version = "0.3.5", optional = true }
blake2 = { version = "0.9", default-features = false, optional = true }
arrayref = { version = "0.3.6", optional = true }
blake2 = { version = "0.10", default-features = false, optional = true }
block-modes = { version = "0.7", optional = true }
block-padding = { version = "0.2", optional = true }
clear_on_drop = { version = "0.2.4", optional = true }
console_error_panic_hook = { version = "0.1.5", optional = true }
curve25519-dalek = { version = "3.1", default-features = false, optional = true }
block-padding = { version = "0.3", optional = true }
clear_on_drop = { version = "0.2.5", optional = true }
console_error_panic_hook = { version = "0.1.7", optional = true }
curve25519-dalek = { version = "3.2", default-features = false, optional = true }
ed25519-dalek = { version = "1.0", default-features = false, optional = true }
env_logger = { version = "0.7.0", optional = true }
failure = { version = "0.1.6", optional = true }
env_logger = { version = "0.10", optional = true }
failure = { version = "0.1.8", optional = true }
ffi-support = { version = "0.4", optional = true }
glass_pumpkin = { version = "0.4", optional = true }
hex = { version = "0.4.0", optional = true }
hkdf = { version = "0.11.0", optional = true }
hmac = { version = "0.11.0", optional = true }
glass_pumpkin = { version = "1.5", optional = true }
hex = { version = "0.4.3", optional = true }
hkdf = { version = "0.12", optional = true }
hmac = { version = "0.12.1", optional = true }
int_traits = { version = "0.1.1", optional = true }
js-sys = { version = "0.3.13", optional = true }
js-sys = { version = "0.3.61", optional = true }
lazy_static = { version = "1.4", optional = true }
log = { version = "0.4.8", optional = true }
num-bigint = { version = "0.3.0", features = ["rand"], optional = true}
num-integer = { version = "=0.1.42", optional = true }
num-traits = { version = "=0.2.11", optional = true }
log = { version = "0.4.17", optional = true }
num-bigint = { version = "0.4", features = ["rand"], optional = true }
num-integer = { version = "0.1.45", optional = true }
num-traits = { version = "0.2.15", optional = true }
openssl = { version = "0.10", optional = true }
# TODO: Find out if the wasm-bindgen feature can be made dependent on our own wasm feature
rand = { version = "0.7", features = ["wasm-bindgen"], optional = true }
rand_chacha = { version = "=0.2.1", optional = true }
rustchacha20poly1305 = { version = "0.7", package = "chacha20poly1305", optional = true }
k256 = { version = "0.9.6", optional = true, features = ["ecdh", "ecdsa", "sha256"]}
bitcoinsecp256k1 = { version = "0.19", package = "secp256k1", optional = true, features = ["rand", "serde"]}
serde = { version = "1.0", features = ["derive"], optional = true}
k256 = { version = "0.12", optional = true, features = ["ecdh", "ecdsa", "sha256"]}
bitcoinsecp256k1 = { version = "0.26", package = "secp256k1", optional = true, features = ["rand", "serde"]}
serde = { version = "1.0", features = ["derive"], optional = true }
serde_json = { version = "1.0", optional = true }
sha2 = { version = "0.9.5", default-features = false, optional = true }
sha3 = { version = "0.9.1", optional = true }
subtle = { version = "2.3", optional = true }
sha2 = { version = "0.10", default-features = false, optional = true }
sha3 = { version = "0.10", optional = true }
subtle = { version = "2.4", optional = true }
wasm-bindgen = { version = "0.2", optional = true, features = ["serde-serialize"] }
x25519-dalek = { version = "1.1", optional = true, default-features = false }
zeroize = { version = "1.1", features = ["zeroize_derive"], optional = true }
x25519-dalek = { version = "1.2.1", optional = true, default-features = false, git = "https://github.com/appetrosyan/x25519-dalek" }
zeroize = { version = "1.5", features = ["zeroize_derive"], optional = true }

[dev-dependencies]
bytebuffer-rs = "0.3.0"
bytebuffer-rs = "2.0.1"
criterion = "0.3"
openssl = "0.10"
k256 = { version = "0.9.6"}
bitcoinsecp256k1 = { version = "0.19", package = "secp256k1"}
k256 = { version = "0.12"}
bitcoinsecp256k1 = { version = "0.26", package = "secp256k1"}
serde_json = "1.0"

[[bench]]
Expand Down
2 changes: 1 addition & 1 deletion libursa/src/encryption/symm/aescbc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use aead::{
use aes::{Aes128, Aes256};
use block_modes::block_padding::Pkcs7;
use block_modes::{BlockMode, Cbc};
use hmac::{Hmac, Mac, NewMac};
use hmac::{Hmac, Mac};
#[cfg(feature = "serde")]
use serde::{de::Visitor, Deserialize, Deserializer, Serialize, Serializer};
use sha2::{Sha256, Sha512};
Expand Down
12 changes: 6 additions & 6 deletions libursa/src/ffi/bls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ pub extern "C" fn ursa_bls_generator_free(gen: *const c_void) -> ErrorCode {
check_useful_c_ptr!(gen, ErrorCode::CommonInvalidParam1);

unsafe {
Box::from_raw(gen as *mut Generator);
drop(Box::from_raw(gen as *mut Generator));
}
let res = ErrorCode::Success;

Expand Down Expand Up @@ -294,7 +294,7 @@ pub extern "C" fn ursa_bls_sign_key_free(sign_key: *const c_void) -> ErrorCode {
);

unsafe {
Box::from_raw(sign_key as *mut SignKey);
drop(Box::from_raw(sign_key as *mut SignKey));
}
let res = ErrorCode::Success;

Expand Down Expand Up @@ -444,7 +444,7 @@ pub extern "C" fn ursa_bls_ver_key_free(ver_key: *const c_void) -> ErrorCode {
trace!("ursa_bls_ver_key_free: >>> ver_key: {:?}", ver_key);

unsafe {
Box::from_raw(ver_key as *mut VerKey);
drop(Box::from_raw(ver_key as *mut VerKey));
}
let res = ErrorCode::Success;

Expand Down Expand Up @@ -594,7 +594,7 @@ pub extern "C" fn ursa_bls_pop_free(pop: *const c_void) -> ErrorCode {
trace!("ursa_bls_pop_free: >>> pop: {:?}", pop);

unsafe {
Box::from_raw(pop as *mut ProofOfPossession);
drop(Box::from_raw(pop as *mut ProofOfPossession));
}
let res = ErrorCode::Success;

Expand Down Expand Up @@ -701,7 +701,7 @@ pub extern "C" fn ursa_bls_signature_free(signature: *const c_void) -> ErrorCode
trace!("ursa_bls_signature_free: >>> signature: {:?}", signature);

unsafe {
Box::from_raw(signature as *mut Signature);
drop(Box::from_raw(signature as *mut Signature));
}
let res = ErrorCode::Success;

Expand Down Expand Up @@ -864,7 +864,7 @@ pub extern "C" fn ursa_bls_multi_signature_free(multi_sig: *const c_void) -> Err
);

unsafe {
Box::from_raw(multi_sig as *mut MultiSignature);
drop(Box::from_raw(multi_sig as *mut MultiSignature));
}
let res = ErrorCode::Success;

Expand Down
4 changes: 2 additions & 2 deletions libursa/src/hash/blake2.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[cfg(target_pointer_width = "64")]
pub use crate::blake2::{Blake2b as Blake2, VarBlake2b as VarBlake2};
pub use crate::blake2::Blake2b as Blake2;
#[cfg(target_pointer_width = "32")]
pub use crate::blake2::{Blake2s as Blake2, VarBlake2s as VarBlake2};
pub use crate::blake2::Blake2s as Blake2;
18 changes: 10 additions & 8 deletions libursa/src/kex/secp256k1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ mod ecdh_secp256k1 {
sk.clone_from_slice(d.as_slice());
}
};
let k256_sk = k256::SecretKey::from_bytes(&sk)
let k256_sk = k256::SecretKey::from_be_bytes(&sk)
.map_err(|e| CryptoError::ParseError(format!("{:?}", e)))?;
let k256_pk = k256_sk.public_key();
use k256::elliptic_curve::sec1::ToEncodedPoint;
Expand All @@ -183,16 +183,18 @@ mod ecdh_secp256k1 {
where
D: Digest<OutputSize = U32> + Default,
{
let sk = k256::SecretKey::from_bytes(&local_private_key)
let sk = k256::SecretKey::from_be_bytes(local_private_key.as_ref())
.map_err(|e| CryptoError::ParseError(format!("{:?}", e)))?;

let pk = k256::PublicKey::from_sec1_bytes(&remote_public_key[..])
.map_err(|e| CryptoError::ParseError(format!("{:?}", e)))?;

//Note: this does not return possibility of error.
let shared_secret =
k256::elliptic_curve::ecdh::diffie_hellman(sk.to_secret_scalar(), pk.as_affine());
Ok(SessionKey(shared_secret.as_bytes().to_vec()))
let shared_secret = k256::elliptic_curve::ecdh::diffie_hellman(
k256::NonZeroScalar::from(sk),
pk.as_affine(),
);
Ok(SessionKey(shared_secret.raw_secret_bytes().to_vec()))
}
}
}
Expand Down Expand Up @@ -233,11 +235,11 @@ mod tests {

let scheme = EcdhSecp256k1Sha256::new();
let (pk, sk) = scheme.keypair(None).unwrap();
let sk1 = SecretKey::from_bytes(&sk[..]).unwrap();
let sk1 = SecretKey::from_be_bytes(&sk[..]).unwrap();
let pk1 = PublicKey::from_sec1_bytes(&pk[..]).unwrap();
let secret = diffie_hellman(sk1.to_secret_scalar(), pk1.as_affine());
let secret = diffie_hellman(k256::NonZeroScalar::from(sk1), pk1.as_affine());
assert_eq!(
secret.as_bytes().to_vec(),
secret.raw_secret_bytes().to_vec(),
scheme
.compute_shared_secret(&sk, &pk)
.unwrap()
Expand Down
44 changes: 17 additions & 27 deletions libursa/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,32 +247,23 @@ impl std::fmt::Display for CryptoError {
#[cfg(feature = "bitcoinsecp256k1")]
impl From<bitcoinsecp256k1::Error> for CryptoError {
fn from(error: bitcoinsecp256k1::Error) -> CryptoError {
match error {
bitcoinsecp256k1::Error::IncorrectSignature => {
CryptoError::ParseError("Incorrect Signature".to_string())
use bitcoinsecp256k1::Error::*;
CryptoError::ParseError(
match error {
IncorrectSignature => "Incorrect signature",
InvalidMessage => "Invalid message",
InvalidPublicKey => "Invalid public key",
InvalidPublicKeySum => "Invalid public key sum",
InvalidSignature => "Invalid signature",
InvalidSharedSecret => "Invalid shared secret",
InvalidSecretKey => "Invalid secret key",
InvalidRecoveryId => "Invalid recovery id",
InvalidTweak => "Invalid tweak",
NotEnoughMemory => "Not enough memory",
InvalidParityValue(_) => "Invalid parity", // Value is opaque, cannot print
}
bitcoinsecp256k1::Error::InvalidMessage => {
CryptoError::ParseError("Invalid Message".to_string())
}
bitcoinsecp256k1::Error::InvalidPublicKey => {
CryptoError::ParseError("Invalid Public Key".to_string())
}
bitcoinsecp256k1::Error::InvalidSignature => {
CryptoError::ParseError("Invalid Signature".to_string())
}
bitcoinsecp256k1::Error::InvalidSecretKey => {
CryptoError::ParseError("Invalid Secret Key".to_string())
}
bitcoinsecp256k1::Error::InvalidRecoveryId => {
CryptoError::ParseError("Invalid Recovery Id".to_string())
}
bitcoinsecp256k1::Error::InvalidTweak => {
CryptoError::ParseError("Invalid Tweak".to_string())
}
bitcoinsecp256k1::Error::NotEnoughMemory => {
CryptoError::ParseError("Not Enough Memory".to_string())
}
}
.to_owned(),
)
}
}

Expand All @@ -290,7 +281,6 @@ impl From<bitcoinsecp256k1::Error> for CryptoError {
))]
impl From<errors::UrsaCryptoError> for CryptoError {
fn from(err: errors::UrsaCryptoError) -> Self {
let kind = err.kind();
CryptoError::GeneralError(format!("{}", kind))
CryptoError::GeneralError(format!("{}", err.kind()))
}
}
Loading

0 comments on commit 0ee4c27

Please sign in to comment.