Skip to content

Commit 8786219

Browse files
authored
Merge pull request #18 from ionut-arm/prefix
Add "psa_" prefix to method names.
2 parents 37e0b0a + 5d2b463 commit 8786219

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

src/core/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ impl Provider {
180180
///};
181181
///
182182
///client
183-
/// .generate_key(desired_provider, key_name, key_attrs)
183+
/// .psa_generate_key(desired_provider, key_name, key_attrs)
184184
/// .expect("Failed to create key!");
185185
///```
186186
///
@@ -281,7 +281,7 @@ impl CoreClient {
281281
///
282282
/// See the operation-specific response codes returned by the service
283283
/// [here](https://parallaxsecond.github.io/parsec-book/parsec_client/operations/psa_generate_key.html#specific-response-status-codes).
284-
pub fn generate_key(
284+
pub fn psa_generate_key(
285285
&self,
286286
provider: Provider,
287287
key_name: String,
@@ -304,12 +304,12 @@ impl CoreClient {
304304
/// Destroy a key.
305305
///
306306
/// Given that keys are namespaced at a provider level, it is
307-
/// important to call `destroy_key` on the correct combination of
307+
/// important to call `psa_destroy_key` on the correct combination of
308308
/// `provider` and `key_name`.
309309
///
310310
/// See the operation-specific response codes returned by the service
311311
/// [here](https://parallaxsecond.github.io/parsec-book/parsec_client/operations/psa_destroy_key.html#specific-response-status-codes).
312-
pub fn destroy_key(&self, provider: Provider, key_name: String) -> Result<()> {
312+
pub fn psa_destroy_key(&self, provider: Provider, key_name: String) -> Result<()> {
313313
let op = PsaDestroyKey { key_name };
314314

315315
let _ = self.op_handler.process_operation(
@@ -342,7 +342,7 @@ impl CoreClient {
342342
///
343343
/// See the operation-specific response codes returned by the service
344344
/// [here](https://parallaxsecond.github.io/parsec-book/parsec_client/operations/psa_import_key.html#specific-response-status-codes).
345-
pub fn import_key(
345+
pub fn psa_import_key(
346346
&self,
347347
provider: Provider,
348348
key_name: String,
@@ -377,7 +377,7 @@ impl CoreClient {
377377
///
378378
/// See the operation-specific response codes returned by the service
379379
/// [here](https://parallaxsecond.github.io/parsec-book/parsec_client/operations/psa_export_public_key.html#specific-response-status-codes).
380-
pub fn export_public_key(&self, provider: Provider, key_name: String) -> Result<Vec<u8>> {
380+
pub fn psa_export_public_key(&self, provider: Provider, key_name: String) -> Result<Vec<u8>> {
381381
let op = PsaExportPublicKey { key_name };
382382

383383
let res = self.op_handler.process_operation(
@@ -409,7 +409,7 @@ impl CoreClient {
409409
///
410410
/// See the operation-specific response codes returned by the service
411411
/// [here](https://parallaxsecond.github.io/parsec-book/parsec_client/operations/psa_sign_hash.html#specific-response-status-codes).
412-
pub fn sign_hash(
412+
pub fn psa_sign_hash(
413413
&self,
414414
provider: Provider,
415415
key_name: String,
@@ -451,7 +451,7 @@ impl CoreClient {
451451
///
452452
/// See the operation-specific response codes returned by the service
453453
/// [here](https://parallaxsecond.github.io/parsec-book/parsec_client/operations/psa_verify_hash.html#specific-response-status-codes).
454-
pub fn verify_hash_signature(
454+
pub fn psa_verify_hash(
455455
&self,
456456
provider: Provider,
457457
key_name: String,

src/core/testing/core_tests.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ fn list_provider_operations_test() {
117117
}
118118

119119
#[test]
120-
fn generate_key_test() {
120+
fn psa_generate_key_test() {
121121
let mut client: TestCoreClient = Default::default();
122122
client.set_mock_read(&get_response_bytes_from_result(
123123
NativeResult::PsaGenerateKey(operations::psa_generate_key::Result {}),
@@ -144,7 +144,7 @@ fn generate_key_test() {
144144
};
145145

146146
client
147-
.generate_key(Provider::Tpm, key_name.clone(), key_attrs.clone())
147+
.psa_generate_key(Provider::Tpm, key_name.clone(), key_attrs.clone())
148148
.expect("failed to generate key");
149149

150150
// Check request:
@@ -161,14 +161,14 @@ fn generate_key_test() {
161161
}
162162

163163
#[test]
164-
fn destroy_key_test() {
164+
fn psa_destroy_key_test() {
165165
let mut client: TestCoreClient = Default::default();
166166
client.set_mock_read(&get_response_bytes_from_result(
167167
NativeResult::PsaDestroyKey(operations::psa_destroy_key::Result {}),
168168
));
169169
let key_name = String::from("key-name");
170170
client
171-
.destroy_key(Provider::Pkcs11, key_name.clone())
171+
.psa_destroy_key(Provider::Pkcs11, key_name.clone())
172172
.expect("Failed to call destroy key");
173173

174174
// Check request:
@@ -184,7 +184,7 @@ fn destroy_key_test() {
184184
}
185185

186186
#[test]
187-
fn import_key_test() {
187+
fn psa_import_key_test() {
188188
let mut client: TestCoreClient = Default::default();
189189
client.set_mock_read(&get_response_bytes_from_result(NativeResult::PsaImportKey(
190190
operations::psa_import_key::Result {},
@@ -211,7 +211,7 @@ fn import_key_test() {
211211
};
212212
let key_data = vec![0xff_u8; 128];
213213
client
214-
.import_key(
214+
.psa_import_key(
215215
Provider::Pkcs11,
216216
key_name.clone(),
217217
key_data.clone(),
@@ -234,7 +234,7 @@ fn import_key_test() {
234234
}
235235

236236
#[test]
237-
fn export_public_key_test() {
237+
fn psa_export_public_key_test() {
238238
let mut client: TestCoreClient = Default::default();
239239
let key_data = vec![0xa5; 128];
240240
client.set_mock_read(&get_response_bytes_from_result(
@@ -247,7 +247,7 @@ fn export_public_key_test() {
247247
// Check response:
248248
assert_eq!(
249249
client
250-
.export_public_key(Provider::MbedCrypto, key_name.clone())
250+
.psa_export_public_key(Provider::MbedCrypto, key_name.clone())
251251
.expect("Failed to export public key"),
252252
key_data
253253
);
@@ -262,7 +262,7 @@ fn export_public_key_test() {
262262
}
263263

264264
#[test]
265-
fn sign_hash_test() {
265+
fn psa_sign_hash_test() {
266266
let mut client: TestCoreClient = Default::default();
267267
let hash = vec![0x77_u8; 32];
268268
let key_name = String::from("key_name");
@@ -279,7 +279,7 @@ fn sign_hash_test() {
279279
// Check response:
280280
assert_eq!(
281281
client
282-
.sign_hash(
282+
.psa_sign_hash(
283283
Provider::MbedCrypto,
284284
key_name.clone(),
285285
hash.clone(),
@@ -314,7 +314,7 @@ fn verify_hash_test() {
314314
));
315315

316316
client
317-
.verify_hash_signature(
317+
.psa_verify_hash(
318318
Provider::MbedCrypto,
319319
key_name.clone(),
320320
hash.clone(),
@@ -346,7 +346,7 @@ fn different_response_type_test() {
346346
));
347347
let key_name = String::from("key-name");
348348
let err = client
349-
.destroy_key(Provider::Pkcs11, key_name)
349+
.psa_destroy_key(Provider::Pkcs11, key_name)
350350
.expect_err("Error was expected");
351351

352352
assert_eq!(
@@ -404,7 +404,7 @@ fn auth_value_test() {
404404
));
405405
let key_name = String::from("key-name");
406406
client
407-
.destroy_key(Provider::Pkcs11, key_name)
407+
.psa_destroy_key(Provider::Pkcs11, key_name)
408408
.expect("Failed to call destroy key");
409409

410410
let req = get_req_from_bytes(client.get_mock_write());

0 commit comments

Comments
 (0)