Merge "Merge branch 'master' into notification-service" into notification-service
[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 #if defined(__WITH_X509__) || defined(__WITH_TLS__)
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
80 /**
81  * function to provision Trust certificate chain to devices.
82  *
83  * @param[in] ctx Application context would be returned in result callback.
84  * @param[in] type Type of credentials to be provisioned to the device.
85  * @param[in] credId CredId of trust certificate chain to be provisioned to the device.
86  * @param[in] selectedDeviceInfo Pointer to OCProvisionDev_t instance,respresenting resource to be provsioned.
87  * @param[in] resultCallback callback provided by API user, callback will be called when
88  *            provisioning request recieves a response from first resource server.
89  * @return  OC_STACK_OK in case of success and other value otherwise.
90  */
91 OCStackResult SRPProvisionTrustCertChain(void *ctx, OicSecCredType_t type, uint16_t credId,
92                                       const OCProvisionDev_t *selectedDeviceInfo,
93                                       OCProvisionResultCB resultCallback);
94
95 /**
96  * function to save Trust certificate chain into Cred of SVR.
97  *
98  * @param[in] trustCertChain Trust certificate chain to be saved in Cred of SVR.
99  * @param[in] chainSize Size of trust certificate chain to be saved in Cred of SVR
100  * @param[in] encodingType Encoding type of trust certificate chain to be saved in Cred of SVR
101  * @param[out] credId CredId of saved trust certificate chain in Cred of SVR.
102  * @return  OC_STACK_OK in case of success and other value otherwise.
103  */
104 OCStackResult SRPSaveTrustCertChain(uint8_t *trustCertChain, size_t chainSize,
105                                         OicEncodingType_t encodingType,uint16_t *credId);
106
107 #endif // __WITH_X509__ || __WITH_TLS__
108 /**
109  * API to send Direct-Pairing Configuration to a device.
110  *
111  * @param[in] selectedDeviceInfo Selected target device.
112  * @param[in] pconf PCONF pointer.
113  * @param[in] resultCallback callback provided by API user, callback will be called when
114  *            provisioning request recieves a response from resource server.
115  * @return OC_STACK_OK in case of success and other value otherwise.
116  */
117 OCStackResult SRPProvisionDirectPairing(void *ctx, const OCProvisionDev_t *selectedDeviceInfo,
118                                         OicSecPconf_t *pconf, OCProvisionResultCB resultCallback);
119
120 /**
121  * API to send Direct-Pairing Configuration to a device.
122  *
123  * @param[in] selectedDeviceInfo Selected target device.
124  * @param[in] pconf PCONF pointer.
125  * @param[in] resultCallback callback provided by API user, callback will be called when
126  *            provisioning request recieves a response from resource server.
127  * @return OC_STACK_OK in case of success and other value otherwise.
128  */
129 OCStackResult SRPProvisionDirectPairing(void *ctx, const OCProvisionDev_t *selectedDeviceInfo,
130                                         OicSecPconf_t *pconf, OCProvisionResultCB resultCallback);
131
132 /**
133  * API to provision credential to devices.
134  *
135  * @param[in] type Type of credentials to be provisioned to the device.
136  * @param[in] pDev1 Pointer to PMOwnedDeviceInfo_t instance,respresenting resource to be provsioned.
137    @param[in] pDev2 Pointer to PMOwnedDeviceInfo_t instance,respresenting resource to be provsioned.
138  * @param[in] resultCallback callback provided by API user, callback will be called when
139  *            provisioning request recieves a response from first resource server.
140  * @return OC_STACK_OK in case of success and other value otherwise.
141  */
142 OCStackResult SRPProvisionCredentials(void *ctx,OicSecCredType_t type, size_t keySize,
143                                       const OCProvisionDev_t *pDev1,
144                                       const OCProvisionDev_t *pDev2,
145                                       OCProvisionResultCB resultCallback);
146
147 /**
148  * Function to unlink devices.
149  * This function will remove the credential & relationship between the two devices.
150  *
151  * @param[in] ctx Application context would be returned in result callback
152  * @param[in] pTargetDev1 first device information to be unlinked.
153  * @param[in] pTargetDev2 second device information to be unlinked.
154  * @param[in] resultCallback callback provided by API user, callback will be called when
155  *            device unlink is finished.
156  *            when there is an error, this user callback is called immediately.
157  * @return OC_STACK_OK in case of success and other value otherwise.
158  */
159 OCStackResult SRPUnlinkDevices(void* ctx,
160                               const OCProvisionDev_t* pTargetDev1,
161                               const OCProvisionDev_t* pTargetDev2,
162                               OCProvisionResultCB resultCallback);
163
164 /*
165  * Function to device revocation.
166  * This function will remove credential of target device from all devices in subnet.
167  *
168  * @param[in] ctx Application context would be returned in result callback
169  * @param[in] waitTimeForOwnedDeviceDiscovery Maximum wait time for owned device discovery.(seconds)
170  * @param[in] pTargetDev Device information to be revoked.
171  * @param[in] resultCallback callback provided by API user, callback will be called when
172  *            credential revocation is finished.
173  *            when there is an error, this user callback is called immediately.
174  * @return OC_STACK_OK in case of success and other value otherwise.
175  *         If OC_STACK_OK is returned, the caller of this API should wait for callback.
176  *         OC_STACK_CONTINUE means operation is success but no request is need to be initiated.
177  */
178 OCStackResult SRPRemoveDevice(void* ctx,
179                               unsigned short waitTimeForOwnedDeviceDiscovery,
180                               const OCProvisionDev_t* pTargetDev,
181                               OCProvisionResultCB resultCallback);
182
183 /*
184 * Function to device revocation
185 * This function will remove credential of target device from all devices in subnet.
186 *
187 * @param[in] ctx Application context would be returned in result callback
188 * @param[in] pOwnedDevList List of owned devices
189 * @param[in] pTargetDev Device information to be revoked.
190 * @param[in] resultCallback callback provided by API user, callback will be called when
191 *            credential revocation is finished.
192 * @return  OC_STACK_OK in case of success and other value otherwise.
193 *          If OC_STACK_OK is returned, the caller of this API should wait for callback.
194 *          OC_STACK_CONTINUE means operation is success but no request is need to be initiated.
195 */
196 OCStackResult SRPRemoveDeviceWithoutDiscovery(void* ctx, const OCProvisionDev_t* pOwnedDevList,
197                              const OCProvisionDev_t* pTargetDev, OCProvisionResultCB resultCallback);
198
199 /*
200  * Function to sync-up credential and ACL of the target device.
201  * This function will remove credential and ACL of target device from all devices in subnet.
202  *
203  * @param[in] ctx Application context would be returned in result callback
204  * @param[in] waitTimeForOwnedDeviceDiscovery Maximum wait time for owned device discovery.(seconds)
205  * @param[in] pTargetDev Device information to be revoked.
206  * @param[in] resultCallback callback provided by API user, callback will be called when
207  *            credential revocation is finished.
208  *            when there is an error, this user callback is called immediately.
209  * @return OC_STACK_OK in case of success and other value otherwise.
210  *         If OC_STACK_OK is returned, the caller of this API should wait for callback.
211  *         OC_STACK_CONTINUE means operation is success but no request is need to be initiated.
212  */
213 OCStackResult SRPSyncDevice(void* ctx, unsigned short waitTimeForOwnedDeviceDiscovery,
214                          const OCProvisionDev_t* pTargetDev, OCProvisionResultCB resultCallback);
215
216 /*
217  * Function for remote reset
218  * This function will send pstat POST(modify) message to the target device
219  * to change current mode to reset state in order to initiate remote reset.
220  *
221  * @param[in] pTargetDev Device information to be revoked.
222  * @param[in] resultCallback callback provided by API user, callback will be called when
223  *            credential revocation is finished.
224  *            when there is an error, this user callback is called immediately.
225  * @return OC_STACK_OK in case of success and other value otherwise.
226  *         If OC_STACK_OK is returned, the caller of this API should wait for callback.
227  *         OC_STACK_CONTINUE means operation is success but no request is need to be initiated.
228  */
229 OCStackResult SRPResetDevice(const OCProvisionDev_t* pTargetDev,
230         OCProvisionResultCB resultCallback);
231
232 #ifdef __cplusplus
233 }
234 #endif
235 #endif //SRP_SECURERESOURCEPROVIDER_H