Commit 7b0c4962 authored by Ashwini Kumar's avatar Ashwini Kumar Committed by Sachin Agrawal

Add 'sct' (Supported Credential Types) in doxm resource.

- Implements madatory property 'sct' in doxm resource.

1. Modify marshalling/Unmarshalling functions in doxmresource.c.
2. Modify all SVR databases that have 'doxm' resource.

[Patch #2] Modify property(attribute ID) and wrong usage of a type for sct.
[Patch #3] Rebase & Fix Arduino build error
[Patch #4] Fix Provisioning C++ Sample build error
[Patch #5] Add 'sct' to resource/provisioning/example/xxx.json
[Patch #6] Updated xxx_client.json acl perms

Change-Id: I4340de22a138437f4307639a2e05dbe8a5affb8b
Signed-off-by: default avatarWoochul Shim <woochul.shim@samsung.com>
Signed-off-by: default avatarAshwini Kumar <k.ashwini@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/2470Tested-by: default avatarjenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: default avatarSachin Agrawal <sachin.agrawal@intel.com>
parent db6848e8
......@@ -35,6 +35,7 @@
"doxm": {
"oxm": [0],
"oxmsel": 0,
"sct": 1,
"owned": true,
"deviceid": "MjIyMjIyMjIyMjIyMjIyMg==",
"ownr": "MjIyMjIyMjIyMjIyMjIyMg=="
......
......@@ -41,6 +41,7 @@
"doxm": {
"oxm": [0],
"oxmsel": 0,
"sct": 1,
"owned": true,
"deviceid": "MTExMTExMTExMTExMTExMQ==",
"ownr": "MjIyMjIyMjIyMjIyMjIyMg=="
......
......@@ -85,6 +85,7 @@ extern const char * OIC_JSON_OM_NAME;
extern const char * OIC_JSON_SM_NAME;
extern const char * OIC_JSON_SERVICE_DEVICE_ID;
extern const char * OIC_JSON_SERVICE_TYPE;
extern const char * OIC_JSON_SUPPORTED_CRED_TYPE_NAME;
extern OicUuid_t WILDCARD_SUBJECT_ID;
extern size_t WILDCARD_SUBJECT_ID_LEN;
......
......@@ -159,18 +159,6 @@ typedef struct OicSecAmacl OicSecAmacl_t;
typedef struct OicSecCred OicSecCred_t;
/**
* @brief /oic/sec/credtype (Credential Type) data type.
* Derived from OIC Security Spec /oic/sec/cred; see Spec for details.
* 0: no security mode
* 1: symmetric pair-wise key
* 2: symmetric group key
* 4: asymmetric key
* 8: signed asymmetric key (aka certificate)
* 16: PIN /password
*/
typedef uint16_t OicSecCredType_t;
/**
* Aid for assigning/testing vals with OicSecCredType_t.
* Example:
......@@ -188,8 +176,21 @@ typedef enum OSCTBitmask
ASYMMETRIC_KEY = (0x1 << 2),
SIGNED_ASYMMETRIC_KEY = (0x1 << 3),
PIN_PASSWORD = (0x1 << 4),
ASYMMETRIC_ENCRYPTION_KEY = (0x1 << 5),
} OSCTBitmask_t;
/**
* @brief /oic/sec/credtype (Credential Type) data type.
* Derived from OIC Security Spec /oic/sec/cred; see Spec for details.
* 0: no security mode
* 1: symmetric pair-wise key
* 2: symmetric group key
* 4: asymmetric key
* 8: signed asymmetric key (aka certificate)
* 16: PIN /password
*/
typedef OSCTBitmask_t OicSecCredType_t;
typedef struct OicSecDoxm OicSecDoxm_t;
typedef enum OicSecDpm
......@@ -362,14 +363,16 @@ struct OicSecDoxm
OicSecOxm_t *oxm; // 1:R:M:N:UINT16
size_t oxmLen; // the number of elts in Oxm
OicSecOxm_t oxmSel; // 2:R/W:S:Y:UINT16
bool owned; // 3:R:S:Y:Boolean
OicSecCredType_t sct; // 3:R:S:Y:oic.sec.credtype
bool owned; // 4:R:S:Y:Boolean
//TODO: Need more clarification on deviceIDFormat field type.
//OicSecDvcIdFrmt_t deviceIDFormat; // 4:R:S:Y:UINT8
OicUuid_t deviceID; // 5:R:S:Y:oic.uuid
OicUuid_t owner; // 6:R:S:Y:oic.uuid
//OicSecDvcIdFrmt_t deviceIDFormat; // 5:R:S:Y:UINT8
OicUuid_t deviceID; // 6:R:S:Y:oic.uuid
OicUuid_t owner; // 7:R:S:Y:oic.uuid
// NOTE: we are using UUID for Owner instead of Svc type for mid-April
// SRM version only; this will change to Svc type for full implementation.
//OicSecSvc_t Owner; // 5:R:S:Y:oic.sec.svc
//OicSecSvc_t devOwner; // 7:R:S:Y:oic.sec.svc
//OicSecSvc_t rOwner; // 8:R:S:Y:oic.sec.svc
//TODO change Owner type to oic.sec.svc
};
......
......@@ -7,7 +7,8 @@
"/oic/d",
"/oic/p",
"/oic/res/types/d",
"/oic/ad"
"/oic/ad",
"/oic/sec/amacl"
],
"perms": 2,
"ownrs" : ["YWRtaW5EZXZpY2VVVUlEMA=="]
......@@ -16,11 +17,9 @@
"sub": "Kg==",
"rsrc": [
"/oic/sec/doxm",
"/oic/sec/pstat",
"/oic/sec/acl",
"/oic/sec/cred"
"/oic/sec/pstat"
],
"perms": 7,
"perms": 2,
"ownrs" : ["YWRtaW5EZXZpY2VVVUlEMA=="]
}
],
......@@ -36,6 +35,7 @@
"doxm": {
"oxm": [0],
"oxmsel": 0,
"sct": 1,
"owned": true,
"deviceid": "YWRtaW5EZXZpY2VVVUlEMA==",
"ownr": "YWRtaW5EZXZpY2VVVUlEMA=="
......
......@@ -36,6 +36,7 @@
"doxm": {
"oxm": [0],
"oxmsel": 0,
"sct": 1,
"owned": true,
"deviceid": "YWRtaW5EZXZpY2VVVUlE",
"ownr": "YWRtaW5EZXZpY2VVVUlE"
......
......@@ -39,6 +39,7 @@
"doxm": {
"oxm": [0],
"oxmsel": 0,
"sct": 1,
"owned": false,
"deviceid": "anVzdHdvcmtzRGV2VVVJRA=="
}
......
......@@ -39,6 +39,7 @@
"doxm": {
"oxm": [0,2],
"oxmsel": 0,
"sct": 1,
"owned": false,
"deviceid": "cmFuZG9tUGluRGV2VVVJRA=="
}
......
......@@ -37,6 +37,7 @@
"doxm": {
"oxm": [0],
"oxmsel": 0,
"sct": 1,
"owned": false,
"deviceid": "MTExMTExMTExMTExMTExMQ=="
}
......
......@@ -275,7 +275,7 @@ OicSecCred_t * JSONToCredBin(const char * jsonStr)
jsonObj = cJSON_GetObjectItem(jsonCred, OIC_JSON_CREDTYPE_NAME);
VERIFY_NON_NULL(TAG, jsonObj, ERROR);
VERIFY_SUCCESS(TAG, cJSON_Number == jsonObj->type, ERROR);
cred->credType = jsonObj->valueint;
cred->credType = (OicSecCredType_t)jsonObj->valueint;
//PrivateData is mandatory for some of the credential types listed below.
jsonObj = cJSON_GetObjectItem(jsonCred, OIC_JSON_PRIVATEDATA_NAME);
......
......@@ -60,6 +60,7 @@ static OicSecDoxm_t gDefaultDoxm =
&gOicSecDoxmJustWorks, /* uint16_t *oxm */
1, /* size_t oxmLen */
OIC_JUST_WORKS, /* uint16_t oxmSel */
SYMMETRIC_PAIR_WISE_KEY,/* OicSecCredType_t sct */
false, /* bool owned */
{.id = {0}}, /* OicUuid_t deviceID */
{.id = {0}}, /* OicUuid_t owner */
......@@ -131,6 +132,9 @@ char * BinToDoxmJSON(const OicSecDoxm_t * doxm)
//OxmSel -- Mandatory
cJSON_AddNumberToObject(jsonDoxm, OIC_JSON_OXM_SEL_NAME, (int)doxm->oxmSel);
//sct -- Mandatory
cJSON_AddNumberToObject(jsonDoxm, OIC_JSON_SUPPORTED_CRED_TYPE_NAME, (int)doxm->sct);
//Owned -- Mandatory
cJSON_AddBoolToObject(jsonDoxm, OIC_JSON_OWNED_NAME, doxm->owned);
......@@ -244,6 +248,19 @@ OicSecDoxm_t * JSONToDoxmBin(const char * jsonStr)
doxm->oxmSel = gDoxm->oxmSel;
}
//sct -- Mandatory
jsonObj = cJSON_GetObjectItem(jsonDoxm, OIC_JSON_SUPPORTED_CRED_TYPE_NAME);
if(jsonObj)
{
VERIFY_SUCCESS(TAG, cJSON_Number == jsonObj->type, ERROR);
doxm->sct = (OicSecCredType_t)jsonObj->valueint;
}
else // PUT/POST JSON may not have sct so set it to the gDoxm->sct
{
VERIFY_NON_NULL(TAG, gDoxm, ERROR);
doxm->sct = gDoxm->sct;
}
//Owned -- Mandatory
jsonObj = cJSON_GetObjectItem(jsonDoxm, OIC_JSON_OWNED_NAME);
if(jsonObj)
......
......@@ -84,6 +84,7 @@ const char * OIC_JSON_SERVICE_TYPE = "svct";
const char * OIC_JSON_PERIOD_NAME = "prd";
const char * OIC_JSON_PERIODS_NAME = "prds";
const char * OIC_JSON_RECURRENCES_NAME = "recurs";
const char * OIC_JSON_SUPPORTED_CRED_TYPE_NAME = "sct";
OicUuid_t WILDCARD_SUBJECT_ID = {"*"};
size_t WILDCARD_SUBJECT_ID_LEN = 1;
......
......@@ -69,7 +69,7 @@ OicSecCred_t * getCredList()
#endif
cred->credType = 1;
cred->credType = SYMMETRIC_PAIR_WISE_KEY;
cred->privateData.data = (char *)OICCalloc(1, strlen("My private Key11") + 1);
VERIFY_NON_NULL(TAG, cred->privateData.data, ERROR);
strcpy(cred->privateData.data, "My private Key11");
......@@ -85,7 +85,7 @@ OicSecCred_t * getCredList()
#if 0
cred->next->roleIdsLen = 0;
#endif
cred->next->credType = 1;
cred->next->credType = SYMMETRIC_PAIR_WISE_KEY;
sz = strlen("My private Key21") + 1;
cred->next->privateData.data = (char *)OICCalloc(1, sz);
VERIFY_NON_NULL(TAG, cred->next->privateData.data, ERROR);
......
......@@ -84,6 +84,7 @@ OicSecDoxm_t * getBinDoxm()
doxm->oxm[0] = OIC_JUST_WORKS;
doxm->oxmSel = OIC_JUST_WORKS;
doxm->sct = SYMMETRIC_PAIR_WISE_KEY;
doxm->owned = true;
//TODO: Need more clarification on deviceIDFormat field type.
//doxm.deviceIDFormat = URN;
......
......@@ -39,6 +39,7 @@
"doxm": {
"oxm": [0],
"oxmsel": 0,
"sct": 1,
"owned": false,
"deviceid": "MjIyMjIyMjIyMjIyMjIyMg=="
}
......
......@@ -36,6 +36,7 @@
"doxm": {
"oxm": [0],
"oxmsel": 0,
"sct": 1,
"owned": true,
"deviceid": "MjIyMjIyMjIyMjIyMjIyMg==",
"ownr": "MjIyMjIyMjIyMjIyMjIyMg=="
......
......@@ -65,6 +65,7 @@
"doxm": {
"oxm": [0],
"oxmsel": 0,
"sct": 1,
"owned": true,
"deviceid": "MTExMTExMTExMTExMTExMQ==",
"ownr": "YWRtaW5EZXZpY2VVVUlEAA=="
......
......@@ -35,6 +35,7 @@
"doxm": {
"oxm": [0],
"oxmsel": 0,
"sct": 1,
"owned": true,
"deviceid": "MjIyMjIyMjIyMjIyMjIyMg==",
"ownr": "MjIyMjIyMjIyMjIyMjIyMg=="
......
......@@ -41,6 +41,7 @@
"doxm": {
"oxm": [0],
"oxmsel": 0,
"sct": 1,
"owned": true,
"deviceid": "MTExMTExMTExMTExMTExMQ==",
"ownr": "MjIyMjIyMjIyMjIyMjIyMg=="
......
......@@ -7,7 +7,8 @@
"/oic/d",
"/oic/p",
"/oic/res/types/d",
"/oic/ad"
"/oic/ad",
"/oic/sec/amacl"
],
"perms": 2,
"ownrs" : ["YWRtaW5EZXZpY2VVVUlEMA=="]
......@@ -16,11 +17,9 @@
"sub": "Kg==",
"rsrc": [
"/oic/sec/doxm",
"/oic/sec/pstat",
"/oic/sec/acl",
"/oic/sec/cred"
"/oic/sec/pstat"
],
"perms": 7,
"perms": 2,
"ownrs" : ["YWRtaW5EZXZpY2VVVUlEMA=="]
}
],
......@@ -36,6 +35,7 @@
"doxm": {
"oxm": [0],
"oxmsel": 0,
"sct": 1,
"owned": true,
"deviceid": "YWRtaW5EZXZpY2VVVUlEMA==",
"ownr": "YWRtaW5EZXZpY2VVVUlEMA=="
......
......@@ -488,7 +488,7 @@ static int InputCredentials(Credential &cred)
switch (choice){
case 1:
cred.setCredentialType(choice);
cred.setCredentialType(static_cast<OicSecCredType_t>(choice));
choice = 0; //validation of the accepted choice.
break;
case 2:
......@@ -709,7 +709,7 @@ int main(void)
pOwnedDevList[first]->getDeviceID();
std::cout << " and "<< pOwnedDevList[second]->getDeviceID() << std::endl;
Credential cred(0,0);
Credential cred( NO_SECURITY_MODE ,0);
std::cout << "Please input credentials for selected devices: " << std::endl;
if (0 != InputCredentials(cred))
break;
......@@ -737,7 +737,7 @@ int main(void)
pOwnedDevList[first]->getDeviceID();
std::cout << " and "<< pOwnedDevList[second]->getDeviceID() << std::endl;
Credential cred(0,0);
Credential cred( NO_SECURITY_MODE, 0);
std::cout << "Please input credentials for selected devices: " << std::endl;
if (0 != InputCredentials(cred))
break;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment