Skip to content

Commit 1ac5e6a

Browse files
authored
Merge pull request #64 from gilles-peskine-arm/storage_spec-key_file_id
Update the architecture document regarding key file identifiers
2 parents c8ed00a + 11eca71 commit 1ac5e6a

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

docs/architecture/mbed-crypto-storage-specification.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ Mbed Crypto 0.2.0
9191

9292
To be released for Mbed OS 5.12.
9393

94-
Supported backends:
94+
Supported integrations:
9595

9696
* [PSA platform](#file-namespace-on-a-psa-platform-for-0.2.0)
9797
* [library using PSA ITS](#file-namespace-on-its-as-a-library-for-0.2.0)
@@ -106,12 +106,14 @@ Backward compatibility commitments: TBD
106106

107107
### Key names for 0.2.0
108108

109-
Information about each key is stored in a dedicated file whose name is constructed from the 32-bit key identifier (`psa_key_id_t`) and, if applicable, the owner identifier. The way in which the file name is constructed depends on the storage backend. The content of the file is described [below](#key-file-format-for-0.2.0).
109+
Information about each key is stored in a dedicated file designated by a _key file identifier_ (`psa_key_file_id_t`). The key file identifier is constructed from the 32-bit key identifier (`psa_key_id_t`) and, if applicable, an identifier of the owner of the key. In integrations where there is no concept of key owner (in particular, in library integrations), the key file identifier is exactly the key identifier. When the library is integrated into a service, the service determines the semantics of the owner identifier.
110+
111+
The way in which the file name is constructed from the key file identifier depends on the storage backend. The content of the file is described [below](#key-file-format-for-0.2.0).
110112

111113
The valid values for a key identifier are the range from 1 to 0xfffeffff. This limitation on the range is not documented in user-facing documentation: according to the user-facing documentation, arbitrary 32-bit values are valid.
112114

113115
* Library integration: the key file name is just the key identifer. This is a 32-bit value.
114-
* PSA service integration: the key file name is `key_id << 32 | owner_uid` where `key_id` is the key identifier specified by the application and `owner_uid` is the calling partition identifier provided to the server by the partition manager. This is a 64-bit value.
116+
* PSA service integration: the key file identifier is `(uint32_t)owner_uid << 32 | key_id` where `key_id` is the key identifier specified by the application and `owner_uid` (of type `int32_t`) is the calling partition identifier provided to the server by the partition manager. This is a 64-bit value.
115117

116118
### Key file format for 0.2.0
117119

@@ -125,21 +127,27 @@ The layout is identical to [0.1.0](#key-file-format-for-0.1.0) so far. However n
125127

126128
Assumption: ITS provides a 64-bit file identifier namespace. The Crypto service can use arbitrary file identifiers and no other part of the system accesses the same file identifier namespace.
127129

128-
* Files 0 through 0xffffff51, 0xffffff53 through 0xffffffff: unused.
130+
Assumption: the owner identifier is a nonzero value of type `int32_t`.
131+
132+
* Files 0 through 0xffffff51, 0xffffff53 through 0xffffffff: unused, reserved for internal use of the crypto library or crypto service.
129133
* File 0xffffff52 (`PSA_CRYPTO_ITS_RANDOM_SEED_UID`): [nonvolatile random seed](#nonvolatile-random-seed-file-format-for-0.1.0).
130-
* Files 0x100000000 through 0xffffffffffff: [content](#key-file-format-for-0.2.0) of the [key whose identifier is the file identifier](#key-names-for-0.2.0).
134+
* Files 0x100000000 through 0xffffffffffff: [content](#key-file-format-for-0.2.0) of the [key whose identifier is the file identifier](#key-names-for-0.2.0). The upper 32 bits determine the owner.
131135

132136
### File namespace on ITS as a library for 0.2.0
133137

134138
Assumption: ITS provides a 64-bit file identifier namespace. The entity using the crypto library can use arbitrary file identifiers and no other part of the system accesses the same file identifier namespace.
135139

140+
This is a library integration, so there is no owner. The key file identifier is identical to the key identifier.
141+
136142
* File 0: unused.
137143
* Files 1 through 0xfffeffff: [content](#key-file-format-for-0.2.0) of the [key whose identifier is the file identifier](#key-names-for-0.2.0).
138144
* File 0xffffff52 (`PSA_CRYPTO_ITS_RANDOM_SEED_UID`): [nonvolatile random seed](#nonvolatile-random-seed-file-format-for-0.2.0).
139145
* Files 0xffff0000 through 0xffffff51, 0xffffff53 through 0xffffffff, 0x100000000 through 0xffffffffffffffff: unused.
140146

141147
### File namespace on stdio for 0.2.0
142148

149+
This is a library integration, so there is no owner. The key file identifier is identical to the key identifier.
150+
143151
[Identical to 0.1.0](#file-namespace-on-stdio-for-0.1.0).
144152

145153
### Upgrade from 0.1.0 to 0.2.0.

0 commit comments

Comments
 (0)