diff --git a/Cargo.toml b/Cargo.toml index 89870d1..2f96782 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "colink" -version = "0.1.17" +version = "0.1.18" edition = "2021" description = "CoLink Rust SDK" license = "MIT" @@ -16,7 +16,7 @@ chrono = "0.4" ctrlc = { version = "3.2", features = ["termination"] } futures-lite = "1.12" lapin = "2.1" -openssl = { version = "0.10", features = ["vendored"] } +sha2 = "0.10" prost = "0.10" rand = { version = "0.8.4", features = ["std_rng"] } secp256k1 = { version = "0.21.2", features = ["rand-std"] } diff --git a/src/application.rs b/src/application.rs index 79cf787..2b76d23 100644 --- a/src/application.rs +++ b/src/application.rs @@ -6,9 +6,9 @@ use lapin::{ types::FieldTable, Connection, ConnectionProperties, Consumer, }; -use openssl::sha::sha256; use secp256k1::Secp256k1; use serde::{Deserialize, Serialize}; +use sha2::{Digest, Sha256}; use tonic::{ metadata::MetadataValue, transport::{Certificate, Channel, ClientTlsConfig, Identity}, @@ -516,8 +516,11 @@ pub fn prepare_import_user_signature( msg.extend_from_slice(&signature_timestamp.to_le_bytes()); msg.extend_from_slice(&expiration_timestamp.to_le_bytes()); msg.extend_from_slice(&core_pub_key.serialize()); + let mut hasher = Sha256::new(); + hasher.update(&msg); + let sha256 = hasher.finalize(); let signature = secp.sign_ecdsa( - &secp256k1::Message::from_slice(&sha256(&msg)).unwrap(), + &secp256k1::Message::from_slice(&sha256).unwrap(), user_sec_key, ); (signature_timestamp, signature.serialize_compact().to_vec())