Remove unused pkg dependancy
[platform/upstream/iotivity.git] / extlibs / tinydtls / 0001-Fixed-issue-to-pass-PSK-identity-hint-to-application.patch
1 From 116451f8fab0df90e87d394d1fa1ac9e739c7dbe Mon Sep 17 00:00:00 2001
2 From: Sachin Agrawal <sachin.agrawal@intel.com>
3 Date: Tue, 20 Jan 2015 15:57:40 -0800
4 Subject: [PATCH 1/1] Fixed issue to pass PSK identity hint to application in
5  callback
6 MIME-Version: 1.0
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
9
10 In cases (with PSK ciphersuite) where Server is sending
11 'PSK Identity Hint’ inside ServerKeyExchange message, DTLS library
12 is not passing the ‘identity hint’ inside ‘desc’ argument in
13 get_psk_info(DTLS_PSK_KEY, desc) callback. Instead, ‘desc’ contains
14 the identity of the client itself. The reason for this is that the
15 code inside dtls_send_client_key_exchange() method
16 overwrites the ‘identity hint’ received earlier.
17
18 Change-Id: Ibf447e3a6b33284118908a52aed4cf636038ab23
19 Signed-off-by: Sachin Agrawal <sachin.agrawal@intel.com>
20 ---
21  extlibs/tinydtls/dtls.c |   17 +++++++----------
22  1 file changed, 7 insertions(+), 10 deletions(-)
23
24 diff --git a/extlibs/tinydtls/dtls.c b/extlibs/tinydtls/dtls.c
25 index 92222eb..9090f22 100644
26 --- a/extlibs/tinydtls/dtls.c
27 +++ b/extlibs/tinydtls/dtls.c
28 @@ -2164,6 +2164,7 @@ static int
29  dtls_send_client_key_exchange(dtls_context_t *ctx, dtls_peer_t *peer)
30  {
31    uint8 buf[DTLS_CKXEC_LENGTH];
32 +  uint8 client_id[DTLS_PSK_MAX_CLIENT_IDENTITY_LEN];
33    uint8 *p;
34    dtls_handshake_parameters_t *handshake = peer->handshake_params;
35  
36 @@ -2175,28 +2176,24 @@ dtls_send_client_key_exchange(dtls_context_t *ctx, dtls_peer_t *peer)
37      int len;
38  
39      len = CALL(ctx, get_psk_info, &peer->session, DTLS_PSK_IDENTITY,
40 -              handshake->keyx.psk.identity, handshake->keyx.psk.id_length,
41 -              buf + sizeof(uint16),
42 -              min(sizeof(buf) - sizeof(uint16),
43 -                  sizeof(handshake->keyx.psk.identity)));
44 +               NULL, 0,
45 +               client_id,
46 +               sizeof(client_id));
47      if (len < 0) {
48        dtls_crit("no psk identity set in kx\n");
49        return len;
50      }
51  
52      if (len + sizeof(uint16) > DTLS_CKXEC_LENGTH) {
53 -      memset(&handshake->keyx.psk, 0, sizeof(dtls_handshake_parameters_psk_t));
54        dtls_warn("the psk identity is too long\n");
55        return dtls_alert_fatal_create(DTLS_ALERT_INTERNAL_ERROR);
56      }
57 -    handshake->keyx.psk.id_length = (unsigned int)len;
58 -    memcpy(handshake->keyx.psk.identity, p + sizeof(uint16), len);
59  
60 -    dtls_int_to_uint16(p, handshake->keyx.psk.id_length);
61 +    dtls_int_to_uint16(p, len);
62      p += sizeof(uint16);
63  
64 -    memcpy(p, handshake->keyx.psk.identity, handshake->keyx.psk.id_length);
65 -    p += handshake->keyx.psk.id_length;
66 +    memcpy(p, client_id, len);
67 +    p += len;
68  
69      break;
70    }
71 -- 
72 1.7.9.5
73