Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1628247rdb; Mon, 2 Oct 2023 16:13:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHSfnCIvUA8wuWXrs031Zu5BmGAVMI0bcC0jCv2jicaV+4b4stjxTalxWXMu21FE+TQWV0i X-Received: by 2002:a9d:6ac4:0:b0:6b9:cba0:93a9 with SMTP id m4-20020a9d6ac4000000b006b9cba093a9mr13323315otq.31.1696288403076; Mon, 02 Oct 2023 16:13:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696288403; cv=none; d=google.com; s=arc-20160816; b=MtwL8FxVxViONoqgLgiBL7LDU2TSmSBeuajgbXFi9tr9ZJvqQe2AWkxL8A8Kgx52Su O1SOWG60jN7RIF4+sbAD7iKWhYdbiW7MTaS7iL5Mm0W79oLBZsReyMt8QIr+LH/4iPki tjF9Qd8CaZCToBmY8dgb5TezPnkL5iaDUeSNnS0CxTNSFfkCjw/QKCfynWjSDnIjNbfs PxHx/LPr6+DNs+arSZSoNpbT/cVKQsyklf+U/QBHMDTOKSmxgodWWv11td4OH+sVLPfu fjNHIlSlRPKc8YblqYtf9ZRNUsSasrJlRRxeitnBZ4tZhNYwhj0NO2/KhRlg3onkv90P UCmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=f0DzF5mqOD1kMWTkgMUl5iJBtPUnq8TgdRfUEKxTAb0=; fh=4lGQI6056MBa4/oovMyIYaKLn+Wz/24RGvUivMmQP8E=; b=UdMOBQgOKZ332nayJUAcRAFHmPXYIILGTzE9JCs5sXUuG6w5BH53VPtPlBD7vb5OAC ur98/bF1BgM53UCn0nLdKjEXHLYuiiE3cFyTer6WCULVvJrsk8jmaJFTgm6THMASPomw k7Wl7SwuhGyj92+LBRoVwwJahm7xcspAmBTrBiRQIMhRKgaN5VAThVMdKm97832G7vf0 GVdp9U+nmk+6rzEr78eshxxqRjTnCWM3iHXVKejkA2na4pCbM65GA9Oyx5Dyef4DoZ9O 8I90O4O8FctoEVEjLg5j5AmGzjttiEV4IvBrEERj8tsl7yStV4YIbvlEgYieatP9fM5P D4vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Tow5NGx2; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id m1-20020a656a01000000b0056fa1ac3722si32140228pgu.698.2023.10.02.16.13.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 16:13:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Tow5NGx2; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id DA47780FDDC8; Mon, 2 Oct 2023 16:13:21 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237200AbjJBXNW (ORCPT + 99 others); Mon, 2 Oct 2023 19:13:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229954AbjJBXNW (ORCPT ); Mon, 2 Oct 2023 19:13:22 -0400 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E823AC for ; Mon, 2 Oct 2023 16:13:19 -0700 (PDT) Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1c328b53aeaso2455535ad.2 for ; Mon, 02 Oct 2023 16:13:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696288398; x=1696893198; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=f0DzF5mqOD1kMWTkgMUl5iJBtPUnq8TgdRfUEKxTAb0=; b=Tow5NGx2qoS1i+5rRupn14fM9Oqfq4Fz/G9ULh1TVOsWtnTa31/oGWQBNlQi9gBmjA OWt3lRpbhFxSy0AbOVe+dyz1djiv92d4GScZp+1BEgyfbdbM8Ga4qKW7BKHteZvkgMsS XhQc2WwErckUJePWuteIOZbYt4OO12oJzbYLt+FSvpF0KiopiROP+axHe4snLXVBpR/f yukQ2oPTSxqwhC9jfAG2JFsASDns0276sNru3tPLGdzE5sKGaPhRmaRr/EJsTKK6ynTo NLPP+UFetzoo5pKL2GdUIiCwNP2m2YF+bmcX3/7f9h7qZ4lyTFlE5OjFYkplqAQ0XpOr zr8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696288398; x=1696893198; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=f0DzF5mqOD1kMWTkgMUl5iJBtPUnq8TgdRfUEKxTAb0=; b=pidGTDr3SAUbLE4zYYXSSTfOt+K+holhkevMTaOmG/JFC6LGQdKHdjy4Lpg0ss8Ywu lD8MzQaYFQFgyDalDD1d6pk1PLkLr5aE5ZXlwc9CXj9lbxQhENO16IDlhOQuclwxvHZX sH3zToF+iQgMVlQnRoU8f338YE+1R9kcGBCjFHCVjRfAeO6H7vuFUndnqnHtUs/Gb/k8 Egwbu25HTdbIICux1GuvMxbMe92BE8j6Kh0fFIKwOcEcnU0CyEzFy3RCJdMoXw4J6Jcy bS2Q/ejLmuBvZ7feNQPKQsU2rR2e7CKHJuMqkGm7fcPzb6xRcvo8tEiCkr3QuOqw0nR2 5XCw== X-Gm-Message-State: AOJu0Yw8/Pc5ZRQbe5JZu1BPLqE1JG7MQJnjpr//hzH+IAoeA1whGsLj nGMSYny5xnB2RlsNUpvnjKyWRoseoujHDxTp X-Received: by 2002:a17:902:9b8e:b0:1c0:cbaf:6930 with SMTP id y14-20020a1709029b8e00b001c0cbaf6930mr11958854plp.54.1696288398399; Mon, 02 Oct 2023 16:13:18 -0700 (PDT) Received: from lvondent-mobl4.. (c-98-232-221-87.hsd1.or.comcast.net. [98.232.221.87]) by smtp.gmail.com with ESMTPSA id l11-20020a170902d34b00b001c75627545csm5181817plk.135.2023.10.02.16.13.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 16:13:17 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 4/6] device: Add btd_device_get_ltk Date: Mon, 2 Oct 2023 16:13:08 -0700 Message-ID: <20231002231311.3104749-4-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231002231311.3104749-1-luiz.dentz@gmail.com> References: <20231002231311.3104749-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 02 Oct 2023 16:13:22 -0700 (PDT) From: Luiz Augusto von Dentz This adds btd_device_get_ltk function which can be used by plugins to access the LTK key. --- src/device.c | 17 +++++++++++++++++ src/device.h | 2 ++ 2 files changed, 19 insertions(+) diff --git a/src/device.c b/src/device.c index 35ce1df0fe74..a734fff0dc73 100644 --- a/src/device.c +++ b/src/device.c @@ -1938,6 +1938,23 @@ void device_set_ltk(struct btd_device *device, const uint8_t val[16], queue_foreach(device->sirks, add_set, device); } +bool btd_device_get_ltk(struct btd_device *device, uint8_t key[16], + bool *central, uint8_t *enc_size) +{ + if (!device || !device->ltk || !key) + return false; + + memcpy(key, device->ltk->key, sizeof(device->ltk->key)); + + if (central) + *central = device->ltk->central; + + if (enc_size) + *enc_size = device->ltk->enc_size; + + return true; +} + static bool match_sirk(const void *data, const void *match_data) { const struct sirk_info *sirk = data; diff --git a/src/device.h b/src/device.h index 0a9e51533ca5..8bb38669d457 100644 --- a/src/device.h +++ b/src/device.h @@ -132,6 +132,8 @@ void device_request_disconnect(struct btd_device *device, DBusMessage *msg); bool device_is_disconnecting(struct btd_device *device); void device_set_ltk(struct btd_device *device, const uint8_t val[16], bool central, uint8_t enc_size); +bool btd_device_get_ltk(struct btd_device *device, uint8_t val[16], + bool *central, uint8_t *enc_size); bool btd_device_add_set(struct btd_device *device, bool encrypted, uint8_t sirk[16], uint8_t size, uint8_t rank); void device_store_svc_chng_ccc(struct btd_device *device, uint8_t bdaddr_type, -- 2.41.0