mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-30 01:27:31 +08:00
feat(auth): Add support for partial-auth, by facilitating injection of authentication parameters in headers (#4802)
Co-authored-by: Jagan <jaganelavarasan@gmail.com>
This commit is contained in:
@ -238,6 +238,43 @@ impl VerifySignature for HmacSha512 {
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Blake3
|
||||
#[derive(Debug)]
|
||||
pub struct Blake3(String);
|
||||
|
||||
impl Blake3 {
|
||||
/// Create a new instance of Blake3 with a key
|
||||
pub fn new(key: impl Into<String>) -> Self {
|
||||
Self(key.into())
|
||||
}
|
||||
}
|
||||
|
||||
impl SignMessage for Blake3 {
|
||||
fn sign_message(
|
||||
&self,
|
||||
secret: &[u8],
|
||||
msg: &[u8],
|
||||
) -> CustomResult<Vec<u8>, errors::CryptoError> {
|
||||
let key = blake3::derive_key(&self.0, secret);
|
||||
let output = blake3::keyed_hash(&key, msg).as_bytes().to_vec();
|
||||
Ok(output)
|
||||
}
|
||||
}
|
||||
|
||||
impl VerifySignature for Blake3 {
|
||||
fn verify_signature(
|
||||
&self,
|
||||
secret: &[u8],
|
||||
signature: &[u8],
|
||||
msg: &[u8],
|
||||
) -> CustomResult<bool, errors::CryptoError> {
|
||||
let key = blake3::derive_key(&self.0, secret);
|
||||
let output = blake3::keyed_hash(&key, msg);
|
||||
Ok(output.as_bytes() == signature)
|
||||
}
|
||||
}
|
||||
|
||||
/// Represents the GCM-AES-256 algorithm
|
||||
#[derive(Debug)]
|
||||
pub struct GcmAes256;
|
||||
|
||||
Reference in New Issue
Block a user