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"
36 * API to send ACL information to resource.
38 * @param[in] ctx Application context to be returned in result callback.
39 * @param[in] selectedDeviceInfo Selected target device.
40 * @param[in] acl ACL to provision.
41 * @param[in] resultCallback callback provided by API user, callback will be called when
42 * provisioning request recieves a response from resource server.
43 * @return OC_STACK_OK in case of success and other value otherwise.
45 OCStackResult SRPProvisionACL(void *ctx, const OCProvisionDev_t *selectedDeviceInfo,
46 OicSecAcl_t *acl, OCProvisionResultCB resultCallback);
49 * API to save ACL which has several ACE into Acl of SVR.
51 * @param acl ACL to be saved in Acl of SVR.
52 * @return OC_STACK_OK in case of success and other value otherwise.
54 OCStackResult SRPSaveACL(const OicSecAcl_t *acl);
57 * API to request CRED information to resource.
59 * @param[in] ctx Application context to be returned in result callback.
60 * @param[in] selectedDeviceInfo Selected target device.
61 * @param[in] resultCallback callback provided by API user, callback will be called when
62 * provisioning request recieves a response from resource server.
63 * @return OC_STACK_OK in case of success and other value otherwise.
65 OCStackResult SRPGetCredResource(void *ctx, const OCProvisionDev_t *selectedDeviceInfo,
66 OCProvisionResultCB resultCallback);
69 * API to request ACL information to resource.
71 * @param[in] ctx Application context to be returned in result callback.
72 * @param[in] selectedDeviceInfo Selected target device.
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 SRPGetACLResource(void *ctx, const OCProvisionDev_t *selectedDeviceInfo,
78 OCProvisionResultCB resultCallback);
81 * API to request the Certificate Signing Request (CSR) resource.
83 * @param[in] selectedDeviceInfo Selected target device.
84 * @param[in] resultCallback callback provided by API user, callback will be called when
85 * provisioning request recieves a response from resource server.
86 * @return OC_STACK_OK in case of success and other value otherwise.
88 OCStackResult SRPGetCSRResource(void *ctx, const OCProvisionDev_t *selectedDeviceInfo,
89 OCGetCSRResultCB resultCallback);
91 #if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
94 * function to provision Trust certificate chain to devices.
96 * @param[in] ctx Application context to be returned in result callback.
97 * @param[in] type Type of credentials to be provisioned to the device.
98 * @param[in] credId CredId of trust certificate chain to be provisioned to the device.
99 * @param[in] selectedDeviceInfo Pointer to OCProvisionDev_t instance,respresenting resource to be provsioned.
100 * @param[in] resultCallback callback provided by API user, callback will be called when
101 * provisioning request recieves a response from first resource server.
102 * @return OC_STACK_OK in case of success and other value otherwise.
104 OCStackResult SRPProvisionTrustCertChain(void *ctx, OicSecCredType_t type, uint16_t credId,
105 const OCProvisionDev_t *selectedDeviceInfo,
106 OCProvisionResultCB resultCallback);
109 * function to save Trust certificate chain into Cred of SVR.
111 * @param[in] trustCertChain Trust certificate chain to be saved in Cred of SVR.
112 * @param[in] chainSize Size of trust certificate chain to be saved in Cred of SVR
113 * @param[in] encodingType Encoding type of trust certificate chain to be saved in Cred of SVR
114 * @param[out] credId CredId of saved trust certificate chain in Cred of SVR.
115 * @return OC_STACK_OK in case of success and other value otherwise.
117 OCStackResult SRPSaveTrustCertChain(uint8_t *trustCertChain, size_t chainSize,
118 OicEncodingType_t encodingType,uint16_t *credId);
121 * function to save own certificate chain into Cred of SVR.
123 * @param[in] cert own certificate chain to be saved in Cred of SVR.
124 * @param[in] key own secret key to be saved in Cred of SVR.
125 * @param[out] credId CredId of saved trust certificate chain in Cred of SVR.
126 * @return OC_STACK_OK in case of success and other value otherwise.
128 OCStackResult SRPSaveOwnCertChain(OicSecKey_t * cert, OicSecKey_t * key, uint16_t *credId);
131 * function to register callback, for getting notification for TrustCertChain change.
133 * @param[in] ctx user context to be passed.
134 * @param[in] TrustCertChainChangeCB notifier callback function
135 * @return OC_STACK_OK in case of success and other value otherwise.
137 OCStackResult SRPRegisterTrustCertChainNotifier(void *ctx, TrustCertChainChangeCB callback);
140 * function to de-register TrustCertChain notification callback.
142 void SRPRemoveTrustCertChainNotifier(void);
144 #endif // __WITH_DTLS__ || __WITH_TLS__
146 * API to send Direct-Pairing Configuration to a device.
148 * @param[in] ctx Application context to be returned in result callback.
149 * @param[in] selectedDeviceInfo Selected target device.
150 * @param[in] pconf PCONF pointer.
151 * @param[in] resultCallback callback provided by API user, callback will be called when
152 * provisioning request recieves a response from resource server.
153 * @return OC_STACK_OK in case of success and other value otherwise.
155 OCStackResult SRPProvisionDirectPairing(void *ctx, const OCProvisionDev_t *selectedDeviceInfo,
156 OicSecPconf_t *pconf, OCProvisionResultCB resultCallback);
159 * API to send Direct-Pairing Configuration to a device.
161 * @param[in] selectedDeviceInfo Selected target device.
162 * @param[in] pconf PCONF pointer.
163 * @param[in] resultCallback callback provided by API user, callback will be called when
164 * provisioning request recieves a response from resource server.
165 * @return OC_STACK_OK in case of success and other value otherwise.
167 OCStackResult SRPProvisionDirectPairing(void *ctx, const OCProvisionDev_t *selectedDeviceInfo,
168 OicSecPconf_t *pconf, OCProvisionResultCB resultCallback);
171 * API to provision credential to devices.
173 * @param[in] ctx Application context to be returned in result callback.
174 * @param[in] type Type of credentials to be provisioned to the device.
175 * @param[in] keySize size of key
176 * @param[in] pDev1 Pointer to PMOwnedDeviceInfo_t instance, respresenting resource to be provsioned.
177 * @param[in] pDev2 Pointer to PMOwnedDeviceInfo_t instance, respresenting resource to be provsioned.
178 * @param[in] pemCert When provisioning a certificate (type is SIGNED_ASYMMETRIC_KEY), this is the
179 * certificate, encoded as PEM.
180 * @param[in] resultCallback callback provided by API user, callback will be called when
181 * provisioning request recieves a response from first resource server.
182 * @return OC_STACK_OK in case of success and other value otherwise.
184 OCStackResult SRPProvisionCredentials(void *ctx,OicSecCredType_t type, size_t keySize,
185 const OCProvisionDev_t *pDev1,
186 const OCProvisionDev_t *pDev2,
188 OCProvisionResultCB resultCallback);
191 * Function to unlink devices.
192 * This function will remove the credential & relationship between the two devices.
194 * @param[in] ctx Application context to be returned in result callback
195 * @param[in] pTargetDev1 first device information to be unlinked.
196 * @param[in] pTargetDev2 second device information to be unlinked.
197 * @param[in] resultCallback callback provided by API user, callback will be called when
198 * device unlink is finished.
199 * when there is an error, this user callback is called immediately.
200 * @return OC_STACK_OK in case of success and other value otherwise.
202 OCStackResult SRPUnlinkDevices(void* ctx,
203 const OCProvisionDev_t* pTargetDev1,
204 const OCProvisionDev_t* pTargetDev2,
205 OCProvisionResultCB resultCallback);
208 * Function to device revocation.
209 * This function will remove credential of target device from all devices in subnet.
211 * @param[in] ctx Application context to be returned in result callback
212 * @param[in] waitTimeForOwnedDeviceDiscovery Maximum wait time for owned device discovery.(seconds)
213 * @param[in] pTargetDev Device information to be revoked.
214 * @param[in] resultCallback callback provided by API user, callback will be called when
215 * credential revocation is finished.
216 * when there is an error, this user callback is called immediately.
217 * @return OC_STACK_OK in case of success and other value otherwise.
218 * If OC_STACK_OK is returned, the caller of this API should wait for callback.
219 * OC_STACK_CONTINUE means operation is success but no request is need to be initiated.
221 OCStackResult SRPRemoveDevice(void* ctx,
222 unsigned short waitTimeForOwnedDeviceDiscovery,
223 const OCProvisionDev_t* pTargetDev,
224 OCProvisionResultCB resultCallback);
227 * Function to device revocation
228 * This function will remove credential of target device from all devices in subnet.
230 * @param[in] ctx Application context to be returned in result callback
231 * @param[in] pOwnedDevList List of owned devices
232 * @param[in] pTargetDev Device information to be revoked.
233 * @param[in] resultCallback callback provided by API user, callback will be called when
234 * credential revocation is finished.
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 SRPRemoveDeviceWithoutDiscovery(void* ctx, const OCProvisionDev_t* pOwnedDevList,
240 const OCProvisionDev_t* pTargetDev, OCProvisionResultCB resultCallback);
243 * Function to sync-up credential and ACL of the target device.
244 * This function will remove credential and ACL of target device from all devices in subnet.
246 * @param[in] ctx Application context to be returned in result callback
247 * @param[in] waitTimeForOwnedDeviceDiscovery Maximum wait time for owned device discovery.(seconds)
248 * @param[in] pTargetDev Device information to be revoked.
249 * @param[in] resultCallback callback provided by API user, callback will be called when
250 * credential revocation is finished.
251 * when there is an error, this user callback is called immediately.
252 * @return OC_STACK_OK in case of success and other value otherwise.
253 * If OC_STACK_OK is returned, the caller of this API should wait for callback.
254 * OC_STACK_CONTINUE means operation is success but no request is need to be initiated.
256 OCStackResult SRPSyncDevice(void* ctx, unsigned short waitTimeForOwnedDeviceDiscovery,
257 const OCProvisionDev_t* pTargetDev, OCProvisionResultCB resultCallback);
260 * Function for remote reset
261 * This function will send pstat POST(modify) message to the target device
262 * to change current mode to reset state in order to initiate remote reset.
264 * @param[in] pTargetDev Device information to be revoked.
265 * @param[in] resultCallback callback provided by API user, callback will be called when
266 * credential revocation is finished.
267 * when there is an error, this user callback is called immediately.
268 * @return OC_STACK_OK in case of success and other value otherwise.
269 * If OC_STACK_OK is returned, the caller of this API should wait for callback.
270 * OC_STACK_CONTINUE means operation is success but no request is need to be initiated.
272 OCStackResult SRPResetDevice(const OCProvisionDev_t* pTargetDev,
273 OCProvisionResultCB resultCallback);
276 * Function to read Trust certificate chain from SVR.
277 * Caller must free when done using the returned trust certificate
278 * @param[in] credId CredId of trust certificate chain in SVR.
279 * @param[out] trustCertChain Trust certificate chain.
280 * @param[out] chainSize Size of trust certificate chain
281 * @return OC_STACK_OK in case of success and other value otherwise.
283 OCStackResult SRPReadTrustCertChain(uint16_t credId, uint8_t **trustCertChain,
288 #endif //SRP_SECURERESOURCEPROVIDER_H