diff --git a/crates/router/src/core/admin.rs b/crates/router/src/core/admin.rs index 44c4242f30..72f2e9eaa9 100644 --- a/crates/router/src/core/admin.rs +++ b/crates/router/src/core/admin.rs @@ -129,7 +129,7 @@ pub async fn create_merchant_account( let payment_response_hash_key = req .payment_response_hash_key - .or(Some(generate_cryptographically_secure_random_string(32))); + .or(Some(generate_cryptographically_secure_random_string(64))); db.insert_merchant_key_store(key_store) .await diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs index fc67e4b111..00dcc4a851 100644 --- a/crates/router/src/core/payments/helpers.rs +++ b/crates/router/src/core/payments/helpers.rs @@ -1242,14 +1242,14 @@ pub fn make_url_with_signature( .payment_response_hash_key .as_ref() .get_required_value("payment_response_hash_key")?; - let signature = hmac_sha256_sorted_query_params( + let signature = hmac_sha512_sorted_query_params( &mut url.query_pairs().collect::>(), key.as_str(), )?; url.query_pairs_mut() .append_pair("signature", &signature) - .append_pair("signature_algorithm", "HMAC-SHA256"); + .append_pair("signature_algorithm", "HMAC-SHA512"); url.to_owned() } else { url.to_owned() @@ -1275,7 +1275,7 @@ pub fn make_url_with_signature( }) } -pub fn hmac_sha256_sorted_query_params( +pub fn hmac_sha512_sorted_query_params( params: &mut [(Cow<'_, str>, Cow<'_, str>)], key: &str, ) -> RouterResult { @@ -1286,8 +1286,8 @@ pub fn hmac_sha256_sorted_query_params( .collect::>() .join("&"); - let signature = crypto::HmacSha256::sign_message( - &crypto::HmacSha256, + let signature = crypto::HmacSha512::sign_message( + &crypto::HmacSha512, key.as_bytes(), final_string.as_bytes(), ) diff --git a/crates/router/src/lib.rs b/crates/router/src/lib.rs index c3925fa5f4..67234af661 100644 --- a/crates/router/src/lib.rs +++ b/crates/router/src/lib.rs @@ -64,7 +64,7 @@ pub mod headers { pub const X_CC_VERSION: &str = "X-CC-Version"; pub const X_ACCEPT_VERSION: &str = "X-Accept-Version"; pub const X_DATE: &str = "X-Date"; - pub const X_WEBHOOK_SIGNATURE: &str = "X-Webhook-Signature"; + pub const X_WEBHOOK_SIGNATURE: &str = "X-Webhook-Signature-512"; } pub mod pii {