Skip to content

Commit 62e0e60

Browse files
committed
Added CanDoCrypto to basic client.
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>
1 parent 1d26694 commit 62e0e60

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ edition = "2018"
1212
documentation = "https://docs.rs/crate/parsec-client"
1313

1414
[dependencies]
15-
parsec-interface = "0.25.0"
15+
parsec-interface = { git = "https://github.com/parallaxsecond/parsec-interface-rs", branch = "can-do-crypto" }
1616
num = "0.3.0"
1717
log = "0.4.11"
1818
derivative = "2.1.1"

src/core/basic_client.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use super::operation_client::OperationClient;
55
use crate::auth::Authentication;
66
use crate::error::{ClientErrorKind, Error, Result};
77
use log::{debug, warn};
8+
use parsec_interface::operations::can_do_crypto::{CheckType, Operation as CanDoCrypto};
89
use parsec_interface::operations::delete_client::Operation as DeleteClient;
910
use parsec_interface::operations::list_authenticators::{
1011
AuthenticatorInfo, Operation as ListAuthenticators,
@@ -1284,6 +1285,30 @@ impl BasicClient {
12841285
}
12851286
}
12861287

1288+
/// **[Capability Discovery Operation]** Check if attributes are supported.
1289+
///
1290+
/// Checks if the given attributes are supported for the given type of operation.
1291+
///
1292+
/// #Errors
1293+
///
1294+
/// This operation will either return Ok(()) or Err(PsaErrorNotSupported) indicating whether the attributes are supported.
1295+
///
1296+
/// See the operation-specific response codes returned by the service
1297+
/// [here](https://parallaxsecond.github.io/parsec-book/parsec_client/operations/can_do_crypto.html#specific-response-status-codes).
1298+
pub fn can_do_crypto(&self, check_type: CheckType, attributes: Attributes) -> Result<()> {
1299+
let crypto_provider = self.can_provide_crypto()?;
1300+
let op = CanDoCrypto {
1301+
check_type,
1302+
attributes,
1303+
};
1304+
let _ = self.op_client.process_operation(
1305+
NativeOperation::CanDoCrypto(op),
1306+
crypto_provider,
1307+
&self.auth_data,
1308+
)?;
1309+
Ok(())
1310+
}
1311+
12871312
fn can_provide_crypto(&self) -> Result<ProviderId> {
12881313
match self.implicit_provider {
12891314
ProviderId::Core => Err(Error::Client(ClientErrorKind::InvalidProvider)),

0 commit comments

Comments
 (0)