Commit 9baaa75f authored by leechul's avatar leechul Committed by Randeep

Revert back cbor related patches.

[Patch #1] Intial upload.
[Patch #2] Modify provisionig sample's SConscript to ignore sample codes in case of tizen.
             * The json file will be copied in case of tizen.
[Patch #3] Remove the segmentation fault in debug mode.
[Patch #4] Modify the build script to not include security samples in case of tizen build.
[Patch #5] Revmoe the printf

Change-Id: I88b9b5b68bc641f219bcf0c26dbf1dd4c61ae177
Signed-off-by: default avatarleechul <chuls.lee@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/5897Reviewed-by: default avatarJongsung Lee <js126.lee@samsung.com>
Reviewed-by: default avatardongik Lee <dongik.lee@samsung.com>
Tested-by: default avatarjenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Randeep's avatarRandeep Singh <randeep.s@samsung.com>
parent 06c66db4
This diff was suppressed by a .gitattributes entry.
{
"acl": "gaRnc3ViAHJzckEqZ3JzcmMAYW2IaC9vaWMvcmVzZi9vaWMvZGYvb2ljL3BwL29pYy9yZXMvdHlwZXMvZGcvb2ljL2FkbC9vaWMvc2VjL2FjbG0vb2ljL3NlYy9kb3htbi9vaWMvc2VjL3BzdGF0Z3Blcm1zAG8CZ293bnJzAG-BUDIyMjIyMjIyMjIyMjIyMjI"
}
......@@ -145,3 +145,4 @@ libocsrm_env.InstallTarget(libocsrm, 'libocsrm')
if target_os in ['linux', 'android', 'tizen'] and env.get('SECURED') == '1':
SConscript('provisioning/SConscript')
//******************************************************************
//
// Copyright 2015 Samsung Electronics All Rights Reserved.
//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
/******************************************************************
*
* Copyright 2015 Samsung Electronics All Rights Reserved.
*
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************/
#ifndef _IOTVT_B64_H_
#define _IOTVT_B64_H_
......@@ -41,27 +41,27 @@ extern "C" {
#define B64DECODE_OUT_SAFESIZE(x) (((x)*3)/4)
/**
* Result code of base64 functions.
* Result code of base64 functions
*/
typedef enum
{
typedef enum {
B64_OK = 0,
B64_INVALID_PARAM,
B64_OUTPUT_BUFFER_TOO_SMALL,
B64_ERROR
} B64Result;
}B64Result;
/**
* Encode the plain message in base64.
*
* @param in is the plain message to be converted.
* @param inLen is the byte length of plain message.
* @param outBuf is the output buffer containing Base64 encoded message.
* @note outBuf adds a NULL to the string configuration.
* @param outBufSize is the size of output buffer.
* @param outLen is the byte length of encoded message.
* @param[in] in Plain message
* @param[in] inLen Byte length of 'in'
* @param[in,out] outBuf Output buffer
* Base64 encoded message will be written into 'outBuf'
* NOTE : This method adds a NULL to the string configuration
* @param[in] outBufSize Size of output buffer
* @param[out] outLen Byte length of encoded message
*
* @return ::B64_OK for Success, otherwise some error value.
* @return B64_OK for Success, otherwise some error value
*/
B64Result b64Encode(const uint8_t* in, const size_t inLen,
char* outBuf, const size_t outBufSize, uint32_t *outLen);
......@@ -69,14 +69,14 @@ B64Result b64Encode(const uint8_t* in, const size_t inLen,
/**
* Decode the encoded message in base64.
*
* @param in is the Base64 encoded message to be converted.
* @param inLen is the byte length of the encoded message.
* @param outBuf is the output buffer containing decoded message.
* @note outBuf adds a NULL to the string configuration.
* @param outBufSize is the size of output buffer.
* @param outLen is the byte length of decoded message.
* @param[in] in Base64 encoded message
* @param[in] inLen Byte lenth of 'in'
* @param[in, out] outBuf Output buffer
* Base64 decoded message will be written into 'outBuf'
* @param[in] outBufSize Size of output buffer
* @param[out] outLen Byte length of decoded message
*
* @return ::B64_OK for Success, otherwise some error value.
* @return B64_OK for Success, otherwise some error value
*/
B64Result b64Decode(const char* in, const size_t inLen,
uint8_t* outBuf, size_t outBufSize, uint32_t *outLen);
......
......@@ -28,15 +28,16 @@ extern "C" {
/**
* Initialize ACL resource by loading data from persistent storage.
*
* @return ::OC_STACK_OK for Success, otherwise some error value.
* @retval OC_STACK_OK for Success, otherwise some error value
*/
OCStackResult InitACLResource();
/**
* Perform cleanup for ACL resources.
*
* @retval none
*/
OCStackResult DeInitACLResource();
void DeInitACLResource();
/**
* This method is used by PolicyEngine to retrieve ACL for a Subject.
......@@ -45,39 +46,38 @@ OCStackResult DeInitACLResource();
* @param savePtr is used internally by @ref GetACLResourceData to maintain index between
* successive calls for same subjectId.
*
* @note On the first call to @ref GetACLResourceData, savePtr should point to NULL.
* @retval reference to @ref OicSecAcl_t if ACL is found, else NULL
*
* @return reference to @ref OicSecAcl_t if ACL is found, else NULL.
* @note On the first call to @ref GetACLResourceData, savePtr should point to NULL
*/
const OicSecAcl_t* GetACLResourceData(const OicUuid_t* subjectId, OicSecAcl_t **savePtr);
/**
* This function converts ACL data into CBOR format.
* This function converts ACL data into JSON format.
* Caller needs to invoke 'free' when done using
* returned string.
* @param acl instance of OicSecAcl_t structure.
*
* @param acl instance of @ref OicSecAcl_t structure.
* @param outPayload is the pointer to allocated memory for cbor payload.
* @param size of the cbor payload.
*
* @return ::OC_STACK_OK for Success, otherwise some error value.
* @retval pointer to ACL in json format.
*/
OCStackResult AclToCBORPayload(const OicSecAcl_t * acl, uint8_t **outPayload, size_t *size);
char* BinToAclJSON(const OicSecAcl_t * acl);
/**
* This function deletes ACL data.
*
* @param acl instance of @ref OicSecAcl_t structure to be deleted.
* @param acl instance of OicSecAcl_t structure.
*/
void DeleteACLList(OicSecAcl_t* acl);
/**
* This function installs a new ACL.
* @param newJsonStr JSON string representing a new ACL.
*
* @param payload cbor value representing a new ACL.
* @param size of the cbor payload.
*
* @return ::OC_STACK_OK for Success, otherwise some error value
* @retval OC_STACK_OK for Success, otherwise some error value
*/
OCStackResult InstallNewACL(const uint8_t* payload, const size_t size);
OCStackResult InstallNewACL(const char* newJsonStr);
/**
* This function updates default ACL which is required for ownership transfer.
......@@ -92,3 +92,5 @@ OCStackResult UpdateDefaultSecProvACL();
#endif
#endif //IOTVT_SRM_ACLR_H
......@@ -36,12 +36,14 @@ extern "C" {
/**
* Initialize Amacl resource by loading data from persistent storage.
*
* @return ::OC_STACK_OK for Success, otherwise some error value.
* @retval OC_STACK_OK for Success, otherwise some error value
*/
OCStackResult InitAmaclResource();
/**
* Perform cleanup for Amacl resources.
*
* @retval none
*/
void DeInitAmaclResource();
......@@ -50,31 +52,30 @@ void DeInitAmaclResource();
* If the Amacl is found for the given resource then populate the parameter
* amsId with Amacl resource amss id.
*
* @param resource for which AMS service is required.
* @param amsId of the ams service for the given resource.
* @param resource resource for which AMS service is required.
* @param amsId ID of the ams service for the given resource
*
* @retval
* OC_STACK_OK If Amacl found for the resource
* OC_STACK_ERROR If no Amacl found for the resource
*
* @return ::OC_STACK_OK, if Amacl is found for the resource, else ::OC_STACK_ERROR,
* if no Amacl found for the resource.
*/
OCStackResult AmaclGetAmsDeviceId(const char *resource, OicUuid_t *amsId);
/**
* This function converts Amacl data into CBOR format.
* Caller needs to invoke 'free' when done using returned string.
*
* @param amacl instance of @ref OicSecAmacl_t structure.
* @param cborPayload is the converted cbor value of @ref OicSecAmacl_t structure.
* @param cborSize is the size of the cbor payload. This value is the size of the
* cborPayload. It should not be NON-NULL value.
* This function converts Amacl data into JSON format.
* Caller needs to invoke 'free' when done using
* returned string.
* @param Amacl instance of OicSecAmacl_t structure.
*
* @return ::OC_STACK_OK for Success. ::OC_STACK_INVALID in case of invalid parameters.
* ::OC_STACK_ERROR in case of error in converting to cbor.
* @retval pointer to Amacl in json format.
*/
OCStackResult AmaclToCBORPayload(const OicSecAmacl_t *amacl, uint8_t **cborPayload,
size_t *cborSize);
char* BinToAmaclJSON(const OicSecAmacl_t * amacl);
#ifdef __cplusplus
}
#endif
#endif //IOTVT_SRM_AMACLR_H
......@@ -21,18 +21,17 @@
#ifndef IOTVT_SRM_AMSMGR_H
#define IOTVT_SRM_AMSMGR_H
#include <stdlib.h>
#include <stdint.h>
#include "ocstack.h"
#include "logger.h"
#include "policyengine.h"
#include "securevirtualresourcetypes.h"
#include "cainterface.h"
#include <stdlib.h>
#include <stdint.h>
typedef struct PEContext PEContext_t;
/**
* The AMS context.
* @brief The AMS context..
*/
typedef struct AmsMgrContext
{
......@@ -41,95 +40,103 @@ typedef struct AmsMgrContext
CARequestInfo_t *requestInfo;
} AmsMgrContext_t;
/**
* This method updates AmsMgr context's endpoint & requestInfo.
* @brief This method updates AmsMgr context's endpoint & requestInfo
*
* @param context is the policy engine context.
* @param endpoint is the CA Endpoint info of the requester.
* @param requestInfo is the CA RequestInfo of the requester.
*
* @return ::OC_STACK_OK if successful, else other value in case of error.
* @param context Policy engine context.
* @param endpoint CA Endpoint info of the requester
* @param requestInfo CA RequestInfo of the requester
*/
OCStackResult UpdateAmsMgrContext(PEContext_t *context,
const CAEndpoint_t *endpoint,
const CARequestInfo_t *requestInfo);
OCStackResult UpdateAmsMgrContext(PEContext_t *context, const CAEndpoint_t *endpoint,
const CARequestInfo_t *requestInfo);
/**
*
* This method is called by PolicyEngine to Discover AMS service.
* It sends muticast discovery request such as
* /oic/sec/doxm?deviceid="AMSSrvcDeviceID" to discover AMS service
* with deviceId="AMSSrvcDeviceID".
* with deviceId="AMSSrvcDeviceID"
*
* @param context Policy engine context.
*
* @param context is the policy engine context.
* @retval
* OC_STACK_OK If able to successfully send multicast discovery request.
* OC_STACK_ERROR If unable to successfully send multicast discovery request due to error.
*
* @return ::OC_STACK_OK,If able to successfully send multicast discovery request.
* else ::OC_STACK_ERROR, If unable to successfully send multicast discovery request
* due to error.
*/
OCStackResult DiscoverAmsService(PEContext_t *context);
/**
*
* This method sends unicast request to retrieve the secured port info of the
* discovered AMS service. It sends unicast discovery request such as
* /oic/res?rt="oic.sec.doxm" to the discovered AMS service.
* /oic/res?rt="oic.sec.doxm" to the discovered AMS service
*
* @param context is the policy engine context.
* @param context Policy engine context.
*
* @retval
* OC_STACK_OK If able to successfully send unicast discovery request
* OC_STACK_ERROR If unable to successfully send unicast discovery request due to error
*
* @return ::OC_STACK_OK,If able to successfully send unicast discovery request.
* else ::OC_STACK_ERROR, If unable to successfully send unicast discovery request
* due to error.
*/
OCStackResult SendUnicastSecurePortDiscovery(PEContext_t *context,
OCDevAddr *devAddr,
OCConnectivityType connType);
OCStackResult SendUnicastSecurePortDiscovery(PEContext_t *context,OCDevAddr *devAddr,
OCConnectivityType connType);
/**
*
* This method sends unicast request to AMS service to get ACL for
* the Subject and/or Resource. It sends unicast request such as
* /oic/sec/acl?sub="subjectId";rsrc="/a/led" to get the ACL for
* the subject & resource.
* the subject & resource
*
* @param context is the policy engine context.
* @param context Policy engine context.
*
* @return ::OC_STACK_OK, If able to successfully send unicast ACL request.
* ::OC_STACK_ERROR, If unable to successfully send unicast ACL request due to error.
* @retval
* OC_STACK_OK If able to successfully send unicast ACL request
* OC_STACK_ERROR If unable to successfully send unicast ACL request due to error
*
*/
OCStackResult SendAclReq(PEContext_t *context,
OCDevAddr *devAddr,
OCConnectivityType connType,
uint16_t securedPort);
OCStackResult SendAclReq(PEContext_t *context, OCDevAddr *devAddr, OCConnectivityType connType,
uint16_t securedPort);
/*
* Cleanup CARequestInfo_t object.
*
* @param requestInfo is the pointer to @ref CARequestInfo_t.
* Cleanup CARequestInfo_t object
* @param requestInfo pointer to RequestInfo_t object
*/
void FreeCARequestInfo(CARequestInfo_t *requestInfo);
/*
* This method is used by Policy engine to checks Amacl resource.
* If Amacl is found then it fills up context->amsMgrContext->amsDeviceId
* with amsID of the Amacl else leaves it empty.
*
* @param context is the policy engine context.
* @param context Policy engine context.
*
* @return true, if Amacl for the resource is found. false, if Amacl for the
* resource is not found
* @return true if AMacl for the resource is found
* false if AMacl for the resource is not found
*/
bool FoundAmaclForRequest(PEContext_t *context);
/*
* This method is used by Policy engine to process AMS request.
* This method is used by Policy engine to process AMS request
*
* @param context Policy engine context.
*
* @param context is the policy engine context.
*/
void ProcessAMSRequest(PEContext_t *context);
/*
* This method is used by Policy engine to free AMS context requestInfo/
* This method is used by Policy engine to free AMS context requestInfo
*
* @param requestInfo pointer to CARequestInfo_t.
*
* @param requestInfo is the pointer to @ref CARequestInfo_t.
*/
void FreeCARequestInfo(CARequestInfo_t *requestInfo);
......
......@@ -32,42 +32,45 @@ extern "C" {
/**
* Initialize credential resource by loading data from persistent storage.
*
* @return ::OC_STACK_OK, if initialization is successful, else ::OC_STACK_ERROR if
* initialization fails.
* @retval
* OC_STACK_OK - no errors
* OC_STACK_ERROR - stack process error
*/
OCStackResult InitCredResource();
/**
* Perform cleanup for credential resources.
*
* @return ::OC_STACK_OK, if no errors. ::OC_STACK_ERROR, if stack process error.
* ::OC_STACK_NO_RESOURCE, if resource not found.
* ::OC_STACK_INVALID_PARAM, if invalid param.
* @retval
* OC_STACK_OK - no errors
* OC_STACK_ERROR - stack process error
* OC_STACK_NO_RESOURCE - resource not found
* OC_STACK_INVALID_PARAM - invalid param
*/
OCStackResult DeInitCredResource();
/**
* This method is used by tinydtls/SRM to retrieve credential for given subject.
* This method is used by tinydtls/SRM to retrieve credential for given Subject.
*
* @param subjectId for which credential is required.
* @param subject - subject for which credential is required.
*
* @return reference to @ref OicSecCred_t, if credential is found, else NULL, if credential
* not found.
* @retval
* reference to OicSecCred_t - if credential is found
* NULL - if credential not found
*/
const OicSecCred_t* GetCredResourceData(const OicUuid_t* subjectId);
/**
* This function converts credential data into CBOR format.
* Caller needs to invoke 'free' when done using returned string.
*
* @param cred is the pointer to instance of OicSecCred_t structure.
* @param cborPayload is the CBOR converted value.
* @param cborSize is the size of the CBOR.
*
* @return ::OC_STACK_OK if conversion is successful, else ::OC_STACK_ERROR if unsuccessful.
* This function converts credential data into JSON format.
* Caller needs to invoke 'free' when done using
* returned string.
* @param cred pointer to instance of OicSecCred_t structure.
*
* @retval
* pointer to JSON credential representation - if credential for subjectId found
* NULL - if credential for subjectId not found
*/
OCStackResult CredToCBORPayload(const OicSecCred_t* cred, uint8_t **cborPayload,
size_t *cborSize);
char* BinToCredJSON(const OicSecCred_t* cred);
/**
* This function generates the bin credential data.
......@@ -79,42 +82,53 @@ OCStackResult CredToCBORPayload(const OicSecCred_t* cred, uint8_t **cborPayload,
* @param ownersLen length of owners array
* @param owners array of owners.
*
* @return pointer to instance of @ref OicSecCred_t if successful. else NULL in case of error.
* @retval
* pointer to instance of OicSecCred_t - success
* NULL - error
*/
OicSecCred_t * GenerateCredential(const OicUuid_t* subject, OicSecCredType_t credType,
const uint8_t * publicData, const uint8_t * privateData,
size_t ownersLen, const OicUuid_t * owners);
const char * publicData, const char * privateData, size_t ownersLen,
const OicUuid_t * owners);
/**
* This function adds the new cred to the credential list.
*
* @param cred is the pointer to new credential.
* @param cred pointer to new credential.
*
* @return ::OC_STACK_OK, cred not NULL and persistent storage gets updated.
* ::OC_STACK_ERROR, cred is NULL or fails to update persistent storage.
* @retval
* OC_STACK_OK - cred not NULL and persistent storage gets updated
* OC_STACK_ERROR - cred is NULL or fails to update persistent storage
*/
OCStackResult AddCredential(OicSecCred_t * cred);
/**
* Function to remove the credential from SVR DB.
*
* @param credId is the Credential ID to be deleted.
* @param credId Credential ID to be deleted.
*
* @return ::OC_STACK_OK for success, or errorcode otherwise.
* @return OC_STACK_OK for success and errorcode otherwise.
*/
OCStackResult RemoveCredential(const OicUuid_t *credId);
OCStackResult RemoveCredential(const OicUuid_t* credId);
/**
* Remove all credential data on credential resource and persistent storage
*
* @retval
* OC_STACK_OK - no errors
* OC_STACK_ERROR - stack process error
*/
OCStackResult RemoveAllCredentials(void);
#if defined(__WITH_DTLS__)
/**
* This internal callback is used by lower stack (i.e. CA layer) to
* retrieve PSK credentials from RI security layer.
*
* @param type of PSK data required by CA layer during DTLS handshake.
* @param desc Additional request information.
* @param desc_len is the actual length of desc.
* @param result is must be filled with the requested information.
* @param result_length is the maximum size of @p result.
* @param[in] type type of PSK data required by CA layer during DTLS handshake.
* @param[in] desc Additional request information.
* @param[in] desc_len The actual length of desc.
* @param[out] result Must be filled with the requested information.
* @param[in] result_length Maximum size of @p result.
*
* @return The number of bytes written to @p result or a value
* less than zero on error.
......@@ -124,22 +138,21 @@ int32_t GetDtlsPskCredentials( CADtlsPskCredType_t type,
unsigned char *result, size_t result_length);
/**
* Add temporal PSK to PIN based OxM.
* Add temporal PSK to PIN based OxM
*
* @param tmpSubject is the UUID of target device
* @param credType is the type of credential to be added
* @param pin is the numeric characters
* @param pinSize is the length of 'pin'
* @param ownersLen is the number of owners
* @param owners is the array of owners
* @param tmpCredSubject is the generated credential's subject.
* @param[in] tmpSubject UUID of target device
* @param[in] credType Type of credential to be added
* @param[in] pin numeric characters
* @param[in] pinSize length of 'pin'
* @param[in] ownersLen Number of owners
* @param[in] owners Array of owners
* @param[out] tmpCredSubject Generated credential's subject.
*
* @return ::OC_STACK_OK for success or else errorcode.
* @return OC_STACK_OK for success and errorcode otherwise.
*/
OCStackResult AddTmpPskWithPIN(const OicUuid_t* tmpSubject, OicSecCredType_t credType,
const char * pin, size_t pinSize,
size_t ownersLen, const OicUuid_t * owners,
OicUuid_t* tmpCredSubject);
size_t ownersLen, const OicUuid_t * owners, OicUuid_t* tmpCredSubject);
#endif /* __WITH_DTLS__ */
......@@ -147,17 +160,18 @@ OCStackResult AddTmpPskWithPIN(const OicUuid_t* tmpSubject, OicSecCredType_t cre
/**
* This function is used toretrieve certificate credentials from RI security layer.
*
* @param credInfo is the binary structure containing certificate credentials
* @param credInfo
* binary structure containing certificate credentials
*
* @return 0 on success.
* @retval 0 on scuccess
*/
int GetDtlsX509Credentials(CADtlsX509Creds_t *credInfo);
#endif /*__WITH_X509__*/
/**
* Function to deallocate allocated memory to OicSecCred_t.
* Function to deallocate allocated memory to OicSecCred_t
*
* @param cred pointer to cred type.
* @param cred pointer to cred type
*
*/
void DeleteCredList(OicSecCred_t* cred);
......@@ -167,3 +181,5 @@ void DeleteCredList(OicSecCred_t* cred);
#endif
#endif //IOTVT_SRM_CREDR_H