From patchwork Tue Sep 24 12:04:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13810860 Received: from mail-qk1-f180.google.com (mail-qk1-f180.google.com [209.85.222.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 91D9B19ADA6 for ; Tue, 24 Sep 2024 12:04:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727179499; cv=none; b=IdvShSHAhD70G7od3q3F4c2UPal6aOr0+lc1PTVfq8SwYCJUSkIrLs5dPw4OEW7svLiYXwutmWEk7IRGeJXiqTj/sVD4ZNbtC1hlEqQRz+mPvKo2tk3oksoIXByE15aB9eAWjhzF7aswMd5GYyJWorJHpGfAj2ZgRW7O2wzL38M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727179499; c=relaxed/simple; bh=z0yBTUKx5fKOKjGm23Ru/35W7KY5QasPJR4dWIGgFxY=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=Vap4DAy2Xdx6Uqd3yV3NDEPDodJHwXQ/S08b7dqrVYjAVHgcSmSu2Llq4ZQwLn0sERsRmRfmixIuxs72wKiPgm+Kk85frMwvivk3DjqArRgrwcRbCd4O+9Xn8C5QAO/sQokcu9lxZ+mXC9sj232kGSw+6TlE24hBO63+P7x1WdQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=iTGl9aj6; arc=none smtp.client-ip=209.85.222.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="iTGl9aj6" Received: by mail-qk1-f180.google.com with SMTP id af79cd13be357-7a9b3cd75e5so550091985a.0 for ; Tue, 24 Sep 2024 05:04:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727179496; x=1727784296; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=EJo5gxtRrPtF/Pc3AD1/CwaBVPj8+nPLub6e463m9g0=; b=iTGl9aj6W7830LR3yyNZtJd0rh6+vs8r4ZgtTzN/N6dMH/vSrMhQID1l3jI6gxg6+B n3Z1hHErLLC8tMKeTM5wUp5xe2i0ojzKv55YWCqzlp08X8bfFz+A6kVR+KZfa/Sp4St6 W6c1lUF7SGbhAiZgme6Qqy05QbyeGiX556h+WeBUux1eB7rwAkjioSkUUYucGN2rvjEm ZN9HaGlpXPQBOqr37A/GObc2pNNFs9Yhu5BqyZt7r7tLkCF89GG96kZCN7jrnvasKrD2 cMbRmvTPP7GhsOjdmg9uFIOG8hI1lPsWg9TM0dP/HoE30oAzWQBPf0s9ACK6jBXaNKmP SQVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727179496; x=1727784296; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=EJo5gxtRrPtF/Pc3AD1/CwaBVPj8+nPLub6e463m9g0=; b=jbqEBLuWwJp5XJtag5yqfdQ4EMMq4dUiiMhDCf4jHjhNMN/cwwQ65+hdh8HFqJ5lFI +jVk8LOOqal8AozbDgf5SH0hSHqaUcqc9blNPNQ+nYEsAgQU4Na3y/H6YHvotaAIIShs Sv7DaXQZ6WzL+vK6LsgdL59fGCjRBgTNf/yANpVOfnL/8Lu/mh25cPv/KyUqJzw6kYqi o7Q5Z0/vrxMqLTNepVVO3EW4IZZtGybw+YX1itDolZaPvLGvAiNDBjQMDMWGe9rJlpw0 A964dhwUvcBVx3OZ5iKMUrM63LwopcX3jaO7h0ljXZE0PHq5RX2nNsJSRip7nUJXr17V OGEA== X-Gm-Message-State: AOJu0YxrrvHiYvGLLXTOl4D6gQPV/3+VSTd7N7vtu6raV9UKsilXb/9N DvfTSFgU8yZBB8JQLXNDOMpc3x2rO7YOj5mY4Hd68UXxNLlyyo1T4xbctg== X-Google-Smtp-Source: AGHT+IGKQ++MqAz41sUWYfYi18S8QC01TFQ7sjKHit9tu5fPFfyJDGPeERHUY0PqjpXxt9Qc2YOxrA== X-Received: by 2002:a05:6214:3d9a:b0:6c5:bc97:3498 with SMTP id 6a1803df08f44-6c7bd5b7f0emr193729266d6.45.1727179496051; Tue, 24 Sep 2024 05:04:56 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6cb0f4a6178sm5948056d6.7.2024.09.24.05.04.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Sep 2024 05:04:55 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 01/16] ie: add IE_AKM_IS_PSK Date: Tue, 24 Sep 2024 05:04:32 -0700 Message-Id: <20240924120447.251761-1-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 --- src/ie.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/ie.h b/src/ie.h index 4498785a..28931a01 100644 --- a/src/ie.h +++ b/src/ie.h @@ -399,6 +399,15 @@ static inline bool IE_AKM_IS_8021X(uint32_t akm) IE_RSN_AKM_SUITE_FT_OVER_8021X_SHA384); } +static inline bool IE_AKM_IS_PSK(uint32_t akm) +{ + return akm & (IE_RSN_AKM_SUITE_PSK | + IE_RSN_AKM_SUITE_FT_USING_PSK | + IE_RSN_AKM_SUITE_PSK_SHA256 | + IE_RSN_AKM_SUITE_SAE_SHA256 | + IE_RSN_AKM_SUITE_FT_OVER_SAE_SHA256); +} + static inline bool IE_CIPHER_IS_GCMP_CCMP(uint32_t cipher_suite) { return cipher_suite & (IE_RSN_CIPHER_SUITE_CCMP | From patchwork Tue Sep 24 12:04:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13810861 Received: from mail-qv1-f42.google.com (mail-qv1-f42.google.com [209.85.219.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 99B5817C222 for ; Tue, 24 Sep 2024 12:04:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727179500; cv=none; b=EytG9Am46i159SRnX+LHdzd666+yNJYjQXZmGY5SfjlUZ/oue/2wZiKSla7vzyxmikWobr3OLxe4/CGQ6OMycFizgut9jIBwovTSWpujfcbWpKDSw/IvQqpr/x/lzH8LdFVaFl2buRr8gYmlkEeDvcFbu7ZrPCXpxxuLreI85fM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727179500; c=relaxed/simple; bh=xYVwNCGu2F8pJB3SCCjGcoZDkc/4z21P39Zn+tA65pA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dBfyYo6XnxSl92dt9eBUoEDTmcuWxBnWNaAGugEehXKVTei0Ut6FC0KNeqJ4nH52AMfehJeYbrdnu0U+hmR/2WArlQfwH0z7qjJhMo3hR6HN2d1zem3qLTUO28nPdVRg6LgdWNMefmLikWGzWMvPM/eJcnbX1OljEjahWdmIA+U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=UqdIWM+y; arc=none smtp.client-ip=209.85.219.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UqdIWM+y" Received: by mail-qv1-f42.google.com with SMTP id 6a1803df08f44-6c524b4a3aeso42031046d6.3 for ; Tue, 24 Sep 2024 05:04:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727179497; x=1727784297; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DyJ582zmnCoyqJDD5W8Z3S/udtnUYPlBYJ2opG1tsnM=; b=UqdIWM+yxlGyMPEo27UkbPzxINqsFvwMoCoqd6MnorDyJ9RNMkRYOvUK54XBcjYdo7 F4A4QWXKptRz+W87c+RSiTRKQtfmuZ+tyllf+L00c64q9m/L6W5f7Akuzqv6cGymO6kK TcIcQpR6FyJ/W8QGVKmHNIy7GEEkbYzcjx3W5X4cpbJu4DaSA+Wb//G85WJqLj3Be5q4 MeX3h5ebDXbKDcCQ3OvzOcjuSOs5GuohzAEShQ944FNnICakViapxX9L66cGMnue6RdI OdfyG6nB+Crc5pr7sDcFQePWjc//NTLFMxq44SSVHdu9HawMOgm2XjxGA7Qiyu8F9tFH 7xiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727179497; x=1727784297; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DyJ582zmnCoyqJDD5W8Z3S/udtnUYPlBYJ2opG1tsnM=; b=sOnI9veaHLtIKNlujzoAeupP3eE9YoWKpIVQtSOMkb/dbShpbAEcS8YErk3f3PwYsc Q5Tpoqok43EuJaX5A46J4LC1IOW4hVv5eSczAkX3ZU/npFdG30FOPqL0wu34JwfcDMh8 8u/8XjfXLGLbjob2o5wPwyiJqnz6DcQdiqxx4Yd1iwfdYb3Cgrr1IT5NTAzZ2PL6EccH MjYvlZ0lkUvQttEQAtEUHgNb3iiy9uDAoYY9A077YabacXNuJpkHa+9rwewSz9JP42vk J+lgbaXU0B7kUpO7pKdqz0vf7WU5eAjlWOXrLnPdeWGuacVmX4fEaXERmzRDaIO0akPZ 1asw== X-Gm-Message-State: AOJu0YzLUP4PPLktBpxY6E5rlLIs80lC3KG8C+H0HJeX/p2yN24LrXkn V/gA0vq4v9893yLuRFqVDXep0noPxQdO1g0IZqZ8TBYm/kgmLbpThV0g+Q== X-Google-Smtp-Source: AGHT+IEtgz0B2H1ExzQaztSd1xJ5wCwufM46sxv55X2d3H6xLry/RGvdddCj31Pqvi+1C5xsjSDROg== X-Received: by 2002:a05:6214:5b86:b0:6c5:7138:d515 with SMTP id 6a1803df08f44-6c7bd5b92ebmr227037476d6.46.1727179497320; Tue, 24 Sep 2024 05:04:57 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6cb0f4a6178sm5948056d6.7.2024.09.24.05.04.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Sep 2024 05:04:56 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 02/16] dpp-util: refactor dpp_configuration_new into a _psk helper Date: Tue, 24 Sep 2024 05:04:33 -0700 Message-Id: <20240924120447.251761-2-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240924120447.251761-1-prestwoj@gmail.com> References: <20240924120447.251761-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Prior to adding 802.1x configuration with DPP we need to isolate the configuration object creation into a PSK variant, as 802.1x options don't require the passphrase/psk fields. --- src/dpp-util.c | 41 ++++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/src/dpp-util.c b/src/dpp-util.c index cfdedbdd..2eacc587 100644 --- a/src/dpp-util.c +++ b/src/dpp-util.c @@ -315,17 +315,12 @@ char *dpp_configuration_to_json(struct dpp_configuration *config) config->hidden ? "true" : "false"); } -struct dpp_configuration *dpp_configuration_new( - const struct l_settings *settings, - const char *ssid, - enum ie_rsn_akm_suite akm_suite) +static struct dpp_configuration *dpp_configuration_new_psk( + const struct l_settings *settings) { struct dpp_configuration *config; _auto_(l_free) char *passphrase = NULL; _auto_(l_free) char *psk = NULL; - size_t ssid_len = strlen(ssid); - bool send_hostname; - bool hidden; if (!l_settings_has_group(settings, "Security")) return NULL; @@ -340,15 +335,39 @@ struct dpp_configuration *dpp_configuration_new( config = l_new(struct dpp_configuration, 1); - memcpy(config->ssid, ssid, ssid_len); - config->ssid[ssid_len] = '\0'; - config->ssid_len = ssid_len; - if (passphrase) config->passphrase = l_steal_ptr(passphrase); else config->psk = l_steal_ptr(psk); + return config; +} + +struct dpp_configuration *dpp_configuration_new( + const struct l_settings *settings, + const char *ssid, + enum ie_rsn_akm_suite akm_suite) +{ + struct dpp_configuration *config; + size_t ssid_len = strlen(ssid); + bool send_hostname; + bool hidden; + + if (IE_AKM_IS_PSK(akm_suite)) + config = dpp_configuration_new_psk(settings); + else { + l_warn("DPP not supported using AKM suite %x", akm_suite); + return NULL; + } + + if (!config) { + l_warn("Failed to parse profile settings for DPP"); + return NULL; + } + + memcpy(config->ssid, ssid, ssid_len); + config->ssid[ssid_len] = '\0'; + config->ssid_len = ssid_len; config->akm_suites = akm_suite; From patchwork Tue Sep 24 12:04:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13810862 Received: from mail-qv1-f52.google.com (mail-qv1-f52.google.com [209.85.219.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E046917BED2 for ; Tue, 24 Sep 2024 12:04:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727179501; cv=none; b=MN3uUDyZYR15i2h75cwyYP4O/vnV+Xoib9nhW0GAx60AlnRMxk9lFTNkFWD9EI9MnZnpSeoXeN9rfIWiU09OoXvyPR+d9gbAQBkvsWe2neIhovWtgPVA1Brq3iVuDB7jt2ENs2kPqGG75ONM/gD28cy7u3aibUG2MA3t462rAzg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727179501; c=relaxed/simple; bh=fEAgoRFuEY11L4SO9is/6401fCUwEpY0bkfZj+I2gac=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=IoQ68yCMDRNwYf36a7g1khhatIIFscpr4ZazeOJ53kR9cvEOpWHGfcqLeq8a5NMd7Rguy82j09RWBz4h3ffk0ML+Gdo7zkVuFgWkuuLGQIgcd+ecujrvD2RC/zl8RvLAuFIUqMVy7kcizhzs/0EfhaDV+LjAClsjPC4ozA3ycHw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=fmvU2uCI; arc=none smtp.client-ip=209.85.219.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fmvU2uCI" Received: by mail-qv1-f52.google.com with SMTP id 6a1803df08f44-6c351809a80so39390706d6.1 for ; Tue, 24 Sep 2024 05:04:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727179498; x=1727784298; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IC+H7P/jFNZABBiVNGUwQyX/JPQjFJ1pXzjY++KXT74=; b=fmvU2uCIJVXZmOiP2vyeQIOBBn5ExW5IDyKApnYXywgbQpvQEDDDczoIem7FvOpA+b gQoyo/KVqo9/8IkRDfxOA2hVhcJC+lvthiBVzBqw/HFFSgJGTJUpXvjvikwldUWpGso4 kJXD/Uev6o2o05DcdrIfmXTKblqSOJlb5u7vdxlY9xjb71xFB7fKtQfpg/GSfK7dhp1k GICYLY8y6GiTAh46bnlASMsevfd6DOfG8BbjiwXonoe62geeZdaS2HxYAY4Mr2YZDvaA lltYmb3Mvigv8alxZf7NeyAFqWjYrmjwaW3s1v0+jbKPDZBbHZT8xwGMcWAwUvwmacae 1a9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727179498; x=1727784298; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IC+H7P/jFNZABBiVNGUwQyX/JPQjFJ1pXzjY++KXT74=; b=dDFfHYIKqeCRIXxoShFPJA7BkkwQbWAs1t4htci+r68Zr0H6waOTFNCH8RWgsZpzcd GMKjFj57RAcy62su94/tDfKbyP4fEt+ivmI04B9dWhGwQDxej31CUoq9ZbIVfjoQcAFH Wf3vFJrYW2G1tUCTQh5cHBHU8zQdaFVqOWorhYg4RzvDc3vOuN+Tc0GqhBSkvRX0Z9S5 V6jCFyzN570eV/A7t2iI2LfmcoKXsodcb2VZ7IL6mMNoMPT0ROaIaSi23fpA2JjBbZQh krg2RoyTQV1Euw5djBVU1Y7QUSEQiYxMxsA9bOVWjvQYHQsP88G8R8wVSOtSyG4azZSW ErbQ== X-Gm-Message-State: AOJu0Yz++S7/2yw07YSmWOoaMO6wTPjIUjuUYhgMRgVv+kdezDe1QWdy 1fZgvYDu96BGQwgnW8QEOHkMVau+HS9EIBv9GBTZqSsggL/H7KufYdLqgg== X-Google-Smtp-Source: AGHT+IEqsEa0EkbmOPQqgkuzMWVayhPVbnAnjBW72gevOu08dKKXZ5Y3cEcfhYEk36jy/Zp1GDw6nQ== X-Received: by 2002:a05:6214:5982:b0:6c5:ab33:6300 with SMTP id 6a1803df08f44-6c7bd4cf296mr218743166d6.6.1727179498561; Tue, 24 Sep 2024 05:04:58 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6cb0f4a6178sm5948056d6.7.2024.09.24.05.04.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Sep 2024 05:04:58 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 03/16] dpp: fix some return/cleanup issues for error cases Date: Tue, 24 Sep 2024 05:04:34 -0700 Message-Id: <20240924120447.251761-3-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240924120447.251761-1-prestwoj@gmail.com> References: <20240924120447.251761-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 There were several error paths which did not reset the dpp_sm and would then result in the state showing incorrectly as some values would have remained initialized. --- src/dpp.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/dpp.c b/src/dpp.c index 03e2a7a6..32160d96 100644 --- a/src/dpp.c +++ b/src/dpp.c @@ -4169,11 +4169,15 @@ static struct l_dbus_message *dpp_start_configurator_common( dpp->state = DPP_STATE_PRESENCE; if (!responder) { - if (!l_dbus_message_get_arguments(message, "s", &uri)) - return dbus_error_invalid_args(message); + if (!l_dbus_message_get_arguments(message, "s", &uri)) { + reply = dbus_error_invalid_args(message); + goto error; + } - if (!dpp_configurator_start_presence(dpp, uri)) - return dbus_error_invalid_args(message); + if (!dpp_configurator_start_presence(dpp, uri)) { + reply = dbus_error_invalid_args(message); + goto error; + } /* Since we have the peer's URI generate the keys now */ l_getrandom(dpp->i_nonce, dpp->nonce_len); @@ -4196,6 +4200,10 @@ static struct l_dbus_message *dpp_start_configurator_common( dpp->config = dpp_configuration_new(settings, network_get_ssid(network), hs->akm_suite); + if (!dpp->config) { + reply = dbus_error_not_supported(message); + goto error; + } dpp_property_changed_notify(dpp); @@ -4209,6 +4217,10 @@ static struct l_dbus_message *dpp_start_configurator_common( l_dbus_message_set_arguments(reply, "s", dpp->uri); return reply; + +error: + dpp_reset(dpp); + return reply; } static struct l_dbus_message *dpp_dbus_start_configurator(struct l_dbus *dbus, @@ -4613,6 +4625,10 @@ static struct l_dbus_message *dpp_start_pkex_configurator(struct dpp_sm *dpp, dpp->config = dpp_configuration_new(network_get_settings(network), network_get_ssid(network), hs->akm_suite); + if (!dpp->config) { + dpp_reset(dpp); + return dbus_error_not_supported(message); + } dpp_reset_protocol_timer(dpp, DPP_PKEX_PROTO_TIMEOUT); dpp_property_changed_notify(dpp); From patchwork Tue Sep 24 12:04:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13810863 Received: from mail-qv1-f50.google.com (mail-qv1-f50.google.com [209.85.219.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5133F1A4F36 for ; Tue, 24 Sep 2024 12:05:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727179502; cv=none; b=jyQxsYqWHXgpbNgvMGCq9NxT9Re4CWsg9tVmFSo6rUFcNnXbFbQ4xJjA4oEsq+7LJkrVY93Mu7FggjGts4EXvZzPM9u7wLaPKD4QjhTnNJX8eIA57ekCzOZbfnd92pz3rhm4IO0jt426CzUOIQNbyJn8f6U0ZA65YnLwQgb8rnY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727179502; c=relaxed/simple; bh=LDd79XMLHxHMjjAgWLgMmmTGJdXUeRwnMuA1y91yiCc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=g7IOb/jkNfTcBmQf/I2GIXQIS+RV4pdH0g5ODVwUCsX57x96Y7Wa3AdCeDSKbLGu7AaRSOr76U5Gg4oh+R93UUSA3GN0RviFw1L65W+D40ctD7POB3wcOfJIlmNna82fCiFv9nLP0ddXHSytEuhFbQEUUB7Bvd1oCABnxiTJxBo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=gdCHU7I7; arc=none smtp.client-ip=209.85.219.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gdCHU7I7" Received: by mail-qv1-f50.google.com with SMTP id 6a1803df08f44-6c7b57e2b17so40234896d6.3 for ; Tue, 24 Sep 2024 05:05:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727179500; x=1727784300; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1E3YxwmgXCvRIyIfTR9wGMSLDzPBeoSS+JUO6w1cIuE=; b=gdCHU7I70tgArZhhTdjIE1FZG7FYWoQkrgb5OdBaOtfsVWjdHjXDYawlr6VM+iH13H 7xn3ZGc0m1wlvAaE5D3gLJ7V1whWwj5iiukTX8QV/jxAd42hD6q/7ZcyadUZgGgDi6wE +4S8gA5fQ+LoiehHSkewhnDlQvFlDbLG/Fy78dMr32QqYT2QRjyJ0VQ7CjH2NBiNW86o 2N5AyS83PCWL1D/5ON2wq1koD14wGxXxbJ2+AGjb27VlGrCYBeJmCNK+mgESch+RUUED KvTXuwNj41EKLCsmCChQl2t3uMrYnyj+j1NlGx5MEkohT5ZasD72HD2UCG3Una+rY5n/ nBwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727179500; x=1727784300; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1E3YxwmgXCvRIyIfTR9wGMSLDzPBeoSS+JUO6w1cIuE=; b=Fuj1x4mSyuCdKeGbX3txdT2xRll/q4kcKhpaF5EhXjtT6ydOXMPqaOBHDQSqXzBBSz Jw/FowVmH++fVoLUydSAwBGj1yjyMHcempFcyw7o53YLMkiqkrdqkgzQcM9daQNglSdA RJVo7kAL5i1n4Qgi0EwJofReV1ZPbdf3LPSH9PdxMsJscWgptb9z68UW016zjjCPqNI3 mlWvVtfM7f6L786xh/TFQgnOh8KsPLvSOwD8PnG7xeYYgfNLBHDefRBNypgBeW7O1+hp xnwpfy8/g7jYq+vE7EpkzTbt+/PKYQ1VZ1Ildj/5JqEvXfzqEPTlHOCczBdUSmOr8eOF oaEQ== X-Gm-Message-State: AOJu0Yykvcjq5SHYsoy4cyGGnLgnMPyFE8nJM4sXbk2pyyWK/sANPVEu 9U2iqf2JJo2m4TvHIEaVrRYaN7nd9XWt32tpkWwmEwV2hSqAfmxKv6TYgQ== X-Google-Smtp-Source: AGHT+IFwdt4K+Ge2/H4QgA8jliZ0Lk0V4KFez1Ldc6fWxZE3GoOSBKTToAuqqx2+1L/VEsr3VfsUaQ== X-Received: by 2002:ad4:52c4:0:b0:6c7:c5bf:5b0d with SMTP id 6a1803df08f44-6c7c5bf5b4dmr160607536d6.38.1727179499839; Tue, 24 Sep 2024 05:04:59 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6cb0f4a6178sm5948056d6.7.2024.09.24.05.04.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Sep 2024 05:04:59 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 04/16] dpp-util: refactor dpp_configuration_to_json for only PSK networks Date: Tue, 24 Sep 2024 05:04:35 -0700 Message-Id: <20240924120447.251761-4-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240924120447.251761-1-prestwoj@gmail.com> References: <20240924120447.251761-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This renames dpp_configuration_to_json to dpp_psk_config_to_json to prepare for adding 802.1x provisioning. The 802.1x variant will need to take additional arguments, so we'll need to isolate the PSK logic into its own API. --- src/dpp-util.c | 27 +++++++++++++++++---------- src/dpp-util.h | 2 +- src/dpp.c | 2 +- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/dpp-util.c b/src/dpp-util.c index 2eacc587..62db2081 100644 --- a/src/dpp-util.c +++ b/src/dpp-util.c @@ -282,22 +282,15 @@ static const char *dpp_akm_to_string(enum ie_rsn_akm_suite akm_suite) } } -char *dpp_configuration_to_json(struct dpp_configuration *config) +static char *dpp_configuration_to_json(struct dpp_configuration *config, + const char *creds) { - _auto_(l_free) char *pass_or_psk; _auto_(l_free) char *ssid; ssid = l_malloc(config->ssid_len + 1); memcpy(ssid, config->ssid, config->ssid_len); ssid[config->ssid_len] = '\0'; - if (config->passphrase) - pass_or_psk = l_strdup_printf("\"pass\":\"%s\"", - config->passphrase); - else - pass_or_psk = l_strdup_printf("\"psk\":\"%s\"", - config->psk); - return l_strdup_printf("{\"wi-fi_tech\":\"infra\"," "\"discovery\":{" "\"ssid\":\"%s\"" @@ -310,11 +303,25 @@ char *dpp_configuration_to_json(struct dpp_configuration *config) "\"hidden\":%s}" "}", ssid, dpp_akm_to_string(config->akm_suites), - pass_or_psk, + creds, config->send_hostname ? "true" : "false", config->hidden ? "true" : "false"); } +char *dpp_psk_config_to_json(struct dpp_configuration *config) +{ + _auto_(l_free) char *pass_or_psk; + + if (config->passphrase) + pass_or_psk = l_strdup_printf("\"pass\":\"%s\"", + config->passphrase); + else + pass_or_psk = l_strdup_printf("\"psk\":\"%s\"", + config->psk); + + return dpp_configuration_to_json(config, pass_or_psk); +} + static struct dpp_configuration *dpp_configuration_new_psk( const struct l_settings *settings) { diff --git a/src/dpp-util.h b/src/dpp-util.h index 86ef36f9..f7d7122c 100644 --- a/src/dpp-util.h +++ b/src/dpp-util.h @@ -132,7 +132,7 @@ struct dpp_configuration *dpp_configuration_new( const struct l_settings *settings, const char *ssid, enum ie_rsn_akm_suite akm_suite); -char *dpp_configuration_to_json(struct dpp_configuration *config); +char *dpp_psk_config_to_json(struct dpp_configuration *config); void dpp_configuration_free(struct dpp_configuration *conf); struct dpp_attr_iter { diff --git a/src/dpp.c b/src/dpp.c index 32160d96..41e56197 100644 --- a/src/dpp.c +++ b/src/dpp.c @@ -1212,7 +1212,7 @@ static void dpp_send_config_response(struct dpp_sm *dpp, uint8_t status) * STATUS_CONFIGURE_FAILURE which only includes the E-Nonce. */ if (status == DPP_STATUS_OK) { - json = dpp_configuration_to_json(dpp->config); + json = dpp_psk_config_to_json(dpp->config); json_len = strlen(json); ptr += dpp_append_wrapped_data(attrs + 2, ptr - attrs - 2, From patchwork Tue Sep 24 12:04:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13810864 Received: from mail-qv1-f45.google.com (mail-qv1-f45.google.com [209.85.219.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A26C317BED2 for ; Tue, 24 Sep 2024 12:05:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727179504; cv=none; b=GW7Ad55j9nl/6ZlWTDGnz5PoZdj4JY0SvILXrdmbSLhStjAuBO1n3R8twci4g2HGdxY3h5K2r0UbNS5JgoaR2+59TjSH1s82X3doyFI8D+I2T2jM2QKustKnmPkw1IyhNNglATbKc5HGDm6pmCgo7X+5xGCL/pireHx0NC8yTYM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727179504; c=relaxed/simple; bh=n5TzOevuzyu4chNUnnvBVYsHz9V+iImR+WMOprPRZmQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=n4CiugqTimLg6rkVT7mUq4FDHsQs5BmrWUfffhC5BWCSn7go/mm1yDiMJ8M8jfreOJQmkqxqFwwSIo3/HubuB+G1v7g1euqyhIcmaGl+07x9G+HCXplbwX2XVFLElJrQScleaomFQMKSBOu5nVSkWSXbCnty6z7OQCdx6twKErc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=eBCfPcbG; arc=none smtp.client-ip=209.85.219.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eBCfPcbG" Received: by mail-qv1-f45.google.com with SMTP id 6a1803df08f44-6c353f2f954so41903136d6.3 for ; Tue, 24 Sep 2024 05:05:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727179501; x=1727784301; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LP4OsRCnhcCR79gzwA2W1zQiq7C514LA0zuV1FZxDeQ=; b=eBCfPcbGIqbwXDc7zX+m7aGSCRQSu04Dx3SWVUtwz1p0xs2q+88Uejr4c/5COk8SWI XNxjyNaSdO0H3HNonsOmOnOeF4qYPwhdn0l8n0owP9okuoh0Its6O7qu3wo5pgl0POsP FDTYsDEpX6kZcCpOm885XpcF3cSRCub1h4kFozq/tQv4sazNelu+iVYOt8GgEnDjHHjm gt27Urt+Q/LLkYLZVvOIB52PcifwIHN4+7M+zo1FQEK0AnrxV98sbeVx3QbRI80fZS3I tSxOZipQ7TNHf0OhCNPBh9whwt/s8hD3+ON+0NdVUMHXNzo0zH+7r18lzeAaTUGIaFLZ wwig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727179501; x=1727784301; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LP4OsRCnhcCR79gzwA2W1zQiq7C514LA0zuV1FZxDeQ=; b=hNQzHRyJKVJYDhrI2vNffwpASKQ3Lt2G7gSATN3UsRhbYSLb5ILxJKD31MVOFWTLXL VnLICPMkGLrr0k7kwfeHPz8qdmD2DnnC/F4GVU6KofoMsZmViTSYYwLkXXJpnvuf+F1f 20QaFtd6hgpQW9fq/vIyVppm4PR29Hp5JemPzzumI/N0KoPTpLFTyj7RAeEUdAQBDUSV obvJEuH61LCybn5WvxJSdQTYNKiR7eqIyOqlPG5YG+ASBZTvgMBuhdKM0JsX9oXLPb20 R2FFVqQmUWVTlB3pNRcAzsEYsuvbAFUPT5sNoBTMxGAFj4qTF+N/ZpMa33WbrZQ7X2j4 750Q== X-Gm-Message-State: AOJu0YxEZRE7vLFJ1JCwFZCkqnq1kssFCFfbxLseW+o2T/ahTPIFtYax tVQ3DelrQOVasMExZ8BcHEq3V0Yi+0dCcHH8ppJnT4HZjhERUCKllxIN8Q== X-Google-Smtp-Source: AGHT+IE6ktU440ELzflVi84VLhz9I+9oZ3iHwDUgecIzXu9y+h7oSVrt7OJN2NbcRwM5f768S9nTdg== X-Received: by 2002:a05:6214:5684:b0:6c3:53d4:8554 with SMTP id 6a1803df08f44-6c7bd6024d6mr193295386d6.48.1727179501153; Tue, 24 Sep 2024 05:05:01 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6cb0f4a6178sm5948056d6.7.2024.09.24.05.05.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Sep 2024 05:05:00 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 05/16] dpp: refactor dpp_send_config_response to take JSON as a parameter Date: Tue, 24 Sep 2024 05:04:36 -0700 Message-Id: <20240924120447.251761-5-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240924120447.251761-1-prestwoj@gmail.com> References: <20240924120447.251761-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The future 802.1x config is too complicated for this to handle internally so it will now be passed in as an argument. --- src/dpp.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/dpp.c b/src/dpp.c index 41e56197..19d10daa 100644 --- a/src/dpp.c +++ b/src/dpp.c @@ -1163,13 +1163,13 @@ static void dpp_handle_config_response_frame(const struct mmpdu_header *frame, dpp_reset(dpp); } -static void dpp_send_config_response(struct dpp_sm *dpp, uint8_t status) +static void dpp_send_config_response(struct dpp_sm *dpp, uint8_t status, + const char *json) { - _auto_(l_free) char *json = NULL; struct iovec iov[3]; uint8_t hdr[41]; - uint8_t attrs[512]; - size_t json_len; + size_t json_len = json ? strlen(json) : 0; + uint8_t attrs[256 + json_len]; uint8_t *ptr = hdr + 24; memset(hdr, 0, sizeof(hdr)); @@ -1211,10 +1211,7 @@ static void dpp_send_config_response(struct dpp_sm *dpp, uint8_t status) * included. For now IWD's basic DPP implementation will assume * STATUS_CONFIGURE_FAILURE which only includes the E-Nonce. */ - if (status == DPP_STATUS_OK) { - json = dpp_psk_config_to_json(dpp->config); - json_len = strlen(json); - + if (status == DPP_STATUS_OK) ptr += dpp_append_wrapped_data(attrs + 2, ptr - attrs - 2, NULL, 0, ptr, sizeof(attrs), dpp->ke, dpp->key_len, 2, @@ -1222,7 +1219,7 @@ static void dpp_send_config_response(struct dpp_sm *dpp, uint8_t status) dpp->nonce_len, dpp->e_nonce, DPP_ATTR_CONFIGURATION_OBJECT, json_len, json); - } else + else ptr += dpp_append_wrapped_data(attrs + 2, ptr - attrs - 2, NULL, 0, ptr, sizeof(attrs), dpp->ke, dpp->key_len, 2, @@ -1272,6 +1269,7 @@ static void dpp_handle_config_request_frame(const struct mmpdu_header *frame, struct json_iter jsiter; _auto_(l_free) char *tech = NULL; _auto_(l_free) char *role = NULL; + _auto_(l_free) char *config_object = NULL; if (dpp->state != DPP_STATE_AUTHENTICATING) { l_debug("Configuration request in wrong state"); @@ -1398,12 +1396,13 @@ static void dpp_handle_config_request_frame(const struct mmpdu_header *frame, dpp->state = DPP_STATE_CONFIGURING; - dpp_send_config_response(dpp, DPP_STATUS_OK); + config_object = dpp_psk_config_to_json(dpp->config); + dpp_send_config_response(dpp, DPP_STATUS_OK, config_object); return; configure_failure: - dpp_send_config_response(dpp, DPP_STATUS_CONFIGURE_FAILURE); + dpp_send_config_response(dpp, DPP_STATUS_CONFIGURE_FAILURE, NULL); /* * The other peer is still authenticated, and can potentially send * additional requests so keep this session alive. From patchwork Tue Sep 24 12:04:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13810865 Received: from mail-qv1-f44.google.com (mail-qv1-f44.google.com [209.85.219.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BCA3019F461 for ; Tue, 24 Sep 2024 12:05:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727179505; cv=none; b=RH/4YT7PJwb1XZgbgkiSNn5aye/HXx7Q134BCoNMAxZz3kHkhUwSSCXoJu2tJC2cL+pyxssfuaDrKPlhLzFHDgy2zvhPvMgyrvApg/KIBWZlhjMhM2yL0FsJcPxgI0dj0Mj3PIPWFaP/DBJcUJRECX0plIh4gwxVNQieQgTCMjY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727179505; c=relaxed/simple; bh=h97Z8ReCU+xd+KNDmeZpqXLVq0EMJ7zDMWEMSX7xcCo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rOQUoqLibUIL1B9V9CMynNDEDMnzFOmU0m6+UI9JZ36feAeIGkDBzx1Te9xmHL8GuPpPVACQ4NWiWy8Liiv1b3t5sAjV7wdiDynnQetImPHIaao/7WiO7gZ+NRw+hTJ3mr8rfTe+zxqWhWHpsRZykLDYmqQkyPSoJt7BrY7OSwY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=E8W8AewK; arc=none smtp.client-ip=209.85.219.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="E8W8AewK" Received: by mail-qv1-f44.google.com with SMTP id 6a1803df08f44-6c524b4a3aeso42031676d6.3 for ; Tue, 24 Sep 2024 05:05:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727179502; x=1727784302; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zDdOGuVfdua5B6mt395zYJs4zH5s9MfP1lE9KgT4DwE=; b=E8W8AewKVoVFJZSW0pd6hWoR2W8UtRGm7u34bBBB27nwLiA1rsxS+OXhh/1+lYLdwV iWLhuacay+mhiiETj9KkyOcW6zRqNaxwRfHFINopUakj2P25KDzqRoywmuv2a0W7aRXr qucdtiA/ghTYKSb66x1sM256bOuZDJxd+MFqkjDAMi0AaxRimx047mXtLMG1s/Dnl0td UvMI79wHOrCC45JZIDz3iPLDOWSq9sOmbsFpWKcWoYCF9OGAG2VUV9vb7e9bV+F35oKK zYGZEhSVesrXB4zpw6xsJXn27Qrb0OROK21zyZYavMSGUg7fs9wxAUtHtU6mukXcRDMt eSfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727179502; x=1727784302; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zDdOGuVfdua5B6mt395zYJs4zH5s9MfP1lE9KgT4DwE=; b=eewMfQKh2F6EZw3x35NGjAB24HLc4mYruZinoMFLNEYt0XWqEu2UJRlHaafIyrZJmZ 89hBbSVAy4L1HgPXzHFKX8fAfEJoxopLde9dcb/z6IE+qt1f/Zv80nH/DiZQUDKErIw9 noy8JF4YV3B3reZ+9as9DVc3jKC6sEdNlNx0hlQkSc73Ysz7R4WAPNzYAU98yl7YMFF/ jM6NidMYUtXjUgsmvww90o+gki8KM/VglCDjxiVOjp9Tx4vF4FFEbeJIJcXTJk1/+1vR 5GD6Rd1sACQdf8Bh+BnSF26v5lVyKVUFAH7Md8ufmMoah/AOwNZIUN5baStDB4145PYS Jz/A== X-Gm-Message-State: AOJu0YycPKuW0jcGHt5xGlcaRIVJWx8Mwte3p2gvMwjhknkGjLIBt1+h 1Rq2wHtPR5zFjwdyBPdTJmu5GoCdR1Iwf8InUdEw+c+xXe0UPpo8jxzQLQ== X-Google-Smtp-Source: AGHT+IHjE8QSig3lCZHN4L/LddEHuGVWGJ4p6o9OHDJmEksByRaCiB2WqK7tzCRuD/4V58KOVQKn+g== X-Received: by 2002:a05:6214:4598:b0:6c5:64b2:71c3 with SMTP id 6a1803df08f44-6c7bd51b60dmr191784566d6.25.1727179502431; Tue, 24 Sep 2024 05:05:02 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6cb0f4a6178sm5948056d6.7.2024.09.24.05.05.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Sep 2024 05:05:02 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 06/16] dpp: refactor dpp_configuration_start to take the JSON as a parameter Date: Tue, 24 Sep 2024 05:04:37 -0700 Message-Id: <20240924120447.251761-6-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240924120447.251761-1-prestwoj@gmail.com> References: <20240924120447.251761-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The configuration request for PSK networks is simple and static. This is now defined as a static string and passed to dpp_configuration_start. For future 802.1x networks the configuration request object is more complex (contains a CSR). --- src/dpp.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/dpp.c b/src/dpp.c index 19d10daa..16d0a711 100644 --- a/src/dpp.c +++ b/src/dpp.c @@ -60,6 +60,17 @@ #define DPP_AUTH_PROTO_TIMEOUT 10 #define DPP_PKEX_PROTO_TIMEOUT 120 #define DPP_PKEX_PROTO_PER_FREQ_TIMEOUT 10 +/* + * The default JSON configuration object sent initially. For PSK networks this + * is sufficient, but for 802.1x the enrollee will be asked to send another + * request containing a CSR + */ +#define DPP_CONFIG_REQUEST_DEFAULT_VALUES \ + "\"name\":\"IWD\"," \ + "\"wi-fi_tech\":\"infra\"," \ + "\"netRole\":\"sta\"" +#define DPP_CONFIG_REQUEST_DEFAULT_OBJECT \ + "{" DPP_CONFIG_REQUEST_DEFAULT_VALUES "}" static uint32_t netdev_watch; static struct l_genl_family *nl80211; @@ -753,14 +764,13 @@ static void dpp_reset_protocol_timer(struct dpp_sm *dpp, uint32_t time) * does effect the resulting encryption/decryption so this is also what IWD * will do to remain compliant with it. */ -static void dpp_configuration_start(struct dpp_sm *dpp, const uint8_t *addr) +static void dpp_configuration_start(struct dpp_sm *dpp, const uint8_t *addr, + const char *json) { - const char *json = "{\"name\":\"IWD\",\"wi-fi_tech\":\"infra\"," - "\"netRole\":\"sta\"}"; struct iovec iov[3]; uint8_t hdr[37]; - uint8_t attrs[512]; size_t json_len = strlen(json); + uint8_t attrs[256 + json_len]; uint8_t *ptr = attrs; l_getrandom(&dpp->diag_token, 1); @@ -1689,7 +1699,8 @@ static void authenticate_confirm(struct dpp_sm *dpp, const uint8_t *from, dpp_reset_protocol_timer(dpp, DPP_AUTH_PROTO_TIMEOUT); if (dpp->role == DPP_CAPABILITY_ENROLLEE) - dpp_configuration_start(dpp, from); + dpp_configuration_start(dpp, from, + DPP_CONFIG_REQUEST_DEFAULT_OBJECT); return; @@ -2490,7 +2501,8 @@ static void authenticate_response(struct dpp_sm *dpp, const uint8_t *from, dpp_send_authenticate_confirm(dpp); if (dpp->role == DPP_CAPABILITY_ENROLLEE) - dpp_configuration_start(dpp, from); + dpp_configuration_start(dpp, from, + DPP_CONFIG_REQUEST_DEFAULT_OBJECT); } From patchwork Tue Sep 24 12:04:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13810866 Received: from mail-qv1-f43.google.com (mail-qv1-f43.google.com [209.85.219.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 919CD1A7070 for ; Tue, 24 Sep 2024 12:05:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727179507; cv=none; b=D1HB2DftCMuA+DiB1dH0rPagHbPKNW8LWJxVr35D9YtXsKn2QexMu51Iaante53NkzDwdxnJMUMJsTGs9eZ+ASL9BTA29SO/+eTji/L+PsXweyN7yeMWN+IXN9KW9004Yl15Y9iMLtwduFUzjiA4Jj2tAeAcEbjjlPH6RhJaAmU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727179507; c=relaxed/simple; bh=iUtGnNKS63XYfg0fZ60XqNv1LJGS5KM6yz1RxGdgZ00=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WiFmbinqPUYImHrI35vLVvDV+mWQ66bOpolHBiaZcnJu/3tTnylfJdr1/Mlc9NWy7y4nAn6uADkikDruQ0zFXHz/7cqsrG4sLSCOcSaSNNcsxfxVF5L5mtjvOS6nKBUXo+jCaWhYbT8/OjR+1tR0lYUcjZjCKRgi58MtPCS/qvI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=fNnBf+eu; arc=none smtp.client-ip=209.85.219.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fNnBf+eu" Received: by mail-qv1-f43.google.com with SMTP id 6a1803df08f44-6c579748bf4so51763046d6.1 for ; Tue, 24 Sep 2024 05:05:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727179504; x=1727784304; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=L7J33SePf1FjwXDV3HEwxL7tGP9jtud0nYWTRHN10jk=; b=fNnBf+euOBUo+q/uPNYU6m2AprYmIU6THOnkhYdoobbwMxFkAjirLbrv3L2xajJ6be qRmNS3W3VVef50Wpp32HKbaPI9j5UJarvF1S3jWnB8QCez5mrgL+7G65G/bg+EeeTC9F nbEhYemylk7Hx9PhmGSn1tu1XKMdMrAn4alkcz/5/d3rY1n6kXePD3z4dYLMZ1CifxnL h1fUA6VcR9UFOYLNmTjKNBfT0wuxmzlqSwZVxJl7JlVi3VSrf1Y9xRK1H/QEDll5SYQg vdGIZv48qQS7nmbu+Z+aTtHPvP+FnN2qoa9QvmRozMiZJoym0QpSffzq+CJbmgzI3Rds GmPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727179504; x=1727784304; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=L7J33SePf1FjwXDV3HEwxL7tGP9jtud0nYWTRHN10jk=; b=VUe8bkR+4XcxmHW6mv2H4J46sLqJ8x0oT1k85LJJ8vt5x9UWJJfKQqx9nZMyWNfndX IzWOfXHk1sQz7vfOY8O0D7RlsP8qPQA3GSz/dRDrMPT5CURot3GgxXNpHO1TOAIBseJo DnCPJVunFBE7+oOADWZQPW5W61TsfhQXjJhBU3GbEX/OqcpRq4RxyyFgsP61OOmsM2Hf 3Nk9vup6Esw88JcoW81ZASKsSyTmWajR6fGppQrnRHAgvmXk6Q83TNSxCMmvmteSXkRd HPXU5RUhW2JedFIVFEa8gI2w3JsOSBv2Pdf1bJHgvYxHlbQn/tQGT6joIHEQc44LaWtc PYUA== X-Gm-Message-State: AOJu0Yzu1+z90w2f6vNitQgS8Fy6NelaKoyUSmxR86RJTfmLQQ/KoeaN xbDt+czRiq04JG91Ifx1V7uBC+FjcCZKQSJy4Kq4qidaT0rtzQ5xdLFoNg== X-Google-Smtp-Source: AGHT+IFktp0np/oagE3nZQdmuCm/DwNPDu8EJtKHhouuK+zU/quTAA0wCUU7o0bg3LF3BhObTUMZTg== X-Received: by 2002:a05:6214:498d:b0:6c5:55bc:2705 with SMTP id 6a1803df08f44-6c7bc67b631mr248413336d6.6.1727179503869; Tue, 24 Sep 2024 05:05:03 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6cb0f4a6178sm5948056d6.7.2024.09.24.05.05.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Sep 2024 05:05:03 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 07/16] dpp: refactor config writing, add checks for PSK Date: Tue, 24 Sep 2024 05:04:38 -0700 Message-Id: <20240924120447.251761-7-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240924120447.251761-1-prestwoj@gmail.com> References: <20240924120447.251761-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 When writing the config object ensure the network security of the scanned network is PSK, and matches the config object recieved. --- src/dpp.c | 60 ++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 48 insertions(+), 12 deletions(-) diff --git a/src/dpp.c b/src/dpp.c index 16d0a711..3ad60188 100644 --- a/src/dpp.c +++ b/src/dpp.c @@ -832,25 +832,57 @@ static void send_config_result(struct dpp_sm *dpp, const uint8_t *to) dpp_send_frame(dpp, iov, 2, dpp->current_freq); } -static void dpp_write_config(struct dpp_configuration *config, +static void dpp_write_psk_config(struct dpp_configuration *config, + struct l_settings *settings) +{ + if (config->passphrase) + l_settings_set_string(settings, "Security", "Passphrase", + config->passphrase); + else if (config->psk) + l_settings_set_string(settings, "Security", "PreSharedKey", + config->psk); +} + +static bool dpp_write_config(struct dpp_configuration *config, struct network *network) { _auto_(l_settings_free) struct l_settings *settings = l_settings_new(); - _auto_(l_free) char *path; + _auto_(l_free) char *path = NULL; + enum security security; + + if (!network) { + l_warn("Network not seen in results, can't validate security"); + + if (IE_AKM_IS_PSK(config->akm_suites)) + security = SECURITY_PSK; + else + return false; + + goto write_config; + } else + security = network_get_security(network); - path = storage_get_network_file_path(SECURITY_PSK, config->ssid); + if (security == SECURITY_PSK) { + if (!IE_AKM_IS_PSK(config->akm_suites)) { + l_warn("Network is PSK but DPP config is not!"); + return false; + } + } else { + l_warn("Unsupported network security %s", + security_to_str(security)); + return false; + } + +write_config: + path = storage_get_network_file_path(security, config->ssid); if (l_settings_load_from_file(settings, path)) { /* Remove any existing Security keys */ l_settings_remove_group(settings, "Security"); } - if (config->passphrase) - l_settings_set_string(settings, "Security", "Passphrase", - config->passphrase); - else if (config->psk) - l_settings_set_string(settings, "Security", "PreSharedKey", - config->psk); + if (security == SECURITY_PSK) + dpp_write_psk_config(config, settings); if (config->send_hostname) l_settings_set_bool(settings, "IPv4", "SendHostname", true); @@ -859,8 +891,10 @@ static void dpp_write_config(struct dpp_configuration *config, l_settings_set_bool(settings, "Settings", "Hidden", true); l_debug("Storing credential for '%s(%s)'", config->ssid, - security_to_str(SECURITY_PSK)); - storage_network_sync(SECURITY_PSK, config->ssid, settings); + security_to_str(security)); + storage_network_sync(security, config->ssid, settings); + + return true; } static void dpp_scan_triggered(int err, void *user_data) @@ -1141,7 +1175,8 @@ static void dpp_handle_config_response_frame(const struct mmpdu_header *frame, bss = network_bss_select(network, true); } - dpp_write_config(config, network); + if (!dpp_write_config(config, network)) + goto free_config; send_config_result(dpp, dpp->peer_addr); @@ -1169,6 +1204,7 @@ static void dpp_handle_config_response_frame(const struct mmpdu_header *frame, } } +free_config: dpp_configuration_free(config); dpp_reset(dpp); } From patchwork Tue Sep 24 12:04:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13810867 Received: from mail-qv1-f43.google.com (mail-qv1-f43.google.com [209.85.219.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 03B5419F461 for ; Tue, 24 Sep 2024 12:05:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727179508; cv=none; b=DhAiery0S0ycEl7g9yeLD1Qw7NUJpHKhy5arZoiuQLMEAOBjVHfVYCRB7ixypROZp6oN84X1Zn5VE9FA29zKBLB7A1hKgKpXnmOVuOu66d1BaIPLk1vNYWMLThptNS8dKdfDiGbeDguu+MHY8wApGJC2mqpcPsO3WJJuvhXI5eo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727179508; c=relaxed/simple; bh=G+L82sQPPxrEqHgqh5jXmNuPooVV+zU+PCd3EsCfQdA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=IKTISB/SmPAelCdIVgaU3hi8S5SxU8NFkm4hXmzHhn0/U16tACQmWM6J96VJmajA7yxKlFjc2s0hNUFTixJibh4tpInA2v3bSeQ05XIGQQty+IdsxXgt85G1GS0P5v853BNFQEX/IkghyDfa/424Tw0xRfXnsTUlAMjqSZ41tZw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=S3e28qnw; arc=none smtp.client-ip=209.85.219.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="S3e28qnw" Received: by mail-qv1-f43.google.com with SMTP id 6a1803df08f44-6c3567a143eso44528196d6.2 for ; Tue, 24 Sep 2024 05:05:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727179505; x=1727784305; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=az0dXyE+Pl03OZ00DQO15WEsqalnygBrkTisyrdcAH4=; b=S3e28qnwiZgmsDk1KOObIFl9T4E4JC3DgPWIYyAmFof9NnpullihLiJeLMHavbpEcx DJgyRXN3xn+a9rMCeJ4bY+m+nvd3W95xSpGuGoLKz/jZVW8rUwmqcEfcYApe+PgZpL5g crLfzR9P5zUBY9uG/U8Nu/BkZKsr6zT9gF4g5GtEMh1Vtvf9W11mPM7DVCwxEwtJ5KcP +7r+Sot5LGc7W3dtG9H4Mf347zFsdbLOIBkbCHAZNXSKEsz1Me+6N9+ZPOEaMY3ESSSP qSwQzogQ5b6K/+GRaIFjmwA8UYFw2g6TVE0gDknyaWks0NTtvezo7Pub+Q1iBTeIffZT TqGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727179505; x=1727784305; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=az0dXyE+Pl03OZ00DQO15WEsqalnygBrkTisyrdcAH4=; b=OLYQLRrcOaKNek3wN5BLcYMY8gSSm31P0IFgOjHi1OttQzI8iVvhEnefA4K/fjBkOJ VOM6pZjVf5dxV64ZCI23udOkC42vH0zD8CRxLhnKK9oDPiOWKW+D85IaXnbiyS55dMai lrLN7d8oVkolLQp3I2l09JLa05Wj9/XzjeeKpxZfLCCkzCjQ8OyeO/2Xa9zR5jqdb8yI kaUlE7UYfP4FHz+yh/hse+NEX48lI7fbQlT/TVfoPnORNvkNyYsEdQJNhURR1CRT3qqG 4QEmV+Gsx92qrl/V46P6pi+R9qSwQ4swLQkBOHuEkh48b0D0IQ38YGscyPOQ355GA+U/ 4+TA== X-Gm-Message-State: AOJu0Yxa4j8IUaOeRnkLKrvVAWwjMICP6s8Q3p7fgwkpo2TFIEHvCoW0 k3tMoJbH5K42/p7VRQluj0Rneb6xIZRhU1SG9ncqVJKxbvtMoFAf6d2e/Q== X-Google-Smtp-Source: AGHT+IHVpe1CyPTb9Up0xhn4Dcoaobz1WzdbF6ehulwbjGcUtGmEVlE63oPtBpc03Dhvdt6neR9SlQ== X-Received: by 2002:a05:6214:448b:b0:6c3:657a:cbb9 with SMTP id 6a1803df08f44-6c7bd59bb2cmr270423066d6.34.1727179505174; Tue, 24 Sep 2024 05:05:05 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6cb0f4a6178sm5948056d6.7.2024.09.24.05.05.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Sep 2024 05:05:04 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 08/16] dpp-util: check the AKM is "psk" before further parsing the object Date: Tue, 24 Sep 2024 05:04:39 -0700 Message-Id: <20240924120447.251761-8-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240924120447.251761-1-prestwoj@gmail.com> References: <20240924120447.251761-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 --- src/dpp-util.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/dpp-util.c b/src/dpp-util.c index 62db2081..2e4b181b 100644 --- a/src/dpp-util.c +++ b/src/dpp-util.c @@ -196,6 +196,7 @@ struct dpp_configuration *dpp_parse_configuration_object(const char *json, _auto_(l_free) char *akm = NULL; _auto_(l_free) char *pass = NULL; _auto_(l_free) char *psk = NULL; + uint32_t akm_suites; c = json_contents_new(json, json_len); if (!c) @@ -229,23 +230,28 @@ struct dpp_configuration *dpp_parse_configuration_object(const char *json, JSON_UNDEFINED)) goto free_contents; - if (!pass && (!psk || strlen(psk) != 64)) + akm_suites = dpp_parse_akm(akm); + + if (!akm_suites) goto free_contents; config = l_new(struct dpp_configuration, 1); + config->akm_suites = akm_suites; - if (pass) - config->passphrase = l_steal_ptr(pass); - else - config->psk = l_steal_ptr(psk); + if (IE_AKM_IS_PSK(akm_suites)) { + if (!pass && (!psk || strlen(psk) != 64)) + goto free_config; + + if (pass) + config->passphrase = l_steal_ptr(pass); + else + config->psk = l_steal_ptr(psk); + } else + goto free_config; memcpy(config->ssid, ssid, strlen(ssid)); config->ssid_len = strlen(ssid); - config->akm_suites = dpp_parse_akm(akm); - if (!config->akm_suites) - goto free_config; - if (json_iter_is_valid(&extra)) { if (!dpp_parse_extra_options(config, &extra)) l_warn("Extra settings failed to parse!"); From patchwork Tue Sep 24 12:04:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13810868 Received: from mail-qv1-f42.google.com (mail-qv1-f42.google.com [209.85.219.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3F2931A7074 for ; Tue, 24 Sep 2024 12:05:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727179509; cv=none; b=oXrneBPHjjqqfIpqXjv3ScCDDKonu1HI7Tgl3mRsGJWH9EFXGpg4/cmlisfHB+zlvFl9LW9lXLfcbLmOy2Q91ZlhgQtq2cP5v7W9gctszXraJjQk5oj2JQQUEA5QGAFtKrOUZ/0HLdVIJGqt+YkzfUDQv1wXlp7ZeE71Obv3kJM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727179509; c=relaxed/simple; bh=OAfu/qDdOQsS3OM+bhmz51/Y7uJGodJl++uWV64wVO4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WpZTggnK9mO/V72652NMOM877Z1w4KDkS4rLvEYcX82dpG2nQOGv/l4czx3zxpOEUCbZV5i3S/tmckfEN/AXgjkMQJMhnaad52SJVhKCp6o8QlwRJt8BJtuY94Q+9J5qx9MFm6PAvvmKwDXEHp1OsgPHkKe4Xb5iXQn5JayGAcA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=YR5diTST; arc=none smtp.client-ip=209.85.219.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YR5diTST" Received: by mail-qv1-f42.google.com with SMTP id 6a1803df08f44-6c56eec7fccso37924696d6.3 for ; Tue, 24 Sep 2024 05:05:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727179507; x=1727784307; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=s1zHCE/94UDb6MPRHs3iH1FHSfY4CLhcuJl5Wcvam9w=; b=YR5diTSTYUehwXR5mjA2ogEBp/vnev4ye1VDxj6pnI7oaVNp4x/svdPSIhwd2aDjYz uRvKd3L3i4pX6buI0kiTsx7gr73k7KQZ3OqtjtGbzyQxIL5krloVzeIr9P6UJ9Vi0G6A t0p1/YwT5/Hk5gWzQ/Cd7LBnLM3F6f5MxwCPQIwAgqEEyPbsW7IUs//0lJywwFQzTwx2 y/5N9SijcZmAGmU9JViqHK9N7U6EAg4dT/eSsjNpdE4HAYMmTELYe/rdhjyLEoTIlmHc ypB/YSwj6gAaGn6+U+N1aGQLhFLSPLKfu2CnGVCYvNu44t9PJXyg2aXOQgR3zPUeqjWX ZEaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727179507; x=1727784307; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=s1zHCE/94UDb6MPRHs3iH1FHSfY4CLhcuJl5Wcvam9w=; b=Vom53wjg9dvOj6e5upLpn3fNuZxA0IBhmzOeE8zQHf4lSUHXMElkWH8S9MQ4G3THHz tJ2O2uSlBAZz/IpwiTq1e7p3j6//ftvbxfBjh2t6GVNknCyLLNv+NDK/PkoCfOjQ7mTk J/IZITGu0a5uU8kyCdPhMnT1/vSY+M487S/j/Zo/3D6egFCWtx7JdpbGAVRuNmgmvULp EvNvoDoCwBSbHv0fJ0c/E9VT7+NC9eP98HNPUG2d2FH3P7Uq0q6guwIEIJzVDbBO9yNz b26lzrQtYR17TNK8qW7+P4L4gQuw6SmPkKMIzGjIbtMTEcEZl9coGL66NVDVmBqc3s5C Cu5A== X-Gm-Message-State: AOJu0YxTZoJ/rkQNG0pQC6YnF+d6QDwz5IrKywcvl/botoocbdUyqFAk dRcG8pF5ORqxgfVsn+Mu1LuHbJBnOTdX/ZoVqKRpIcz/c9SaQfG0VI+OQw== X-Google-Smtp-Source: AGHT+IFruA+DfeComHtww/s+ZiPnmgLdWWwnxGx/U6xzm0hJVfzBdp0qF1KpFc9FcKJlr641svnV0Q== X-Received: by 2002:a05:6214:319b:b0:6cb:f8a:ba8a with SMTP id 6a1803df08f44-6cb0f8abd80mr24582916d6.25.1727179506864; Tue, 24 Sep 2024 05:05:06 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6cb0f4a6178sm5948056d6.7.2024.09.24.05.05.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Sep 2024 05:05:06 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 09/16] dbus: add generic DPP agent interface Date: Tue, 24 Sep 2024 05:04:40 -0700 Message-Id: <20240924120447.251761-9-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240924120447.251761-1-prestwoj@gmail.com> References: <20240924120447.251761-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This will handle all DPP related agent requests. --- src/dbus.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/dbus.h b/src/dbus.h index 6d7074bf..d667cb23 100644 --- a/src/dbus.h +++ b/src/dbus.h @@ -49,6 +49,7 @@ "net.connman.iwd.NetworkConfigurationAgent" #define IWD_SHARED_CODE_AGENT_INTERFACE "net.connman.iwd.SharedCodeAgent" #define IWD_BSS_INTERFACE "net.connman.iwd.BasicServiceSet" +#define IWD_DPP_AGENT_INTERFACE "net.connman.iwd.DeviceProvisioningAgent" #define IWD_BASE_PATH "/net/connman/iwd" #define IWD_AGENT_MANAGER_PATH IWD_BASE_PATH From patchwork Tue Sep 24 12:04:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13810869 Received: from mail-qv1-f53.google.com (mail-qv1-f53.google.com [209.85.219.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D3C901A707F for ; Tue, 24 Sep 2024 12:05:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727179511; cv=none; b=uVxTp4pdFtuIRY67Ig+E3P9lq4V7tcFl9ObqoC+PQFgweZ/zLTtGBqS7Lpxn/U3GJwreYIIxIhJR1qUVBn7O4NNkbR6mgU2GD5Mpa/Ybg8FsY4gWCNfryO5n0IoN/RSog5b1y6YiKpb0+Xfc94jeaVFBB/qZXtNSfwlGCo+MQnk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727179511; c=relaxed/simple; bh=GtViNlQFKwvuLX4mnn8PIBFpPm+0UeD9yTz6Exjz3Sk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ea3jQYochf8d0lHd/VQEX+25dGz3M4iS/v7vJG1lxG3ZdtRJGOlKaTJLUpkcR72GuYNSA71BOQ/fNHB+xPbNGZNT3HNt2NA0bWLTGcxhCXwQN0inHEIGt7P1wU+SRkSWmjqwAd+efF7Gtqn4nS1trEqiUu447ddZZKXW//rOZA4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=lNyqmM0s; arc=none smtp.client-ip=209.85.219.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lNyqmM0s" Received: by mail-qv1-f53.google.com with SMTP id 6a1803df08f44-6c56eec7fccso37924926d6.3 for ; Tue, 24 Sep 2024 05:05:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727179508; x=1727784308; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JnTArKTL+e0C2Y6q/FbHwZZp+7nEAeSnKbzJj5QJ0II=; b=lNyqmM0spci247urh9p41cNl89LtJdWPmWQ+al+z+QzgWypT3bLzc2+GjNlV8EXkfD ctgqY++Ul5/ktKfEi5iZJni2F4VJk9GreHG+XMuqwvYVhG4RxBOu53TpB5XQ3AtRNyuo Suptwszxyq9pWG+r9HzZCa6Si16puXawn3OU+ame5nff/+N8aF4h63iknOhfhOl35cyC Iy3u6HuBqPQcs5djt4Qe4zxVvwM47XN5mg9tSfzZd4WtkYykSlcaR3rMOq4+vsTgDN2C 31Sy5piPVTcoqHFJPcHUUsoG6u1vmkmeR3y4LjDRZH6HfsxxD5zuxGWM1xwYKbdQZPd8 hgNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727179508; x=1727784308; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JnTArKTL+e0C2Y6q/FbHwZZp+7nEAeSnKbzJj5QJ0II=; b=A4FFc41QzRJQZ9kMW8xOZIwl5mUhFSICzB7F3lWQr/+0k3u3NSFjEBNMdf76bl6xBQ 3ZZg2Lxm2eibaxJGMFdRTYJxrK3awFPYZ7FXsNRWhwjW3Tvet2/ZZ180CmXsZv4NhW3V JtUIbed1rUmfVaHbBMXk5nXaQuyaZCNoyIkopzmDFh2U2gyAETY2+Dsh5RwO4gwP+z3f HQugtQPIGQFReuCEytJyPgp6h8RgeUYG6h3kfXN0hdfZlzx22bLhsLiD7FeLix6jucrM sIOkBMbqlHwR4lKcrRSh8WN9sYwFfG8v3Nus19NOgX+vbb/kY7An90cQu4C5W1AmaqWx Xjiw== X-Gm-Message-State: AOJu0Yy4zWtGQswceT0OPutbOfLi+bfg0nA/1dtv5KNKul1dqC91WESg AmGD+x+oThhdIuvgkSvINSCfxYD07GMS5GofKNGpqTRYl7M5qEcK7cSKYg== X-Google-Smtp-Source: AGHT+IFw9RuD0k/UiSOk9vlbq2GRMFx+PQ3ivzYkAb2G8mayAM0JVotOeFlN+Uy1JeT8MoZrOHVizg== X-Received: by 2002:a05:6214:4383:b0:6c5:aae1:6442 with SMTP id 6a1803df08f44-6c7bc67fc87mr184395136d6.15.1727179508232; Tue, 24 Sep 2024 05:05:08 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6cb0f4a6178sm5948056d6.7.2024.09.24.05.05.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Sep 2024 05:05:07 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 10/16] dpp: replace PKEX agent with generic DPP agent Date: Tue, 24 Sep 2024 05:04:41 -0700 Message-Id: <20240924120447.251761-10-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240924120447.251761-1-prestwoj@gmail.com> References: <20240924120447.251761-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This is one of two commits which replaces the existing shared code agent with a generic DPP agent. This commit alone breaks DPP PKEX but the next will fully remove the PKEX agent in place of the new generic agent. This is being done to prepare for enterprise DPP configuration where additional agent APIs will be needed. Rather than invent a new agent type it makes sense to bundle both into one and just define separate methods, PKEX/Enterprise. --- src/dpp.c | 168 +++++++++++++++++++++++++++++++++++------------------- src/dpp.h | 24 ++++++++ 2 files changed, 133 insertions(+), 59 deletions(-) create mode 100644 src/dpp.h diff --git a/src/dpp.c b/src/dpp.c index 3ad60188..7b700018 100644 --- a/src/dpp.c +++ b/src/dpp.c @@ -54,6 +54,7 @@ #include "src/handshake.h" #include "src/nl80211util.h" #include "src/knownnetworks.h" +#include "src/dpp.h" #define DPP_FRAME_MAX_RETRIES 5 #define DPP_FRAME_RETRY_TIMEOUT 1 @@ -81,6 +82,10 @@ static uint32_t unicast_watch; static uint8_t dpp_prefix[] = { 0x04, 0x09, 0x50, 0x6f, 0x9a, 0x1a, 0x01 }; +static char *dpp_agent_name; +static char *dpp_agent_path; +static unsigned int dpp_agent_watch; + enum dpp_state { DPP_STATE_NOTHING, DPP_STATE_PRESENCE, @@ -134,6 +139,7 @@ struct dpp_sm { enum dpp_state state; enum dpp_interface interface; + uint32_t agent_request_id; struct pkex_agent *agent; /* @@ -373,64 +379,6 @@ static void dpp_free_pending_pkex_data(struct dpp_sm *dpp) } } -static void pkex_agent_free(void *data) -{ - struct pkex_agent *agent = data; - - l_free(agent->owner); - l_free(agent->path); - l_dbus_remove_watch(dbus_get_bus(), agent->disconnect_watch); - l_free(agent); -} - -static void dpp_agent_cancel(struct dpp_sm *dpp) -{ - struct l_dbus_message *msg; - - const char *reason = "shutdown"; - - msg = l_dbus_message_new_method_call(dbus_get_bus(), - dpp->agent->owner, - dpp->agent->path, - IWD_SHARED_CODE_AGENT_INTERFACE, - "Cancel"); - l_dbus_message_set_arguments(msg, "s", reason); - l_dbus_message_set_no_reply(msg, true); - l_dbus_send(dbus_get_bus(), msg); -} - -static void dpp_agent_release(struct dpp_sm *dpp) -{ - struct l_dbus_message *msg; - - msg = l_dbus_message_new_method_call(dbus_get_bus(), - dpp->agent->owner, - dpp->agent->path, - IWD_SHARED_CODE_AGENT_INTERFACE, - "Release"); - l_dbus_message_set_arguments(msg, ""); - l_dbus_message_set_no_reply(msg, true); - l_dbus_send(dbus_get_bus(), msg); -} - -static void dpp_destroy_agent(struct dpp_sm *dpp) -{ - if (!dpp->agent) - return; - - if (dpp->agent->pending_id) { - dpp_agent_cancel(dpp); - l_dbus_cancel(dbus_get_bus(), dpp->agent->pending_id); - } - - dpp_agent_release(dpp); - - l_debug("Released SharedCodeAgent on path %s", dpp->agent->path); - - pkex_agent_free(dpp->agent); - dpp->agent = NULL; -} - static void dpp_free_auth_data(struct dpp_sm *dpp) { if (dpp->own_proto_public) { @@ -480,6 +428,47 @@ static void dpp_free_auth_data(struct dpp_sm *dpp) } +static void dpp_agent_cancel(struct dpp_sm *dpp) +{ + struct l_dbus_message *msg; + const char *reason = "shutdown"; + + if (L_WARN_ON(!dpp_agent_name)) + return; + + msg = l_dbus_message_new_method_call(dbus_get_bus(), + dpp_agent_name, + dpp_agent_path, + IWD_DPP_AGENT_INTERFACE, + "CancelSharedCode"); + l_dbus_message_set_arguments(msg, "s", reason); + l_dbus_message_set_no_reply(msg, true); + l_dbus_send(dbus_get_bus(), msg); + + l_dbus_cancel(dbus_get_bus(), dpp->agent_request_id); + dpp->agent_request_id = 0; +} + +static void dpp_agent_release(void) +{ + struct l_dbus_message *msg; + + if (L_WARN_ON(!dpp_agent_name)) + return; + + msg = l_dbus_message_new_method_call(dbus_get_bus(), + dpp_agent_name, + dpp_agent_path, + IWD_DPP_AGENT_INTERFACE, + "Release"); + l_dbus_message_set_arguments(msg, ""); + l_dbus_message_set_no_reply(msg, true); + l_dbus_send(dbus_get_bus(), msg); + + l_dbus_remove_watch(dbus_get_bus(), dpp_agent_watch); +} + + static void dpp_reset(struct dpp_sm *dpp) { struct station *station = station_find(netdev_get_ifindex(dpp->netdev)); @@ -555,7 +544,8 @@ static void dpp_reset(struct dpp_sm *dpp) explicit_bzero(dpp->z, dpp->key_len); explicit_bzero(dpp->u, dpp->u_len); - dpp_destroy_agent(dpp); + if (dpp->agent_request_id) + dpp_agent_cancel(dpp); dpp_free_pending_pkex_data(dpp); @@ -599,6 +589,63 @@ static void dpp_free(struct dpp_sm *dpp) l_free(dpp); } +static void dpp_agent_disconnect_cb(struct l_dbus *dbus, void *user_data) +{ + const struct l_queue_entry *e; + + l_debug("DPP agent disconnected"); + + for (e = l_queue_get_entries(dpp_list); e; e = e->next) { + struct dpp_sm *dpp = e->data; + + /* + * If this DPP SM was in the process of making an agent request + * this protocol run won't complete, reset + */ + if (dpp->agent_request_id) + dpp_reset(dpp); + } + + l_dbus_remove_watch(dbus, dpp_agent_watch); +} + +static void dpp_agent_watch_destroy(void *user_data) +{ + dpp_agent_watch = 0; + + l_free(dpp_agent_name); + dpp_agent_name = NULL; + l_free(dpp_agent_path); + dpp_agent_path = NULL; +} + +int dpp_register_agent(const char *name, const char *path) +{ + if (dpp_agent_path) + return -EEXIST; + + dpp_agent_name = l_strdup(name); + dpp_agent_path = l_strdup(path); + dpp_agent_watch = l_dbus_add_disconnect_watch(dbus_get_bus(), + name, + dpp_agent_disconnect_cb, + NULL, dpp_agent_watch_destroy); + return 0; +} + +int dpp_unregister_agent(const char *name, const char *path) +{ + if (!dpp_agent_path || strcmp(dpp_agent_path, path)) + return -ENOENT; + + if (strcmp(dpp_agent_name, name)) + return -EPERM; + + l_dbus_remove_watch(dbus_get_bus(), dpp_agent_watch); + + return 0; +} + static void dpp_send_frame_cb(struct l_genl_msg *msg, void *user_data) { struct dpp_sm *dpp = user_data; @@ -4832,6 +4879,9 @@ static void dpp_exit(void) nl80211 = NULL; l_queue_destroy(dpp_list, (l_queue_destroy_func_t) dpp_free); + + if (dpp_agent_name) + dpp_agent_release(); } IWD_MODULE(dpp, dpp_init, dpp_exit); diff --git a/src/dpp.h b/src/dpp.h new file mode 100644 index 00000000..d66deb52 --- /dev/null +++ b/src/dpp.h @@ -0,0 +1,24 @@ +/* + * + * Wireless daemon for Linux + * + * Copyright (C) 2024 Locus Robotics. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +int dpp_register_agent(const char *name, const char *path); +int dpp_unregister_agent(const char *name, const char *path); From patchwork Tue Sep 24 12:04:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13810870 Received: from mail-qk1-f173.google.com (mail-qk1-f173.google.com [209.85.222.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DA4C91A7079 for ; Tue, 24 Sep 2024 12:05:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727179512; cv=none; b=tQM++W1WXVmlHT+sF6RCte0SJwRIrR20jLbFTO0PCPXNL4vEbrIJEBW9fdVSOfNVb30I19OeJueAih/hQxglZw3TiOttmGVSxrKVJ3a514r4bxmuku8GJ9A/C1GEXZgNJDD55OEsxK1IUujYFSazlCmZVn50fyPNUuEnA7EGSKk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727179512; c=relaxed/simple; bh=2JhI08P+zLYT3hOvvS7aWYftpTpekdhMaNBNh9PbhnM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=i61E7hlDg5xR8itV2+IGQKWf3p9ssh4sumjjJW2bmFxS795vJuau0dHMeHs7HG7oRMV2izv43sAfY6h6LBEsMYBZG88ZLECZ1e3mA1so/1V4j/4C/+ZFJajjfKv38txIKi70heePsGX3HOEzIGHfQqTQ7/6slLH2h5vs6iR2UDU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=TKhIqivC; arc=none smtp.client-ip=209.85.222.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TKhIqivC" Received: by mail-qk1-f173.google.com with SMTP id af79cd13be357-7a9ab8e5f96so91853685a.1 for ; Tue, 24 Sep 2024 05:05:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727179509; x=1727784309; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lm5fjf5QqtpMS5z1VGpk7shoL8IDoIhH6mMTqGyKoE0=; b=TKhIqivCL96GHKEkCDylylrR+ldE9HLihjpnBcKXsVcVcfHzOHlqiyT8XjQpfV3slo qpKaGvAAoJE3cF9XO0dZ60+5Gn/X0CjgjyfkQKCxMmQsC66ydQTF85otoCzsWmd3iKB+ IV7Qa9ABTJ/fNi04pi5w6ZO5CdoYy4A8LJPVWTimqP216ipugJfMC4Wy7Jbkmiu3IHQI Xd0Imhs2YuMsSYedCP97XNGN/pV66zt7Qpx1hqdxjXiTHUqzTVk3FGEslCB+nmXw0nQG 7NZbqHK9IPVI/DfEYbi9c+yzA1dwOQ1khEbw+CygE3ckIZUSS+M5qzvky76IYSVQ0XvP Ym2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727179509; x=1727784309; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lm5fjf5QqtpMS5z1VGpk7shoL8IDoIhH6mMTqGyKoE0=; b=a0s9ZJrth8IRzmrSrfqUPPOG0ovoW7hFUm+63MlSt5O0025vz90L6nO/UK8SQCYxKi n8MqAFwXlszf6GEGIkxZy9y/RuXVf87eDpTmaGqWW2R6IJjRao0X+SsX4hhu9nZLNl2K 1t6JqvhbXZ8u5mQ5rm/S6xCjaHcJ/6KQcgC5c1fbVleQujIqO4dqjDYVfzjlqhrdniI8 QJtIzlPtjv5kpoQCrs1AQTIzcLDgOuU/KhZ1XgAXbbYr8UA0RtoEASIDA+1bNKyHbGeo aX+uws9klP9yx6pe9hER4KIXo5qJgmYNi5iKbSa4Pxg53EoprEgKUzUt3IkeB2xn2vW2 z8vw== X-Gm-Message-State: AOJu0YyMnvDERASIMr9YxL/ZIveCDiWoNoQ0abpaI+H09FpiDDlU4ty+ e4GryFwlD3pB7CAlLgvQGyadRQDGnpipZdbSsLdYDrLR6Cf5lykCxjsYmw== X-Google-Smtp-Source: AGHT+IHtBurul/8zvn6HVp2d+jATqd+5Vx8320LEVcPcJ/7ync9RuZxBufg6br37SX5q8CHO9U0hKA== X-Received: by 2002:a05:6214:460f:b0:6c7:cc6b:f0f5 with SMTP id 6a1803df08f44-6c7cc6bf13emr191948286d6.13.1727179509554; Tue, 24 Sep 2024 05:05:09 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6cb0f4a6178sm5948056d6.7.2024.09.24.05.05.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Sep 2024 05:05:09 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 11/16] agent: add APIs for DeviceProvisioningAgent Date: Tue, 24 Sep 2024 05:04:42 -0700 Message-Id: <20240924120447.251761-11-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240924120447.251761-1-prestwoj@gmail.com> References: <20240924120447.251761-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This adds {Register,Unregister}DeviceProvisioningAgent to the AgentManager interface. These are simple wrappers which just call into DPP. --- src/agent.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/src/agent.c b/src/agent.c index 0f718b87..bf0a88ea 100644 --- a/src/agent.c +++ b/src/agent.c @@ -32,6 +32,7 @@ #include "src/agent.h" #include "src/iwd.h" #include "src/module.h" +#include "src/dpp.h" static unsigned int next_request_id = 0; @@ -639,6 +640,54 @@ static struct l_dbus_message *netconfig_agent_unregister(struct l_dbus *dbus, return reply; } +static struct l_dbus_message *device_provisioning_agent_register( + struct l_dbus *dbus, + struct l_dbus_message *message, + void *user_data) +{ + struct l_dbus_message *reply; + const char *path; + int r; + + l_debug(""); + + if (!l_dbus_message_get_arguments(message, "o", &path)) + return dbus_error_invalid_args(message); + + r = dpp_register_agent(l_dbus_message_get_sender(message), path); + if (r) + return dbus_error_from_errno(r, message); + + l_debug("device provisioning agent %s path %s", + l_dbus_message_get_sender(message), path); + + reply = l_dbus_message_new_method_return(message); + l_dbus_message_set_arguments(reply, ""); + return reply; +} + +static struct l_dbus_message *device_provisioning_agent_unregister(struct l_dbus *dbus, + struct l_dbus_message *message, + void *user_data) +{ + struct l_dbus_message *reply; + const char *path; + int r; + + l_debug(""); + + if (!l_dbus_message_get_arguments(message, "o", &path)) + return dbus_error_invalid_args(message); + + r = dpp_unregister_agent(l_dbus_message_get_sender(message), path); + if (r) + return dbus_error_from_errno(r, message); + + reply = l_dbus_message_new_method_return(message); + l_dbus_message_set_arguments(reply, ""); + return reply; +} + static void setup_agent_interface(struct l_dbus_interface *interface) { l_dbus_interface_method(interface, "RegisterAgent", 0, @@ -654,6 +703,15 @@ static void setup_agent_interface(struct l_dbus_interface *interface) l_dbus_interface_method(interface, "UnregisterNetworkConfigurationAgent", 0, netconfig_agent_unregister, "", "o", "path"); + + l_dbus_interface_method(interface, + "RegisterDeviceProvisioningAgent", 0, + device_provisioning_agent_register, + "", "o", "path"); + l_dbus_interface_method(interface, + "UnregisterDeviceProvisioningAgent", 0, + device_provisioning_agent_unregister, + "", "o", "path"); } static bool release_agent(void *data, void *user_data) From patchwork Tue Sep 24 12:04:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13810871 Received: from mail-qv1-f44.google.com (mail-qv1-f44.google.com [209.85.219.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 001801A7070 for ; Tue, 24 Sep 2024 12:05:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727179513; cv=none; b=X0SuFyk8CDd3tdiqA8GRNw/vh9MoMZoJRUL3BGg2KftrxManyV70L8o3gOQoDH5H6C+UTDwqCu5TESRlbhzB/J9D04TmfuqPebdQbRjqgXhf987//dER0mJpJ9VycHefFE29o5GWWzfYCwLPP865uPInckAJYkH1AWuphkC0DNs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727179513; c=relaxed/simple; bh=Tx5Qjb/6pIct0YUF7PFUL23Ag2a44T4TOhBzDrGxal8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=uA4DAm+pndR8ESHHnrWwlK9qQGmyM5vSqlWXI9sK/CZoRA6CuoZ78C2MCHmrpHiSpLsYK8FF0H6lLnm/ewd8cmj9BYe/WeWAhx2XiE7uIAy5kvtw1GzRYUuixOZQ+oNTC4W37BON/e9HNczueBylZZFbJA0gKmuR+3p/sqaYdyo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=JzAXbt7V; arc=none smtp.client-ip=209.85.219.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JzAXbt7V" Received: by mail-qv1-f44.google.com with SMTP id 6a1803df08f44-6c358b725feso37377196d6.1 for ; Tue, 24 Sep 2024 05:05:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727179511; x=1727784311; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UvfVAwe5kKt4axdHz2a/S6EMPXABIqcprO+86garDts=; b=JzAXbt7VXI5pnhwnLTV5zIa6J06uY55dSVw9yF+C4KVfNh3y2Odvo8e22V1IJaMGNM LhRQDweIye53+otpFlWWDlMIF52eKJIcEo3ASdbJ+4OqTL7TSjmFP7e3epCM5fpFTjbE PUoj4tNCSmSLUDKhyBVgwezIwSnk25/K7V9VKRnyvKwDzZK4er0CHIQz+3Od1fhULvR8 AOzE0ie/HshabX9ZWv1gkieLQD7gBo0DH7yqU1Vzg6fD3ElCMN+yjDkxwAnL415uhvYQ j5JPNOw08WlyZPoubVeFY5+V9oaE7OO7NP6OHo9WGF+SRBToMD+EXLvhO3iSzzDhzK2L jdrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727179511; x=1727784311; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UvfVAwe5kKt4axdHz2a/S6EMPXABIqcprO+86garDts=; b=wOgOpC0mPI0WMm/w4gCJ9oYMBEeXZy8OLw7ZbJQ5BQg5q5p4VhTC6G80qqQ2cJ2f4O tfcVF/aYMaokAFYfioLRYpnowLWd5WEa8VrS4BrFNa2mmB7sLeHtxATP9359iAkZKn1k bLr2aoFkudwmeBhZk1ymEqC6+5L+q8IE2sDsrC4yyMgJMTtNClU3HgLFcKwnVOuOs53q XKjT9raJli/Y6GD2Sju0rBdPs+MXDYKa9VGnRjewE31eKIktqHTbAlxgtUe5Yi3kClx2 w0AtEG661Kg0AE9dyiPb60QMiImE93aMVfykTHSLqvy6KYk3HPpoZ1SPDXuKyYyM/O8f 7KxQ== X-Gm-Message-State: AOJu0Ywd1KI+9iIt2JsvY0jfs6/LiPKt5x8zMRmzDSutTzo2FKAkBkLI M9GIpZ/p/qpE2qw4FCKqy3F9O07yiJ/n7Gk4gJbDILQ5ZxBPwzzb1uFWUg== X-Google-Smtp-Source: AGHT+IHHfKz3vxMGKazH824Fl5KspC9WV/em8X6hjPoXAG+/tMfH7hg+dyTOrKntOkn5fmADLuz7aQ== X-Received: by 2002:a05:6214:398c:b0:6c5:50bb:d59d with SMTP id 6a1803df08f44-6c7bc7ec5a4mr222238356d6.37.1727179510701; Tue, 24 Sep 2024 05:05:10 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6cb0f4a6178sm5948056d6.7.2024.09.24.05.05.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Sep 2024 05:05:10 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 12/16] dpp: replace SharedCodeAgent with DeviceProvisioningAgent Date: Tue, 24 Sep 2024 05:04:43 -0700 Message-Id: <20240924120447.251761-12-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240924120447.251761-1-prestwoj@gmail.com> References: <20240924120447.251761-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This fully removes the SharedCodeAgent which was specific to the PKEX protocol and replaces it with the more generalized DeviceProvisioningAgent. The new agent should still implement the shared code method and effectively behave no differently in that regard. The main difference as far as the API is the new agent must be registered via the AgentManager interface, not passed in via the method arguments to ConfigureEnrollee(). --- src/dpp.c | 63 ++++++++++++------------------------------------------- 1 file changed, 13 insertions(+), 50 deletions(-) diff --git a/src/dpp.c b/src/dpp.c index 7b700018..d1912eaf 100644 --- a/src/dpp.c +++ b/src/dpp.c @@ -106,13 +106,6 @@ enum dpp_interface { DPP_INTERFACE_PKEX, }; -struct pkex_agent { - char *owner; - char *path; - unsigned int disconnect_watch; - uint32_t pending_id; -}; - struct dpp_sm { struct netdev *netdev; char *uri; @@ -140,7 +133,6 @@ struct dpp_sm { enum dpp_interface interface; uint32_t agent_request_id; - struct pkex_agent *agent; /* * List of frequencies to jump between. The presence of this list is @@ -2088,7 +2080,7 @@ static void dpp_offchannel_timeout(int error, void *user_data) switch (dpp->state) { case DPP_STATE_PKEX_EXCHANGE: - if (dpp->role != DPP_CAPABILITY_CONFIGURATOR || !dpp->agent) + if (dpp->role != DPP_CAPABILITY_CONFIGURATOR || !dpp_agent_name) break; /* @@ -2097,7 +2089,7 @@ static void dpp_offchannel_timeout(int error, void *user_data) * for our response so cancel the request and continue waiting * for another request */ - if (dpp->agent->pending_id) { + if (dpp->agent_request_id) { dpp_free_pending_pkex_data(dpp); dpp_agent_cancel(dpp); } @@ -3228,10 +3220,10 @@ static void dpp_pkex_agent_reply(struct l_dbus_message *message, const char *error, *text; const char *code; - dpp->agent->pending_id = 0; + dpp->agent_request_id = 0; - l_debug("SharedCodeAgent %s path %s replied", dpp->agent->owner, - dpp->agent->path); + l_debug("DeviceProvisioningAgent %s path %s replied", dpp_agent_name, + dpp_agent_path); if (l_dbus_message_get_error(message, &error, &text)) { l_error("RequestSharedCode(%s) returned %s(\"%s\")", @@ -3240,7 +3232,7 @@ static void dpp_pkex_agent_reply(struct l_dbus_message *message, } if (!l_dbus_message_get_arguments(message, "s", &code)) { - l_debug("Invalid arguments, check SharedCodeAgent!"); + l_debug("Invalid arguments, check DeviceProvisioningAgent!"); goto reset; } @@ -3257,25 +3249,25 @@ static bool dpp_pkex_agent_request(struct dpp_sm *dpp) { struct l_dbus_message *msg; - if (!dpp->agent) + if (!dpp_agent_name) return false; - if (L_WARN_ON(dpp->agent->pending_id)) + if (L_WARN_ON(dpp->agent_request_id)) return false; msg = l_dbus_message_new_method_call(dbus_get_bus(), - dpp->agent->owner, - dpp->agent->path, - IWD_SHARED_CODE_AGENT_INTERFACE, + dpp_agent_name, + dpp_agent_path, + IWD_DPP_AGENT_INTERFACE, "RequestSharedCode"); l_dbus_message_set_arguments(msg, "s", dpp->pkex_id); - dpp->agent->pending_id = l_dbus_send_with_reply(dbus_get_bus(), + dpp->agent_request_id = l_dbus_send_with_reply(dbus_get_bus(), msg, dpp_pkex_agent_reply, dpp, NULL); - return dpp->agent->pending_id != 0; + return dpp->agent_request_id != 0; } static void dpp_handle_pkex_exchange_request(struct dpp_sm *dpp, @@ -4648,32 +4640,6 @@ invalid_args: return dbus_error_invalid_args(message); } -static void pkex_agent_disconnect(struct l_dbus *dbus, void *user_data) -{ - struct dpp_sm *dpp = user_data; - - l_debug("SharedCodeAgent %s disconnected", dpp->agent->path); - - dpp_reset(dpp); -} - -static void dpp_create_agent(struct dpp_sm *dpp, const char *path, - struct l_dbus_message *message) -{ - const char *sender = l_dbus_message_get_sender(message); - - dpp->agent = l_new(struct pkex_agent, 1); - dpp->agent->owner = l_strdup(sender); - dpp->agent->path = l_strdup(path); - dpp->agent->disconnect_watch = l_dbus_add_disconnect_watch( - dbus_get_bus(), - sender, - pkex_agent_disconnect, - dpp, NULL); - - l_debug("Registered a SharedCodeAgent on path %s", path); -} - static struct l_dbus_message *dpp_start_pkex_configurator(struct dpp_sm *dpp, const char *key, const char *identifier, const char *agent_path, @@ -4708,9 +4674,6 @@ static struct l_dbus_message *dpp_start_pkex_configurator(struct dpp_sm *dpp, if (key) dpp->pkex_key = l_strdup(key); - if (agent_path) - dpp_create_agent(dpp, agent_path, message); - dpp->role = DPP_CAPABILITY_CONFIGURATOR; dpp->state = DPP_STATE_PKEX_EXCHANGE; dpp->interface = DPP_INTERFACE_PKEX; From patchwork Tue Sep 24 12:04:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13810872 Received: from mail-qv1-f53.google.com (mail-qv1-f53.google.com [209.85.219.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9A018126C02 for ; Tue, 24 Sep 2024 12:05:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727179515; cv=none; b=VUVFZiTjKqcYXuYPr7EeB6wRVgj+bmOgJWK3O1j+3MqzVT0+rU1Bks+30+IcIlQVz75WcDNy6WPirBLvY86W1pZJDNccu/UeNteywSNNTRpPQy5qa02Gfzcx2+KdHsWiR7YkujiNP10nKXoTqq+Bw6zUgLHhJpZK4OYrrLDXb1c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727179515; c=relaxed/simple; bh=bzJ0RwYjoFvTb2rnJWhb0BvefmJupwcZEBMzITTcGwo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dmF8IYbEjmx1iOODQDpELIj08OvsvAFGCA0wbdVy/9xKVRKUPyHxZ/d+anxU4LXkzNSfLrZ3kUq5bdlXUffgkv0Eb5gX8cT2SI2OeKzPcmEngWan8ELWvjut+oljo2RQlEechnuHofdm0x0InTe87TctdmupyztrvzdS5UtGZAE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=jt7fkEoG; arc=none smtp.client-ip=209.85.219.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jt7fkEoG" Received: by mail-qv1-f53.google.com with SMTP id 6a1803df08f44-6c34dd6c21aso37399836d6.2 for ; Tue, 24 Sep 2024 05:05:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727179512; x=1727784312; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GzpW3PZRVaqKzgq/WFqn1FsGo2R2+ica6UrYBOq8LhY=; b=jt7fkEoGW8+VYJSZvvQXBS47tFWrzLIZPAgu8oixKqHQBeAAOf5Ec/kiOFoyOLIPWM EyS4WZiucdWhiyfQp3N3xlExN/0Hq2yN9BeonzB9usAI+NF7HYY/G6VIDBdMX2XfOcDR STXeems+7bvXnjbB9KiHjk7UILgj9qBpYPwIVF664O65jXUIi6QDyDCupXoWVfFcYHST 5wJxG4Rzwt0rREZ2ASunTVNOhmUjpbjeD3VPovAd7wv8GG+dgQ/YcEQgHzw6SANdrOl/ xuclDDGjAdl/C6bZH/ihvzAdXaWUV9WXzGy1eGz/UHy4ZwaGC4iGYxkTGDZYkW4/nyu1 RV3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727179512; x=1727784312; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GzpW3PZRVaqKzgq/WFqn1FsGo2R2+ica6UrYBOq8LhY=; b=cvMXdPfx7j0kgnjZHCIunlDHCb3N2jYoGuMcn2/eAWS46ShYGoYqb6ZavvttZBGnTF NNcW8BWj61FH/nNPveh/6bUVi0gfNOxoaoBvpuDSp+FZWcK8njc/RzKDhCkZtHfgmlue 1gDwIMMGc26FJsbKrNunGGqVpM8JkEPETPtw1Hp17AvDxAlOG9t7ujEWSu7oTUrRcyZ3 RS92FUEXJ5IWrvsQ/QRWjquGdJHdvzKqxPFKybVY+t5SHPFOHxnMrPpJIy6jeFhuHvWD kz7r8QiMn84WIiDYBj8C/HtsOFM1QW/jSVhmRSMTbpf8PAdQeFVr/7pugOIh2dKpKHex Zkmg== X-Gm-Message-State: AOJu0YymThptGUiF9NBC+5tTbmUZBivGDuSAsM2WabqHedSEMS71Kfng /X27V3GBGzjlHVOp27sLlBnFP6SHq/n+wyhJ/u9Dp28BZYECueHv90G4Ww== X-Google-Smtp-Source: AGHT+IG5/H7Sv/3U+uUFTEG0gScS1yhkwtagPnW6xOrWPxQtyyhzDF8pdnxFbVA+/sdDBkgJCK27zg== X-Received: by 2002:a05:6214:4408:b0:6c5:688a:63b4 with SMTP id 6a1803df08f44-6c7bc83203fmr209670956d6.50.1727179511920; Tue, 24 Sep 2024 05:05:11 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6cb0f4a6178sm5948056d6.7.2024.09.24.05.05.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Sep 2024 05:05:11 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 13/16] dpp: remove agent path from StartConfigurator Date: Tue, 24 Sep 2024 05:04:44 -0700 Message-Id: <20240924120447.251761-13-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240924120447.251761-1-prestwoj@gmail.com> References: <20240924120447.251761-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The agent must now be registered via the AgentManager interface, so remove the path argument as it is not used anymore. --- src/dpp.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/dpp.c b/src/dpp.c index d1912eaf..7a744ed3 100644 --- a/src/dpp.c +++ b/src/dpp.c @@ -4642,7 +4642,6 @@ invalid_args: static struct l_dbus_message *dpp_start_pkex_configurator(struct dpp_sm *dpp, const char *key, const char *identifier, - const char *agent_path, struct l_dbus_message *message) { struct handshake_state *hs = netdev_get_handshake(dpp->netdev); @@ -4715,7 +4714,7 @@ static struct l_dbus_message *dpp_dbus_pkex_configure_enrollee( if (!dpp_parse_pkex_args(message, &key, &id, NULL, NULL)) return dbus_error_invalid_args(message); - return dpp_start_pkex_configurator(dpp, key, id, NULL, message); + return dpp_start_pkex_configurator(dpp, key, id, message); } static struct l_dbus_message *dpp_dbus_pkex_start_configurator( @@ -4724,12 +4723,8 @@ static struct l_dbus_message *dpp_dbus_pkex_start_configurator( void *user_data) { struct dpp_sm *dpp = user_data; - const char *path; - if (!l_dbus_message_get_arguments(message, "o", &path)) - return dbus_error_invalid_args(message); - - return dpp_start_pkex_configurator(dpp, NULL, NULL, path, message); + return dpp_start_pkex_configurator(dpp, NULL, NULL, message); } static void dpp_setup_interface(struct l_dbus_interface *interface) @@ -4774,7 +4769,7 @@ static void dpp_setup_pkex_interface(struct l_dbus_interface *interface) l_dbus_interface_method(interface, "ConfigureEnrollee", 0, dpp_dbus_pkex_configure_enrollee, "", "a{sv}", "args"); l_dbus_interface_method(interface, "StartConfigurator", 0, - dpp_dbus_pkex_start_configurator, "", "o", "path"); + dpp_dbus_pkex_start_configurator, "", ""); l_dbus_interface_property(interface, "Started", 0, "b", dpp_pkex_get_started, NULL); From patchwork Tue Sep 24 12:04:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13810873 Received: from mail-qv1-f41.google.com (mail-qv1-f41.google.com [209.85.219.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CB797176ADE for ; Tue, 24 Sep 2024 12:05:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727179516; cv=none; b=T7l1tP3P5ll2jME14XoAITTnFjjM8PbNYHhPtMCbRvTlU7v2GoKJgM/od7fCHkVtG6xzkbt8VMG2FXzcMURAoKZZm532Q/uI5mPX9U+vcg+zQyBK5f3qwxF75OobLtzB8pm7RE/C+7fTSgsnnsAyE6GfvNcnWsr12Rn1CiiGmZg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727179516; c=relaxed/simple; bh=0TblQlnV1b1AGbXTScJbBhKYf2a0AHZUNpdwuzpyaOU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=HTL3XYob2FnVH1UUdwvgVNw73Z6dTG+H+oKA3sH8e8m6qACFlb6yHmgx263X6L7JvftQ4FHFPgGs1K4PMv5Kot9C4vQdx8i0Ga3jTAv1zCmI4Q6uoFg32rRBSVGU9tE73z4QyhMzGeOyKI977pR2XItwivxv0/Dlz3gmRptlAoM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=jZ3AcDpn; arc=none smtp.client-ip=209.85.219.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jZ3AcDpn" Received: by mail-qv1-f41.google.com with SMTP id 6a1803df08f44-6c54b1f52f7so35611596d6.3 for ; Tue, 24 Sep 2024 05:05:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727179513; x=1727784313; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=yLLtYNQR+C3oSPVjkUh2qQFzpK0wvefIlOfPrWG7IRg=; b=jZ3AcDpnmQBLTn6QPEQOBEOLX3dLHyjxTdrfuTiNH/oHprFOgNfjC1+r4kyKg29rGM R9TESZP6FkbDYY6r2MEXOm3ou9wm7XwUMqzMYCdfzuwvidqjm+tPK/XcNTw3GhXBcTVj S0qJAzxEQlgrMBx/x3Vl6a/z7mT+h52DbJnMrNsFNuITwKUljwMyaIWNl6Q/NUVzPD19 g4pXMectv9U2d514pomzJwUFVnREt+g2rQqAp9YeC8xAi8RZIKk2XCHvApMvyC+ZV09U 3Rpxyl8ekBhOD2Z9+F0bV8zOKQn4WxtrocbBAYzT1wEuDCUWsVJMOa1zad+rjKmDG3Vk 0omw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727179513; x=1727784313; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yLLtYNQR+C3oSPVjkUh2qQFzpK0wvefIlOfPrWG7IRg=; b=jT7kDYdZRtTcgxf5AYtuvsQf9BmMoyS7jkN/X7VRVs32aQcvaCfyyzhI9xd9gRse8x rzLbiwvUPqromQGc8nztkkR6xBqXcBCjnl0YB+ujo0iQ8s7XMpWQfTRYtmppVFW+YIjN F1EGBlHA+dZvpsfsVmhPw23TnAufTE+refH+h/cODOV3ZFqcDs+5k4tpky9xNSjGwMj2 eBWtTSxtvgydFrC3kE5hapT4I5dBkHvrVyrHgAkRqtixPbH5P44Qxh/mv6GOKIf3LH6S BlM/fc7asHHJjROmyKcAAdRsA2FD3TQG5QPSlEmyDeepxcqLmliVP4vLg7Zh0FScmssY iUVQ== X-Gm-Message-State: AOJu0YzlrmZupF4dtXDT8UViRL/SXfCpAl5wEPUBxj2gDMULJW/3wRGl pBq9gmh8lzOcdzxYJUHuiYOsbYPQCazQhqyBOO3dZV789vKFPzudcFezYw== X-Google-Smtp-Source: AGHT+IHyaiesgBvSauoqJopA+KfuKdvWgQczDiZFK3dkKKP4aABxeZWo5AsQbSLXy4NMxVGng2gPzw== X-Received: by 2002:a05:6214:398c:b0:6c5:50bb:d59d with SMTP id 6a1803df08f44-6c7bc7ec5a4mr222240406d6.37.1727179513400; Tue, 24 Sep 2024 05:05:13 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6cb0f4a6178sm5948056d6.7.2024.09.24.05.05.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Sep 2024 05:05:12 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 14/16] auto-t: update utils to use DeviceProvisioningAgent Date: Tue, 24 Sep 2024 05:04:45 -0700 Message-Id: <20240924120447.251761-14-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240924120447.251761-1-prestwoj@gmail.com> References: <20240924120447.251761-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 --- autotests/util/iwd.py | 48 ++++++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 12 deletions(-) diff --git a/autotests/util/iwd.py b/autotests/util/iwd.py index 83f2d9ef..262afe52 100755 --- a/autotests/util/iwd.py +++ b/autotests/util/iwd.py @@ -43,7 +43,7 @@ IWD_P2P_WFD_INTERFACE = 'net.connman.iwd.p2p.Display' IWD_STATION_DEBUG_INTERFACE = 'net.connman.iwd.StationDebug' IWD_DPP_INTERFACE = 'net.connman.iwd.DeviceProvisioning' IWD_DPP_PKEX_INTERFACE = 'net.connman.iwd.SharedCodeDeviceProvisioning' -IWD_SHARED_CODE_AGENT_INTERFACE = 'net.connman.iwd.SharedCodeAgent' +IWD_DPP_AGENT_INTERFACE = 'net.connman.iwd.DeviceProvisioningAgent' IWD_AGENT_MANAGER_PATH = '/net/connman/iwd' IWD_TOP_LEVEL_PATH = '/' @@ -214,31 +214,32 @@ class SignalAgent(dbus.service.Object): def handle_new_level(self, path, level): pass -class SharedCodeAgent(dbus.service.Object): +class DeviceProvisioningAgent(dbus.service.Object): def __init__(self, codes = {}): self._path = '/test/agent/' + str(int(round(time.time() * 1000))) self._codes = codes + self._bus = dbus.bus.BusConnection(address_or_type=ctx.dbus_address) - dbus.service.Object.__init__(self, ctx.get_bus(), self._path) + dbus.service.Object.__init__(self, self._bus, self._path) @property def path(self): return self._path - @dbus.service.method(IWD_SHARED_CODE_AGENT_INTERFACE, + @dbus.service.method(IWD_DPP_AGENT_INTERFACE, in_signature='', out_signature='') def Release(self): - print("SharedCodeAgent released") + print("DeviceProvisioningAgent released") - @dbus.service.method(IWD_SHARED_CODE_AGENT_INTERFACE, + @dbus.service.method(IWD_DPP_AGENT_INTERFACE, in_signature='s', out_signature='') - def Cancel(self, reason): - print("SharedCodeAgent canceled (%s)" % reason) + def CancelSharedCode(self, reason): + print("DeviceProvisioningAgent canceled (%s)" % reason) - @dbus.service.method(IWD_SHARED_CODE_AGENT_INTERFACE, + @dbus.service.method(IWD_DPP_AGENT_INTERFACE, in_signature='s', out_signature='s') def RequestSharedCode(self, identifier): - print("SharedCodeAgent request for %s" % identifier) + print("DeviceProvisioningAgent request for %s" % identifier) code = self._codes.get(identifier, None) if not code: @@ -352,8 +353,8 @@ class SharedCodeDeviceProvisioning(IWDDBusAbstract): self._iface.StartEnrollee(args) - def start_configurator(self, path): - self._iface.StartConfigurator(dbus.ObjectPath(path)) + def start_configurator(self): + self._iface.StartConfigurator() def configure_enrollee(self, code, identifier=None): args = { @@ -1572,6 +1573,29 @@ class IWD(AsyncOpAbstract): self._wait_for_async_op() self.psk_agents.remove(psk_agent) + def register_dpp_agent(self, dpp_agent): + iface = dbus.Interface(dpp_agent._bus.get_object(IWD_SERVICE, + IWD_AGENT_MANAGER_PATH), + IWD_AGENT_MANAGER_INTERFACE) + iface.RegisterDeviceProvisioningAgent(dpp_agent.path, + dbus_interface=IWD_AGENT_MANAGER_INTERFACE, + reply_handler=self._success, + error_handler=self._failure) + + self._wait_for_async_op() + self.dpp_agent = dpp_agent + + def unregister_dpp_agent(self, dpp_agent): + iface = dbus.Interface(dpp_agent._bus.get_object(IWD_SERVICE, + IWD_AGENT_MANAGER_PATH), + IWD_AGENT_MANAGER_INTERFACE) + iface.UnregisterDeviceProvisioningAgent(dpp_agent.path, + dbus_interface=IWD_AGENT_MANAGER_INTERFACE, + reply_handler=self._success, + error_handler=self._failure) + self._wait_for_async_op() + self.dpp_agent = None + @staticmethod def get_instance(): return IWD._default_instance() From patchwork Tue Sep 24 12:04:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13810874 Received: from mail-qk1-f181.google.com (mail-qk1-f181.google.com [209.85.222.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1E2EA1A3AB7 for ; Tue, 24 Sep 2024 12:05:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727179517; cv=none; b=pgSnuop/xqmEHFNcs+r411+oPS3u9K88lg31et4R/O8q2L7wKNeRUA+9b2fKfWF0HWttCgjLVWYm18WTfpGC1cg5fJDEXSi1vlS4fi3ZjhdsyiKUx+PK+Vb+0qkhQI8yb9OT9COXIz/OYRaKzqHeHJnL6Y1xWOfQ14tYuT6OO9M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727179517; c=relaxed/simple; bh=osg9DviIC5Z0rbnSVMr5v4fmRBpfZcIg9/+qSJY/fp4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=MOKj1OZbwzYUgcbfF1ZI5H9JXrEOS6Q69bpnE5lzqGnaIvefhdP3u0K99qjjZp4vJ3www2MY6V26gb6YizdGP7RTXpE4vlDQPTOraEN3PsZIeHEVYYkVDBHHgbCxFBxh5nB/P3gphp0GCWJmH3MuuVwdmW4vSYSmVBRganoLuCA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=gMUilmUC; arc=none smtp.client-ip=209.85.222.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gMUilmUC" Received: by mail-qk1-f181.google.com with SMTP id af79cd13be357-7a9a30a045cso517418385a.2 for ; Tue, 24 Sep 2024 05:05:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727179515; x=1727784315; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2KwLQ8lGs2AMHlshY9fQ1ypZampfp5fCrE1DHaIDeog=; b=gMUilmUCahFDwKnx+Q+eC1MqTyRNMWjcjRRuK0Rtco0A729ditvvwV5j8er4fCNFwk 257Red16A0mqO6uNHr+nkv0nNHd9yI07QqG4M3UpO1AyUlHc38JXr0hZNom0NPnscF5b 4M5gPQUXT+Dcbgbh4addwZJJFLzcy5FdrAnKPuSwuqbMSd8scKspdK2vEvqGnPFELgyT pa2CQGZIwXKzkg/0UK7d2EScP5nByt0GhgzdbTW9uBtlqEk6HwqRSin0fr5DpBhWTyrM 6BLMTpn3iuqray4Qc56EwyEIMH3EUSf8MIqGzXAMXDVsXXZJKd+aLzLVjgiTjbSF5ZKw wB5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727179515; x=1727784315; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2KwLQ8lGs2AMHlshY9fQ1ypZampfp5fCrE1DHaIDeog=; b=p/WA39Qta3hGk7Z1bMjPk5dde89W01HtOfqLNZ1UrrSqkfg8yzYviIgo2tnbvoI6w7 j3KobMTTUkhCH5yzO07UZpNtE4nPw1ZvFTeLOVp6ErdJkjGlQWuU9akWBs/NBe/+L/ho 7CrU7WvweCiH20HQrS/8/LwokQV1RsXJwQKcQDwHJh4x4xD/AlZkSO5knReIX/VcjZUy wxzBICjdE2HbyK/jWQB/rHLzp42Z7mU2DbJUZ4Po2mWxehss/xyXj1TT/z0+z02pY9at IFzIQ5tRv9M1q2j6wT92fbN72RoAWt5LR9NkVDJYpjqYCbhiKv7FZaLS7KPQfzREfDH2 UimA== X-Gm-Message-State: AOJu0Yybmy/MakXMEafWhmx/DOcwWq/wiwf7Hlhy8J8O52tOI5s1M1sd TUrIwSKRRO3xNTaTIs0tZd+oJj+HlsXasPJpqFlWgCGI5lHYH8NaZaxWag== X-Google-Smtp-Source: AGHT+IEd51YjkmscShfZlfAFVsIkLXW+w7xMW2AnKD2EQCZoqp9d6/Lfsz7tEGYBhyS0xvePaY16nw== X-Received: by 2002:a05:6214:540e:b0:6c9:e8f8:4a71 with SMTP id 6a1803df08f44-6c9e8f84a91mr51068926d6.51.1727179514929; Tue, 24 Sep 2024 05:05:14 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6cb0f4a6178sm5948056d6.7.2024.09.24.05.05.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Sep 2024 05:05:14 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 15/16] auto-t: update PKEX test to use DeviceProvisioningAgent Date: Tue, 24 Sep 2024 05:04:46 -0700 Message-Id: <20240924120447.251761-15-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240924120447.251761-1-prestwoj@gmail.com> References: <20240924120447.251761-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This also removes the unused import of the old SharedCodeAgent object from the state change test --- autotests/testDPP/pkex_test.py | 7 ++++--- autotests/testDPP/state_change_test.py | 8 +------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/autotests/testDPP/pkex_test.py b/autotests/testDPP/pkex_test.py index a651c6f6..62172785 100644 --- a/autotests/testDPP/pkex_test.py +++ b/autotests/testDPP/pkex_test.py @@ -4,7 +4,7 @@ import unittest import sys sys.path.append('../util') -from iwd import IWD, SharedCodeAgent, DeviceState +from iwd import IWD, DeviceProvisioningAgent, DeviceState from iwd import DeviceProvisioning from wpas import Wpas from hostapd import HostapdCLI @@ -37,9 +37,10 @@ class Test(unittest.TestCase): self.wd.wait_for_object_condition(device, condition) if agent: - self.agent = SharedCodeAgent(codes = {"test": "secret123"}) + agent = DeviceProvisioningAgent(codes = {"test": "secret123"}) + self.wd.register_dpp_agent(agent) - device.dpp_pkex_start_configurator(self.agent.path) + device.dpp_pkex_start_configurator() else: device.dpp_pkex_configure_enrollee('secret123', identifier="test") diff --git a/autotests/testDPP/state_change_test.py b/autotests/testDPP/state_change_test.py index d52f2b12..f1ac7d5e 100644 --- a/autotests/testDPP/state_change_test.py +++ b/autotests/testDPP/state_change_test.py @@ -4,14 +4,8 @@ import unittest import sys sys.path.append('../util') -from iwd import IWD, SharedCodeAgent, DeviceState -from iwd import DeviceProvisioning -from wpas import Wpas +from iwd import IWD from hostapd import HostapdCLI -from hwsim import Hwsim -from config import ctx -from time import time -import os class Test(unittest.TestCase): def auto_connect(self): From patchwork Tue Sep 24 12:04:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13810875 Received: from mail-qv1-f49.google.com (mail-qv1-f49.google.com [209.85.219.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C61741A707A for ; Tue, 24 Sep 2024 12:05:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727179519; cv=none; b=kkOnfqXKaETh2FGj7dnryuCd+V6etEZtnGSegEB2gvkfryGwSVCRQ9Jrp/4ST77VJA2fByHaA6cHhgQSTn2uD17bafb+xgtlcA3bgOMZanYj51FQ7Enwdi0qLHo+eqLw4Xefa2BJOQo3nqA32jg4W9axfm4zY52+XDAvzBQjPJY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727179519; c=relaxed/simple; bh=WOPDNNUeD5sCrU2Gh20UEoMhHmD+a9gE6O2j8NUGbfc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sbAZaawKP3JBRX1NzrAmMG6/LZqJN4pPTewlwXzrGJ1uapv025pChVGY7ZuUqSzuRUGBZXnvQsTG1BkwgiPVbnTVDXzYHg0qGXqt/So8EC1dE90oMXrm7/0jlmUZN2by35tILGP5iR32UGD32W/SUGXN/CeX5Wuq7DP0dk3knCs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=mpNN3QAI; arc=none smtp.client-ip=209.85.219.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mpNN3QAI" Received: by mail-qv1-f49.google.com with SMTP id 6a1803df08f44-6c35357cdacso37030006d6.0 for ; Tue, 24 Sep 2024 05:05:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727179516; x=1727784316; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gViNHPHf5IcyhfwjY8yBkY0iMYvg67DYXX0wC5m06Ko=; b=mpNN3QAIgKZdJn0v2+lLtJvCbXMwotTLgjzav117iL3FRCYcasmAmxjRSVrkJALg7u 71Ca2ZVrH6cTRZUpSrr8YjjDpAukaOj+AqA4RWroRIDr0y+x2pLYkU+k18THUU48gq+G DH1QzSiwacN2JtKvhJ93UIUYf+9cFad6bBl0k++CbjE7A1CRRm6TOHccM6SN/sWXUAN1 QW5NMbrG52VSnKDLpArMKzVDO0794df6Mxtn6WQLniQvhbkgo38Amx/Z4uL0/M6hCuWp ADN8jdGLFonX4/pKyn60pvcdWsRU5nlhJeofMHTbO/1adsVNvayoStekg6oxg6/E4XAL eQ9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727179516; x=1727784316; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gViNHPHf5IcyhfwjY8yBkY0iMYvg67DYXX0wC5m06Ko=; b=qEClHMJPHTH1FIOsnS71FNrDmmgw4TcGUGaIZY0L8KZ5P4Leg7P4/ajO5mLtptNy0+ PtqqwSLDRD8RYXuFzL8fe0MOHLfgsZGgVN7Oe4ZiOGTCXCkI689CkSbVWXlpvpCVtjVg lwV+eBJ1wxH6X3FqqeANsLlExcj7bynCCV/iI2Y4h9TeuS7ry27ZU6tTPWg+5N7bOKhQ WpHAIa0KMLmjX/88YnghV4LlsocndXOK7L30frlnYtpPW/K+KRem9USCK7zWlsKPBffQ d7RA28qRXT5aPGSIwSzacOhNabZ4q5B06cs+MDrDGRg5WprVbfWIKPVFqJlfsixEBzLf htRg== X-Gm-Message-State: AOJu0YxfHFOalTn3vVDleHnKrXd4iC56PLlm8WxkGvOvRxErfM8J4zD/ Cpe1HTi3IPI9m7zcRtJpWLxdXT5utf9dz0y7uwOZX5bgB4RseLAYb7Awug== X-Google-Smtp-Source: AGHT+IH27xoawgey6waMsCDnvvypGttcgauiBZP5/S/4/klEB7wPl4V0MoG3cjxYSNY0kb6l3ZWb7w== X-Received: by 2002:a05:6214:3990:b0:6c3:5dcf:bf5a with SMTP id 6a1803df08f44-6c7bd5e2475mr234001206d6.37.1727179516294; Tue, 24 Sep 2024 05:05:16 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6cb0f4a6178sm5948056d6.7.2024.09.24.05.05.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Sep 2024 05:05:15 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 16/16] doc: Document new DeviceProvisioningAgent Date: Tue, 24 Sep 2024 05:04:47 -0700 Message-Id: <20240924120447.251761-16-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240924120447.251761-1-prestwoj@gmail.com> References: <20240924120447.251761-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This moves the SharedCodeAgent docs into the AgentManager interface and renames it to DeviceProvisioningAgent. The agent path parameter was also removed from the StartConfigurator() method. --- doc/agent-api.txt | 56 +++++++++++++++++++++++++++++++++ doc/device-provisioning-api.txt | 48 ++++------------------------ 2 files changed, 62 insertions(+), 42 deletions(-) diff --git a/doc/agent-api.txt b/doc/agent-api.txt index e9bb95ca..1cc7eafe 100644 --- a/doc/agent-api.txt +++ b/doc/agent-api.txt @@ -67,6 +67,31 @@ Methods void RegisterAgent(object path) [service].NotFound [service].NotAvailable + void RegisterDeviceProvisioningAgent(object path) + + Register an agent for handling Device Provisioning (DPP) + specific requests. + + This includes: + - Requests for shared codes when using shared code + device provisioning. + - Requests for certificate signing requests + - Requests to send a certificate signing request + + The details of these are explained in the DBus method + docs below for the + net.connman.iwd.DeviceProvisioningAgent interface. + + + Possible Errors: [service].InvalidArguments + [service].AlreadyExists + + void UnregisterDeviceProvisioningAgent(object path) + + Unregisters an existing Device Provisioning agent + + Possible Errors: [service].InvalidArguments + [service].NotFound Agent hierarchy =============== @@ -263,3 +288,34 @@ Methods void Release() [noreply] void CancelIPv6(object device, string reason) [noreply] Same as CancelIPv4 above but for IPv6. + +DeviceProvisioningAgent hierarchy +================================= + +Service unique name +Interface net.connman.iwd.DeviceProvisioningAgent [Experimental] +Object path freely definable + +Methods void Release() [noreply] + + This method gets called when the service daemon + unregisteres the agent + + void CancelSharedCode(string reason) [noreply] + + This method gets called to indicate that the agent + request for a shared code failed before a reply was + returned. The argument will indicate why the request is + being cancelled and may be "user-canceled", "timed-out" + or "shutdown". + + string RequestSharedCode(string identifier) + + This method gets called when a shared code is requested + for a particular enrollee, distingushed by the + identifier. The shared code agent should lookup the + identifier and return the shared code, or return an + error if not found. + + Possible Errors: [service].Error.Canceled + [service].Error.NotFound diff --git a/doc/device-provisioning-api.txt b/doc/device-provisioning-api.txt index 6cf16fb8..37d8f67e 100644 --- a/doc/device-provisioning-api.txt +++ b/doc/device-provisioning-api.txt @@ -132,14 +132,13 @@ Object path /net/connman/iwd/{phy0,phy1,...}/{1,2,...} Possible errors: net.connman.iwd.Busy net.connman.iwd.InvalidArguments - void StartConfigurator(object agent_path) + void StartConfigurator(void) - Start a shared code configurator using an agent - (distingushed by 'agent_path') to obtain the shared - code. This method is meant for an automated use case - where a configurator is capable of configuring multiple - enrollees, and distinguishing between them by their - identifier. + Start a shared code configurator which depends on an + agent (registered via AgentManager). This method is + meant for an automated use case where a configurator is + capable of configuring multiple enrollees, and + distinguishing between them by their identifier. If the agent service disappears during the shared code exchange it will be stopped, and the protocol will fail. @@ -180,38 +179,3 @@ Properties boolean Started [readonly] Indicates the DPP role. Possible values are "enrollee" or "configurator". This property is only available when Started is true. - -SharedCodeAgent hierarchy -========================= - -Service unique name -Interface net.connman.iwd.SharedCodeAgent [Experimental] -Object path freely definable - -Methods void Release() [noreply] - - This method gets called when the service daemon - unregisters the agent. - - string RequestSharedCode(string identifier) - - This method gets called when a shared code is requested - for a particular enrollee, distingushed by the - identifier. The shared code agent should lookup the - identifier and return the shared code, or return an - error if not found. - - Possible Errors: [service].Error.Canceled - [service].Error.NotFound - - void Cancel(string reason) [noreply] - - This method gets called to indicate that the agent - request failed before a reply was returned. The - argument will indicate why the request is being - cancelled and may be "user-canceled", "timed-out" or - "shutdown". - -Examples Requesting a shared code for an enrollee identified by "foo" - - RequestSharedCode("foo") ==> "super_secret_code"