Project

General

Profile

PublicKey Info Base » History » Version 79

Davide Pesavento, 06/15/2023 12:40 AM

1 79 Davide Pesavento
**NOTICE**: *This document is obsolete and is kept only for historical purposes.*
2
3
---
4
5
# Public key Info Base (PIB) Service
6 1 Yingdi Yu
7
## Public Key Info Management 
8
9
NDN data packets are secured through digital signatures.
10 2 Yingdi Yu
In order to generate a valid signature, an NDN application needs to know not only the correct key to use but also the correct public key information that should be put into the `KeyLocator` of a data packet. 
11
The information needs to be managed locally on the system where the application is running.
12
13
The information related to keys is managed at three granularities: identities, keys, and certificates. 
14
A key is always associated with a namespace, called "identity".
15 4 Yingdi Yu
An identity however may have more than one keys.
16
Each key is named as `/<Identity>/[KeyId]`. 
17
The `KeyId` uniquely identifies a key which belongs to the `Identity`.
18 2 Yingdi Yu
Among these keys, only one is the default key of the identity.
19
If only identity is provided when signing a packet, the default key of the identity will be used to sign the packet.
20
21
A certificate is always associated with the key in the certificate
22
If a certificate is provided when signing a packet, the corresponding private key should be used to sign the packet 
23
and the name of the certificate name may be put into the `KeyLocator` of the packet.
24
25
A key may have more than one certificates (e.g., certificates may be issued by different parties).
26
Among these certificates, only one is the default certificate of the key.
27
The default certificate of the default key of an identity is the default certificate of the identity.
28
If only identity is provided when signing a packet, the name of the default certificate of the identity may be put into the `KeyLocator` of the packet.
29
30 3 Yingdi Yu
All the information above may be accessed by different APIs and applications on the same system, 
31
therefore it is desirable to make the information provisioning as a system service. 
32 1 Yingdi Yu
33 3 Yingdi Yu
Since public keys and certificates are supposed to be publicly available, 
34
the service also serves as a local storage of certificate and public keys, 
35
besides providing the public key related information.
36 1 Yingdi Yu
37 3 Yingdi Yu
## PIB management model
38 1 Yingdi Yu
39 3 Yingdi Yu
The public key information of each system user is managed separately in PIB.
40 68 Yingdi Yu
PIB service is run as a separate service for each user.
41 1 Yingdi Yu
42 66 Yingdi Yu
Users' public key information is managed in three tables in PIB: identity table, key table, and certificate table.
43 1 Yingdi Yu
Identity table schema:
44
45 76 Yingdi Yu
    identities(
46 68 Yingdi Yu
        id                   INTEGER PRIMARY KEY,
47 1 Yingdi Yu
        identity             BLOB NOT NULL,        
48 76 Yingdi Yu
        is_default           INTEGER DEFAULT 0
49 68 Yingdi Yu
    );
50 66 Yingdi Yu
51 68 Yingdi Yu
A unique index is created on (identity).
52
53 1 Yingdi Yu
Key table schema:
54 4 Yingdi Yu
55 76 Yingdi Yu
    keys(
56 68 Yingdi Yu
        id                   INTEGER PRIMARY KEY,
57 66 Yingdi Yu
        identity             BLOB NOT NULL,        
58
        key_id               BLOB NOT NULL,        
59 18 Yingdi Yu
        key_type             INTEGER NOT NULL,     
60 1 Yingdi Yu
        key_bits             BLOB NOT NULL,        
61 76 Yingdi Yu
        is_default           INTEGER DEFAULT 0,
62 68 Yingdi Yu
        FOREIGN KEY(identity) REFERENCES identities(identity) ON DELETE CASCADE             
63
    );    
64 1 Yingdi Yu
65 68 Yingdi Yu
A unique index is created on (identity, key_id).
66
67 1 Yingdi Yu
Certificate table schema:
68 66 Yingdi Yu
69 76 Yingdi Yu
    certificates(
70 68 Yingdi Yu
        id                   INTEGER PRIMARY KEY,
71 18 Yingdi Yu
        certificate_name     BLOB NOT NULL,        
72
        identity             BLOB NOT NULL,        
73
        key_id               BLOB NOT NULL,        
74
        certificate_data     BLOB NOT NULL,        
75 76 Yingdi Yu
        is_default           INTEGER DEFAULT 0,
76 68 Yingdi Yu
        FOREIGN KEY(identity, key_id) REFERENCES keys(identity, key_id) ON DELETE CASCADE
77 4 Yingdi Yu
    );
