replace : iotivity -> iotivity-sec
[platform/upstream/iotivity.git] / resource / csdk / security / include / internal / security_internals.h
1 //******************************************************************
2 //
3 //Copyright 2016 Samsung Electronics 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 #ifndef IOTVT_SRM_SECURITY_INTERNALS_H
21 #define IOTVT_SRM_SECURITY_INTERNALS_H
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
27 OicSecAcl_t* CBORPayloadToAcl(const uint8_t *payload, const size_t size);
28
29 void DeleteACLList(OicSecAcl_t* acl);
30
31 /**
32  * This internal method is to retrieve the default ACL.
33  * If SVR database in persistent storage got corrupted or
34  * is not available for some reason, a default ACL is created
35  * which allows user to initiate ACL provisioning again.
36  */
37 OCStackResult  GetDefaultACL(OicSecAcl_t** defaultAcl);
38
39 /**
40  * This internal method is the entity handler for ACL resources and
41  * will handle REST request (GET/PUT/POST/DEL) for them.
42  */
43 OCEntityHandlerResult ACLEntityHandler(OCEntityHandlerFlag flag,
44             OCEntityHandlerRequest * ehRequest, void* callbackParameter);
45
46 OCStackResult SetDefaultACL(OicSecAcl_t *acl);
47
48 /**
49  * Create PSTAT resource after default PSTAT initialization is done.
50  */
51 OCStackResult CreatePstatResource();
52
53 /**
54  * This internal method is the entity handler for PSTAT resources and
55  * will handle REST request (GET/PUT/POST/DEL) for them.
56  */
57 OCEntityHandlerResult PstatEntityHandler(OCEntityHandlerFlag flag,
58                                          OCEntityHandlerRequest * ehRequest);
59
60 /**
61  * Converts CBOR payload to AMACL.
62  *
63  * @param cborPayload is the amacl payload cbor value that neds to be converted.
64  * @param cborSize of the cborPayload. In case size is not known, it is 0.
65  * It should be NON-NULL.
66  * @param amacl is the value that is initialized. It is NULL in case of error.
67  */
68 OCStackResult CBORPayloadToAmacl(const uint8_t *cborPayload, size_t cborSize,
69                                  OicSecAmacl_t **amacl);
70
71 void DeleteAmaclList(OicSecAmacl_t *amacl);
72
73 /**
74  * This internal method is the entity handler for Cred resources
75  * to handle REST request (PUT/POST/DEL)
76  */
77 OCEntityHandlerResult CredEntityHandler(OCEntityHandlerFlag flag,
78                                         OCEntityHandlerRequest * ehRequest,
79                                         void* callbackParameter);
80
81 /**
82  * This internal method is used to create '/oic/sec/Cred' resource.
83  */
84 OCStackResult CreateCredResource();
85
86 /**
87  * This function converts from CBOR format into credential structure .
88  * Caller needs to invoke 'free' for allocated structure.
89  *
90  * @param cborPayload is the CBOR value that is assigned to the structure.
91  * @param size is the size of the CBOR.
92  * @param secCred is the pointer to instance of @ref OicSecCred_t structure that will be allocated.
93  * If it fails it will return NULL.
94  *
95  * @return ::OC_STACK_OK if conversion is successful, else ::OC_STACK_ERROR if unsuccessful.
96  */
97 OCStackResult CBORPayloadToCred(const uint8_t *cborPayload, size_t size,
98                                 OicSecCred_t **secCred);
99
100 /**
101  * This internal method is used to create '/oic/sec/doxm' resource.
102  */
103 OCStackResult CreateDoxmResource();
104
105 /**
106  * This internal method is the entity handler for DOXM resources.
107  */
108 OCEntityHandlerResult DoxmEntityHandler(OCEntityHandlerFlag flag,
109                                         OCEntityHandlerRequest * ehRequest,
110                                         void* callbackParam);
111
112 #ifdef __cplusplus
113 }
114 #endif
115
116 #endif //IOTVT_SRM_SECURITY_INTERNALS_H