X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=resource%2Fcsdk%2Fsecurity%2Fprovisioning%2Fsrc%2Focprovisioningmanager.c;h=1a3f56c1aa3038d0f3f97a2896d0ad8683f6231a;hb=ae97988f9b8122969e7a95884e7a9f0990b1abfc;hp=60dc0a3996127605e28176035ec3a6b7c67e7192;hpb=cb8f68346843213bd8d6a8dcc2ecaa3714ff6b2f;p=platform%2Fupstream%2Fiotivity.git diff --git a/resource/csdk/security/provisioning/src/ocprovisioningmanager.c b/resource/csdk/security/provisioning/src/ocprovisioningmanager.c old mode 100755 new mode 100644 index 60dc0a3..1a3f56c --- a/resource/csdk/security/provisioning/src/ocprovisioningmanager.c +++ b/resource/csdk/security/provisioning/src/ocprovisioningmanager.c @@ -24,6 +24,9 @@ #include "pmutility.h" #include "srmutility.h" #include "ownershiptransfermanager.h" +#ifdef MULTIPLE_OWNER +#include "multipleownershiptransfermanager.h" +#endif //MULTIPLE_OWNER #include "oic_malloc.h" #include "logger.h" #include "secureresourceprovider.h" @@ -32,8 +35,10 @@ #include "utlist.h" #include "aclresource.h" //Note: SRM internal header #include "pconfresource.h" +#include "psinterface.h" +#include "srmresourcestrings.h" -#define TAG "OCPMAPI" +#define TAG "OIC_OCPMAPI" typedef struct Linkdata Linkdata_t; struct Linkdata @@ -50,6 +55,18 @@ struct Linkdata }; +#ifdef MULTIPLE_OWNER +typedef struct ProvPreconfPINCtx ProvPreconfPINCtx_t; +struct ProvPreconfPINCtx +{ + void *ctx; + const OCProvisionDev_t *devInfo; + const char* pin; + size_t pinLen; + OCProvisionResultCB resultCallback; +}; +#endif //MULTIPLE_OWNER + /** * The function is responsible for initializaton of the provisioning manager. It will load * provisioning database which have owned device's list and their linked status. @@ -65,6 +82,16 @@ OCStackResult OCInitPM(const char* dbPath) return PDMInit(dbPath); } +void OCTerminatePM() +{ + OTMTerminate(); +} + +OCStackResult OCPDMCleanupForTimeout() +{ + return PDMDeleteDeviceWithState(PDM_DEVICE_INIT); +} + /** * The function is responsible for discovery of owned/unowned device is specified endpoint/deviceID. * And this function will only return the specified device's response. @@ -87,6 +114,33 @@ OCStackResult OCDiscoverSingleDevice(unsigned short timeout, const OicUuid_t* de } /** + * The function is responsible for discovery of owned/unowned device is specified endpoint/deviceID. + * And this function will only return the specified device's response. + * + * @param[in] timeout Timeout in seconds, value till which function will listen to responses from + * server before returning the device. + * @param[in] deviceID deviceID of target device. + * @param[in] hostAddress MAC address of target device. + * @param[in] connType ConnectivityType for discovery. + * @param[out] ppFoundDevice OCProvisionDev_t of found device. + * @return OTM_SUCCESS in case of success and other value otherwise. + */ +OCStackResult OCDiscoverSingleDeviceInUnicast(unsigned short timeout, const OicUuid_t* deviceID, + const char* hostAddress, OCConnectivityType connType, + OCProvisionDev_t **ppFoundDevice) +{ + if( NULL == ppFoundDevice || NULL != *ppFoundDevice || 0 == timeout || NULL == deviceID || + NULL == hostAddress) + { + OIC_LOG(ERROR, TAG, "OCDiscoverSingleDeviceInUnicast : Invalid Parameter"); + return OC_STACK_INVALID_PARAM; + } + + return PMSingleDeviceDiscoveryInUnicast(timeout, deviceID, hostAddress, connType, + ppFoundDevice); +} + +/** * The function is responsible for discovery of device is current subnet. It will list * all the device in subnet which are not yet owned. Please call OCInit with OC_CLIENT_SERVER as * OCMode. @@ -125,6 +179,117 @@ OCStackResult OCDiscoverOwnedDevices(unsigned short timeout, OCProvisionDev_t ** return PMDeviceDiscovery(timeout, true, ppList); } +#ifdef MULTIPLE_OWNER +/** + * The function is responsible for discovery of MOT enabled device is current subnet. + * + * @param[in] timeout Timeout in seconds, value till which function will listen to responses from + * server before returning the list of devices. + * @param[out] ppList List of MOT enabled devices. + * @return OC_STACK_OK in case of success and other value otherwise. + */ +OCStackResult OCDiscoverMultipleOwnerEnabledDevices(unsigned short timeout, OCProvisionDev_t **ppList) +{ + if( ppList == NULL || *ppList != NULL || 0 == timeout) + { + return OC_STACK_INVALID_PARAM; + } + + return PMMultipleOwnerDeviceDiscovery(timeout, false, ppList); +} + +/** + * The function is responsible for discovery of Multiple Owned device is current subnet. + * + * @param[in] timeout Timeout in seconds, value till which function will listen to responses from + * server before returning the list of devices. + * @param[out] ppList List of Multiple Owned devices. + * @return OC_STACK_OK in case of success and other value otherwise. + */ +OCStackResult OCDiscoverMultipleOwnedDevices(unsigned short timeout, OCProvisionDev_t **ppList) +{ + if( ppList == NULL || *ppList != NULL || 0 == timeout) + { + return OC_STACK_INVALID_PARAM; + } + + return PMMultipleOwnerDeviceDiscovery(timeout, true, ppList); +} + + +/** + * API to add preconfigured PIN to local SVR DB. + * + * @param[in] targetDeviceInfo Selected target device. + * @param[in] preconfigPin Preconfig PIN which is used while multiple owner authentication + * @param[in] preconfigPinLen Byte length of preconfigPin + * + * @return OC_STACK_OK in case of success and other value otherwise. + */ +OCStackResult OCAddPreconfigPin(const OCProvisionDev_t *targetDeviceInfo, + const char *preconfigPin, + size_t preconfigPinLen) +{ + return MOTAddPreconfigPIN(targetDeviceInfo, preconfigPin, preconfigPinLen); +} + + +OCStackResult OCDoMultipleOwnershipTransfer(void* ctx, + OCProvisionDev_t *targetDevices, + OCProvisionResultCB resultCallback) +{ + if( NULL == targetDevices ) + { + return OC_STACK_INVALID_PARAM; + } + if (NULL == resultCallback) + { + OIC_LOG(INFO, TAG, "OCDoOwnershipTransfer : NULL Callback"); + return OC_STACK_INVALID_CALLBACK; + } + return MOTDoOwnershipTransfer(ctx, targetDevices, resultCallback); +} + +OCStackResult OCRemoveSubOwner(void* ctx, + const OCProvisionDev_t *targetDeviceInfo, + const OicUuid_t* subOwner, + OCProvisionResultCB resultCallback) +{ + if (NULL == targetDeviceInfo || NULL == subOwner) + { + OIC_LOG_V(ERROR, TAG, "%s : NULL Param", __func__); + return OC_STACK_INVALID_PARAM; + } + if (NULL == resultCallback) + { + OIC_LOG_V(ERROR, TAG, "%s : NULL Callback", __func__); + return OC_STACK_INVALID_CALLBACK; + } + + return MOTRemoveSubOwner(ctx, targetDeviceInfo, subOwner, resultCallback); +} + +OCStackResult OCRemoveAllSubOwner(void* ctx, + const OCProvisionDev_t *targetDeviceInfo, + OCProvisionResultCB resultCallback) +{ + if (NULL == targetDeviceInfo) + { + OIC_LOG_V(ERROR, TAG, "%s : NULL Param", __func__); + return OC_STACK_INVALID_PARAM; + } + if (NULL == resultCallback) + { + OIC_LOG_V(ERROR, TAG, "%s : NULL Callback", __func__); + return OC_STACK_INVALID_CALLBACK; + } + + return MOTRemoveSubOwner(ctx, targetDeviceInfo, &WILDCARD_SUBJECT_ID, resultCallback); +} + + +#endif //MULTIPLE_OWNER + /** * API to register for particular OxM. * @@ -142,6 +307,19 @@ OCStackResult OCSetOwnerTransferCallbackData(OicSecOxm_t oxm, OTMCallbackData_t* return OTMSetOwnershipTransferCallbackData(oxm, callbackData); } +/** + * API to set a allow status of OxM + * + * @param[in] oxm Owership transfer method (ref. OicSecOxm_t) + * @param[in] allowStatus allow status (true = allow, false = not allow) + * + * @return OC_STACK_OK in case of success and other value otherwise. + */ +OCStackResult OCSetOxmAllowStatus(const OicSecOxm_t oxm, const bool allowStatus) +{ + return OTMSetOxmAllowStatus(oxm, allowStatus); +} + OCStackResult OCDoOwnershipTransfer(void* ctx, OCProvisionDev_t *targetDevices, OCProvisionResultCB resultCallback) @@ -158,6 +336,23 @@ OCStackResult OCDoOwnershipTransfer(void* ctx, return OTMDoOwnershipTransfer(ctx, targetDevices, resultCallback); } +OCStackResult OCDoCustomOwnershipTransfer(void* ctx, + OCProvisionDev_t *selectedDevice, + OCProvisionResultCB resultCallback, + const OicSecOxm_t method) +{ + if( NULL == selectedDevice ) + { + return OC_STACK_INVALID_PARAM; + } + if (!resultCallback) + { + OIC_LOG(INFO, TAG, "OCDoCustomOwnershipTransfer : NULL Callback"); + return OC_STACK_INVALID_CALLBACK; + } + return OTMDoCustomOwnershipTransfer(ctx, selectedDevice, resultCallback, method); +} + /** * This function deletes memory allocated to linked list created by OCDiscover_XXX_Devices API. * @@ -185,6 +380,17 @@ OCStackResult OCProvisionACL(void* ctx, const OCProvisionDev_t *selectedDeviceIn } /** + * function to save ACL which has several ACE into Acl of SVR. + * + * @param acl ACL to be saved in Acl of SVR. + * @return OC_STACK_OK in case of success and other value otherwise. + */ +OCStackResult OCSaveACL(const OicSecAcl_t* acl) +{ + return SRPSaveACL(acl); +} + +/** * this function requests CRED information to resource. * * @param[in] ctx Application context would be returned in result callback. @@ -214,6 +420,12 @@ OCStackResult OCGetACLResource(void* ctx, const OCProvisionDev_t *selectedDevice return SRPGetACLResource(ctx, selectedDeviceInfo, resultCallback); } + +OCStackResult OCReadTrustCertChain(uint16_t credId, uint8_t **trustCertChain, + size_t *chainSize) +{ + return SRPReadTrustCertChain(credId, trustCertChain, chainSize); +} /** * function to provision credential to devices. * @@ -251,6 +463,58 @@ OCStackResult OCProvisionDirectPairing(void* ctx, const OCProvisionDev_t *select return SRPProvisionDirectPairing(ctx, selectedDeviceInfo, pconf, resultCallback); } +#ifdef MULTIPLE_OWNER +static void AddPreconfPinOxMCB(void* ctx, int nOfRes, OCProvisionResult_t *arr, bool hasError) +{ + ProvPreconfPINCtx_t* provCtx = (ProvPreconfPINCtx_t*)ctx; + if(provCtx) + { + OCStackResult res = MOTProvisionPreconfigPIN(provCtx->ctx, provCtx->devInfo, provCtx->pin, provCtx->pinLen, provCtx->resultCallback); + if(OC_STACK_OK != res) + { + arr->res = res; + provCtx->resultCallback(provCtx->ctx, nOfRes, arr, true); + } + } +} + +OCStackResult OCProvisionPreconfigPin(void *ctx, + OCProvisionDev_t *targetDeviceInfo, + const char *preconfigPin, + size_t preconfigPinLen, + OCProvisionResultCB resultCallback) +{ + if( NULL == targetDeviceInfo || NULL == preconfigPin || 0 == preconfigPinLen ) + { + return OC_STACK_INVALID_PARAM; + } + if (NULL == resultCallback) + { + OIC_LOG(INFO, TAG, "OCProvisionPreconfigPinCredential : NULL Callback"); + return OC_STACK_INVALID_CALLBACK; + } + + ProvPreconfPINCtx_t* provCtx = (ProvPreconfPINCtx_t*)OICCalloc(1, sizeof(ProvPreconfPINCtx_t)); + if(NULL == provCtx) + { + return OC_STACK_NO_MEMORY; + } + provCtx->ctx = ctx; + provCtx->devInfo = targetDeviceInfo; + provCtx->pin = preconfigPin; + provCtx->pinLen = preconfigPinLen; + provCtx->resultCallback = resultCallback; + /* + * First of all, update OxMs to support preconfigured PIN OxM. + * In case of Preconfigured PIN OxM already supported on the server side, + * MOTAddMOTMethod API will be send POST Cred request. + * In case of Preconfigure PIN OxM not exist on the server side, + * the MOTAddMOTMethod API will be send POST doxm request to update OxMs and then send POST Cred request. + */ + return MOTAddMOTMethod((void*)provCtx, targetDeviceInfo, OIC_PRECONFIG_PIN, AddPreconfPinOxMCB); +} +#endif //MULTIPLE_OWNER + /* * Function to unlink devices. * This function will remove the credential & relationship between the two devices. @@ -347,7 +611,7 @@ static OCStackResult RemoveDeviceInfoFromLocal(const OCProvisionDev_t* pTargetDe * Change the device status as stale status. * If all request are successed, this device information will be deleted. */ - res = PDMSetDeviceStale(&pTargetDev->doxm->deviceID); + res = PDMSetDeviceState(&pTargetDev->doxm->deviceID, PDM_DEVICE_STALE); if (res != OC_STACK_OK) { OIC_LOG(WARNING, TAG, "OCRemoveDevice : Failed to set device status as stale"); @@ -356,14 +620,12 @@ static OCStackResult RemoveDeviceInfoFromLocal(const OCProvisionDev_t* pTargetDe // TODO: We need to add new mechanism to clean up the stale state of the device. // Close the DTLS session of the removed device. - CAEndpoint_t *endpoint = (CAEndpoint_t *)&pTargetDev->endpoint; - endpoint->port = pTargetDev->securePort; - CAResult_t caResult = CAcloseSslSession(endpoint); + CAResult_t caResult = CAcloseSslConnectionUsingUuid(pTargetDev->doxm->deviceID.id + , sizeof(pTargetDev->doxm->deviceID.id)); if(CA_STATUS_OK != caResult) { - OIC_LOG_V(WARNING, TAG, "OCRemoveDevice : Failed to close DTLS session : %d", caResult); + OIC_LOG_V(WARNING, TAG, "OCRemoveDevice : Failed to close (D)TLS session : %d", caResult); } - OIC_LOG(DEBUG, TAG, "OUT RemoveDeviceInfoFromLocal"); error: return res; @@ -460,6 +722,7 @@ OCStackResult OCRemoveDeviceWithUuid(void* ctx, unsigned short waitTimeForOwnedD OCProvisionDev_t* pTargetDev = NULL; bool discoverdFlag = false; OCProvisionDev_t* pOwnedDevList = NULL; + OCStackResult resReq = OC_STACK_CONTINUE; if (!pTargetUuid || 0 == waitTimeForOwnedDeviceDiscovery) { @@ -479,68 +742,92 @@ OCStackResult OCRemoveDeviceWithUuid(void* ctx, unsigned short waitTimeForOwnedD goto error; } - //2. Find owned device from the network - res = PMDeviceDiscovery(waitTimeForOwnedDeviceDiscovery, true, &pOwnedDevList); - if (OC_STACK_OK != res) + //Generate OCProvisionDev_t instance to use when target device not found on the network. + //In this case, the device id required only. + pTargetDev = (OCProvisionDev_t*)OICCalloc(1, sizeof(OCProvisionDev_t)); + if(NULL == pTargetDev) { - OIC_LOG(ERROR, TAG, "OCRemoveDeviceWithUuid : Failed to PMDeviceDiscovery"); + OIC_LOG(ERROR, TAG, "Failed to allocate memory."); + res = OC_STACK_NO_MEMORY; goto error; } - - LL_FOREACH(pOwnedDevList, pTargetDev) + pTargetDev->doxm = (OicSecDoxm_t*)OICCalloc(1, sizeof(OicSecDoxm_t)); + if(NULL == pTargetDev->doxm) { - if(memcmp(&pTargetDev->doxm->deviceID.id, pTargetUuid->id, sizeof(pTargetUuid->id)) == 0) - { - break; - } + OIC_LOG(ERROR, TAG, "Failed to allocate memory."); + res = OC_STACK_NO_MEMORY; + goto error; } + memcpy(pTargetDev->doxm->deviceID.id, pTargetUuid->id, sizeof(pTargetUuid->id)); - if(NULL == pTargetDev) + OCUuidList_t* linkedDevices = NULL; + size_t numOfLinkedDevices = 0; + res = PDMGetLinkedDevices(pTargetUuid, &linkedDevices, &numOfLinkedDevices); + if(OC_STACK_OK != res) { - OIC_LOG_V(WARNING, TAG, "Can not find [%s] on the network.", strUuid); - OIC_LOG(WARNING, TAG, "Device information will be deleted from local and other devices."); + OIC_LOG(ERROR, TAG, "Error in PDMGetLinkedDevices"); + goto error; + } + PDMDestoryOicUuidLinkList(linkedDevices); - pTargetDev = (OCProvisionDev_t*)OICCalloc(1, sizeof(OCProvisionDev_t)); - if(NULL == pTargetDev) + //If there is no linked devices, device revocation step can be skipped. + if(0 != numOfLinkedDevices) + { + OIC_LOG_V(INFO, TAG, "[%s] linked with other devices.", strUuid); + //2. Find owned device from the network + res = PMDeviceDiscovery(waitTimeForOwnedDeviceDiscovery, true, &pOwnedDevList); + if (OC_STACK_OK != res) { - OIC_LOG(ERROR, TAG, "Failed to memory allocation."); + OIC_LOG(ERROR, TAG, "OCRemoveDeviceWithUuid : Failed to PMDeviceDiscovery"); goto error; } - pTargetDev->doxm = (OicSecDoxm_t*)OICCalloc(1, sizeof(OicSecDoxm_t)); - if(NULL == pTargetDev->doxm) + OCProvisionDev_t* tempDev = NULL; + LL_FOREACH(pOwnedDevList, tempDev) { - OIC_LOG(ERROR, TAG, "Failed to memory allocation."); - goto error; + if(memcmp(&tempDev->doxm->deviceID.id, pTargetUuid->id, sizeof(pTargetUuid->id)) == 0) + { + break; + } } - //in case of can't find target device, the device id required only. - memcpy(pTargetDev->doxm->deviceID.id, pTargetUuid->id, sizeof(pTargetUuid->id)); - } - else - { - discoverdFlag = true; - OIC_LOG_V(INFO, TAG, "[%s] is dectected on the network.", strUuid); - } - - OIC_LOG_V(INFO, TAG, "Trying [%s] revocation.", strUuid); - - // Send DELETE requests to linked devices - OCStackResult resReq = OC_STACK_ERROR; // Check that we have to wait callback or not. - resReq = SRPRemoveDeviceWithoutDiscovery(ctx, pOwnedDevList, pTargetDev, resultCallback); - if (OC_STACK_OK != resReq) - { - if (OC_STACK_CONTINUE == resReq) + if(NULL == tempDev) { - OIC_LOG(DEBUG, TAG, "OCRemoveDeviceWithUuid : Revoked device has no linked device except PT."); + OIC_LOG_V(WARNING, TAG, "Can not find [%s] on the network.", strUuid); + OIC_LOG_V(WARNING, TAG, "[%s]'s information will be deleted from local and other devices.", strUuid); } else { - OIC_LOG(ERROR, TAG, "OCRemoveDeviceWithUuid : Failed to invoke SRPRemoveDevice"); - res = resReq; - goto error; + OICFree(pTargetDev->doxm); + OICFree(pTargetDev); + pTargetDev = tempDev; + discoverdFlag = true; + OIC_LOG_V(INFO, TAG, "[%s] is dectected on the network.", strUuid); + } + + OIC_LOG_V(INFO, TAG, "Trying [%s] revocation.", strUuid); + + // Send DELETE requests to linked devices + resReq = SRPRemoveDeviceWithoutDiscovery(ctx, pOwnedDevList, pTargetDev, resultCallback); + if (OC_STACK_OK != resReq) + { + if (OC_STACK_CONTINUE == resReq) + { + OIC_LOG(INFO, TAG, "OCRemoveDeviceWithUuid : Revoked device has no linked device except PT."); + } + else + { + OIC_LOG(ERROR, TAG, "OCRemoveDeviceWithUuid : Failed to invoke SRPRemoveDevice"); + res = resReq; + goto error; + } } } + else + { + OIC_LOG_V(INFO, TAG, "There is no linked devices with [%s]", strUuid); + OIC_LOG(INFO, TAG, "Device discovery and SRPRemoveDevice will be skipped."); + } res = RemoveDeviceInfoFromLocal(pTargetDev); if(OC_STACK_OK != res) @@ -587,7 +874,8 @@ error: */ OCStackResult OCResetDevice(void* ctx, unsigned short waitTimeForOwnedDeviceDiscovery, const OCProvisionDev_t* pTargetDev, - OCProvisionResultCB resultCallback) + OCProvisionResultCB resultCallback, + OCClientContextDeleter deleteCallback) { OIC_LOG(INFO, TAG, "IN OCResetDevice"); OCStackResult res = OC_STACK_ERROR; @@ -596,7 +884,7 @@ OCStackResult OCResetDevice(void* ctx, unsigned short waitTimeForOwnedDeviceDisc OIC_LOG(INFO, TAG, "OCResetDevice : Invalid parameters"); return OC_STACK_INVALID_PARAM; } - if (!resultCallback) + if (!deleteCallback || !resultCallback) { OIC_LOG(INFO, TAG, "OCResetDevice : NULL Callback"); return OC_STACK_INVALID_CALLBACK; @@ -611,7 +899,7 @@ OCStackResult OCResetDevice(void* ctx, unsigned short waitTimeForOwnedDeviceDisc { resultCallback(ctx, 0, NULL, false); } - SRPResetDevice(pTargetDev, resultCallback); + SRPResetDevice(pTargetDev, deleteCallback); res = OC_STACK_OK; } else if(OC_STACK_OK != res) @@ -623,6 +911,26 @@ OCStackResult OCResetDevice(void* ctx, unsigned short waitTimeForOwnedDeviceDisc } /** + * This function resets SVR DB to its factory setting. + * + * @return OC_STACK_OK in case of successful reset and other value otherwise. + */ +OCStackResult OCResetSVRDB(void) +{ + return ResetSecureResourceInPS(); +} + +/** + * This function configures SVR DB as self-ownership. + * + *@return OC_STACK_OK in case of successful configue and other value otherwise. + */ +OCStackResult OCConfigSelfOwnership(void) +{ + return ConfigSelfOwnership(); +} + +/** * Internal Function to update result in link result array. */ static void UpdateLinkResults(Linkdata_t *link, int device, OCStackResult stackresult) @@ -1044,6 +1352,55 @@ void OCDeletePdAclList(OicSecPdAcl_t* pPdAcl) { FreePdAclList(pPdAcl); } + +#ifdef MULTIPLE_OWNER +/** + * API to update 'doxm.mom' to resource server. + * + * @param[in] targetDeviceInfo Selected target device. + * @param[in] momType Mode of multiple ownership transfer (ref. oic.sec.mom) + * @param[in] resultCallback callback provided by API user, callback will be called when + * POST 'mom' request recieves a response from resource server. + * @return OC_STACK_OK in case of success and other value otherwise. + */ +OCStackResult OCChangeMOTMode(void *ctx, const OCProvisionDev_t *targetDeviceInfo, + const OicSecMomType_t momType, OCProvisionResultCB resultCallback) +{ + return MOTChangeMode(ctx, targetDeviceInfo, momType, resultCallback); +} + +/** + * API to update 'doxm.oxmsel' to resource server. + * + * @param[in] targetDeviceInfo Selected target device. + * @param[in] oxmSelValue Method of multiple ownership transfer (ref. oic.sec.oxm) + * @param[in] resultCallback callback provided by API user, callback will be called when + * POST 'oxmsel' request recieves a response from resource server. + * @return OC_STACK_OK in case of success and other value otherwise. + */ +OCStackResult OCSelectMOTMethod(void *ctx, const OCProvisionDev_t *targetDeviceInfo, + const OicSecOxm_t oxmSelValue, OCProvisionResultCB resultCallback) +{ + return MOTSelectMOTMethod(ctx, targetDeviceInfo, oxmSelValue, resultCallback); +} +#endif //MULTIPLE_OWNER + +/** + * Function to select appropriate security provisioning method. + * + * @param[in] supportedMethods Array of supported methods + * @param[in] numberOfMethods number of supported methods + * @param[out] selectedMethod Selected methods + * @param[in] ownerType type of owner device (SUPER_OWNER or SUB_OWNER) + * @return OC_STACK_OK on success + */ +OCStackResult OCSelectOwnershipTransferMethod(const OicSecOxm_t *supportedMethods, + size_t numberOfMethods, OicSecOxm_t *selectedMethod, OwnerType_t ownerType) +{ + return OTMSelectOwnershipTransferMethod(supportedMethods, numberOfMethods, + selectedMethod, ownerType); +} + #if defined(__WITH_DTLS__) || defined(__WITH_TLS__) /** * function to provision Trust certificate chain to devices. @@ -1063,6 +1420,7 @@ OCStackResult OCProvisionTrustCertChain(void *ctx, OicSecCredType_t type, uint16 return SRPProvisionTrustCertChain(ctx, type, credId, selectedDeviceInfo, resultCallback); } + /** * function to save Trust certificate chain into Cred of SVR. * @@ -1078,5 +1436,44 @@ OCStackResult OCSaveTrustCertChain(uint8_t *trustCertChain, size_t chainSize, return SRPSaveTrustCertChain(trustCertChain, chainSize, encodingType, credId); } +/** + * function to register notifier for Trustcertchain change. + * + * @param[in] ctx user context. + * @param[in] TrustCertChainChangeCB notification callback fucntion. + * @return OC_STACK_OK in case of success and other value otherwise. + */ +OCStackResult OCRegisterTrustCertChainNotifier(void *ctx, TrustCertChainChangeCB Callback) +{ + return SRPRegisterTrustCertChainNotifier(ctx, Callback); +} + +/** + * function to de-register notifier for Trustcertchain change. + */ +void OCRemoveTrustCertChainNotifier() +{ + SRPRemoveTrustCertChainNotifier(); +} + +/** + * This function sets the callback to utilize peer certificate information + */ +OCStackResult OCSetPeerCertCallback(void *ctx, PeerCertCallback peerCertCallback) +{ + CAResult_t ret; + + OIC_LOG_V(DEBUG, TAG, "IN %s", __func__); + ret = CAsetPeerCertCallback(ctx, peerCertCallback); + if (CA_STATUS_OK != ret) + { + OIC_LOG_V(ERROR, TAG, "CAsetPeerCertCallback() Failed(%d)", ret); + return OC_STACK_ERROR; + } + OIC_LOG_V(DEBUG, TAG, "OUT %s", __func__); + + return OC_STACK_OK; +} + #endif // __WITH_DTLS__ || __WITH_TLS__