[IOT-2052] Update to support OCF 1.0 47/24647/3
authorv.riznyk <v.riznyk@samsung.com>
Fri, 13 Apr 2018 15:17:00 +0000 (18:17 +0300)
committerAleksey Volkov <a.volkov@samsung.com>
Tue, 17 Apr 2018 10:48:02 +0000 (10:48 +0000)
missing fix for task, changed size of map

Change-Id: I8a6cf6fc06058c003da3ec52d695aa0dd303c63f
Signed-off-by: v.riznyk <v.riznyk@samsung.com>
resource/csdk/security/provisioning/src/secureresourceprovider.c
resource/csdk/security/src/aclresource.c
resource/csdk/security/src/credresource.c

index b8cfd0e..6da75e6 100644 (file)
@@ -4390,7 +4390,7 @@ static OCStackApplicationResult ProvisionAclCB(void *ctx, OCDoHandle UNUSED,
             return OC_STACK_NO_MEMORY;
         }
         secPayload->base.type = PAYLOAD_TYPE_SECURITY;
-        bool propertiesToInclude[PSTAT_PROPERTY_COUNT];
+        bool propertiesToInclude[ACL_PROPERTY_COUNT];
         memset(propertiesToInclude, 0, sizeof(propertiesToInclude));
         propertiesToInclude[ACL_ACELIST] = true;
         if (OC_STACK_OK != AclToCBORPayloadPartial(aclData->acl, aclData->aclVersion, &secPayload->securityData,
index d885ee6..ab242d6 100644 (file)
@@ -56,7 +56,7 @@
 #define NUMBER_OF_DEFAULT_SEC_RSCS 2
 #define STRING_UUID_SIZE (UUID_LENGTH * 2 + 5)
 
-static const uint8_t ACL_MAP_SIZE = 4; // aclist, rowneruuid, RT and IF
+static const uint8_t ACL_MAP_SIZE = 2; // RT and IF
 static const uint8_t ACL_ACLIST_MAP_SIZE = 1; // aces object
 static const uint8_t ACL_ACE_MAP_SIZE = 3; // subject, resource, permissions
 static const uint8_t ACL_ACE2_MAP_SIZE = 4; // aceid, subject, resource, permissions
@@ -418,6 +418,16 @@ OCStackResult AclToCBORPayloadPartial(const OicSecAcl_t *secAcl,
         cborLen = CBOR_SIZE;
     }
 
+    int sizeOfMap = ACL_MAP_SIZE;
+    if (propertiesToInclude[ACL_ACELIST])
+    {
+        sizeOfMap++;
+    }
+    if (propertiesToInclude[ACL_ROWNERUUID])
+    {
+        sizeOfMap++;
+    }
+
     outPayload = (uint8_t *)OICCalloc(1, cborLen);
     VERIFY_NOT_NULL_RETURN(TAG, outPayload, ERROR, OC_STACK_ERROR);
 
@@ -426,7 +436,7 @@ OCStackResult AclToCBORPayloadPartial(const OicSecAcl_t *secAcl,
     // Create ACL Map which contains aclist or aclist2, rowneruuid, rt and if
     if(propertiesToInclude[ACL_ACELIST])
     {
-        cborEncoderResult = cbor_encoder_create_map(&encoder, &aclMap, ACL_MAP_SIZE);
+        cborEncoderResult = cbor_encoder_create_map(&encoder, &aclMap, sizeOfMap);
         VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, cborEncoderResult, "Failed Creating ACL Map.");
         OIC_LOG_V(DEBUG, TAG, "%s starting encoding of %s resource.",
             __func__, (OIC_SEC_ACL_V1 == aclVersion)?"v1 acl":"v2 acl2");
index f25ee75..25930ff 100644 (file)
@@ -88,8 +88,8 @@
 static const uint16_t CBOR_SIZE = 2048;
 
 /** CRED size - Number of mandatory items. */
-static const uint8_t CRED_ROOT_MAP_SIZE = 4;
-static const uint8_t CRED_MAP_SIZE = 2;
+static const uint8_t CRED_ROOT_MAP_SIZE = 3;
+static const uint8_t CRED_MAP_SIZE = 3;
 static const uint8_t ROLEID_MAP_SIZE = 1;
 
 
@@ -691,6 +691,10 @@ OCStackResult CredToCBORPayloadPartial(const OicSecCred_t *credS, const OicUuid_
     cbor_encoder_init(&encoder, outPayload, cborLen, 0);
 
     size_t credRootMapSize = CRED_ROOT_MAP_SIZE;
+    if (propertiesToInclude[CRED_ROWNERUUID])
+    {
+        credRootMapSize++;
+    }
 
     // Create CRED Root Map (creds, rownerid)
     cborEncoderResult = cbor_encoder_create_map(&encoder, &credRootMap, credRootMapSize);
@@ -714,10 +718,7 @@ OCStackResult CredToCBORPayloadPartial(const OicSecCred_t *credS, const OicUuid_
         {
             mapSize++;
         }
-        if(propertiesToInclude[CRED_ROWNERUUID])
-        {
-            mapSize++;
-        }
+
 #if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
 #ifdef MULTIPLE_OWNER
         if(cred->eownerID)
@@ -987,9 +988,9 @@ OCStackResult CredToCBORPayload(const OicSecCred_t *credS, uint8_t **cborPayload
 OCStackResult CredToCBORPayloadWithRowner(const OicSecCred_t *credS, const OicUuid_t *rownerId, uint8_t **cborPayload,
                                 size_t *cborSize, int secureFlag)
 {
-    bool allProps[PSTAT_PROPERTY_COUNT];
+    bool allProps[CRED_PROPERTY_COUNT];
 
-    for (int i = 0; i < PSTAT_PROPERTY_COUNT; i++)
+    for (int i = 0; i < CRED_PROPERTY_COUNT; i++)
     {
         allProps[i] = true;
     }