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_DTLS__) || defined(__WITH_TLS__)
70 * function to provision Trust certificate chain to devices.
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.
80 OCStackResult SRPProvisionTrustCertChain(void *ctx, OicSecCredType_t type, uint16_t credId,
81 const OCProvisionDev_t *selectedDeviceInfo,
82 OCProvisionResultCB resultCallback);
85 * function to save Trust certificate chain into Cred of SVR.
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.
93 OCStackResult SRPSaveTrustCertChain(uint8_t *trustCertChain, size_t chainSize,
94 OicEncodingType_t encodingType,uint16_t *credId);
97 * function to save own certificate chain into Cred of SVR.
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.
104 OCStackResult SRPSaveOwnCertChain(OicSecCert_t * cert, OicSecKey_t * key, uint16_t *credId);
106 #endif // __WITH_DTLS__ || __WITH_TLS__
108 * API to send Direct-Pairing Configuration to a device.
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.
116 OCStackResult SRPProvisionDirectPairing(void *ctx, const OCProvisionDev_t *selectedDeviceInfo,
117 OicSecPconf_t *pconf, OCProvisionResultCB resultCallback);
120 * API to send Direct-Pairing Configuration to a device.
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.
128 OCStackResult SRPProvisionDirectPairing(void *ctx, const OCProvisionDev_t *selectedDeviceInfo,
129 OicSecPconf_t *pconf, OCProvisionResultCB resultCallback);
132 * API to provision credential to devices.
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.
141 OCStackResult SRPProvisionCredentials(void *ctx,OicSecCredType_t type, size_t keySize,
142 const OCProvisionDev_t *pDev1,
143 const OCProvisionDev_t *pDev2,
144 OCProvisionResultCB resultCallback);
147 * Function to unlink devices.
148 * This function will remove the credential & relationship between the two devices.
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.
158 OCStackResult SRPUnlinkDevices(void* ctx,
159 const OCProvisionDev_t* pTargetDev1,
160 const OCProvisionDev_t* pTargetDev2,
161 OCProvisionResultCB resultCallback);
164 * Function to device revocation.
165 * This function will remove credential of target device from all devices in subnet.
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.
177 OCStackResult SRPRemoveDevice(void* ctx,
178 unsigned short waitTimeForOwnedDeviceDiscovery,
179 const OCProvisionDev_t* pTargetDev,
180 OCProvisionResultCB resultCallback);
183 * Function to device revocation
184 * This function will remove credential of target device from all devices in subnet.
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.
195 OCStackResult SRPRemoveDeviceWithoutDiscovery(void* ctx, const OCProvisionDev_t* pOwnedDevList,
196 const OCProvisionDev_t* pTargetDev, OCProvisionResultCB resultCallback);
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.
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.
212 OCStackResult SRPSyncDevice(void* ctx, unsigned short waitTimeForOwnedDeviceDiscovery,
213 const OCProvisionDev_t* pTargetDev, OCProvisionResultCB resultCallback);
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.
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.
228 OCStackResult SRPResetDevice(const OCProvisionDev_t* pTargetDev,
229 OCProvisionResultCB resultCallback);
234 #endif //SRP_SECURERESOURCEPROVIDER_H