Skip to content

Commit 89b4fff

Browse files
committed
Remove references to key lifetime
Changes needed after they were removed from parallaxsecond/parsec-interface-rs#5. Signed-off-by: Hugues de Valon <[email protected]>
1 parent 2ec3183 commit 89b4fff

10 files changed

+41
-48
lines changed

docs/operation_directory/psa_crypto/key_attributes.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@
1616
--->
1717
# **PSA Crypto Key Attributes**
1818

19-
## **Key Lifetime**
20-
21-
Key lifetime is an attribute that determines when the key is destroyed:
22-
* *volatile* - key is destroyed as soon as application closes the handle of the key (e.g. when the application terminates)
23-
* *persistent* - key is destroyed only when the [**PSA Destroy Key**](/psa_destroy_key.md) operation is executed
24-
2519
## **Key Type and Algorithm**
2620

2721
Types of cryptographic keys and cryptographic algorithms are encoded separately. Each is encoded as a field in the *Key Attributes* structure.

docs/operation_directory/psa_crypto/psa_asymmetric_sign.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ Note that to perform a hash-and-sign signature algorithm, you must first calcula
2626
## **Parameters**
2727

2828
**`key_name`** Name of the key used for signing the hash
29-
**`key_lifetime`** Lifetime of the key named in the request (see the [**key attributes**](/key_attributes.md) file for more details)
3029
**`hash`** Hash of the data that must be signed
3130

3231
## **Result values**

docs/operation_directory/psa_crypto/psa_asymmetric_verify.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ Note that to perform a hash-and-sign signature algorithm, you must first calcula
2626
## **Parameters**
2727

2828
**`key_name`** Name of the key used for signing the hash
29-
**`key_lifetime`** Lifetime of the key named in the request (see the [**key attributes**](/key_attributes.md) file for more details)
3029
**`hash`** Hash of the data that was signed
3130
**`signature`** Signature that must be verified
3231

docs/operation_directory/psa_crypto/psa_destroy_key.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ This function also erases any metadata such as policies and frees all resources
2828
## **Parameters**
2929

3030
**`key_name`** Name of the key used for signing the hash
31-
**`key_lifetime`** Lifetime of the key named in the request (see the [**key attributes**](/key_attributes.md) file for more details)
3231

3332
## **Contract**
3433

docs/operation_directory/psa_crypto/psa_export_public_key.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ For standard key types, the output format is as follows:
3030
RSAPublicKey ::= SEQUENCE {
3131
modulus INTEGER, -- n
3232
publicExponent INTEGER } -- e
33-
* For elliptic curve public keys (key of type [`ECC_Public_Key`](/key_attributes.md)), the format is the uncompressed representation defined by *SEC1 §2.3.3* as the content of an ECPoint. Let m be the bit size associated with the curve, i.e. the bit size of q for a curve over F_q. The representation consists of:
33+
* For elliptic curve public keys (key of type [`ECC_Public_Key`](/key_attributes.md)), the format is the uncompressed representation defined by *SEC1 §2.3.3* as the content of an ECPoint. Let m be the bit size associated with the curve, i.e. the bit size of q for a curve over F\_q. The representation consists of:
3434
– The byte 0x04;
35-
x_P as a ceiling(m/8)-byte string, big-endian;
36-
y_P as a ceiling(m/8)-byte string, big-endian.
35+
x\_P as a ceiling(m/8)-byte string, big-endian;
36+
y\_P as a ceiling(m/8)-byte string, big-endian.
3737
* For DSA public keys ([`DSA_Public_Key`](/key_attributes.md)), the `subjectPublicKey` format is defined by *RFC 3279 §2.3.2* as `DSAPublicKey`, with the OID `id-dsa`, and with the parameters `DSS-Parms`.
3838
id-dsa OBJECT IDENTIFIER ::= {
3939
iso(1) member-body(2) us(840) x9-57(10040) x9cm(4) 1 }
@@ -47,7 +47,6 @@ For standard key types, the output format is as follows:
4747
## **Parameters**
4848

4949
**`key_name`** Name of the key used for signing the hash
50-
**`key_lifetime`** Lifetime of the key named in the request (see the [**key attributes**](/key_attributes.md) file for more details)
5150

5251
## **Result values**
5352

docs/operation_directory/psa_crypto/psa_import_key.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ This specification supports a single format for each key type. Implementations m
2828
## **Parameters**
2929

