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