Skip to content

Commit

Permalink
lli - move custom engine to utils
Browse files Browse the repository at this point in the history
Signed-off-by: lli <lli@anonyome.com>
  • Loading branch information
lukewli-anonyome committed Dec 18, 2023
1 parent f3bd27b commit 50113d0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
17 changes: 2 additions & 15 deletions aries/aries_vcx/src/common/signing.rs
Original file line number Diff line number Diff line change
@@ -1,25 +1,12 @@
use aries_vcx_core::wallet::base_wallet::BaseWallet;
use base64::{
self, alphabet,
engine::{general_purpose, DecodePaddingMode, GeneralPurpose, GeneralPurposeConfig},
Engine,
};
use base64::{self, engine::general_purpose, Engine};
use messages::msg_fields::protocols::connection::{
response::{ConnectionSignature, ResponseContent},
ConnectionData,
};
use time;

use crate::errors::error::prelude::*;

/// A default [GeneralPurposeConfig] configuration with a [decode_padding_mode] of
/// [DecodePaddingMode::Indifferent]
pub const LENIENT_PAD: GeneralPurposeConfig =
GeneralPurposeConfig::new().with_decode_padding_mode(DecodePaddingMode::Indifferent);

/// A [GeneralPurpose] engine using the [alphabet::URL_SAFE] base64 alphabet and
/// [DecodePaddingMode::Indifferent] config to decode both padded and unpadded.
pub const URL_SAFE_LENIENT: GeneralPurpose = GeneralPurpose::new(&alphabet::URL_SAFE, LENIENT_PAD);
use crate::{errors::error::prelude::*, utils::base64::URL_SAFE_LENIENT};

// Utility function to handle both padded and unpadded Base64URL data
fn base64url_decode(encoded: &str) -> VcxResult<Vec<u8>> {
Expand Down
13 changes: 13 additions & 0 deletions aries/aries_vcx/src/utils/base64.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
use base64::{
alphabet,
engine::{DecodePaddingMode, GeneralPurpose, GeneralPurposeConfig},
};

/// A default [GeneralPurposeConfig] configuration with a [decode_padding_mode] of
/// [DecodePaddingMode::Indifferent]
pub const LENIENT_PAD: GeneralPurposeConfig =
GeneralPurposeConfig::new().with_decode_padding_mode(DecodePaddingMode::Indifferent);

/// A [GeneralPurpose] engine using the [alphabet::URL_SAFE] base64 alphabet and
/// [DecodePaddingMode::Indifferent] config to decode both padded and unpadded.
pub const URL_SAFE_LENIENT: GeneralPurpose = GeneralPurpose::new(&alphabet::URL_SAFE, LENIENT_PAD);
1 change: 1 addition & 0 deletions aries/aries_vcx/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ macro_rules! secret {
}};
}

pub mod base64;
pub mod openssl;
pub mod qualifier;

Expand Down

0 comments on commit 50113d0

Please sign in to comment.