78 3 Yingdi Yu
79 68 Yingdi Yu
A unique index is created on (certificate_name).
80 1 Yingdi Yu
81 68 Yingdi Yu
Besides these tables  PIB has one more management tables: `mgmt` table.
82
`mgmt` table stores owner name, corresponding tpm locator, and local management key (we will discuss it later).
83
84 19 Yingdi Yu
User table schema:
85
86 75 Yingdi Yu
    mgmt(                                       
87 68 Yingdi Yu
        id                    INTEGER PRIMARY KEY
88
        owner                 BLOB NOT NULL,
89
        tpm_locator           BLOB,
90 19 Yingdi Yu
        local_management_cert BLOB NOT NULL,    
91 5 Yingdi Yu
    );
92 4 Yingdi Yu
93 68 Yingdi Yu
The read access to PIB is not restricted,
94
while the write access to PIB requires authentication.
95 63 Yingdi Yu
The write access is expressed as signed commands. 
96
The signing key can be authenticated only if the key already exists in the corresponding user's PIB tables.
97
Each key has its own write access privilege which is defined as:
98
99 68 Yingdi Yu
* The local management key is allowed to change anything in the PIB info in the three tables. The identity of the user local management key is `/localhost/pib/user/[UserName]`, and the name of the key should be `/localhost/pib/user/[UserName]/[KeyId]`. Adding a new normal user's local management key is not restricted for now, because we expect in future that OS will prevent a user from registering another user in PIB. However, changing a existing user's local management key requires a signature generated by the existing key.
100 63 Yingdi Yu
* All the other keys are called **regular keys**. A regular key is allowed to change keys/certificates with identities under the key's own namespace, e.g., a key with the identity `/ndn/ucla/alice` is allowed to change a key with the identity `/ndn/ucla/alice/chat` but is not allowed to change a key with the identity `/ndn/ucla/bob`. Importing a self-signed regular key requires the signature generated by the corresponding user's local management key.
101 3 Yingdi Yu
102
## PIB Service Protocol 
103
104
PIB service provides an interface to NDN applications for public key info lookup. 
105 1 Yingdi Yu
The interface is defined in terms of NDN packets (interest/data).
106 32 Yingdi Yu
Depending on the query type, a query to PIB is expressed as a **[signed interest](http://redmine.named-data.net/projects/ndn-cxx/wiki/SignedInterest)** (for Write operation) or normal interest (for Read operation).
107 5 Yingdi Yu
The query interest is defined as:
108
109
    /localhost/pib/[UserName]/[Verb]/[Param]/<signed_interest_security_components>
110 34 Yingdi Yu
                                            |<-- Required for Write operation -->|
111 5 Yingdi Yu
112
`UserName` indicates the tables in which the query should apply.
113
`Verb` indicates the access operation. 
114 42 Yingdi Yu
Five types of operations are defined: 
115 40 Yingdi Yu
116 41 Yingdi Yu
Verb                 | Access Type       | Description
117 42 Yingdi Yu
-------------------- | ----------------- | ----------------------------------------------------------
118
Get                  | Read              | Get a single entity (user, identity, key, or certificate)
119 41 Yingdi Yu
Default              | Read              | Get the default setting of an entity
120
List                 | Read              | List the name of a set of entities
121 1 Yingdi Yu
Update               | Write             | Add/Change an entity
122
Delete               | Write             | Delete an entity
123
124
`Param` is a TLV block containing parameters of the query.
125
Different types of operations have their own parameters.
126
127 42 Yingdi Yu
### Query Responses
128
129
The response to a query interest is a data packet signed by PIB.
130
The public key certificate of PIB is stored in a read-only file and is accessible to all users on the system.
131
132
Several TLVs are defined for the content of query responses.
133
`Identity` TLV:
134
135
    PibIdentity := PIB-IDENTITY-TYPE TLV-LENGTH
136
                   Name
137
138
`PublicKey` TLV:
139
140
    PibPublicKey := PIB-PUBLIC-KEY-TYPE TLV-LENGTH
141
                    Name
142
                    PibBytes
143
144
`Certificate` TLV:
145
146
    PibCertificate := PIB-CERTIFICATE-TYPE TLV-LENGTH
147
                      Data 
148 55 Yingdi Yu
149
`User` TLV:
150
151
    PibUser := PIB-USER-TYPE TLV-LENGTH
152
               Data // local management certificate
153 56 Yingdi Yu
               ...  // Other information to add if exists
154 42 Yingdi Yu
 
155
A response may also be a error code defined a non-negative integer:
156
157 64 Yingdi Yu
     PibError := PIB-ERROR-TYPE TLV-LENGTH
158 53 Yingdi Yu
                 ErrorCode
159
                 Bytes
160
161 78 Davide Pesavento
    ErrorCode := ERROR-CODE-TYPE TLV-LENGTH NonNegativeInteger
162 42 Yingdi Yu
163
Error code                    | Value             | Description
164
----------------------------- | ----------------- | ----------------------------------
165
ERR\_SUCCESS                  | 0                 | No error
166
ERR\_INCOMPLETE\_COMMAND      | 1                 | Incomplete interest
167
ERR\_WRONG\_VERB              | 2                 | Wrong verb in interest
168
ERR\_WRONG\_PARAM             | 3                 | Wrong parameter in interest
169
ERR\_NON\_EXISTING\_USER      | 128               | User does not exist
170
ERR\_NON\_EXISTING\_ID        | 129               | Identity does not exist
171
ERR\_NON\_EXISTING\_KEY       | 130               | Public key does not exist
172
ERR\_NON\_EXISTING\_CERT      | 131               | Certificate does not exist
173
ERR\_NO\_DEFAULT\_ID          | 256               | No default identity is set
174
ERR\_NO\_DEFAULT\_KEY         | 257               | No default public key is set 
175
ERR\_NO\_DEFAULT\_CERT        | 258               | No default certificate is set
176
ERR\_DELETE\_DEFAULT\_SETTING | 384               | Trying to delete default setting
177
178 70 Yingdi Yu
A response is signed by a PIB instance key with the name `/localhost/pib/[UserName]/dsk-...`.
179
The PIB instance key is signed by another key with the name `/localhost/pib/[UserName]/ksk-...` which is the trust anchor of the PIB service.
180 73 Yingdi Yu
Note that it is difference from the management key name which is `/localhost/pib/`**user**`/[UserName]/dsk-...`.
181 74 Yingdi Yu
Management key is used by PIB owner to sign update/delete command interest,
182
while PIB instance key is used by PIB service to sign PIB responses.
183 62 Yingdi Yu
184 11 Yingdi Yu
### `Get` Parameters
185 8 Yingdi Yu
For `get` operation, `Param` is defined as:
186 1 Yingdi Yu
187 42 Yingdi Yu
    PibGetParam := PIB-GET-PARAM-TYPE TLV-LENGTH
188
                   PibType
189
                   Name?
190 1 Yingdi Yu
191
`Type` indicates which table the query will be applied eventually.
192 42 Yingdi Yu
193 78 Davide Pesavento
    PibType := PIB-TYPE-TYPE TLV-LENGTH NonNegativeInteger
194 22 Yingdi Yu
195 42 Yingdi Yu
Type constant                               | Assigned value    | Assigned value (hex)
196
------------------------------------------- | ----------------- | --------------------
197
USER                                        | 0                 | 0x00
198
ID                                          | 1                 | 0x01
199
KEY                                         | 2                 | 0x02
200
CERT                                        | 3                 | 0x03
201 30 Yingdi Yu
202 5 Yingdi Yu
203 48 Yingdi Yu
`Name` is the name of the queried entity. It is a TLV defined in [NDN-TLV spec](http://named-data.net/doc/ndn-tlv/name.html#name).
204
Name is ignored if type is USER.
205 5 Yingdi Yu
206 42 Yingdi Yu
If error happens during processing the query, the content of the response is an ErrorCode TLV.
207
If no error happens, the content depends on the `Type`.
208 5 Yingdi Yu
When `Type` is `ID`, the query is actually invalid. 
209 42 Yingdi Yu
The response is an ErrorCode with value `ERR_WRONG_PARAM`.
210
211 57 Yingdi Yu
For `USER`, the content is a `PibUser` TLV.
212 42 Yingdi Yu
For `KEY`, the content is a `PibPublicKey` TLV. 
213 48 Yingdi Yu
For `CERT`, the content is a `PibCertificate` TLV.
214 1 Yingdi Yu
215 42 Yingdi Yu
### `Default` Parameters
216 1 Yingdi Yu
217 42 Yingdi Yu
The parameters of `default` operation is defined as.
218 12 Yingdi Yu
219 42 Yingdi Yu
      PibDefaultParam := PIB-DEFAULT-PARAM-TYPE TLV-LENGTH
220
                         PibType    // target type
221
                         PibType    // origin type
222
                         Name?      // origin name
223 12 Yingdi Yu
224
225 42 Yingdi Yu
The response to a `default` query is the default entity of the "target type" of the "origin".
226 21 Yingdi Yu
227 42 Yingdi Yu
Possible values of target type include `ID`, `KEY`, and `CERT`.
228
Possible values of origin type include `USER`, `ID`, and `KEY`.
229
The target type should be always "below" the origin type (e.g., it is wrong to have a target type `ID` and an origin type `CERT`.)
230
The origin name should be consistent with the origin type.
231
Origin name is ignored if origin type is `USER`.
232
When wrong parameters are supplied, the content of response is an ErrorCode with value `ERR_WRONG_PARAM`.
233 37 Yingdi Yu
234 42 Yingdi Yu
If no error happens in processing the query, the response could be `PibIdentity`, `PibPublicKey`, or `PibCertificate`, depending on the target type.
235 37 Yingdi Yu
236 42 Yingdi Yu
### `List` Parameters
237 36 Yingdi Yu
238 42 Yingdi Yu
The parameters of `list` operation are defined as: 
239 36 Yingdi Yu
240 42 Yingdi Yu
    PibListParam := PIB-LIST-PARAM-TYPE TLV-LENGTH
241
                    PibType // origin type
242
                    Name?   // origin name
243 36 Yingdi Yu
244 42 Yingdi Yu
The response to the `list` query is a list of `Name`, depending on the origin type.
245
Possible values of origin type include `USER`, `ID`, and `KEY`.
246
Origin name is ignored if origin type is `USER`.
247
If the origin type is `USER`, the response is a list of identities of the user.
248
If the origin type is `ID`, the response is a list of names of keys of the identity.
249
If the origin type is `KEY`, the response is a list of names of certificates of the key.
250 1 Yingdi Yu
251 50 Yingdi Yu
    PibNameList := PIB-NAME-LIST-TYPE TLV-LENGTH
252
                   Name+
253
254 42 Yingdi Yu
### `Update` Parameters
255 1 Yingdi Yu
256 42 Yingdi Yu
The parameters of `update` operation are defined as: 
257 1 Yingdi Yu
258 45 Yingdi Yu
    PibUpdateParam := PIB-UPDATE-PARAM-TYPE TLV-LENGTH
259 59 Yingdi Yu
                      (PibUser | PibIdentity | PibPublicKey | PibCertificate)
260 42 Yingdi Yu
                      PibDefaultOpt
261 1 Yingdi Yu
262
`DefaultOpt` is the default option:
263
264 42 Yingdi Yu
265 78 Davide Pesavento
    PibDefaultOpt := PIB-DEFAULT-OPT-TYPE TLV-LENGTH NonNegativeInteger
266 42 Yingdi Yu
267
DefaultOpt constant                         | Assigned value    | Assigned value (hex)
268 1 Yingdi Yu
------------------------------------------- | ----------------- | --------------------
269 54 Yingdi Yu
DEFAULT\_OPT\_NO                            | 0                 | 0x00
270
DEFAULT\_OPT\_KEY                           | 1                 | 0x01
271
DEFAULT\_OPT\_ID                            | 3                 | 0x03
272
DEFAULT\_OPT\_USER                          | 7                 | 0x07
273 1 Yingdi Yu
274 42 Yingdi Yu
The operation, once validated, will add a new entry in the corresponding table if no such an entry exists or update the existing entry,
275
and change the default setting according to `PibDefaultOpt`.
276 1 Yingdi Yu
277 42 Yingdi Yu
The response is always an ErrorCode: `ERR_SUCCESS` for a successful operation, others for failure.
278 1 Yingdi Yu
279 42 Yingdi Yu
### `Delete` Parameters
280 1 Yingdi Yu
281 42 Yingdi Yu
The parameters of `delete` operation are defined as: 
282
283 44 Yingdi Yu
    PibDeleteParam := PIB-DELETE-PARAM-TYPE TLV-LENGTH
284
                      PibType
285 42 Yingdi Yu
                      Name
286
287
The entity and its belonging entities will be deleted once the operation is validated.
288
289
The response is always an ErrorCode: `ERR_SUCCESS` for a successful deletion, others for failure.
290
291
### TLV-TYPE assignments
292
293
Type                                            | Assigned value    | Assigned value (hex)
294
----------------------------------------------- | ----------------- | --------------------
295
PibGetParam                                     | 128               | 0x80
296
PibDefaultParam                                 | 129               | 0x81
297 49 Yingdi Yu
PibListParam                                    | 130               | 0x82
298
PibUpdateParam                                  | 131               | 0x83
299
PibDeleteParam                                  | 132               | 0x84
300 77 Yingdi Yu
PibUser                                         | 144               | 0x90
301 43 Yingdi Yu
PibIdentity                                     | 145               | 0x91
302
PibPublicKey                                    | 146               | 0x92
303
PibCertificate                                  | 147               | 0x93
304
PibBytes                                        | 148               | 0x94 
305
PibDefaultOpt                                   | 149               | 0x95
306 52 Yingdi Yu
PibNameList                                     | 150               | 0x96
307 77 Yingdi Yu
PibType                                         | 151               | 0x97
308 58 Yingdi Yu
PibError                                        | 152               | 0x98
309 77 Yingdi Yu
PibTpmLocator                                   | 153               | 0x99
310 47 Yingdi Yu
PibErrorCode                                    | 252               | 0xfc
311 67 Yingdi Yu
312
## Misc
313
314
In that case root user's private key is lost in TPM, you have to delete the root user directly in the database. 
315
Since the database file is guarded by filesystem, only system admin can do that.