Commit 0bc046a5 authored by George Nash's avatar George Nash

Merge 'origin/master' into swig

Change-Id: Ic75bc8930a20554b7d871d54097fe422cdcefb68
Signed-off-by: George Nash's avatarGeorge Nash <george.nash@intel.com>
parents 44f739dc 0b100dc5
......@@ -167,6 +167,8 @@ oc_cloud_provision_conf_resource(oc_cloud_context_t *ctx, const char *server,
ctx->store.status = OC_CLOUD_INITIALIZED;
ctx->cps = OC_CPS_READYTOREGISTER;
cloud_store_dump_async(&ctx->store);
if (ctx->cloud_manager) {
cloud_reconnect(ctx);
}
......@@ -350,6 +352,7 @@ oc_cloud_shutdown(void)
cloud_store_deinit(&ctx->store);
cloud_close_endpoint(ctx->cloud_ep);
oc_free_endpoint(ctx->cloud_ep);
oc_list_remove(cloud_context_list, ctx);
oc_memb_free(&cloud_context_pool, ctx);
OC_DBG("cloud_shutdown for %d", (int)device);
}
......
......@@ -31,9 +31,9 @@ OC_LIST(oc_blockwise_requests);
OC_LIST(oc_blockwise_responses);
static oc_blockwise_state_t *
oc_blockwise_init_buffer(struct oc_memb *pool, const char *href, size_t href_len,
oc_endpoint_t *endpoint, oc_method_t method,
oc_blockwise_role_t role)
oc_blockwise_init_buffer(struct oc_memb *pool, const char *href,
size_t href_len, oc_endpoint_t *endpoint,
oc_method_t method, oc_blockwise_role_t role)
{
if (href_len == 0)
return NULL;
......@@ -184,12 +184,12 @@ oc_blockwise_scrub_buffers_for_client_cb(void *cb)
#endif /* OC_CLIENT */
void
oc_blockwise_scrub_buffers()
oc_blockwise_scrub_buffers(bool all)
{
oc_blockwise_state_t *buffer = oc_list_head(oc_blockwise_requests), *next;
while (buffer != NULL) {
next = buffer->next;
if (buffer->ref_count == 0) {
if (buffer->ref_count == 0 || all) {
oc_blockwise_free_request_buffer(buffer);
}
buffer = next;
......@@ -198,7 +198,7 @@ oc_blockwise_scrub_buffers()
buffer = oc_list_head(oc_blockwise_responses);
while (buffer != NULL) {
next = buffer->next;
if (buffer->ref_count == 0) {
if (buffer->ref_count == 0 || all) {
oc_blockwise_free_response_buffer(buffer);
}
buffer = next;
......
......@@ -827,6 +827,7 @@ oc_rep_to_json_format(oc_rep_t *rep, char *buf, size_t buf_size, int tab_depth,
}
}
num_char_printed = snprintf(buf, buf_size, "]");
OC_JSON_UPDATE_BUFFER_AND_TOTAL;
break;
}
case OC_REP_BYTE_STRING_ARRAY: {
......
......@@ -1484,7 +1484,7 @@ oc_ri_shutdown(void)
free_all_client_cbs();
#endif /* OC_CLIENT */
#ifdef OC_BLOCK_WISE
oc_blockwise_scrub_buffers();
oc_blockwise_scrub_buffers(true);
#endif /* OC_BLOCK_WISE */
while (oc_main_poll() != 0)
......
......@@ -740,7 +740,7 @@ TEST(TestRep, OCRepSetGetBoolArray)
json_size = oc_rep_to_json(rep, NULL, 0, false);
json = (char *)malloc(json_size + 1);
oc_rep_to_json(rep, json, json_size + 1, false);
const char non_pretty_json[] = "{\"flip\":[false,false,true,false,false}";
const char non_pretty_json[] = "{\"flip\":[false,false,true,false,false]}";
EXPECT_STREQ(non_pretty_json, json);
free(json);
json = NULL;
......@@ -748,7 +748,7 @@ TEST(TestRep, OCRepSetGetBoolArray)
json = (char *)malloc(json_size + 1);
oc_rep_to_json(rep, json, json_size + 1, true);
const char pretty_json[] = "{\n"
" \"flip\" : [false, false, true, false, false\n"
" \"flip\" : [false, false, true, false, false]\n"
"}\n";
EXPECT_STREQ(pretty_json, json);
free(json);
......@@ -808,7 +808,7 @@ TEST(TestRep, OCRepAddGetBoolArray)
json_size = oc_rep_to_json(rep, NULL, 0, false);
json = (char *)malloc(json_size + 1);
oc_rep_to_json(rep, json, json_size + 1, false);
const char non_pretty_json[] = "{\"flip\":[false,false,true,false,false}";
const char non_pretty_json[] = "{\"flip\":[false,false,true,false,false]}";
EXPECT_STREQ(non_pretty_json, json);
free(json);
json = NULL;
......@@ -816,7 +816,7 @@ TEST(TestRep, OCRepAddGetBoolArray)
json = (char *)malloc(json_size + 1);
oc_rep_to_json(rep, json, json_size + 1, true);
const char pretty_json[] = "{\n"
" \"flip\" : [false, false, true, false, false\n"
" \"flip\" : [false, false, true, false, false]\n"
"}\n";
EXPECT_STREQ(pretty_json, json);
free(json);
......
......@@ -22,6 +22,7 @@
#include "gtest/gtest.h"
#include "oc_uuid.h"
#include "port/oc_random.h"
#define UUID "12345678123412341234123456789012"
......@@ -61,8 +62,68 @@ TEST(UUIDGeneration, NonWildcardUUID)
char nonwc[37];
oc_uuid_t uuid;
oc_str_to_uuid(u, &uuid);
EXPECT_EQ('*', uuid.id[0]);
EXPECT_EQ(0xf0, uuid.id[1]);
EXPECT_EQ(0x7d, uuid.id[2]);
EXPECT_EQ(0x57, uuid.id[3]);
EXPECT_EQ(0xb2, uuid.id[4]);
EXPECT_EQ(0xe3, uuid.id[5]);
EXPECT_EQ(0x41, uuid.id[6]);
EXPECT_EQ(0x20, uuid.id[7]);
EXPECT_EQ(0x92, uuid.id[8]);
EXPECT_EQ(0x92, uuid.id[9]);
EXPECT_EQ(0xf9, uuid.id[10]);
EXPECT_EQ(0xfe, uuid.id[11]);
EXPECT_EQ(0xf1, uuid.id[12]);
EXPECT_EQ(0x6b, uuid.id[13]);
EXPECT_EQ(0x41, uuid.id[14]);
EXPECT_EQ(0xd7, uuid.id[15]);
oc_uuid_to_str(&uuid, nonwc, 37);
EXPECT_EQ(strlen(u), strlen(nonwc));
EXPECT_EQ(memcmp(u, nonwc, strlen(u)), 0);
EXPECT_STREQ(u, nonwc);
}
/*
* Text from RFC 4122 4.4 placed here since it helps to understand the bit
* twiddling done in the test.
*
* The version 4 UUID is meant for generating UUIDs from truly-random or
* pseudo-random numbers.
*
* The algorithm is as follows:
*
* o Set the two most significant bits (bits 6 and 7) of the
* clock_seq_hi_and_reserved to zero and one, respectively.
*
* o Set the four most significant bits (bits 12 through 15) of the
* time_hi_and_version field to the 4-bit version number from
* Section 4.1.3.
*
* o Set all the other bits to randomly (or pseudo-randomly) chosen
* values.
*/
TEST(UUIDGeneration, GenerateType4UUID) {
// Type 4 uuid uses iotivities psudo random number generator.
oc_random_init();
oc_uuid_t uuid;
oc_gen_uuid(&uuid);
// `clock_seq_hi_and_reserved` is the 8th byte bit 7 is zero per spec
EXPECT_EQ(0, (uuid.id[8] & 0x80));
// `clock_seq_hi_and_reserved` is the 8th byte bit 6 is one per spec
EXPECT_EQ(0x40, (uuid.id[8] & 0x40));
// `time_hi_version` is the 6th and 7th bytes bits 15 through 12 should
// be set to 0 1 0 0 (0x40) per spec
EXPECT_EQ(0x40, (uuid.id[6] & 0x40));
char uuid_str[OC_UUID_LEN];
oc_uuid_to_str(&uuid, uuid_str, OC_UUID_LEN);
EXPECT_EQ('-', uuid_str[8]);
EXPECT_EQ('-', uuid_str[13]);
EXPECT_EQ('4', uuid_str[14]); // For Version 4 UUIDs this will always be a 4
EXPECT_EQ('-', uuid_str[18]);
EXPECT_EQ('-', uuid_str[23]);
oc_random_destroy();
}
-----BEGIN CERTIFICATE-----
MIIEEzCCA7igAwIBAgIJAI0K+3tTskz5MAoGCCqGSM49BAMCMFsxDDAKBgNVBAoM
MIIEHDCCA8GgAwIBAgIJAI0K+3tTsk0lMAoGCCqGSM49BAMCMFsxDDAKBgNVBAoM
A09DRjEiMCAGA1UECwwZS3lyaW8gVGVzdCBJbmZyYXN0cnVjdHVyZTEnMCUGA1UE
AwweS3lyaW8gVEVTVCBJbnRlcm1lZGlhdGUgQ0EwMDAyMB4XDTE5MTAwODAxMjIz
M1oXDTE5MTEwNzAxMjIzM1owYTEMMAoGA1UECgwDT0NGMSIwIAYDVQQLDBlLeXJp
byBUZXN0IEluZnJhc3RydWN0dXJlMS0wKwYDVQQDDCQyOGNjYWIxZC1mNDEwLTQ0
N2UtYjliNC0zMTUyYjEyYjI3NjUwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAAT9
LQRB/K0yeD56w8D0yZeJCFzP2YijUPU8JI24jZ/vJD9x7Rs3iAEKqICFAjObJGDC
U3p8w5Q5u+FCjc42pMBMo4ICXTCCAlkwCQYDVR0TBAIwADAO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Z
jBraXKeZs1W9FXar3nk5tAuKOCaADAuMQQ==
-----END EC PRIVATE KEY-----
......@@ -33,9 +33,36 @@ typedef enum { C = 100, F, K } units_t;
units_t temp_units = C;
static bool switch_state;
const char *mfg_persistent_uuid = "f6e10d9c-a1c9-43ba-a800-f1b0aad2a889";
static pthread_t toggle_switch_thread;
oc_resource_t *temp_resource = NULL, *bswitch = NULL, *col = NULL;
oc_define_interrupt_handler(toggle_switch)
{
if (bswitch) {
oc_notify_observers(bswitch);
}
}
static void *
toggle_switch_resource(void *data)
{
(void)data;
while (quit != 1) {
getchar();
if (quit != 1) {
PRINT("\nSwitch toggled\n");
switch_state = !switch_state;
oc_signal_interrupt_handler(toggle_switch);
}
}
return NULL;
}
static int
app_init(void)
{
oc_activate_interrupt_handler(toggle_switch);
int err = oc_init_platform("Intel", NULL, NULL);
err |= oc_add_device("/oic/d", "oic.d.switch", "Temp_sensor", "ocf.2.0.5",
......@@ -470,51 +497,32 @@ get_platform_properties(oc_resource_t *resource, oc_interface_mask_t iface_mask,
}
}
static void
get_platform(oc_request_t *request, oc_interface_mask_t iface_mask,
void *user_data)
{
oc_rep_start_root_object();
get_platform_properties(request->resource, iface_mask, user_data);
oc_rep_end_root_object();
oc_send_response(request, OC_STATUS_OK);
}
static void
post_platform(oc_request_t *request, oc_interface_mask_t iface_mask,
void *user_data)
{
(void)iface_mask;
set_platform_properties(request->resource, request->request_payload,
user_data);
oc_send_response(request, OC_STATUS_OK);
}
static void
register_resources(void)
{
oc_resource_t *temp = oc_new_resource(NULL, "/temp", 1, 0);
oc_resource_bind_resource_type(temp, "oic.r.temperature");
oc_resource_bind_resource_interface(temp, OC_IF_A);
oc_resource_bind_resource_interface(temp, OC_IF_S);
oc_resource_set_default_interface(temp, OC_IF_A);
oc_resource_set_discoverable(temp, true);
oc_resource_set_periodic_observable(temp, 1);
oc_resource_set_request_handler(temp, OC_GET, get_temp, NULL);
oc_resource_set_request_handler(temp, OC_POST, post_temp, NULL);
oc_add_resource(temp);
oc_resource_t *bswitch = oc_new_resource(NULL, "/switch", 1, 0);
temp_resource = oc_new_resource(NULL, "/temp", 1, 0);
oc_resource_bind_resource_type(temp_resource, "oic.r.temperature");
oc_resource_bind_resource_interface(temp_resource, OC_IF_A);
oc_resource_bind_resource_interface(temp_resource, OC_IF_S);
oc_resource_set_default_interface(temp_resource, OC_IF_A);
oc_resource_set_discoverable(temp_resource, true);
oc_resource_set_periodic_observable(temp_resource, 1);
oc_resource_set_request_handler(temp_resource, OC_GET, get_temp, NULL);
oc_resource_set_request_handler(temp_resource, OC_POST, post_temp, NULL);
oc_add_resource(temp_resource);
bswitch = oc_new_resource(NULL, "/switch", 1, 0);
oc_resource_bind_resource_type(bswitch, "oic.r.switch.binary");
oc_resource_bind_resource_interface(bswitch, OC_IF_A);
oc_resource_set_default_interface(bswitch, OC_IF_A);
oc_resource_set_observable(bswitch, true);
oc_resource_set_discoverable(bswitch, true);
oc_resource_set_request_handler(bswitch, OC_GET, get_switch, NULL);
oc_resource_set_request_handler(bswitch, OC_POST, post_switch, NULL);
oc_add_resource(bswitch);
#ifdef OC_COLLECTIONS
oc_resource_t *col = oc_new_collection(NULL, "/platform", 1, 0);
col = oc_new_collection(NULL, "/platform", 1, 0);
oc_resource_bind_resource_type(col, "oic.wk.col");
oc_resource_set_discoverable(col, true);
......@@ -528,15 +536,8 @@ register_resources(void)
oc_link_t *l1 = oc_new_link(bswitch);
oc_collection_add_link(col, l1);
/* Add a defined or custom link parameter to this link */
oc_link_add_link_param(l1, "name", "platform_switch");
/* Add self-link to the Collection */
oc_link_t *l2 = oc_new_link(col);
oc_collection_add_link(col, l2);
oc_link_add_link_param(l1, "x.org.openconnectivity.name", "platform_switch");
/* The following enables batch RETRIEVEs/UPDATEs to Collection properties */
oc_resource_set_request_handler(col, OC_GET, get_platform, NULL);
oc_resource_set_request_handler(col, OC_POST, post_platform, NULL);
/* The following enables baseline RETRIEVEs/UPDATEs to Collection properties
*/
oc_resource_set_properties_cbs(col, get_platform_properties, NULL,
......@@ -698,6 +699,11 @@ main(void)
oc_set_random_pin_callback(random_pin_cb, NULL);
#endif /* OC_SECURITY */
if (pthread_create(&toggle_switch_thread, NULL, &toggle_switch_resource,
NULL) != 0) {
return -1;
}
init = oc_main_init(&handler);
if (init < 0)
return init;
......@@ -717,5 +723,8 @@ main(void)
oc_main_shutdown();
PRINT("\nPress any key to exit...\n");
pthread_join(toggle_switch_thread, NULL);
return 0;
}
......@@ -83,20 +83,22 @@ oc_blockwise_state_t *oc_blockwise_find_response_buffer_by_client_cb(
oc_endpoint_t *endpoint, void *client_cb);
oc_blockwise_state_t *oc_blockwise_find_request_buffer(
const char *href, size_t href_len, oc_endpoint_t *endpoint, oc_method_t method,
const char *query, size_t query_len, oc_blockwise_role_t role);
const char *href, size_t href_len, oc_endpoint_t *endpoint,
oc_method_t method, const char *query, size_t query_len,
oc_blockwise_role_t role);
oc_blockwise_state_t *oc_blockwise_find_response_buffer(
const char *href, size_t href_len, oc_endpoint_t *endpoint, oc_method_t method,
const char *query, size_t query_len, oc_blockwise_role_t role);
const char *href, size_t href_len, oc_endpoint_t *endpoint,
oc_method_t method, const char *query, size_t query_len,
oc_blockwise_role_t role);
oc_blockwise_state_t *oc_blockwise_alloc_request_buffer(
const char *href, size_t href_len, oc_endpoint_t *endpoint, oc_method_t method,
oc_blockwise_role_t role);
const char *href, size_t href_len, oc_endpoint_t *endpoint,
oc_method_t method, oc_blockwise_role_t role);
oc_blockwise_state_t *oc_blockwise_alloc_response_buffer(
const char *href, size_t href_len, oc_endpoint_t *endpoint, oc_method_t method,
oc_blockwise_role_t role);
const char *href, size_t href_len, oc_endpoint_t *endpoint,
oc_method_t method, oc_blockwise_role_t role);
void oc_blockwise_free_request_buffer(oc_blockwise_state_t *buffer);
......@@ -112,7 +114,7 @@ bool oc_blockwise_handle_block(oc_blockwise_state_t *buffer,
const uint8_t *incoming_block,
uint32_t incoming_block_size);
void oc_blockwise_scrub_buffers(void);
void oc_blockwise_scrub_buffers(bool all);
void oc_blockwise_scrub_buffers_for_client_cb(void *cb);
......
......@@ -407,6 +407,16 @@ coap_receive(oc_message_t *msg)
#endif /* !OC_TCP */
if (incoming_block_len > 0) {
OC_DBG("creating request buffer");
request_buffer = oc_blockwise_find_request_buffer(
href, href_len, &msg->endpoint, message->code,
message->uri_query, message->uri_query_len,
OC_BLOCKWISE_SERVER);
if (request_buffer) {
oc_blockwise_free_request_buffer(request_buffer);
request_buffer = NULL;
}
request_buffer = oc_blockwise_alloc_request_buffer(
href, href_len, &msg->endpoint, message->code,
OC_BLOCKWISE_SERVER);
......@@ -746,7 +756,7 @@ send_message:
#endif /* OC_SECURITY */
#ifdef OC_BLOCK_WISE
oc_blockwise_scrub_buffers();
oc_blockwise_scrub_buffers(false);
#endif /* OC_BLOCK_WISE */
return coap_status_code;
......
......@@ -168,7 +168,7 @@ coap_send_transaction(coap_transaction_t *t)
#endif /* OC_CLIENT */
#ifdef OC_BLOCK_WISE
oc_blockwise_scrub_buffers();
oc_blockwise_scrub_buffers(false);
#endif /* OC_BLOCK_WISE */
#ifdef OC_SECURITY
if (t->message->endpoint.flags & SECURED) {
......
From fab6a1dd40001636d9b367062ad7f6ffa71c1129 Mon Sep 17 00:00:00 2001
From: Kishen Maloor <kishen.maloor@intel.com>
Date: Sat, 12 Oct 2019 15:41:55 +0300
Subject: [PATCH] ocf constrained
---
include/mbedtls/config.h | 3344 ++--------------------------------------------
library/entropy_poll.c | 24 +-
2 files changed, 122 insertions(+), 3246 deletions(-)
diff --git a/include/mbedtls/config.h b/include/mbedtls/config.h
index 654f972..774aef4 100644
index 654f9725e..fd6446b38 100644
--- a/include/mbedtls/config.h
+++ b/include/mbedtls/config.h
@@ -1,3294 +1,150 @@
@@ -1,3294 +1,154 @@
-/**
- * \file config.h
- *
......@@ -1641,7 +1631,7 @@ index 654f972..774aef4 100644
- * Comment this macro to disable support for server name indication in SSL
- */
-#define MBEDTLS_SSL_SERVER_NAME_INDICATION
-
-/**
- * \def MBEDTLS_SSL_TRUNCATED_HMAC
- *
......@@ -1745,7 +1735,7 @@ index 654f972..774aef4 100644
- * Comment to skip keyUsage checking for both CA and leaf certificates.
- */
-#define MBEDTLS_X509_CHECK_KEY_USAGE
-
-/**
- * \def MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE
- *
......@@ -3158,8 +3148,6 @@ index 654f972..774aef4 100644
-/* SSL Cache options */
-//#define MBEDTLS_SSL_CACHE_DEFAULT_TIMEOUT 86400 /**< 1 day */
-//#define MBEDTLS_SSL_CACHE_DEFAULT_MAX_ENTRIES 50 /**< Maximum entries in cache */
-
-/* SSL options */
+#define MBEDTLS_ECP_DP_SECP256R1_ENABLED
+#define MBEDTLS_ECP_C
+#define MBEDTLS_BIGNUM_C
......@@ -3171,6 +3159,9 @@ index 654f972..774aef4 100644
+#define MBEDTLS_PKCS1_V15
+#define MBEDTLS_X509_CRT_PARSE_C
-/* SSL options */
+#define MBEDTLS_X509_USE_C
-/** \def MBEDTLS_SSL_MAX_CONTENT_LEN
- *
- * Maximum length (in bytes) of incoming and outgoing plaintext fragments.
......@@ -3196,7 +3187,10 @@ index 654f972..774aef4 100644
- * incoming and outgoing I/O buffers.
- */
-//#define MBEDTLS_SSL_MAX_CONTENT_LEN 16384
+#define MBEDTLS_X509_USE_C
+#define MBEDTLS_ASN1_PARSE_C
+#define MBEDTLS_OID_C
+#define MBEDTLS_PK_PARSE_C
+#define MBEDTLS_PK_C
-/** \def MBEDTLS_SSL_IN_CONTENT_LEN
- *
......@@ -3222,10 +3216,7 @@ index 654f972..774aef4 100644
- * independently of the outgoing I/O buffer.
- */
-//#define MBEDTLS_SSL_IN_CONTENT_LEN 16384
+#define MBEDTLS_ASN1_PARSE_C
+#define MBEDTLS_OID_C
+#define MBEDTLS_PK_PARSE_C
+#define MBEDTLS_PK_C
+#define MBEDTLS_CIPHER_MODE_CBC
-/** \def MBEDTLS_SSL_OUT_CONTENT_LEN
- *
......@@ -3250,7 +3241,7 @@ index 654f972..774aef4 100644
- * independently of the incoming I/O buffer.
- */
-//#define MBEDTLS_SSL_OUT_CONTENT_LEN 16384
+#define MBEDTLS_CIPHER_MODE_CBC
+#define MBEDTLS_SSL_SRV_RESPECT_CLIENT_PREFERENCE
-/** \def MBEDTLS_SSL_DTLS_MAX_BUFFERING
- *
......@@ -3268,11 +3259,6 @@ index 654f972..774aef4 100644
- *
- */
-//#define MBEDTLS_SSL_DTLS_MAX_BUFFERING 32768
+#define MBEDTLS_SSL_SRV_RESPECT_CLIENT_PREFERENCE
-//#define MBEDTLS_SSL_DEFAULT_TICKET_LIFETIME 86400 /**< Lifetime of session tickets (if enabled) */
-//#define MBEDTLS_PSK_MAX_LEN 32 /**< Max size of TLS pre-shared keys, in bytes (default 256 bits) */
-//#define MBEDTLS_SSL_COOKIE_TIMEOUT 60 /**< Default expiration delay of DTLS cookies, in seconds if HAVE_TIME, or in number of cookies issued */
+#define MBEDTLS_SSL_EXTENDED_MASTER_SECRET
+#define MBEDTLS_SSL_ALL_ALERT_MESSAGES
+#define MBEDTLS_PKCS5_C
......@@ -3281,6 +3267,11 @@ index 654f972..774aef4 100644
+#define MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
+#define MBEDTLS_CCM_C
-//#define MBEDTLS_SSL_DEFAULT_TICKET_LIFETIME 86400 /**< Lifetime of session tickets (if enabled) */
-//#define MBEDTLS_PSK_MAX_LEN 32 /**< Max size of TLS pre-shared keys, in bytes (default 256 bits) */
-//#define MBEDTLS_SSL_COOKIE_TIMEOUT 60 /**< Default expiration delay of DTLS cookies, in seconds if HAVE_TIME, or in number of cookies issued */
+#define MBEDTLS_GCM_C
-/**
- * Complete list of ciphersuites to use, in order of preference.
- *
......@@ -3294,13 +3285,15 @@ index 654f972..774aef4 100644
- * The value below is only an example, not the default.
- */
-//#define MBEDTLS_SSL_CIPHERSUITES MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
+#define MBEDTLS_GCM_C
+#define MBEDTLS_ECP_C
+#define MBEDTLS_ASN1_WRITE_C
-/* X509 options */
-//#define MBEDTLS_X509_MAX_INTERMEDIATE_CA 8 /**< Maximum number of intermediate CAs in a verification chain. */
-//#define MBEDTLS_X509_MAX_FILE_PATH_LEN 512 /**< Maximum length of a path/filename string in bytes including the null terminator character ('\0'). */
+#define MBEDTLS_ECP_C
+#define MBEDTLS_ASN1_WRITE_C
+#define MBEDTLS_PEM_PARSE_C
+#define MBEDTLS_BASE64_C
+#define MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE
-/**
- * Allow SHA-1 in the default TLS configuration for certificate signing.
......@@ -3315,9 +3308,8 @@ index 654f972..774aef4 100644
- *
- */
-// #define MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
+#define MBEDTLS_PEM_PARSE_C
+#define MBEDTLS_BASE64_C
+#define MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE
+#define MBEDTLS_PK_WRITE_C //extract public key
+#define MBEDTLS_PEM_WRITE_C
-/**
- * Allow SHA-1 in the default TLS configuration for TLS 1.2 handshake
......@@ -3335,8 +3327,9 @@ index 654f972..774aef4 100644
- *
- */
-#define MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_KEY_EXCHANGE
+#define MBEDTLS_PK_WRITE_C //extract public key
+#define MBEDTLS_PEM_WRITE_C
+#ifdef OC_CLOUD
+#define MBEDTLS_SHA512_C
+#endif /* OC_CLOUD */
+//
+#define MBEDTLS_X509_EXPANDED_SUBJECT_ALT_NAME_SUPPORT
+#define MBEDTLS_X509_CSR_PARSE_C
......@@ -3408,7 +3401,7 @@ index 654f972..774aef4 100644
#endif /* MBEDTLS_CONFIG_H */
diff --git a/library/entropy_poll.c b/library/entropy_poll.c
index 2792bcb..3034287 100644
index 4556f88a5..aab657d3a 100644
--- a/library/entropy_poll.c
+++ b/library/entropy_poll.c
@@ -50,12 +50,32 @@
......@@ -3446,6 +3439,3 @@ index 2792bcb..3034287 100644
#if !defined(_WIN32_WINNT)
#define _WIN32_WINNT 0x0400
--
1.9.1
......@@ -1459,6 +1459,14 @@ oc_connectivity_init(size_t device)
OC_ERR("setting reuseaddr option %d", errno);
return -1;
}
#ifdef IPV6_ADDR_PREFERENCES
int prefer = 2;
if (setsockopt(dev->server_sock, IPPROTO_IPV6, IPV6_ADDR_PREFERENCES, &prefer,
sizeof(prefer)) == -1) {
OC_ERR("setting src addr preference %d", errno);
return -1;
}
#endif /* IPV6_ADDR_PREFERENCES */
if (bind(dev->server_sock, (struct sockaddr *)&dev->server,
sizeof(dev->server)) == -1) {
OC_ERR("binding server socket %d", errno);
......@@ -1488,6 +1496,13 @@ oc_connectivity_init(size_t device)
OC_ERR("setting reuseaddr option %d", errno);
return -1;
}
#ifdef IPV6_ADDR_PREFERENCES
if (setsockopt(dev->mcast_sock, IPPROTO_IPV6, IPV6_ADDR_PREFERENCES, &prefer,
sizeof(prefer)) == -1) {
OC_ERR("setting src addr preference %d", errno);
return -1;
}
#endif /* IPV6_ADDR_PREFERENCES */
if (bind(dev->mcas