Skip to content

Commit

Permalink
Added CanDoCrypto to basic client.
Browse files Browse the repository at this point in the history
Added the CanDoCrypto operation to the basic client by adding the can_do_crypto function to the implementation of BasicClient

Signed-off-by: Sam Davis <sam.davis@arm.com>
  • Loading branch information
Kakemone committed Sep 13, 2021
1 parent 1d26694 commit 37cf907
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
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/Kakemone/parsec-interface-rs", branch = "CanDoCrypto_patch" }
num = "0.3.0"
log = "0.4.11"
derivative = "2.1.1"
Expand Down
26 changes: 26 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,31 @@ 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 never return a result but will terminate with Err(Success) 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

0 comments on commit 37cf907

Please # to comment.