mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-30 01:27:31 +08:00
feat(connector): [cryptopay] add new connector cryptopay, authorize, sync, webhook and testcases (#1511)
Co-authored-by: arvindpatel24 <arvind.patel@juspay.in>
This commit is contained in:
@ -154,6 +154,34 @@ impl DecodeMessage for NoAlgorithm {
|
||||
}
|
||||
}
|
||||
|
||||
/// Represents the HMAC-SHA-1 algorithm
|
||||
#[derive(Debug)]
|
||||
pub struct HmacSha1;
|
||||
|
||||
impl SignMessage for HmacSha1 {
|
||||
fn sign_message(
|
||||
&self,
|
||||
secret: &[u8],
|
||||
msg: &[u8],
|
||||
) -> CustomResult<Vec<u8>, errors::CryptoError> {
|
||||
let key = hmac::Key::new(hmac::HMAC_SHA1_FOR_LEGACY_USE_ONLY, secret);
|
||||
Ok(hmac::sign(&key, msg).as_ref().to_vec())
|
||||
}
|
||||
}
|
||||
|
||||
impl VerifySignature for HmacSha1 {
|
||||
fn verify_signature(
|
||||
&self,
|
||||
secret: &[u8],
|
||||
signature: &[u8],
|
||||
msg: &[u8],
|
||||
) -> CustomResult<bool, errors::CryptoError> {
|
||||
let key = hmac::Key::new(hmac::HMAC_SHA1_FOR_LEGACY_USE_ONLY, secret);
|
||||
|
||||
Ok(hmac::verify(&key, msg, signature).is_ok())
|
||||
}
|
||||
}
|
||||
|
||||
/// Represents the HMAC-SHA-256 algorithm
|
||||
#[derive(Debug)]
|
||||
pub struct HmacSha256;
|
||||
|
||||
Reference in New Issue
Block a user