replace : iotivity -> iotivity-sec
[platform/upstream/iotivity.git] / resource / csdk / security / include / securevirtualresourcetypes.h
1 //******************************************************************
2 //
3 // Copyright 2015 Intel Mobile Communications GmbH All Rights Reserved.
4 //
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 //
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 //
11 //      http://www.apache.org/licenses/LICENSE-2.0
12 //
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
18 //
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20
21 /**
22  * Data type definitions for all oic.sec.* types defined in the
23  * OIC Security Specification.
24  *
25  * Note that throughout, ptrs are used rather than arrays.  There
26  * are two primary reasons for this:
27  * 1) The Spec defines many structures with optional fields, so pre-
28  *    allocating these would be wasteful.
29  * 2) There are in many cases arrays of Strings or arrays of Structs,
30  *    which could not be defined as variable length arrays (e.g. array[])
31  *    without breaking from the structure order and definition in the Spec.
32  *
33  * The primary drawback to this decision is that marshalling functions
34  * will have to be written by hand to marshal these structures (e.g. to/from
35  * Persistent Storage, or across memory boundaries).
36  *
37  * TODO reconcile against latest OIC Security Spec to ensure all fields correct.
38  * (Last checked against v0.95)
39  */
40
41 #ifndef OC_SECURITY_RESOURCE_TYPES_H
42 #define OC_SECURITY_RESOURCE_TYPES_H
43
44 #include "iotivity_config.h"
45
46 #include <stdint.h> // for uint8_t typedef
47 #include <stdbool.h>
48 #if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
49 #include "byte_array.h"
50 #endif /* __WITH_DTLS__  or __WITH_TLS__*/
51
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
55
56 /**
57  * Values used to create bit-maskable enums for single-value response with
58  * embedded code.
59  */
60 #define ACCESS_GRANTED_DEF            (1 << 0)
61 #define ACCESS_DENIED_DEF             (1 << 1)
62 #define INSUFFICIENT_PERMISSION_DEF   (1 << 2)
63 #define SUBJECT_NOT_FOUND_DEF         (1 << 3)
64 #define RESOURCE_NOT_FOUND_DEF        (1 << 4)
65 #define POLICY_ENGINE_ERROR_DEF       (1 << 5)
66 #define INVALID_PERIOD_DEF            (1 << 6)
67 #define ACCESS_WAITING_DEF            (1 << 7)
68 #define AMS_SERVICE_DEF               (1 << 8)
69 #define REASON_MASK_DEF               (INSUFFICIENT_PERMISSION_DEF | \
70                                        INVALID_PERIOD_DEF | \
71                                        SUBJECT_NOT_FOUND_DEF | \
72                                        RESOURCE_NOT_FOUND_DEF | \
73                                        POLICY_ENGINE_ERROR_DEF)
74
75
76 /**
77  * Access policy in least significant bits (from Spec):
78  * 1st lsb:  C (Create)
79  * 2nd lsb:  R (Read, Observe, Discover)
80  * 3rd lsb:  U (Write, Update)
81  * 4th lsb:  D (Delete)
82  * 5th lsb:  N (Notify)
83  */
84 #define PERMISSION_CREATE       (1 << 0)
85 #define PERMISSION_READ         (1 << 1)
86 #define PERMISSION_WRITE        (1 << 2)
87 #define PERMISSION_DELETE       (1 << 3)
88 #define PERMISSION_NOTIFY       (1 << 4)
89 #define PERMISSION_FULL_CONTROL (PERMISSION_CREATE | \
90                                  PERMISSION_READ | \
91                                  PERMISSION_WRITE | \
92                                  PERMISSION_DELETE | \
93                                  PERMISSION_NOTIFY)
94
95 /**
96  * @brief   Response type for all Action requests from CA layer;
97  *          may include a reason code.
98  *
99  * To extract codes use GetReasonCode function on SRMAccessResponse:
100  *
101  * SRMAccessResponse_t response = SRMRequestHandler(obj, info);
102  * if(SRM_TRUE == IsAccessGranted(response)) {
103  *     SRMAccessResponseReasonCode_t reason = GetReasonCode(response);
104  *     switch(reason) {
105  *         case INSUFFICIENT_PERMISSION:
106  *         ...etc.
107  *     }
108  * }
109  */
110 typedef enum
111 {
112     ACCESS_GRANTED = ACCESS_GRANTED_DEF,
113     ACCESS_DENIED = ACCESS_DENIED_DEF,
114     ACCESS_DENIED_INVALID_PERIOD = ACCESS_DENIED_DEF
115         | INVALID_PERIOD_DEF,
116     ACCESS_DENIED_INSUFFICIENT_PERMISSION = ACCESS_DENIED_DEF
117         | INSUFFICIENT_PERMISSION_DEF,
118     ACCESS_DENIED_SUBJECT_NOT_FOUND = ACCESS_DENIED_DEF
119         | SUBJECT_NOT_FOUND_DEF,
120     ACCESS_DENIED_RESOURCE_NOT_FOUND = ACCESS_DENIED_DEF
121         | RESOURCE_NOT_FOUND_DEF,
122     ACCESS_DENIED_POLICY_ENGINE_ERROR = ACCESS_DENIED_DEF
123         | POLICY_ENGINE_ERROR_DEF,
124     ACCESS_WAITING_FOR_AMS = ACCESS_WAITING_DEF
125         | AMS_SERVICE_DEF,
126     ACCESS_DENIED_AMS_SERVICE_ERROR = ACCESS_DENIED
127         | AMS_SERVICE_DEF
128 } SRMAccessResponse_t;
129
130 /**
131  * Reason code for SRMAccessResponse.
132  */
133 typedef enum
134 {
135     NO_REASON_GIVEN = 0,
136     INSUFFICIENT_PERMISSION = INSUFFICIENT_PERMISSION_DEF,
137     SUBJECT_NOT_FOUND = SUBJECT_NOT_FOUND_DEF,
138     RESOURCE_NOT_FOUND = RESOURCE_NOT_FOUND_DEF,
139 } SRMAccessResponseReasonCode_t;
140
141 /**
142  * Extract Reason Code from Access Response.
143  */
144 INLINE_API SRMAccessResponseReasonCode_t GetReasonCode(
145     SRMAccessResponse_t response)
146 {
147     SRMAccessResponseReasonCode_t reason =
148         (SRMAccessResponseReasonCode_t)(response & REASON_MASK_DEF);
149     return reason;
150 }
151
152 /**
153  * Returns 'true' iff request should be passed on to RI layer.
154  */
155 INLINE_API bool IsAccessGranted(SRMAccessResponse_t response)
156 {
157     if(ACCESS_GRANTED == (response & ACCESS_GRANTED))
158     {
159         return true;
160     }
161     else
162     {
163         return false;
164     }
165 }
166
167 typedef struct OicSecRsrc OicSecRsrc_t;
168
169 typedef struct OicSecValidity OicSecValidity_t;
170
171 typedef struct OicSecAce OicSecAce_t;
172
173 typedef struct OicSecAcl OicSecAcl_t;
174
175 typedef struct OicSecAmacl OicSecAmacl_t;
176
177 typedef struct OicSecCred OicSecCred_t;
178
179 /**
180  * Aid for assigning/testing vals with OicSecCredType_t.
181  * Example:
182  *  OicSecCredType_t ct = PIN_PASSWORD | ASYMMETRIC_KEY;
183  *  if((ct & PIN_PASSWORD) == PIN_PASSWORD)
184  *  {
185  *      // ct contains PIN_PASSWORD flag.
186  *  }
187  */
188 typedef enum OSCTBitmask
189 {
190     NO_SECURITY_MODE                = 0x0,
191     SYMMETRIC_PAIR_WISE_KEY         = (0x1 << 0),
192     SYMMETRIC_GROUP_KEY             = (0x1 << 1),
193     ASYMMETRIC_KEY                  = (0x1 << 2),
194     SIGNED_ASYMMETRIC_KEY           = (0x1 << 3),
195     PIN_PASSWORD                    = (0x1 << 4),
196     ASYMMETRIC_ENCRYPTION_KEY       = (0x1 << 5),
197 } OSCTBitmask_t;
198
199 /**
200  * /oic/sec/credtype (Credential Type) data type.
201  * Derived from OIC Security Spec /oic/sec/cred; see Spec for details.
202  *              0:  no security mode
203  *              1:  symmetric pair-wise key
204  *              2:  symmetric group key
205  *              4:  asymmetric key
206  *              8:  signed asymmetric key (aka certificate)
207  *              16: PIN /password
208  */
209 typedef OSCTBitmask_t OicSecCredType_t;
210
211 typedef struct OicSecDoxm OicSecDoxm_t;
212
213 typedef enum OicSecDpm
214 {
215     NORMAL                          = 0x0,
216     RESET                           = (0x1 << 0),
217     TAKE_OWNER                      = (0x1 << 1),
218     BOOTSTRAP_SERVICE               = (0x1 << 2),
219     SECURITY_MANAGEMENT_SERVICES    = (0x1 << 3),
220     PROVISION_CREDENTIALS           = (0x1 << 4),
221     PROVISION_ACLS                  = (0x1 << 5),
222 #ifdef MULTIPLE_OWNER
223     TAKE_SUB_OWNER                  = (0x1 << 6),
224 #endif
225     // << 7 THROUGH 15 RESERVED
226 } OicSecDpm_t;
227
228 // These types are taken from the Security Spec v1.1.12 /pstat resource definition
229 // Note that per the latest spec, there is NO definition for Multiple Service Client Directed
230 // provisioning mode, so that enum value has been removed.
231 typedef enum OicSecDpom
232 {
233     MULTIPLE_SERVICE_SERVER_DRIVEN    = (0x1 << 0),
234     SINGLE_SERVICE_SERVER_DRIVEN      = (0x1 << 1),
235     SINGLE_SERVICE_CLIENT_DRIVEN      = (0x1 << 2),
236 } OicSecDpom_t;
237
238 //TODO: Need more clarification on deviceIDFormat field type.
239 #if 0
240 typedef enum
241 {
242     URN = 0x0
243 }OicSecDvcIdFrmt_t;
244 #endif
245
246 typedef enum
247 {
248     OIC_R_ACL_TYPE = 0,
249     OIC_R_AMACL_TYPE,
250     OIC_R_CRED_TYPE,
251     OIC_R_CRL_TYPE,
252     OIC_R_DOXM_TYPE,
253     OIC_R_DPAIRING_TYPE,
254     OIC_R_PCONF_TYPE,
255     OIC_R_PSTAT_TYPE,
256     OIC_R_SACL_TYPE,
257     OIC_SEC_SVR_TYPE_COUNT, //define the value to number of SVR
258     NOT_A_SVR_RESOURCE = 99
259 }OicSecSvrType_t;
260
261 typedef enum
262 {
263     OIC_JUST_WORKS                          = 0x0,
264     OIC_RANDOM_DEVICE_PIN                   = 0x1,
265     OIC_MANUFACTURER_CERTIFICATE            = 0x2,
266     OIC_DECENTRALIZED_PUBLIC_KEY            = 0x3,
267     OIC_OXM_COUNT,
268 #ifdef MULTIPLE_OWNER
269     OIC_PRECONFIG_PIN                       = 0xFF00,
270 #endif //MULTIPLE_OWNER
271     OIC_MV_JUST_WORKS                       = 0xFF01,
272     OIC_CON_MFG_CERT                        = 0xFF02,
273 }OicSecOxm_t;
274
275 typedef enum
276 {
277     OIC_ENCODING_UNKNOW = 0,
278     OIC_ENCODING_RAW = 1,
279     OIC_ENCODING_BASE64 = 2,
280     OIC_ENCODING_PEM = 3,
281     OIC_ENCODING_DER = 4
282 }OicEncodingType_t;
283
284 #ifdef MULTIPLE_OWNER
285 typedef enum
286 {
287     MOT_STATUS_READY = 0,
288     MOT_STATUS_IN_PROGRESS = 1,
289     MOT_STATUS_DONE = 2,
290 }MotStatus_t;
291 #endif //MULTIPLE_OWNER
292
293 /*
294  * oic.sec.mom type definition
295  * TODO: This type will be included to OIC Security Spec.
296  * 0 : Disable multiple owner
297  * 1 : Enable multiple owner (Always on)
298  * 2 : Timely multiple owner enable
299  */
300 typedef enum
301 {
302     OIC_MULTIPLE_OWNER_DISABLE = 0,
303     OIC_MULTIPLE_OWNER_ENABLE = 1,
304     OIC_MULTIPLE_OWNER_TIMELY_ENABLE = 2,
305     OIC_NUMBER_OF_MOM_TYPE = 3
306 }OicSecMomType_t;
307
308 typedef struct OicSecKey OicSecKey_t;
309
310 typedef struct OicSecOpt OicSecOpt_t;
311
312 typedef struct OicSecPstat OicSecPstat_t;
313
314 typedef struct OicSecRole OicSecRole_t;
315
316 typedef struct OicSecSacl OicSecSacl_t;
317
318 typedef char *OicUrn_t; //TODO is URN type defined elsewhere?
319
320 typedef struct OicUuid OicUuid_t; //TODO is UUID type defined elsewhere?
321
322 #ifdef MULTIPLE_OWNER
323 typedef struct OicSecSubOwner OicSecSubOwner_t;
324 typedef struct OicSecMom OicSecMom_t;
325 #endif //MULTIPLE_OWNER
326
327
328 #if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
329 typedef struct OicSecCrl OicSecCrl_t;
330 typedef ByteArray_t OicSecCert_t;
331 #else
332 typedef void OicSecCert_t;
333 #endif /* __WITH_DTLS__ or __WITH_TLS__*/
334
335 /**
336  * /oic/uuid (Universal Unique Identifier) data type.
337  */
338 #define UUID_LENGTH 128/8 // 128-bit GUID length
339 //TODO: Confirm the length and type of ROLEID.
340 #define ROLEID_LENGTH 128/8 // 128-bit ROLEID length
341 #define OWNER_PSK_LENGTH_128 128/8 //byte size of 128-bit key size
342 #define OWNER_PSK_LENGTH_256 256/8 //byte size of 256-bit key size
343
344 struct OicUuid
345 {
346     // <Attribute ID>:<Read/Write>:<Multiple/Single>:<Mandatory?>:<Type>
347     //TODO fill in unless this is defined elsewhere?
348     uint8_t             id[UUID_LENGTH];
349 };
350
351 /**
352  * /oic/sec/jwk (JSON Web Key) data type.
353  * See JSON Web Key (JWK)  draft-ietf-jose-json-web-key-41
354  */
355 #define JWK_LENGTH 256/8 // 256 bit key length
356 struct OicSecKey
357 {
358     uint8_t                *data;
359     size_t                  len;
360
361     // TODO: This field added as workaround. Will be replaced soon.
362     OicEncodingType_t encoding;
363
364 };
365
366 struct OicSecOpt
367 {
368     uint8_t                *data;
369     size_t                  len;
370
371     OicEncodingType_t encoding;
372     bool                revstat;
373 };
374
375 struct OicSecRsrc
376 {
377     char *href; // 0:R:S:Y:String
378     char *rel; // 1:R:S:N:String
379     char** types; // 2:R:S:N:String Array
380     size_t typeLen; // the number of elts in types
381     char** interfaces; // 3:R:S:N:String Array
382     size_t interfaceLen; // the number of elts in interfaces
383     OicSecRsrc_t *next;
384 };
385
386 struct OicSecValidity
387 {
388     char* period; // 0:R:S:Y:String
389     char** recurrences; // 1:R:M:Y:Array of String
390     size_t recurrenceLen; // the number of elts in recurrence
391     OicSecValidity_t *next;
392 };
393
394 struct OicSecAce
395 {
396     // <Attribute ID>:<Read/Write>:<Multiple/Single>:<Mandatory?>:<Type>
397     OicUuid_t subjectuuid;              // 0:R:S:Y:uuid
398     OicSecRsrc_t *resources;            // 1:R:M:Y:Resource
399     uint16_t permission;                // 2:R:S:Y:UINT16
400     OicSecValidity_t *validities;       // 3:R:M:N:Time-interval
401 #ifdef MULTIPLE_OWNER
402     OicUuid_t* eownerID;                //4:R:S:N:oic.uuid
403 #endif
404     OicSecAce_t *next;
405 };
406
407 /**
408  * /oic/sec/acl (Access Control List) data type.
409  * Derived from OIC Security Spec; see Spec for details.
410  */
411 struct OicSecAcl
412 {
413     // <Attribute ID>:<Read/Write>:<Multiple/Single>:<Mandatory?>:<Type>
414     OicUuid_t           rownerID;        // 0:R:S:Y:oic.uuid
415     OicSecAce_t         *aces; // 1:R:M:N:ACE
416 };
417
418 /**
419  * /oic/sec/amacl (Access Manager Service Accesss Control List) data type.
420  * Derived from OIC Security Spec; see Spec for details.
421  */
422 struct OicSecAmacl
423 {
424     // <Attribute ID>:<Read/Write>:<Multiple/Single>:<Mandatory?>:<Type>
425     size_t              resourcesLen;   // the number of elts in Resources
426     char                **resources;    // 0:R:M:Y:String
427     size_t              amssLen;        // the number of elts in Amss
428     OicUuid_t           *amss;          // 1:R:M:Y:acl
429     OicUuid_t           rownerID;        // 2:R:S:Y:oic.uuid
430     OicSecAmacl_t         *next;
431 };
432
433 /**
434  * /oic/sec/cred (Credential) data type.
435  * Derived from OIC Security Spec; see Spec for details.
436  */
437 struct OicSecCred
438 {
439     // <Attribute ID>:<Read/Write>:<Multiple/Single>:<Mandatory?>:<Type>
440     uint16_t            credId;         // 0:R:S:Y:UINT16
441     OicUuid_t           subject;        // 1:R:S:Y:oic.uuid
442     //Note: Need further clarification on roleID data type
443     //NOTE: Need further clarification on roleId datatype.
444     //size_t              roleIdsLen;     // the number of elts in RoleIds
445     //OicSecRole_t        *roleIds;       // 2:R:M:N:oic.sec.role
446     OicSecCredType_t    credType;       // 3:R:S:Y:oic.sec.credtype
447 #if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
448     OicSecKey_t         publicData;     // own cerificate chain
449     char            *credUsage;            // 4:R:S:N:String
450     OicSecOpt_t        optionalData;   // CA's cerificate chain
451 #endif /* __WITH_DTLS__  or __WITH_TLS__*/
452     OicSecKey_t         privateData;    // 6:R:S:N:oic.sec.key
453     char                *period;        // 7:R:S:N:String
454     OicUuid_t           rownerID;       // 8:R:S:Y:oic.uuid
455 #ifdef MULTIPLE_OWNER
456     OicUuid_t           *eownerID;      //9:R:S:N:oic.uuid
457 #endif //MULTIPLE_OWNER
458     OicSecCred_t        *next;
459 };
460
461 #ifdef MULTIPLE_OWNER
462 struct OicSecSubOwner {
463     OicUuid_t uuid;
464     MotStatus_t status;
465     OicSecSubOwner_t* next;
466 };
467
468 struct OicSecMom{
469     OicSecMomType_t mode;
470 };
471 #endif //MULTIPLE_OWNER
472
473 /**
474  * /oic/sec/doxm (Device Owner Transfer Methods) data type
475  * Derived from OIC Security Spec; see Spec for details.
476  */
477 struct OicSecDoxm
478 {
479     // <Attribute ID>:<Read/Write>:<Multiple/Single>:<Mandatory?>:<Type>
480     OicUrn_t            *oxmType;       // 0:R:M:N:URN
481     size_t              oxmTypeLen;     // the number of elts in OxmType
482     OicSecOxm_t         *oxm;           // 1:R:M:N:UINT16
483     size_t              oxmLen;         // the number of elts in Oxm
484     OicSecOxm_t         oxmSel;         // 2:R/W:S:Y:UINT16
485     OicSecCredType_t    sct;            // 3:R:S:Y:oic.sec.credtype
486     bool                owned;          // 4:R:S:Y:Boolean
487     //TODO: Need more clarification on deviceIDFormat field type.
488     //OicSecDvcIdFrmt_t   deviceIDFormat; // 5:R:S:Y:UINT8
489     OicUuid_t           deviceID;       // 6:R:S:Y:oic.uuid
490     bool                dpc;            // 7:R:S:Y:Boolean
491     OicUuid_t           owner;          // 8:R:S:Y:oic.uuid
492 #ifdef MULTIPLE_OWNER
493     OicSecSubOwner_t* subOwners;        //9:R/W:M:N:oic.uuid
494     OicSecMom_t *mom;                   //10:R/W:S:N:oic.sec.mom
495 #endif //MULTIPLE_OWNER
496     OicUuid_t           rownerID;       // 11:R:S:Y:oic.uuid
497 };
498
499 /**
500  * /oic/sec/pstat (Provisioning Status) data type.
501  */
502 struct OicSecPstat
503 {
504     // <Attribute ID>:<Read/Write>:<Multiple/Single>:<Mandatory?>:<Type>
505     bool                isOp;           // 0:R:S:Y:Boolean
506     OicSecDpm_t         cm;             // 1:R:S:Y:oic.sec.dpm
507     OicSecDpm_t         tm;             // 2:RW:S:Y:oic.sec.dpm
508     OicUuid_t           deviceID;       // 3:R:S:Y:oic.uuid
509     OicSecDpom_t        om;             // 4:RW:M:Y:oic.sec.dpom
510     size_t              smLen;          // the number of elts in Sm
511     OicSecDpom_t        *sm;            // 5:R:M:Y:oic.sec.dpom
512     uint16_t            commitHash;     // 6:R:S:Y:oic.sec.sha256
513     OicUuid_t           rownerID;       // 7:R:S:Y:oic.uuid
514 };
515
516 /**
517  * /oic/sec/role (Role) data type.
518  * Derived from OIC Security Spec; see Spec for details.
519  */
520 struct OicSecRole
521 {
522     // <Attribute ID>:<Read/Write>:<Multiple/Single>:<Mandatory?>:<Type>
523     //TODO fill in with Role definition
524     uint8_t             id[ROLEID_LENGTH];
525 };
526
527 /**
528  * /oic/sec/sacl (Signed Access Control List) data type.
529  * Derived from OIC Security Spec; see Spec for details.
530  */
531 struct OicSecSacl
532 {
533     // <Attribute ID>:<Read/Write>:<Multiple/Single>:<Mandatory?>:<Type>
534     //TODO fill in from OIC Security Spec
535 #if defined(_MSC_VER)
536     uint8_t unused; // VS doesn't like empty structs
537 #endif
538 };
539
540 #if defined(__WITH_DTLS__) ||  defined(__WITH_TLS__)
541 struct OicSecCrl
542 {
543     uint16_t CrlId;
544     ByteArray_t ThisUpdate;
545     OicSecKey_t CrlData;
546 };
547 #endif /* __WITH_DTLS__ or __WITH_TLS__ */
548
549 /**
550  * @brief   direct pairing data type
551  */
552 typedef struct OicPin OicDpPin_t;
553
554 typedef struct OicSecPdAcl OicSecPdAcl_t;
555
556 typedef struct OicSecPconf OicSecPconf_t;
557
558 typedef struct OicSecDpairing OicSecDpairing_t;
559
560 #define DP_PIN_LENGTH 8 // temporary length
561
562 /**
563  * @brief   /oic/sec/prmtype (Pairing Method Type) data type.
564  *              0:  not allowed
565  *              1:  pre-configured pin
566  *              2:  random pin
567  */
568 typedef enum PRMBitmask
569 {
570     PRM_NOT_ALLOWED             = 0x0,
571     PRM_PRE_CONFIGURED        = (0x1 << 0),
572     PRM_RANDOM_PIN               = (0x1 << 1),
573 } PRMBitmask_t;
574
575 typedef PRMBitmask_t OicSecPrm_t;
576
577
578 struct OicPin
579 {
580     uint8_t             val[DP_PIN_LENGTH];
581 };
582
583 /**
584  * @brief   oic.sec.dpacltype (Device Pairing Access Control List) data type.
585  */
586 struct OicSecPdAcl
587 {
588     // <Attribute ID>:<Read/Write>:<Multiple/Single>:<Mandatory?>:<Type>
589     char                  **resources;        // 0:R:M:Y:String
590     size_t                resourcesLen;      // the number of elts in Resources
591     uint16_t             permission;        // 1:R:S:Y:UINT16
592     char                  **periods;            // 2:R:M*:N:String (<--M*; see Spec)
593     char                  **recurrences;    // 3:R:M:N:String
594     size_t                prdRecrLen;         // the number of elts in Periods/Recurrences
595     OicSecPdAcl_t    *next;
596 };
597
598 /**
599  * @brief   /oic/sec/pconf (Pairing Configuration) data type
600  */
601 struct OicSecPconf
602 {
603     // <Attribute ID>:<Read/Write>:<Multiple/Single>:<Mandatory?>:<Type>
604     bool                  edp;                // 0:W:S:M:Boolean
605     OicSecPrm_t      *prm;              // 1:R:M:N:UINT16
606     size_t                prmLen;          // the number of elts in Prm
607     OicDpPin_t          pin;               // 2:R:S:Y:String
608     OicSecPdAcl_t    *pdacls;         // 3:R:M:Y:oic.sec.pdacltype
609     OicUuid_t           *pddevs;        // 4:R:M:Y:oic.uuid
610     size_t                 pddevLen;     // the number of elts in pddev
611     OicUuid_t           deviceID;       // 5:R:S:Y:oic.uuid
612     OicUuid_t           rownerID;          // 6:R:S:Y:oic.uuid
613 };
614
615 /**
616  * @brief   /oic/sec/dpairing (Device Pairing) data type
617  */
618 struct OicSecDpairing
619 {
620     // <Attribute ID>:<Read/Write>:<Multiple/Single>:<Mandatory?>:<Type>
621     OicSecPrm_t      spm;               // 0:R/W:S:Y:UINT16
622     OicUuid_t           pdeviceID;     // 1:R:S:Y:oic.uuid
623     OicUuid_t           rownerID;          // 2:R:S:Y:oic.uuid
624 };
625
626 #define OIC_SEC_MAX_VER_LEN 16 // Security Version length. i.e., 00.00.000 + reserved space
627
628 /**
629  * @brief   security version data type
630  */
631 typedef struct OicSecVer OicSecVer_t;
632
633 /**
634  * @brief   /oic/sec/ver (Security Version) data type
635  */
636 struct OicSecVer
637 {
638     // <Attribute ID>:<Read/Write>:<Multiple/Single>:<Mandatory?>:<Type>
639     char              secv[OIC_SEC_MAX_VER_LEN];          // 0:R:S:Y:String
640     OicUuid_t       deviceID;     // 1:R:S:Y:oic.uuid
641 };
642
643 #ifdef __cplusplus
644 }
645 #endif
646
647 #endif //OC_SECURITY_RESOURCE_TYPES_H