Project

General

Profile

PublicKey Info Base » History » Version 66

Yingdi Yu, 07/28/2014 09:26 AM

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