1 /* *****************************************************************
3 * Copyright 2015 Samsung Electronics All Rights Reserved.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 * *****************************************************************/
21 #ifndef SRP_SECURERESOURCEPROVIDER_H
22 #define SRP_SECURERESOURCEPROVIDER_H
25 #include "securevirtualresourcetypes.h"
34 * API to send ACL information to resource.
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.
42 OCStackResult SRPProvisionACL(void *ctx, const OCProvisionDev_t *selectedDeviceInfo,
43 OicSecAcl_t *acl, OCProvisionResultCB resultCallback);
46 * API to save ACL which has several ACE into Acl of SVR.
48 * @param acl ACL to be saved in Acl of SVR.
49 * @return OC_STACK_OK in case of success and other value otherwise.
51 OCStackResult SRPSaveACL(const OicSecAcl_t *acl);
54 * API to request CRED information to resource.
56 * @param[in] selectedDeviceInfo Selected target device.
57 * @param[in] resultCallback callback provided by API user, callback will be called when
58 * provisioning request recieves a response from resource server.
59 * @return OC_STACK_OK in case of success and other value otherwise.
61 OCStackResult SRPGetCredResource(void *ctx, const OCProvisionDev_t *selectedDeviceInfo,
62 OCProvisionResultCB resultCallback);
65 * API to request ACL information to resource.
67 * @param[in] selectedDeviceInfo Selected target device.
68 * @param[in] resultCallback callback provided by API user, callback will be called when
69 * provisioning request recieves a response from resource server.
70 * @return OC_STACK_OK in case of success and other value otherwise.
72 OCStackResult SRPGetACLResource(void *ctx, const OCProvisionDev_t *selectedDeviceInfo,
73 OCProvisionResultCB resultCallback);
75 #if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
78 * function to provision Trust certificate chain to devices.
80 * @param[in] ctx Application context would be returned in result callback.
81 * @param[in] type Type of credentials to be provisioned to the device.
82 * @param[in] credId CredId of trust certificate chain to be provisioned to the device.
83 * @param[in] selectedDeviceInfo Pointer to OCProvisionDev_t instance,respresenting resource to be provsioned.
84 * @param[in] resultCallback callback provided by API user, callback will be called when
85 * provisioning request recieves a response from first resource server.
86 * @return OC_STACK_OK in case of success and other value otherwise.
88 OCStackResult SRPProvisionTrustCertChain(void *ctx, OicSecCredType_t type, uint16_t credId,
89 const OCProvisionDev_t *selectedDeviceInfo,
90 OCProvisionResultCB resultCallback);
93 * function to save Trust certificate chain into Cred of SVR.
95 * @param[in] trustCertChain Trust certificate chain to be saved in Cred of SVR.
96 * @param[in] chainSize Size of trust certificate chain to be saved in Cred of SVR
97 * @param[in] encodingType Encoding type of trust certificate chain to be saved in Cred of SVR
98 * @param[out] credId CredId of saved trust certificate chain in Cred of SVR.
99 * @return OC_STACK_OK in case of success and other value otherwise.
101 OCStackResult SRPSaveTrustCertChain(uint8_t *trustCertChain, size_t chainSize,
102 OicEncodingType_t encodingType,uint16_t *credId);
105 * function to save own certificate chain into Cred of SVR.
107 * @param[in] cert own certificate chain to be saved in Cred of SVR.
108 * @param[in] key own secret key to be saved in Cred of SVR.
109 * @param[out] credId CredId of saved trust certificate chain in Cred of SVR.
110 * @return OC_STACK_OK in case of success and other value otherwise.
112 OCStackResult SRPSaveOwnCertChain(OicSecCert_t * cert, OicSecKey_t * key, uint16_t *credId);
114 #endif // __WITH_DTLS__ || __WITH_TLS__
116 * API to send Direct-Pairing Configuration to a device.
118 * @param[in] selectedDeviceInfo Selected target device.
119 * @param[in] pconf PCONF pointer.
120 * @param[in] resultCallback callback provided by API user, callback will be called when
121 * provisioning request recieves a response from resource server.
122 * @return OC_STACK_OK in case of success and other value otherwise.
124 OCStackResult SRPProvisionDirectPairing(void *ctx, const OCProvisionDev_t *selectedDeviceInfo,
125 OicSecPconf_t *pconf, OCProvisionResultCB resultCallback);
128 * API to send Direct-Pairing Configuration to a device.
130 * @param[in] selectedDeviceInfo Selected target device.
131 * @param[in] pconf PCONF pointer.
132 * @param[in] resultCallback callback provided by API user, callback will be called when
133 * provisioning request recieves a response from resource server.
134 * @return OC_STACK_OK in case of success and other value otherwise.
136 OCStackResult SRPProvisionDirectPairing(void *ctx, const OCProvisionDev_t *selectedDeviceInfo,
137 OicSecPconf_t *pconf, OCProvisionResultCB resultCallback);
140 * API to provision credential to devices.
142 * @param[in] type Type of credentials to be provisioned to the device.
143 * @param[in] pDev1 Pointer to PMOwnedDeviceInfo_t instance,respresenting resource to be provsioned.
144 @param[in] pDev2 Pointer to PMOwnedDeviceInfo_t instance,respresenting resource to be provsioned.
145 * @param[in] resultCallback callback provided by API user, callback will be called when
146 * provisioning request recieves a response from first resource server.
147 * @return OC_STACK_OK in case of success and other value otherwise.
149 OCStackResult SRPProvisionCredentials(void *ctx,OicSecCredType_t type, size_t keySize,
150 const OCProvisionDev_t *pDev1,
151 const OCProvisionDev_t *pDev2,
152 OCProvisionResultCB resultCallback);
155 * Function to unlink devices.
156 * This function will remove the credential & relationship between the two devices.
158 * @param[in] ctx Application context would be returned in result callback
159 * @param[in] pTargetDev1 first device information to be unlinked.
160 * @param[in] pTargetDev2 second device information to be unlinked.
161 * @param[in] resultCallback callback provided by API user, callback will be called when
162 * device unlink is finished.
163 * when there is an error, this user callback is called immediately.
164 * @return OC_STACK_OK in case of success and other value otherwise.
166 OCStackResult SRPUnlinkDevices(void* ctx,
167 const OCProvisionDev_t* pTargetDev1,
168 const OCProvisionDev_t* pTargetDev2,
169 OCProvisionResultCB resultCallback);
172 * Function to device revocation.
173 * This function will remove credential of target device from all devices in subnet.
175 * @param[in] ctx Application context would be returned in result callback
176 * @param[in] waitTimeForOwnedDeviceDiscovery Maximum wait time for owned device discovery.(seconds)
177 * @param[in] pTargetDev Device information to be revoked.
178 * @param[in] resultCallback callback provided by API user, callback will be called when
179 * credential revocation is finished.
180 * when there is an error, this user callback is called immediately.
181 * @return OC_STACK_OK in case of success and other value otherwise.
182 * If OC_STACK_OK is returned, the caller of this API should wait for callback.
183 * OC_STACK_CONTINUE means operation is success but no request is need to be initiated.
185 OCStackResult SRPRemoveDevice(void* ctx,
186 unsigned short waitTimeForOwnedDeviceDiscovery,
187 const OCProvisionDev_t* pTargetDev,
188 OCProvisionResultCB resultCallback);
191 * Function to device revocation
192 * This function will remove credential of target device from all devices in subnet.
194 * @param[in] ctx Application context would be returned in result callback
195 * @param[in] pOwnedDevList List of owned devices
196 * @param[in] pTargetDev Device information to be revoked.
197 * @param[in] resultCallback callback provided by API user, callback will be called when
198 * credential revocation is finished.
199 * @return OC_STACK_OK in case of success and other value otherwise.
200 * If OC_STACK_OK is returned, the caller of this API should wait for callback.
201 * OC_STACK_CONTINUE means operation is success but no request is need to be initiated.
203 OCStackResult SRPRemoveDeviceWithoutDiscovery(void* ctx, const OCProvisionDev_t* pOwnedDevList,
204 const OCProvisionDev_t* pTargetDev, OCProvisionResultCB resultCallback);
207 * Function to sync-up credential and ACL of the target device.
208 * This function will remove credential and ACL of target device from all devices in subnet.
210 * @param[in] ctx Application context would be returned in result callback
211 * @param[in] waitTimeForOwnedDeviceDiscovery Maximum wait time for owned device discovery.(seconds)
212 * @param[in] pTargetDev Device information to be revoked.
213 * @param[in] resultCallback callback provided by API user, callback will be called when
214 * credential revocation is finished.
215 * when there is an error, this user callback is called immediately.
216 * @return OC_STACK_OK in case of success and other value otherwise.
217 * If OC_STACK_OK is returned, the caller of this API should wait for callback.
218 * OC_STACK_CONTINUE means operation is success but no request is need to be initiated.
220 OCStackResult SRPSyncDevice(void* ctx, unsigned short waitTimeForOwnedDeviceDiscovery,
221 const OCProvisionDev_t* pTargetDev, OCProvisionResultCB resultCallback);
224 * Function for remote reset
225 * This function will send pstat POST(modify) message to the target device
226 * to change current mode to reset state in order to initiate remote reset.
228 * @param[in] pTargetDev Device information to be revoked.
229 * @param[in] resultCallback callback provided by API user, callback will be called when
230 * credential revocation is finished.
231 * when there is an error, this user callback is called immediately.
232 * @return OC_STACK_OK in case of success and other value otherwise.
233 * If OC_STACK_OK is returned, the caller of this API should wait for callback.
234 * OC_STACK_CONTINUE means operation is success but no request is need to be initiated.
236 OCStackResult SRPResetDevice(const OCProvisionDev_t* pTargetDev,
237 OCProvisionResultCB resultCallback);
242 #endif //SRP_SECURERESOURCEPROVIDER_H