Linux bluetooth development
 help / color / mirror / Atom feed
From: Szymon Janc <szymon.janc@tieto.com>
To: Lukasz Rymanowski <lukasz.rymanowski@tieto.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH] android/gatt: Allow signed write only on non encrypted link
Date: Fri, 13 Jun 2014 16:48:09 +0200	[thread overview]
Message-ID: <13891166.2dbPConnFo@uw000953> (raw)
In-Reply-To: <1402571550-8896-1-git-send-email-lukasz.rymanowski@tieto.com>

Hi Łukasz,

On Thursday 12 of June 2014 13:12:30 Lukasz Rymanowski wrote:
> ---
>  android/gatt.c | 32 ++++++++++++++++++++++++++++++--
>  1 file changed, 30 insertions(+), 2 deletions(-)
> 
> diff --git a/android/gatt.c b/android/gatt.c
> index 3ec4118..3e9f092 100644
> --- a/android/gatt.c
> +++ b/android/gatt.c
> @@ -2719,6 +2719,22 @@ static bool signed_write_cmd(struct gatt_device *dev, uint16_t handle,
>  	return true;
>  }
>  
> +static int get_sec_level(struct gatt_device *dev)
> +{
> +	GIOChannel *io;
> +	int sec_level;
> +
> +	io = g_attrib_get_channel(dev->attrib);
> +
> +	if (!bt_io_get(io, NULL, BT_IO_OPT_SEC_LEVEL, &sec_level,
> +							BT_IO_OPT_INVALID)) {
> +		error("gatt: Failed to get sec_level");
> +		return -1;
> +	}
> +
> +	return sec_level;
> +}
> +
>  static void handle_client_write_characteristic(const void *buf, uint16_t len)
>  {
>  	const struct hal_cmd_gatt_client_write_characteristic *cmd = buf;
> @@ -2784,8 +2800,14 @@ static void handle_client_write_characteristic(const void *buf, uint16_t len)
>  							write_char_cb, cb_data);
>  		break;
>  	case GATT_WRITE_TYPE_SIGNED:
> -		res = signed_write_cmd(conn->device, ch->ch.value_handle,
> -					cmd->value, cmd->len);
> +		if (get_sec_level(conn->device) != BT_SECURITY_LOW) {
> +			error("gatt: Cannot write signed on encrypted link");
> +			res = HAL_STATUS_FAILED;
> +		} else {
> +			res = signed_write_cmd(conn->device,
> +							ch->ch.value_handle,
> +							cmd->value, cmd->len);
> +		}
>  		break;
>  	default:
>  		error("gatt: Write type %d unsupported", cmd->write_type);
> @@ -5184,6 +5206,12 @@ static void write_signed_cmd_request(const uint8_t *cmd, uint16_t cmd_len,
>  	uint8_t csrk[16];
>  	uint32_t sign_cnt;
>  
> +	if (get_sec_level(dev) != BT_SECURITY_LOW) {
> +		error("gatt: Remote tries write signed on encrypted link");
> +		connection_cleanup(dev);
> +		return;
> +	}
> +
>  	if (!bt_get_csrk(&dev->bdaddr, REMOTE_CSRK, csrk, &sign_cnt)) {
>  		error("gatt: No valid csrk from remote device");
>  		return;
> 

Patch has been applied, thanks.

-- 
Best regards, 
Szymon Janc

      reply	other threads:[~2014-06-13 14:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-12 11:12 [PATCH] android/gatt: Allow signed write only on non encrypted link Lukasz Rymanowski
2014-06-13 14:48 ` Szymon Janc [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=13891166.2dbPConnFo@uw000953 \
    --to=szymon.janc@tieto.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=lukasz.rymanowski@tieto.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox