1 //******************************************************************
3 //Copyright 2016 Samsung Electronics All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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
11 // http://www.apache.org/licenses/LICENSE-2.0
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.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20 #ifndef IOTVT_SRM_SECURITY_INTERNALS_H
21 #define IOTVT_SRM_SECURITY_INTERNALS_H
27 OicSecAcl_t* CBORPayloadToAcl(const uint8_t *payload, const size_t size);
29 void DeleteACLList(OicSecAcl_t* acl);
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.
37 OCStackResult GetDefaultACL(OicSecAcl_t** defaultAcl);
40 * This internal method is the entity handler for ACL resources and
41 * will handle REST request (GET/PUT/POST/DEL) for them.
43 OCEntityHandlerResult ACLEntityHandler(OCEntityHandlerFlag flag,
44 OCEntityHandlerRequest * ehRequest, void* callbackParameter);
46 OCStackResult SetDefaultACL(OicSecAcl_t *acl);
49 * Create PSTAT resource after default PSTAT initialization is done.
51 OCStackResult CreatePstatResource();
54 * This internal method is the entity handler for PSTAT resources and
55 * will handle REST request (GET/PUT/POST/DEL) for them.
57 OCEntityHandlerResult PstatEntityHandler(OCEntityHandlerFlag flag,
58 OCEntityHandlerRequest * ehRequest);
61 * Converts CBOR payload to AMACL.
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.
68 OCStackResult CBORPayloadToAmacl(const uint8_t *cborPayload, size_t cborSize,
69 OicSecAmacl_t **amacl);
71 void DeleteAmaclList(OicSecAmacl_t *amacl);
74 * This internal method is the entity handler for Cred resources
75 * to handle REST request (PUT/POST/DEL)
77 OCEntityHandlerResult CredEntityHandler(OCEntityHandlerFlag flag,
78 OCEntityHandlerRequest * ehRequest,
79 void* callbackParameter);
82 * This internal method is used to create '/oic/sec/Cred' resource.
84 OCStackResult CreateCredResource();
87 * This function converts from CBOR format into credential structure .
88 * Caller needs to invoke 'free' for allocated structure.
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.
95 * @return ::OC_STACK_OK if conversion is successful, else ::OC_STACK_ERROR if unsuccessful.
97 OCStackResult CBORPayloadToCred(const uint8_t *cborPayload, size_t size,
98 OicSecCred_t **secCred);
101 * This internal method is used to create '/oic/sec/doxm' resource.
103 OCStackResult CreateDoxmResource();
106 * This internal method is the entity handler for DOXM resources.
108 OCEntityHandlerResult DoxmEntityHandler(OCEntityHandlerFlag flag,
109 OCEntityHandlerRequest * ehRequest,
110 void* callbackParam);
116 #endif //IOTVT_SRM_SECURITY_INTERNALS_H