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 request CRED information to resource.
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.
53 OCStackResult SRPGetCredResource(void *ctx, const OCProvisionDev_t *selectedDeviceInfo,
54 OCProvisionResultCB resultCallback);
57 * API to request ACL information to resource.
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.
64 OCStackResult SRPGetACLResource(void *ctx, const OCProvisionDev_t *selectedDeviceInfo,
65 OCProvisionResultCB resultCallback);
67 #if defined(__WITH_X509__) || defined(__WITH_TLS__)
69 * API to send CRL information to resource.
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.
77 OCStackResult SRPProvisionCRL(void *ctx, const OCProvisionDev_t *selectedDeviceInfo,
78 OicSecCrl_t *crl, OCProvisionResultCB resultCallback);
81 * function to provision Trust certificate chain to devices.
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.
91 OCStackResult SRPProvisionTrustCertChain(void *ctx, OicSecCredType_t type, uint16_t credId,
92 const OCProvisionDev_t *selectedDeviceInfo,
93 OCProvisionResultCB resultCallback);
96 * function to save Trust certificate chain into Cred of SVR.
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.
104 OCStackResult SRPSaveTrustCertChain(uint8_t *trustCertChain, size_t chainSize,
105 OicEncodingType_t encodingType,uint16_t *credId);
108 * function to save own certificate chain into Cred of SVR.
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.
115 OCStackResult SRPSaveOwnCertChain(OicSecCert_t * cert, OicSecKey_t * key, uint16_t *credId);
117 #endif // __WITH_X509__ || __WITH_TLS__
119 * API to send Direct-Pairing Configuration to a device.
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.
127 OCStackResult SRPProvisionDirectPairing(void *ctx, const OCProvisionDev_t *selectedDeviceInfo,
128 OicSecPconf_t *pconf, OCProvisionResultCB resultCallback);
131 * API to send Direct-Pairing Configuration to a device.
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.
139 OCStackResult SRPProvisionDirectPairing(void *ctx, const OCProvisionDev_t *selectedDeviceInfo,
140 OicSecPconf_t *pconf, OCProvisionResultCB resultCallback);
143 * API to provision credential to devices.
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.
152 OCStackResult SRPProvisionCredentials(void *ctx,OicSecCredType_t type, size_t keySize,
153 const OCProvisionDev_t *pDev1,
154 const OCProvisionDev_t *pDev2,
155 OCProvisionResultCB resultCallback);
158 * Function to unlink devices.
159 * This function will remove the credential & relationship between the two devices.
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.
169 OCStackResult SRPUnlinkDevices(void* ctx,
170 const OCProvisionDev_t* pTargetDev1,
171 const OCProvisionDev_t* pTargetDev2,
172 OCProvisionResultCB resultCallback);
175 * Function to device revocation.
176 * This function will remove credential of target device from all devices in subnet.
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.
188 OCStackResult SRPRemoveDevice(void* ctx,
189 unsigned short waitTimeForOwnedDeviceDiscovery,
190 const OCProvisionDev_t* pTargetDev,
191 OCProvisionResultCB resultCallback);
194 * Function to device revocation
195 * This function will remove credential of target device from all devices in subnet.
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.
206 OCStackResult SRPRemoveDeviceWithoutDiscovery(void* ctx, const OCProvisionDev_t* pOwnedDevList,
207 const OCProvisionDev_t* pTargetDev, OCProvisionResultCB resultCallback);
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.
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.
223 OCStackResult SRPSyncDevice(void* ctx, unsigned short waitTimeForOwnedDeviceDiscovery,
224 const OCProvisionDev_t* pTargetDev, OCProvisionResultCB resultCallback);
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.
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.
239 OCStackResult SRPResetDevice(const OCProvisionDev_t* pTargetDev,
240 OCProvisionResultCB resultCallback);
245 #endif //SRP_SECURERESOURCEPROVIDER_H