Imported Upstream version 1.1.1
[platform/upstream/iotivity.git] / resource / csdk / security / provisioning / include / internal / secureresourceprovider.h
1 /* *****************************************************************
2  *
3  * Copyright 2015 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
21 #ifndef SRP_SECURERESOURCEPROVIDER_H
22 #define SRP_SECURERESOURCEPROVIDER_H
23
24 #include "ocstack.h"
25 #include "securevirtualresourcetypes.h"
26 #include "pmtypes.h"
27
28 #ifdef __cplusplus
29 extern "C"
30 {
31 #endif
32
33 /**
34  * API to send ACL information to resource.
35  *
36  * @param[in] selectedDeviceInfo Selected target device.
37  * @param[in] acl ACL to provision.
38  * @param[in] resultCallback callback provided by API user, callback will be called when
39  *            provisioning request recieves a response from resource server.
40  * @return OC_STACK_OK in case of success and other value otherwise.
41  */
42 OCStackResult SRPProvisionACL(void *ctx, const OCProvisionDev_t *selectedDeviceInfo,
43                                         OicSecAcl_t *acl, OCProvisionResultCB resultCallback);
44
45 /**
46  * API to request CRED information to resource.
47  *
48  * @param[in] selectedDeviceInfo Selected target device.
49  * @param[in] resultCallback callback provided by API user, callback will be called when
50  *            provisioning request recieves a response from resource server.
51  * @return OC_STACK_OK in case of success and other value otherwise.
52  */
53 OCStackResult SRPGetCredResource(void *ctx, const OCProvisionDev_t *selectedDeviceInfo,
54         OCProvisionResultCB resultCallback);
55
56 /**
57  * API to request ACL information to resource.
58  *
59  * @param[in] selectedDeviceInfo Selected target device.
60  * @param[in] resultCallback callback provided by API user, callback will be called when
61  *            provisioning request recieves a response from resource server.
62  * @return OC_STACK_OK in case of success and other value otherwise.
63  */
64 OCStackResult SRPGetACLResource(void *ctx, const OCProvisionDev_t *selectedDeviceInfo,
65         OCProvisionResultCB resultCallback);
66
67 #ifdef __WITH_X509__
68 /**
69  * API to send CRL information to resource.
70  *
71  * @param[in] selectedDeviceInfo Selected target device.
72  * @param[in] crl CRL to provision.
73  * @param[in] resultCallback callback provided by API user, callback will be called when
74  *            provisioning request recieves a response from resource server.
75  * @return OC_STACK_OK in case of success and other value otherwise.
76  */
77 OCStackResult SRPProvisionCRL(void *ctx, const OCProvisionDev_t *selectedDeviceInfo,
78         OicSecCrl_t *crl, OCProvisionResultCB resultCallback);
79 #endif // __WITH_X509__
80 /**
81  * API to send Direct-Pairing Configuration to a device.
82  *
83  * @param[in] selectedDeviceInfo Selected target device.
84  * @param[in] pconf PCONF pointer.
85  * @param[in] resultCallback callback provided by API user, callback will be called when
86  *            provisioning request recieves a response from resource server.
87  * @return OC_STACK_OK in case of success and other value otherwise.
88  */
89 OCStackResult SRPProvisionDirectPairing(void *ctx, const OCProvisionDev_t *selectedDeviceInfo,
90                                         OicSecPconf_t *pconf, OCProvisionResultCB resultCallback);
91
92 /**
93  * API to provision credential to devices.
94  *
95  * @param[in] type Type of credentials to be provisioned to the device.
96  * @param[in] pDev1 Pointer to PMOwnedDeviceInfo_t instance,respresenting resource to be provsioned.
97    @param[in] pDev2 Pointer to PMOwnedDeviceInfo_t instance,respresenting resource to be provsioned.
98  * @param[in] resultCallback callback provided by API user, callback will be called when
99  *            provisioning request recieves a response from first resource server.
100  * @return OC_STACK_OK in case of success and other value otherwise.
101  */
102 OCStackResult SRPProvisionCredentials(void *ctx,OicSecCredType_t type, size_t keySize,
103                                       const OCProvisionDev_t *pDev1,
104                                       const OCProvisionDev_t *pDev2,
105                                       OCProvisionResultCB resultCallback);
106
107 /**
108  * Function to unlink devices.
109  * This function will remove the credential & relationship between the two devices.
110  *
111  * @param[in] ctx Application context would be returned in result callback
112  * @param[in] pTargetDev1 first device information to be unlinked.
113  * @param[in] pTargetDev2 second device information to be unlinked.
114  * @param[in] resultCallback callback provided by API user, callback will be called when
115  *            device unlink is finished.
116  *            when there is an error, this user callback is called immediately.
117  * @return OC_STACK_OK in case of success and other value otherwise.
118  */
119 OCStackResult SRPUnlinkDevices(void* ctx,
120                               const OCProvisionDev_t* pTargetDev1,
121                               const OCProvisionDev_t* pTargetDev2,
122                               OCProvisionResultCB resultCallback);
123
124 /*
125  * Function to device revocation.
126  * This function will remove credential of target device from all devices in subnet.
127  *
128  * @param[in] ctx Application context would be returned in result callback
129  * @param[in] waitTimeForOwnedDeviceDiscovery Maximum wait time for owned device discovery.(seconds)
130  * @param[in] pTargetDev Device information to be revoked.
131  * @param[in] resultCallback callback provided by API user, callback will be called when
132  *            credential revocation is finished.
133  *            when there is an error, this user callback is called immediately.
134  * @return OC_STACK_OK in case of success and other value otherwise.
135  *         If OC_STACK_OK is returned, the caller of this API should wait for callback.
136  *         OC_STACK_CONTINUE means operation is success but no request is need to be initiated.
137  */
138 OCStackResult SRPRemoveDevice(void* ctx,
139                               unsigned short waitTimeForOwnedDeviceDiscovery,
140                               const OCProvisionDev_t* pTargetDev,
141                               OCProvisionResultCB resultCallback);
142
143 /*
144 * Function to device revocation
145 * This function will remove credential of target device from all devices in subnet.
146 *
147 * @param[in] ctx Application context would be returned in result callback
148 * @param[in] pOwnedDevList List of owned devices
149 * @param[in] pTargetDev Device information to be revoked.
150 * @param[in] resultCallback callback provided by API user, callback will be called when
151 *            credential revocation is finished.
152 * @return  OC_STACK_OK in case of success and other value otherwise.
153 *          If OC_STACK_OK is returned, the caller of this API should wait for callback.
154 *          OC_STACK_CONTINUE means operation is success but no request is need to be initiated.
155 */
156 OCStackResult SRPRemoveDeviceWithoutDiscovery(void* ctx, const OCProvisionDev_t* pOwnedDevList,
157                              const OCProvisionDev_t* pTargetDev, OCProvisionResultCB resultCallback);
158
159 /*
160  * Function to sync-up credential and ACL of the target device.
161  * This function will remove credential and ACL of target device from all devices in subnet.
162  *
163  * @param[in] ctx Application context would be returned in result callback
164  * @param[in] waitTimeForOwnedDeviceDiscovery Maximum wait time for owned device discovery.(seconds)
165  * @param[in] pTargetDev Device information to be revoked.
166  * @param[in] resultCallback callback provided by API user, callback will be called when
167  *            credential revocation is finished.
168  *            when there is an error, this user callback is called immediately.
169  * @return OC_STACK_OK in case of success and other value otherwise.
170  *         If OC_STACK_OK is returned, the caller of this API should wait for callback.
171  *         OC_STACK_CONTINUE means operation is success but no request is need to be initiated.
172  */
173 OCStackResult SRPSyncDevice(void* ctx, unsigned short waitTimeForOwnedDeviceDiscovery,
174                          const OCProvisionDev_t* pTargetDev, OCProvisionResultCB resultCallback);
175
176 /*
177  * Function for remote reset
178  * This function will send pstat POST(modify) message to the target device
179  * to change current mode to reset state in order to initiate remote reset.
180  *
181  * @param[in] pTargetDev Device information to be revoked.
182  * @param[in] resultCallback callback provided by API user, callback will be called when
183  *            credential revocation is finished.
184  *            when there is an error, this user callback is called immediately.
185  * @return OC_STACK_OK in case of success and other value otherwise.
186  *         If OC_STACK_OK is returned, the caller of this API should wait for callback.
187  *         OC_STACK_CONTINUE means operation is success but no request is need to be initiated.
188  */
189 OCStackResult SRPResetDevice(const OCProvisionDev_t* pTargetDev,
190         OCProvisionResultCB resultCallback);
191
192 #ifdef __cplusplus
193 }
194 #endif
195 #endif //SRP_SECURERESOURCEPROVIDER_H