liboctbstack_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
liboctbstack_env.AppendUnique(LIBS = ['coap', 'm'])
+liboctbstack_env.AppendUnique(CPPDEFINES = ['CA_SEC_MERGE_WORKAROUND'])
+
if target_os == 'arduino':
liboctbstack_env.AppendUnique(CPPDEFINES = ['NDEBUG', 'WITH_ARDUINO'])
else:
#include "ocsecurityconfig.h"
+
+#ifdef CA_SEC_MERGE_WORKAROUND
+/**
+ * This is a workaround to enable CA merge into master branch.
+ * This will be removed by updating code in CA library to use updated data structure.
+ */
+typedef struct
+{
+ uint32_t unused;
+ unsigned char identity[DTLS_PSK_ID_LEN];
+ uint32_t num;
+ OCDtlsPskCreds *creds;
+} CADtlsPskCredsBlob;
+#endif //CA_SEC_MERGE_WORKAROUND
+
+
/**
* This callback is used by lower stack (i.e. CA layer) to retrieve PSK
* credentials from RI security layer.
#include "ocmalloc.h"
#include "ocsecurity.h"
#include "ocsecurityconfig.h"
+#ifdef CA_SEC_MERGE_WORKAROUND
+#include "ocsecurityinternal.h"
+#endif //CA_SEC_MERGE_WORKAROUND
#include <string.h>
static OCSecConfigData* secConfigData;
static int secConfigDataLen;
+/**
+ * Currently, there is a disconnect in the data structure used between RI layer
+ * and CA layer to convey DTLS PSK credentials. We cannot update this data
+ * structure until all reviews of CA layer is completed. To enable security
+ * feature in CA branch this workaround is added as a temporary stop-gap.
+ *
+ */
+#ifdef CA_SEC_MERGE_WORKAROUND
+static CADtlsPskCredsBlob *caBlob;
+#endif //CA_SEC_MERGE_WORKAROUND
+
/**
* This internal API removes/clears the global variable holding the security
* config data. This needs to be invoked when OIC stack is shutting down.
OCFree(secConfigData);
secConfigData = NULL;
}
+
+#ifdef CA_SEC_MERGE_WORKAROUND
+ if (caBlob)
+ {
+ OCFree(caBlob->creds);
+ }
+ OCFree(caBlob);
+#endif
+
}
/**
{
if (osb->type == OC_BLOB_TYPE_PSK)
{
+#ifdef CA_SEC_MERGE_WORKAROUND
+ OCDtlsPskCredsBlob * ocBlob = (OCDtlsPskCredsBlob *)osb->val;
+ if (!caBlob)
+ {
+ caBlob = (CADtlsPskCredsBlob *)OCCalloc(sizeof(CADtlsPskCredsBlob), 1);
+ if (caBlob)
+ {
+ memcpy(caBlob->identity, ocBlob->identity, sizeof(caBlob->identity));
+ caBlob->num = ocBlob->num;
+ caBlob->creds =
+ (OCDtlsPskCreds*) OCMalloc(caBlob->num * sizeof(OCDtlsPskCreds));
+ if (caBlob->creds)
+ {
+ memcpy(caBlob->creds, ocBlob->creds,
+ caBlob->num * sizeof(OCDtlsPskCreds));
+ }
+ }
+ }
+ *credInfo = caBlob;
+ break;
+#else
OCDtlsPskCredsBlob * blob;
blob = (OCDtlsPskCredsBlob *)OCMalloc(osb->len);
if (blob)
*credInfo = blob;
break;
}
+#endif //CA_SEC_MERGE_WORKAROUND
}
osb = config_data_next_blob(osb);
}