3030
**`key_name`** Name of the key used for signing the hash
31-
**`key_lifetime`** Lifetime of the key named in the request (see the [**key attributes**](/key_attributes.md) file for more details)
3231
**`key_data`** Bytes of the key in one of the formats described above
3332

3433
## **Contract**

docs/source_code_structure.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Providers can be linked statically into the service. Where this is done, they mu
5858

5959
The `core_provider` module is a provider of operations that are implemented by the service itself, rather than by the platform's underlying security facilities. These core operations include operations for discovery, configuration and housekeeping of the service. They are not cryptographic or key management operations. (The "ping" operation is an example of one that is serviced by the core provider: it allows a client to determine whether the service itself is responding).
6060

61-
The `mbed_provider` module houses a provider based on [**MBed Crypto**](https://github.com/ARMmbed/mbed-crypto), which is the reference implementation of the PSA Crypto API Specification. The `mbed_provider` is a full provider in its own right, and allows for the full capabilities of the service to be provided in a software-only solution. But the `mbed_provider` also services as a branching point to connect with hardware or trusted applications through its own internal Harware Abstraction Layer (HAL).
61+
The `mbed_provider` module houses a provider based on [**MBed Crypto**](https://github.com/ARMmbed/mbed-crypto), which is the reference implementation of the PSA Crypto API Specification. The `mbed_provider` is a full provider in its own right, and allows for the full capabilities of the service to be provided in a software-only solution. But the `mbed_provider` also services as a branching point to connect with hardware or trusted applications through its own internal Harware Abstraction Layer (HAL). This provider only supports persistent key storage.
6262

6363
Like the `client` folder, the `provider` folder is also a key extension point for partner contributors. This project eagerly welcomes contributions of new providers in order to connect the service with the security facilities of host platforms and extend the ecosystem.
6464

@@ -90,4 +90,4 @@ The `client` folder is a key extension point for partner contributors. This proj
9090
## **Repository Map**
9191
Please refer to the following diagram to understand the overall code structure and the dependency arcs between the modules.
9292

93-
![Repository Map](diagrams/source_code_structure.png)
93+
![Repository Map](diagrams/source_code_structure.png)

src/providers/mbed_provider/constants.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ pub const PSA_ALG_KEY_DERIVATION_MASK: psa_algorithm_t = 0x010f_ffff;
157157
pub const PSA_ALG_SELECT_RAW: psa_algorithm_t = 0x3100_0001;
158158
pub const PSA_ALG_FFDH_BASE: psa_algorithm_t = 0x2210_0000;
159159
pub const PSA_ALG_ECDH_BASE: psa_algorithm_t = 0x2220_0000;
160-
pub const PSA_KEY_LIFETIME_VOLATILE: psa_key_lifetime_t = 0x0000_0000;
161160
pub const PSA_KEY_LIFETIME_PERSISTENT: psa_key_lifetime_t = 0x0000_0001;
162161
pub const PSA_KEY_USAGE_EXPORT: psa_key_usage_t = 0x0000_0001;
163162
pub const PSA_KEY_USAGE_ENCRYPT: psa_key_usage_t = 0x0000_0100;

src/providers/mbed_provider/conversion_utils.rs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,13 @@
1313
// See the License for the specific language governing permissions and
1414
// limitations under the License.
1515
use super::constants::*;
16-
use super::psa_crypto_binding::{
17-
psa_algorithm_t, psa_key_lifetime_t, psa_key_type_t, psa_key_usage_t, psa_status_t,
18-
};
16+
use super::psa_crypto_binding::{psa_algorithm_t, psa_key_type_t, psa_key_usage_t, psa_status_t};
1917
use parsec_interface::operations::key_attributes::*;
2018
use parsec_interface::requests::ResponseStatus;
2119
use std::convert::TryFrom;
2220

2321
/// This structure holds key attribute values to be used by the Mbed Crypto library.
2422
pub struct MbedKeyAttributes {
25-
pub key_lifetime: psa_key_lifetime_t,
2623
pub key_type: psa_key_type_t,
2724
pub algorithm: psa_algorithm_t,
2825
pub key_size: usize,
@@ -32,22 +29,13 @@ pub struct MbedKeyAttributes {
3229
/// Converts between native and Mbed Crypto key attributes values.
3330
pub fn convert_key_attributes(attrs: &KeyAttributes) -> MbedKeyAttributes {
3431
MbedKeyAttributes {
35-
key_lifetime: convert_key_lifetime(attrs.key_lifetime),
3632
key_type: convert_key_type(attrs.key_type),
3733
algorithm: convert_algorithm(&attrs.algorithm),
3834
key_size: usize::try_from(attrs.key_size).expect("Key size cannot be represented as usize"),
3935
key_usage: convert_key_usage(attrs),
4036
}
4137
}
4238

43-
/// Converts between native and Mbed Crypto key lifetime values.
44-
pub fn convert_key_lifetime(lifetime: KeyLifetime) -> psa_key_lifetime_t {
45-
match lifetime {
46-
KeyLifetime::Persistent => PSA_KEY_LIFETIME_PERSISTENT,
47-
KeyLifetime::Volatile => PSA_KEY_LIFETIME_VOLATILE,
48-
}
49-
}
50-
5139
/// Converts between native and Mbed Crypto type values.
5240
///
5341
/// # Panics

src/providers/mbed_provider/mod.rs

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ use std::convert::TryInto;
2020
use std::sync::{Arc, Mutex, RwLock};
2121

2222
use log::{error, info, warn};
23-
use parsec_interface::operations::key_attributes::KeyLifetime;
2423
use parsec_interface::operations::ProviderInfo;
2524
use parsec_interface::operations::{OpAsymSign, ResultAsymSign};
2625
use parsec_interface::operations::{OpAsymVerify, ResultAsymVerify};
@@ -201,11 +200,13 @@ impl MbedProvider {
201200
}
202201
};
203202
// Use psa_open_key to check if the key ID actually exists or not.
204-
let lifetime =
205-
conversion_utils::convert_key_lifetime(KeyLifetime::Persistent);
206203
let mut key_handle: psa_crypto_binding::psa_key_handle_t = 0;
207204
let open_key_status = unsafe {
208-
psa_crypto_binding::psa_open_key(lifetime, key_id, &mut key_handle)
205+
psa_crypto_binding::psa_open_key(
206+
constants::PSA_KEY_LIFETIME_PERSISTENT,
207+
key_id,
208+
&mut key_handle,
209+
)
209210
};
210211
if open_key_status == constants::PSA_ERROR_DOES_NOT_EXIST {
211212
to_remove.push(key_triple.clone());
@@ -285,7 +286,11 @@ impl Provide for MbedProvider {
285286
.key_handle_mutex
286287
.lock()
287288
.expect("Grabbing key handle mutex failed");
288-
psa_crypto_binding::psa_create_key(key_attrs.key_lifetime, key_id, &mut key_handle)
289+
psa_crypto_binding::psa_create_key(
290+
constants::PSA_KEY_LIFETIME_PERSISTENT,
291+
key_id,
292+
&mut key_handle,
293+
)
289294
};
290295

291296
let ret_val: Result<ResultCreateKey>;
@@ -378,7 +383,11 @@ impl Provide for MbedProvider {
378383
.key_handle_mutex
379384
.lock()
380385
.expect("Grabbing key handle mutex failed");
381-
psa_crypto_binding::psa_create_key(key_attrs.key_lifetime, key_id, &mut key_handle)
386+
psa_crypto_binding::psa_create_key(
387+
constants::PSA_KEY_LIFETIME_PERSISTENT,
388+
key_id,
389+
&mut key_handle,
390+
)
382391
};
383392

384393
let ret_val: Result<ResultImportKey>;
@@ -452,12 +461,10 @@ impl Provide for MbedProvider {
452461
info!("Mbed Provider - Export Public Key");
453462
let _semaphore_guard = self.key_slot_semaphore.access();
454463
let key_name = op.key_name;
455-
let key_lifetime = op.key_lifetime;
456464
let key_triple = KeyTriple::new(app_name, ProviderID::MbedProvider, key_name);
457465
let store_handle = self.key_id_store.read().expect("Key store lock poisoned");
458466
let key_id = get_key_id(&key_triple, &*store_handle)?;
459467

460-
let lifetime = conversion_utils::convert_key_lifetime(key_lifetime);
461468
let mut key_handle: psa_crypto_binding::psa_key_handle_t = 0;
462469

463470
let ret_val: Result<ResultExportPublicKey>;
@@ -467,7 +474,11 @@ impl Provide for MbedProvider {
467474
.key_handle_mutex
468475
.lock()
469476
.expect("Grabbing key handle mutex failed");
470-
psa_crypto_binding::psa_open_key(lifetime, key_id, &mut key_handle)
477+
psa_crypto_binding::psa_open_key(
478+
constants::PSA_KEY_LIFETIME_PERSISTENT,
479+
key_id,
480+
&mut key_handle,
481+
)
471482
};
472483

473484
if open_key_status == constants::PSA_SUCCESS {
@@ -514,21 +525,23 @@ impl Provide for MbedProvider {
514525
info!("Mbed Provider - Destroy Key");
515526
let _semaphore_guard = self.key_slot_semaphore.access();
516527
let key_name = op.key_name;
517-
let key_lifetime = op.key_lifetime;
518528
let key_triple = KeyTriple::new(app_name, ProviderID::MbedProvider, key_name);
519529
let mut store_handle = self.key_id_store.write().expect("Key store lock poisoned");
520530
let mut local_ids_handle = self.local_ids.write().expect("Local ID lock poisoned");
521531
let key_id = get_key_id(&key_triple, &*store_handle)?;
522532

523-
let lifetime = conversion_utils::convert_key_lifetime(key_lifetime);
524533
let mut key_handle: psa_crypto_binding::psa_key_handle_t = 0;
525534

526535
let open_key_status = unsafe {
527536
let _guard = self
528537
.key_handle_mutex
529538
.lock()
530539
.expect("Grabbing key handle mutex failed");
531-
psa_crypto_binding::psa_open_key(lifetime, key_id, &mut key_handle)
540+
psa_crypto_binding::psa_open_key(
541+
constants::PSA_KEY_LIFETIME_PERSISTENT,
542+
key_id,
543+
&mut key_handle,
544+
)
532545
};
533546

534547
if open_key_status == constants::PSA_SUCCESS {
@@ -554,21 +567,23 @@ impl Provide for MbedProvider {
554567
info!("Mbed Provider - Asym Sign");
555568
let _semaphore_guard = self.key_slot_semaphore.access();
556569
let key_name = op.key_name;
557-
let key_lifetime = op.key_lifetime;
558570
let hash = op.hash;
559571
let key_triple = KeyTriple::new(app_name, ProviderID::MbedProvider, key_name);
560572
let store_handle = self.key_id_store.read().expect("Key store lock poisoned");
561573
let key_id = get_key_id(&key_triple, &*store_handle)?;
562574

563-
let lifetime = conversion_utils::convert_key_lifetime(key_lifetime);
564575
let mut key_handle: psa_crypto_binding::psa_key_handle_t = 0;
565576

566577
let open_key_status = unsafe {
567578
let _guard = self
568579
.key_handle_mutex
569580
.lock()
570581
.expect("Grabbing key handle mutex failed");
571-
psa_crypto_binding::psa_open_key(lifetime, key_id, &mut key_handle)
582+
psa_crypto_binding::psa_open_key(
583+
constants::PSA_KEY_LIFETIME_PERSISTENT,
584+
key_id,
585+
&mut key_handle,
586+
)
572587
};
573588

574589
if open_key_status == constants::PSA_SUCCESS {
@@ -627,22 +642,24 @@ impl Provide for MbedProvider {
627642
info!("Mbed Provider - Asym Verify");
628643
let _semaphore_guard = self.key_slot_semaphore.access();
629644
let key_name = op.key_name;
630-
let key_lifetime = op.key_lifetime;
631645
let hash = op.hash;
632646
let signature = op.signature;
633647
let key_triple = KeyTriple::new(app_name, ProviderID::MbedProvider, key_name);
634648
let store_handle = self.key_id_store.read().expect("Key store lock poisoned");
635649
let key_id = get_key_id(&key_triple, &*store_handle)?;
636650

637-
let lifetime = conversion_utils::convert_key_lifetime(key_lifetime);
638651
let mut key_handle: psa_crypto_binding::psa_key_handle_t = 0;
639652

640653
let open_key_status = unsafe {
641654
let _guard = self
642655
.key_handle_mutex
643656
.lock()
644657
.expect("Grabbing key handle mutex failed");
645-
psa_crypto_binding::psa_open_key(lifetime, key_id, &mut key_handle)
658+
psa_crypto_binding::psa_open_key(
659+
constants::PSA_KEY_LIFETIME_PERSISTENT,
660+
key_id,
661+
&mut key_handle,
662+
)
646663
};
647664

648665
if open_key_status == constants::PSA_SUCCESS {

0 commit comments

Comments
 (0)