[IOT-1884] Allow IoTivity to generate and persist PIID
[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 /**
25  * Reads the database from PS
26  *
27  * @note Caller of this method MUST use OICFree() method to release memory
28  *       referenced by the data argument.
29  *
30  * @param databaseName is the name of the database to access through persistent storage.
31  * @param resourceName is the name of the field for which file content are read.
32  *                     if the value is NULL it will send the content of the whole file.
33  * @param data         is the pointer to the file contents read from the database.
34  * @param size         is the size of the file contents read.
35  *
36  * @return ::OC_STACK_OK for Success, otherwise some error value
37  */
38 OCStackResult ReadDatabaseFromPS(const char *databaseName, const char *resourceName, uint8_t **data, size_t *size);
39
40 /**
41  * This method updates the database in PS
42  *
43  * @param databaseName  is the name of the database to access through persistent storage.
44  * @param resourceName  is the name of the resource that will be updated.
45  * @param payload       is the pointer to memory where the CBOR payload is located.
46  * @param size          is the size of the CBOR payload.
47  *
48  * @return ::OC_STACK_OK for Success, otherwise some error value
49  */
50 OCStackResult UpdateResourceInPS(const char *databaseName, const char *resourceName, const uint8_t *payload, size_t size);
51
52 /**
53  * Reads the Secure Virtual Database from PS into dynamically allocated
54  * memory buffer.
55  *
56  * @note Caller of this method MUST use OICFree() method to release memory
57  *       referenced by return value.
58  *
59  * @return char * reference to memory buffer containing SVR database.
60  */
61 char * GetSVRDatabase();
62
63 /**
64  * Reads the Secure Virtual Database from PS
65  *
66  * @note Caller of this method MUST use OICFree() method to release memory
67  *       referenced by return value.
68  *
69  * @param resourceName is the name of the field for which file content are read.
70  *                     if the value is NULL it will send the content of the whole file.
71  * @param data         is the pointer to the file contents read from the database.
72  * @param size         is the size of the file contents read.
73  *
74  * @return ::OC_STACK_OK for Success, otherwise some error value
75  */
76 OCStackResult GetSecureVirtualDatabaseFromPS(const char *resourceName, uint8_t **data, size_t *size);
77
78 /**
79  * This method updates the Secure Virtual Database in PS
80  *
81  * @param resourceName  is the name of the secure resource that will be updated.
82  * @param payload       is the pointer to memory where the CBOR payload is located.
83  * @param size          is the size of the CBOR payload.
84  *
85  * @return ::OC_STACK_OK for Success, otherwise some error value
86  */
87 OCStackResult UpdateSecureResourceInPS(const char *resourceName, const uint8_t *payload, size_t size);
88
89 /**
90  * This method resets the secure resources according to the reset profile.
91  *
92  * @return ::OC_STACK_OK for Success, otherwise some error value
93  */
94 OCStackResult ResetSecureResourceInPS(void);
95
96 /**
97  * This method creates the reset profile from the persistent storage.
98  * The reset profile is the copy of the initial state of SVR resources
99  * when secure resources are initiated at first.
100  * In remote reset, the SVR will be reset according to the reset profile.
101  *
102  * @return ::OC_STACK_OK for Success, otherwise some error value
103  */
104 OCStackResult CreateResetProfile(void);
105
106 #endif //IOTVT_SRM_PSI_H