493690a254aa256c2fd622fedf7b0cedcf2616b2
[platform/upstream/iotivity.git] / resource / csdk / security / include / internal / psinterface.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 #ifndef IOTVT_SRM_PSI_H
22 #define IOTVT_SRM_PSI_H
23
24 #include "cJSON.h"
25
26 /**
27  * Reads the Secure Virtual Database from PS into dynamically allocated
28  * memory buffer.
29  *
30  * @note Caller of this method MUST use OCFree() method to release memory
31  *       referenced by return value.
32  *
33  * @return char * reference to memory buffer containing SVR database.
34  */
35 char * GetSVRDatabase();
36
37 /**
38  * This method is used by a entity handlers of SVR's to update
39  * SVR database.
40  *
41  * @param rsrcName string denoting the SVR name ("acl", "cred", "pstat" etc).
42  * @param jsonObj JSON object containing the SVR contents.
43  *
44  * @return ::OC_STACK_OK for Success, otherwise some error value
45  */
46 OCStackResult UpdateSVRDatabase(const char* rsrcName, cJSON* jsonObj);
47
48 /**
49  * Reads the Secure Virtual Database from PS
50  *
51  * @note Caller of this method MUST use OCFree() method to release memory
52  *       referenced by return value.
53  *
54  * @param rsrcName is the name of the field for which file content are read.
55                    if the value is NULL it will send the content of the whole file.
56  * @param data is the pointer to the file contents read from the database.
57  * @param size is the size to the file contents read.
58  *
59  * @return ::OC_STACK_OK for Success, otherwise some error value
60  */
61 OCStackResult GetSecureVirtualDatabaseFromPS(const char *rsrcName, uint8_t **data, size_t *size);
62
63 /**
64  * This method converts updates the persistent storage.
65  *
66  * @param rsrcName is the name of the secure resource that will be updated.
67  * @param cborPayload is the pointer holding cbor payload.
68  * @param cborPayload is the size of the cbor payload.
69  *
70  * @return ::OC_STACK_OK for Success, otherwise some error value
71  */
72 OCStackResult UpdateSecureResourceInPS(const char* rsrcName, uint8_t* cborPayload, size_t size);
73
74 /**
75  * This method resets the secure resources according to the reset profile.
76  *
77  * @return ::OC_STACK_OK for Success, otherwise some error value
78  */
79 OCStackResult ResetSecureResourceInPS(void);
80
81 /**
82  * This method creates the reset profile from the persistent storage.
83  * The reset profile is the copy of the initial state of SVR resources
84  * when secure resources are initiated at first.
85  * In remote reset, the SVR will be reset according to the reset profile.
86  *
87  * @return ::OC_STACK_OK for Success, otherwise some error value
88  */
89 OCStackResult CreateResetProfile(void);
90
91 #endif //IOTVT_SRM_PSI_H