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