Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ edition = "2018"
documentation = "https://docs.rs/crate/parsec-client"

[dependencies]
parsec-interface = "0.25.0"
parsec-interface = { git = "https://github.com/parallaxsecond/parsec-interface-rs", branch = "can-do-crypto" }
num = "0.3.0"
log = "0.4.11"
derivative = "2.1.1"
Expand Down
25 changes: 25 additions & 0 deletions src/core/basic_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use super::operation_client::OperationClient;
use crate::auth::Authentication;
use crate::error::{ClientErrorKind, Error, Result};
use log::{debug, warn};
use parsec_interface::operations::can_do_crypto::{CheckType, Operation as CanDoCrypto};
use parsec_interface::operations::delete_client::Operation as DeleteClient;
use parsec_interface::operations::list_authenticators::{
AuthenticatorInfo, Operation as ListAuthenticators,
Expand Down Expand Up @@ -1284,6 +1285,30 @@ impl BasicClient {
}
}

/// **[Capability Discovery Operation]** Check if attributes are supported.
///
/// Checks if the given attributes are supported for the given type of operation.
///
/// #Errors
///
/// This operation will either return Ok(()) or Err(PsaErrorNotSupported) indicating whether the attributes are supported.
///
/// See the operation-specific response codes returned by the service
/// [here](https://parallaxsecond.github.io/parsec-book/parsec_client/operations/can_do_crypto.html#specific-response-status-codes).
pub fn can_do_crypto(&self, check_type: CheckType, attributes: Attributes) -> Result<()> {
let crypto_provider = self.can_provide_crypto()?;
let op = CanDoCrypto {
check_type,
attributes,
};
let _ = self.op_client.process_operation(
NativeOperation::CanDoCrypto(op),
crypto_provider,
&self.auth_data,
)?;
Ok(())
}

fn can_provide_crypto(&self) -> Result<ProviderId> {
match self.implicit_provider {
ProviderId::Core => Err(Error::Client(ClientErrorKind::InvalidProvider)),
Expand Down