Skip to content

Commit

Permalink
Merge pull request #18 from ionut-arm/prefix
Browse files Browse the repository at this point in the history
Add "psa_" prefix to method names.
  • Loading branch information
ionut-arm authored Apr 7, 2020
2 parents 37e0b0a + 5d2b463 commit 8786219
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
16 changes: 8 additions & 8 deletions src/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ impl Provider {
///};
///
///client
/// .generate_key(desired_provider, key_name, key_attrs)
/// .psa_generate_key(desired_provider, key_name, key_attrs)
/// .expect("Failed to create key!");
///```
///
Expand Down Expand Up @@ -281,7 +281,7 @@ impl CoreClient {
///
/// See the operation-specific response codes returned by the service
/// [here](https://parallaxsecond.github.io/parsec-book/parsec_client/operations/psa_generate_key.html#specific-response-status-codes).
pub fn generate_key(
pub fn psa_generate_key(
&self,
provider: Provider,
key_name: String,
Expand All @@ -304,12 +304,12 @@ impl CoreClient {
/// Destroy a key.
///
/// Given that keys are namespaced at a provider level, it is
/// important to call `destroy_key` on the correct combination of
/// important to call `psa_destroy_key` on the correct combination of
/// `provider` and `key_name`.
///
/// See the operation-specific response codes returned by the service
/// [here](https://parallaxsecond.github.io/parsec-book/parsec_client/operations/psa_destroy_key.html#specific-response-status-codes).
pub fn destroy_key(&self, provider: Provider, key_name: String) -> Result<()> {
pub fn psa_destroy_key(&self, provider: Provider, key_name: String) -> Result<()> {
let op = PsaDestroyKey { key_name };

let _ = self.op_handler.process_operation(
Expand Down Expand Up @@ -342,7 +342,7 @@ impl CoreClient {
///
/// See the operation-specific response codes returned by the service
/// [here](https://parallaxsecond.github.io/parsec-book/parsec_client/operations/psa_import_key.html#specific-response-status-codes).
pub fn import_key(
pub fn psa_import_key(
&self,
provider: Provider,
key_name: String,
Expand Down Expand Up @@ -377,7 +377,7 @@ impl CoreClient {
///
/// See the operation-specific response codes returned by the service
/// [here](https://parallaxsecond.github.io/parsec-book/parsec_client/operations/psa_export_public_key.html#specific-response-status-codes).
pub fn export_public_key(&self, provider: Provider, key_name: String) -> Result<Vec<u8>> {
pub fn psa_export_public_key(&self, provider: Provider, key_name: String) -> Result<Vec<u8>> {
let op = PsaExportPublicKey { key_name };

let res = self.op_handler.process_operation(
Expand Down Expand Up @@ -409,7 +409,7 @@ impl CoreClient {
///
/// See the operation-specific response codes returned by the service
/// [here](https://parallaxsecond.github.io/parsec-book/parsec_client/operations/psa_sign_hash.html#specific-response-status-codes).
pub fn sign_hash(
pub fn psa_sign_hash(
&self,
provider: Provider,
key_name: String,
Expand Down Expand Up @@ -451,7 +451,7 @@ impl CoreClient {
///
/// See the operation-specific response codes returned by the service
/// [here](https://parallaxsecond.github.io/parsec-book/parsec_client/operations/psa_verify_hash.html#specific-response-status-codes).
pub fn verify_hash_signature(
pub fn psa_verify_hash(
&self,
provider: Provider,
key_name: String,
Expand Down
26 changes: 13 additions & 13 deletions src/core/testing/core_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ fn list_provider_operations_test() {
}

#[test]
fn generate_key_test() {
fn psa_generate_key_test() {
let mut client: TestCoreClient = Default::default();
client.set_mock_read(&get_response_bytes_from_result(
NativeResult::PsaGenerateKey(operations::psa_generate_key::Result {}),
Expand All @@ -144,7 +144,7 @@ fn generate_key_test() {
};

client
.generate_key(Provider::Tpm, key_name.clone(), key_attrs.clone())
.psa_generate_key(Provider::Tpm, key_name.clone(), key_attrs.clone())
.expect("failed to generate key");

// Check request:
Expand All @@ -161,14 +161,14 @@ fn generate_key_test() {
}

#[test]
fn destroy_key_test() {
fn psa_destroy_key_test() {
let mut client: TestCoreClient = Default::default();
client.set_mock_read(&get_response_bytes_from_result(
NativeResult::PsaDestroyKey(operations::psa_destroy_key::Result {}),
));
let key_name = String::from("key-name");
client
.destroy_key(Provider::Pkcs11, key_name.clone())
.psa_destroy_key(Provider::Pkcs11, key_name.clone())
.expect("Failed to call destroy key");

// Check request:
Expand All @@ -184,7 +184,7 @@ fn destroy_key_test() {
}

#[test]
fn import_key_test() {
fn psa_import_key_test() {
let mut client: TestCoreClient = Default::default();
client.set_mock_read(&get_response_bytes_from_result(NativeResult::PsaImportKey(
operations::psa_import_key::Result {},
Expand All @@ -211,7 +211,7 @@ fn import_key_test() {
};
let key_data = vec![0xff_u8; 128];
client
.import_key(
.psa_import_key(
Provider::Pkcs11,
key_name.clone(),
key_data.clone(),
Expand All @@ -234,7 +234,7 @@ fn import_key_test() {
}

#[test]
fn export_public_key_test() {
fn psa_export_public_key_test() {
let mut client: TestCoreClient = Default::default();
let key_data = vec![0xa5; 128];
client.set_mock_read(&get_response_bytes_from_result(
Expand All @@ -247,7 +247,7 @@ fn export_public_key_test() {
// Check response:
assert_eq!(
client
.export_public_key(Provider::MbedCrypto, key_name.clone())
.psa_export_public_key(Provider::MbedCrypto, key_name.clone())
.expect("Failed to export public key"),
key_data
);
Expand All @@ -262,7 +262,7 @@ fn export_public_key_test() {
}

#[test]
fn sign_hash_test() {
fn psa_sign_hash_test() {
let mut client: TestCoreClient = Default::default();
let hash = vec![0x77_u8; 32];
let key_name = String::from("key_name");
Expand All @@ -279,7 +279,7 @@ fn sign_hash_test() {
// Check response:
assert_eq!(
client
.sign_hash(
.psa_sign_hash(
Provider::MbedCrypto,
key_name.clone(),
hash.clone(),
Expand Down Expand Up @@ -314,7 +314,7 @@ fn verify_hash_test() {
));

client
.verify_hash_signature(
.psa_verify_hash(
Provider::MbedCrypto,
key_name.clone(),
hash.clone(),
Expand Down Expand Up @@ -346,7 +346,7 @@ fn different_response_type_test() {
));
let key_name = String::from("key-name");
let err = client
.destroy_key(Provider::Pkcs11, key_name)
.psa_destroy_key(Provider::Pkcs11, key_name)
.expect_err("Error was expected");

assert_eq!(
Expand Down Expand Up @@ -404,7 +404,7 @@ fn auth_value_test() {
));
let key_name = String::from("key-name");
client
.destroy_key(Provider::Pkcs11, key_name)
.psa_destroy_key(Provider::Pkcs11, key_name)
.expect("Failed to call destroy key");

let req = get_req_from_bytes(client.get_mock_write());
Expand Down

0 comments on commit 8786219

Please sign in to comment.