From patchwork Sat Nov 23 09:05:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivaylo Dimitrov X-Patchwork-Id: 13883808 Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.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 18EDB257D for ; Sat, 23 Nov 2024 09:05:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732352756; cv=none; b=FJmYUKh2Mjvj3ENXKgzrEaZlRP87J6/tSzMKqw7f99AtKc5Iu2xcq+RPAgUtHkttOjlxFdrN/QBebRljP3ICUVbKewWGVUHgRQTjXJN0QMFJdI7YiaBXg6qc05cCR4qNpH0cZNgAzB0NHtsioWV5NDYCJyeOq+fIGd9DzcArIAQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732352756; c=relaxed/simple; bh=FE3vaLyR+bwcI5mdQ6s/4bkG/0dX9Q02jOnFYfd4nD8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=cJCwo7I88cOFJRLDACB3LtUqSojWgRhNEaAPZswLDJFHqyRYciWVsYaelq/Tktn/prelF7CpzeN8S/UpE+Dvm6ySxGWL42dR5fsMw0vLoXEMP/tgcWZwwsDG40yW8JQxfzF3vlQ1ncHTne/A4pdW25iD74DLio34nOh9MkjR86U= 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=RzqFwDZT; arc=none smtp.client-ip=209.85.221.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="RzqFwDZT" Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-382411ea5eeso1646429f8f.0 for ; Sat, 23 Nov 2024 01:05:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732352753; x=1732957553; darn=lists.linux.dev; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=4LPmm/l6a9crMPw4FV8MthZoupAGUct1pPBeunG65j8=; b=RzqFwDZTotkcHK3pss82VgV38soPp3wpf3EkwmEpmVrHg5jiWSGw7kLMWEiSid4K79 n+LuGOnVznp5wrwWcWy9fE/7tFv3lk6/q+F/55UbvqxN59bTBKYhH8NpC3to0xUv5J0a iOZvjIeTXmtFy8BXD8UCEBFQTEXaGOVnTYPu4XBVMgddfVQuBRLAghuhpH1cMGJUy3mn 0UFT3E9YFlHFQJOo7ktZQi8iOKwuPUa7UEpMoRvvNNZNwhyLWwo4T+7sa/CXEnBWxaIE Bo9NAoJZ/Wwfefj2fsuS54gATJObUbRD4ckkI6MqUs6vWjoruEkbaiBQewP47aoVUD+G Npyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732352753; x=1732957553; h=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=4LPmm/l6a9crMPw4FV8MthZoupAGUct1pPBeunG65j8=; b=RKNyWN8fKprRwcHI+4/oQE5c5txFop9UbbowE+62Aelv8aNP/6AvH4Q6YJzMEaMvvD 0t0/0jWmSwXvpAVlN6gp6oOissdCxpm/4RxrgxiXYPQJkVx/ROQMQRWYdzWcaNPLDQ6y DNqLHly6zhFczTYFUMf+SlMGKhdSLNglzeYmqsOsY809ZVAENOP/tRIJuwIUVfJnJmAX OF5szwWVZtjLiR+8C9BuvoenMdAQHvUP89zBz2k6L3g56+JGP3qXz7Bhijl3gbOz5H4f Apq7BhH3XjL4mApA8JVt8N5yWR7OgAax7Q7uZh8B+TpVCteqEq3T/Un7tKCoWnP9LesO 0n6A== X-Gm-Message-State: AOJu0YwNHkbF2RGKM4syQ8AJH01ps2NwDmnOpcV9hg4I1SlvZqmt8Nlo YjvuPOIyy9O3CQ9cLZB3KNi7Uc27kADZlOK7ACoutOqDtB358mQkbOe2NQ== X-Gm-Gg: ASbGncug2Pjt72zwLo3jQmD2c9QsXi832y6eTVcZozK7P5L3eZ7CbDDrAuMkpvLPZkn jty0zYCfZ4vPb5rioyMslRM1gBdVMWeg/Bky7/jcx+cm1z59R/lvzm5AqZtBQZuleYkHS0kRO7Q /XGiB0tLb08kJl7Uo9+mSZ8lh7mAJUPoCZzVmo/z+zeSAVT/83SjBMUEgQmUop+DQNrTYRz+DEe QWLRFcyRxlSyRP/RUDbbxcoagUg634AMfy8cm48tHIdtQueLCVj3d0dKaknpbI3Av0f X-Google-Smtp-Source: AGHT+IH4UPWYqh5ZfrJ+616aqzRmpz0Gki6lOcTeTtf4Bqph2fOaezaLs0xNOG3X1xS953GBbmM/ZQ== X-Received: by 2002:a05:6000:4025:b0:382:46d2:52b6 with SMTP id ffacd0b85a97d-38260072dc4mr5444040f8f.0.1732352753053; Sat, 23 Nov 2024 01:05:53 -0800 (PST) Received: from localhost.localdomain ([95.43.220.235]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3825fad658esm4782814f8f.8.2024.11.23.01.05.52 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 23 Nov 2024 01:05:52 -0800 (PST) From: Ivaylo Dimitrov To: ofono@lists.linux.dev Cc: denkenz@gmail.com, absicsz@gmail.com, merlijn@wizzup.org, Ivaylo Dimitrov Subject: [PATCH 1/4] qmi: sim: Implement query_facility_lock(LockedPins property) Date: Sat, 23 Nov 2024 11:05:32 +0200 Message-Id: <1732352735-31944-2-git-send-email-ivo.g.dimitrov.75@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1732352735-31944-1-git-send-email-ivo.g.dimitrov.75@gmail.com> References: <1732352735-31944-1-git-send-email-ivo.g.dimitrov.75@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: --- drivers/qmimodem/sim.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/drivers/qmimodem/sim.c b/drivers/qmimodem/sim.c index 1fffae2..a700f31 100644 --- a/drivers/qmimodem/sim.c +++ b/drivers/qmimodem/sim.c @@ -41,6 +41,8 @@ struct sim_status { uint8_t app_type; uint8_t passwd_state; int retries[OFONO_SIM_PASSWORD_INVALID]; + uint8_t pin1_state; + uint8_t pin2_state; }; struct sim_data { @@ -486,6 +488,9 @@ static bool get_card_status(const struct qmi_uim_slot_info *slot, break; } + sim_stat->pin1_state = info2->pin1_state; + sim_stat->pin2_state = info2->pin2_state; + sim_stat->retries[OFONO_SIM_PASSWORD_SIM_PIN] = info2->pin1_retries; sim_stat->retries[OFONO_SIM_PASSWORD_SIM_PUK] = info2->puk1_retries; @@ -752,6 +757,74 @@ error: l_free(cbd); } +static void query_locked_cb(struct qmi_result *result, void *user_data) +{ + struct cb_data *cbd = user_data; + ofono_query_facility_lock_cb_t cb = cbd->cb; + struct sim_status sim_stat; + uint8_t pin_state; + gboolean status; + + DBG(""); + + if (handle_get_card_status_result(result, &sim_stat) != + GET_CARD_STATUS_RESULT_OK) { + CALLBACK_WITH_FAILURE(cb, -1, cbd->data); + return; + } + + if (L_PTR_TO_UINT(cbd->user) == OFONO_SIM_PASSWORD_SIM_PIN) + pin_state = sim_stat.pin1_state; + else + pin_state = sim_stat.pin2_state; + + switch (pin_state) { + case 1: /* Enabled and not verified */ + case 2: /* Enabled and verified */ + status = TRUE; + break; + case 0: /* Unknown */ + case 3: /* Disabled */ + case 4: /* Blocked */ + case 5: /* Permanently blocked */ + default: + status = FALSE; + break; + } + + CALLBACK_WITH_SUCCESS(cb, status, cbd->data); +} + +static void qmi_query_locked(struct ofono_sim *sim, + enum ofono_sim_password_type passwd_type, + ofono_query_facility_lock_cb_t cb, void *user_data) +{ + struct sim_data *data = ofono_sim_get_data(sim); + struct cb_data *cbd = cb_data_new(cb, user_data); + + DBG(""); + + switch (passwd_type) { + case OFONO_SIM_PASSWORD_SIM_PIN: + case OFONO_SIM_PASSWORD_SIM_PIN2: + break; + default: + CALLBACK_WITH_CME_ERROR(cb, 4, -1, cbd->data); + l_free(cbd); + return; + } + + cbd->user = L_UINT_TO_PTR(passwd_type); + + if (qmi_service_send(data->uim, QMI_UIM_GET_CARD_STATUS, NULL, + query_locked_cb, cbd, cb_data_unref) > 0) + return; + + CALLBACK_WITH_FAILURE(cb, -1, cbd->data); + + l_free(cbd); +} + static void get_card_status_cb(struct qmi_result *result, void *user_data) { struct ofono_sim *sim = user_data; @@ -894,6 +967,7 @@ static const struct ofono_sim_driver driver = { .query_passwd_state = qmi_query_passwd_state, .query_pin_retries = qmi_query_pin_retries, .send_passwd = qmi_pin_send, + .query_facility_lock = qmi_query_locked, }; OFONO_ATOM_DRIVER_BUILTIN(sim, qmimodem, &driver) From patchwork Sat Nov 23 09:05:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivaylo Dimitrov X-Patchwork-Id: 13883809 Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) (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 CA869257D for ; Sat, 23 Nov 2024 09:05:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732352759; cv=none; b=X9llOBXckpFigsYUo3SJzgUiHm787gys9vyVMdkbi+LcSnYbUmu1hejXww8GlCp5UBYn7dvaZ4yHlbtEMJoDGmjF4Ll5SR11C7x/IvOmPFqlBQZQRogg+pfbCrNSXzdnVKg2NF5f1GSPG2JvrV0IZiGvF/weRt3MORk0Chd57y4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732352759; c=relaxed/simple; bh=SOp+m3G6yP2iu9WujcqytDloyhyAF7KXT9xNr42cMww=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=jMT5bGJE9o/olgEfThYUJpLC/dd/PA6sIjpw2bNhWuUzif+nNlDursTIP32ZjmUPvt+jLysi/EQ+SP8gkzFHJRi2VuAk5pEmHLttgsA9WULa9H/UocN4KrhsHTM9ZcdQJPdZ3tulN0mXF6Dy/KrHWpBVRkaLJFGKk6Ly2ZbRTrg= 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=lLnNBCrQ; arc=none smtp.client-ip=209.85.221.51 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="lLnNBCrQ" Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-382378f359dso1965695f8f.1 for ; Sat, 23 Nov 2024 01:05:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732352756; x=1732957556; darn=lists.linux.dev; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=WFRi8guJPa9M3nipkID+QHkHmVAs4s32oYXTFsp2AxM=; b=lLnNBCrQCCZ/ydLgjBf4PqLx7/zXgTSM05SKpAo3dsME8uyKklsBkwoJaTuud3SHWu APZygDLEEXgH55xkTwiUtfm3ozBPayzjtvIo01VXtfOk5ZBkEcDgIUAotDVL4MqIo2KL n8X7zaszNxGPt9+mEze8uIe0P+vWCmbLW0z8vkaeApP0AVxYdkZDkBKvE/hqaMi1nEAf AdH+3BmpYOyDu0gEvZupmg8CJF9gQU4x2m/epKU7Nk3tieO6SBnAyjj5d37IBETFW4Zk HcOxuwyGhNKEx2/M7jon+VAv9ZTPMrWVfD+z4a2oREoLHmKiApvYXFicbQ/UjGgrxNnp h6bQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732352756; x=1732957556; h=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=WFRi8guJPa9M3nipkID+QHkHmVAs4s32oYXTFsp2AxM=; b=wKPMdsjXa47Z92X/p+KHbbQT/KMJ+zVergFIZZOwVRjPDM1eO8ApfgbT0h3crrXmw5 l7+jnJ5MeOUy8gRbEs63AptRVc8QvlA75NaXDUOD/9GiUE2OGc/BywI/VDTaPutWiPoX i5qYxvTW6dvbFLcLNsDyjJmczJSl7s8giF+DzCZsz5EnErzqLyVK2h4EY3wWZOXSqZD1 Bf4x43DTAdghdBlIAaeK0dG3VEbxfSKqp+h1o7jKoxU/Jc1Gp6u1xHZwho/zX1fpurT8 uXiibkkJVA1is0PAuSqNPlCbw35NCFdxzTZHQnDojRq7ddCy80U+VeJBZi1v9G70elc/ H2sQ== X-Gm-Message-State: AOJu0Yy7IhWqIcEu9lD32wTWIaJZmCURbcLb2DkPqeC2D5+IrC6FIqxU c5kc20M+haLqiJ93JrdWtWpps76Qhyfiuti4u6MCYwlgT0yT26e+12iRsA== X-Gm-Gg: ASbGncttGpgDLdD9ooRjILo5wf7gq+VZTYqTroiQA4FRzTyBIQUK+XjTRo4xJRbxxyv RmRG1lCW+4ShTiTD/ueruNUyej09utohH63W6LlxvJXgQCJQcOKLVeXgZI8ShCEgBQMv8qSrHCk KEm0NaAX2XUyNPJUYQfZtl5lhXE4mK7rXAw1hYNqKceQlsbz6xPRZj/VbqUbS/UzOvB4NxJwXi0 ajAc0u+zEiUi0je1IPpZRI1V4wC/AwYTmWUaeDaSN7GrU8M7ARfdxLAmkWd0OJcjKtL X-Google-Smtp-Source: AGHT+IHzBqEl1M6wDn5WDGY7EnGpv7TJRP9wW+GXRBTj0gnt81kXa+CNHkh3idwsQ8LADs69pYD9OA== X-Received: by 2002:a05:6000:2c6:b0:382:43ee:9f70 with SMTP id ffacd0b85a97d-38260b73bf6mr4944202f8f.22.1732352756021; Sat, 23 Nov 2024 01:05:56 -0800 (PST) Received: from localhost.localdomain ([95.43.220.235]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3825fad658esm4782814f8f.8.2024.11.23.01.05.55 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 23 Nov 2024 01:05:55 -0800 (PST) From: Ivaylo Dimitrov To: ofono@lists.linux.dev Cc: denkenz@gmail.com, absicsz@gmail.com, merlijn@wizzup.org, Ivaylo Dimitrov Subject: [PATCH 2/4] qmi: sim: use struct/enum for session type when sending pin Date: Sat, 23 Nov 2024 11:05:33 +0200 Message-Id: <1732352735-31944-3-git-send-email-ivo.g.dimitrov.75@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1732352735-31944-1-git-send-email-ivo.g.dimitrov.75@gmail.com> References: <1732352735-31944-1-git-send-email-ivo.g.dimitrov.75@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: drop unnecessary passwd checks in qmi_pin_send() while at it drop struct qmi_uim_param_message_info as well --- drivers/qmimodem/sim.c | 40 ++++++++++++++++++---------------------- drivers/qmimodem/uim.h | 36 ++++++++++++++++++++++++++++++------ 2 files changed, 48 insertions(+), 28 deletions(-) diff --git a/drivers/qmimodem/sim.c b/drivers/qmimodem/sim.c index a700f31..724a3d3 100644 --- a/drivers/qmimodem/sim.c +++ b/drivers/qmimodem/sim.c @@ -718,33 +718,30 @@ static void qmi_pin_send(struct ofono_sim *sim, const char *passwd, struct cb_data *cbd = cb_data_new(cb, user_data); int passwd_len; struct qmi_param *param; - struct qmi_uim_param_message_info *info_data; - unsigned char session_info_data[2]; + struct qmi_uim_param_session_info session; + struct { + uint8_t id; + uint8_t length; + uint8_t pin[0]; + } __attribute__((__packed__)) *info; DBG(""); - if (!passwd) - goto error; - passwd_len = strlen(passwd); - - if (passwd_len <= 0 || passwd_len > 0xFF) - goto error; - param = qmi_param_new(); - /* param info */ - info_data = alloca(2 + passwd_len); - info_data->pin_id = 0x01; /* PIN 1 */ - info_data->length = (uint8_t) passwd_len; - memcpy(info_data->pin_value, passwd, passwd_len); - qmi_param_append(param, QMI_UIM_PARAM_MESSAGE_INFO, 2 + passwd_len, - info_data); - /* param Session Information */ - session_info_data[0] = 0x6; - session_info_data[1] = 0x0; - qmi_param_append(param, QMI_UIM_PARAM_MESSAGE_SESSION_INFO, 2, - session_info_data); + /* info */ + info = alloca(sizeof(*info) + passwd_len); + info->id = 0x01; /* PIN 1 */ + info->length = (uint8_t) passwd_len; + memcpy(info->pin, passwd, passwd_len); + qmi_param_append(param, QMI_UIM_PARAM_MESSAGE_INFO, + sizeof(*info) + passwd_len, info); + /* session */ + session.type = QMI_UIM_SESSION_TYPE_CS1; + session.aid_length = 0; + qmi_param_append(param, QMI_UIM_PARAM_MESSAGE_SESSION_INFO, + sizeof(session), &session); if (qmi_service_send(data->uim, QMI_UIM_VERIFY_PIN, param, pin_send_cb, cbd, l_free) > 0) @@ -752,7 +749,6 @@ static void qmi_pin_send(struct ofono_sim *sim, const char *passwd, qmi_param_free(param); -error: CALLBACK_WITH_FAILURE(cb, cbd->data); l_free(cbd); } diff --git a/drivers/qmimodem/uim.h b/drivers/qmimodem/uim.h index 439e25b..92cd963 100644 --- a/drivers/qmimodem/uim.h +++ b/drivers/qmimodem/uim.h @@ -80,11 +80,35 @@ struct qmi_uim_file_attributes { uint8_t raw_value[0]; } __attribute__((__packed__)); -/* Verify PIN parameter */ #define QMI_UIM_PARAM_MESSAGE_SESSION_INFO 0x01 -#define QMI_UIM_PARAM_MESSAGE_INFO 0x02 -struct qmi_uim_param_message_info { - uint8_t pin_id; - uint8_t length; - uint8_t pin_value[0]; + +enum qmi_uim_session_type { + /* Primary GW Provisioning */ + QMI_UIM_SESSION_TYPE_PGWP = 0x00, + /* Primary 1X Provisioning */ + QMI_UIM_SESSION_TYPE_P1XP = 0x01, + /* Secondary GW Provisioning */ + QMI_UIM_SESSION_TYPE_SGWP = 0x02, + /* Secondary 1X Provisioning */ + QMI_UIM_SESSION_TYPE_S1XP = 0x03, + /* NonProvisioning on Slot 1 */ + QMI_UIM_SESSION_TYPE_NPS1 = 0x04, + /* NonProvisioning on Slot 2 */ + QMI_UIM_SESSION_TYPE_NPS2 = 0x05, + /* Card on Slot 1 */ + QMI_UIM_SESSION_TYPE_CS1 = 0x06, + /* Card on Slot 2 */ + QMI_UIM_SESSION_TYPE_CS2 = 0x07, + /* Logical Channel on Slot 1 */ + QMI_UIM_SESSION_TYPE_LCS1 = 0x08, + /* Logical Channel on Slot 2 */ + QMI_UIM_SESSION_TYPE_LCS2 = 0x09 +}; + +struct qmi_uim_param_session_info { + uint8_t type; + uint8_t aid_length; + uint8_t aid[0]; } __attribute__((__packed__)); + +#define QMI_UIM_PARAM_MESSAGE_INFO 0x02 From patchwork Sat Nov 23 09:05:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivaylo Dimitrov X-Patchwork-Id: 13883810 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.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 B0A77257D for ; Sat, 23 Nov 2024 09:05:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732352761; cv=none; b=W7HpMGMUbQFmbBhiyNy9EgdptJVPS095ZASM377mo+w9gsDFfKv1jCL9CIaXJbhrF8ZFdxPOEgK+h/qTFdLsUAqGrymAmfca3dOJRzcRO4xOB6YQkUJnEgO2I+vJ4BAgyeogJ/0Z6WaJQWaJVRVzbCDRKfh0FiEkXL/82V1VDRo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732352761; c=relaxed/simple; bh=OEoCajIp62h0SOdaZUMYvcl+GqqIOJK+7QMsPmAOZiU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=Fvk69Axf8Mwad2qaJM8gxSag+D5ktXo6NFX+jeqTdRnXCYr7JlGulvD4K86niD2ivW4UT4y6u2DAa+kjMYRAb/Ydl1vPGA+sLrOkIrUcYXzOGYOmVyhOpGQT8PerDBAAYF/OcehTvgfSPUTPGyYvgLF84glLRY1YizadEydC34I= 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=MbJfULHT; arc=none smtp.client-ip=209.85.128.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="MbJfULHT" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-4315839a7c9so26847085e9.3 for ; Sat, 23 Nov 2024 01:05:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732352758; x=1732957558; darn=lists.linux.dev; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=/N2yFMzV3JbmMVYsR7Eh2ElkXw/5CKT3FL1WygMokDk=; b=MbJfULHTsZmzbEk96TWHOXPtAlIWTZKBZOUY+AN71f3j8pWeIWW/4Jf9I4jW+i6kGK zplnrOd1Yp6JAhgox+CkjsGKgydmb75n2kDgYS6pnWd972F24ECPQ1RpPujSAS7r+xpY uoSsfYf5JzmO10caTV5eDFWCFODfogqWJ2j+i/Us0ExgQ0idaPY+gsOzvUeMF1N3E2lo dFpx4dDY2NFtuYUux3xILG/TEZyOxsT8EOIdbCjlqB2NNFSHJg18yTU+NEz4UasSwQCM DS9q3uOb1Gqxienw+Y9TnMNj/awfcougBXQgbEO/xrRbT7eXz8WbITGYKv8j9317xHa1 dNFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732352758; x=1732957558; h=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=/N2yFMzV3JbmMVYsR7Eh2ElkXw/5CKT3FL1WygMokDk=; b=WzEvSh6/v/CixZx+PKzcaVuAsLB3i6pwGqqWZA4vytrK23ifFbfp/9cs85FJnodIog U59g3ez4WX5IX1P2x4gDJadSs0dyuqX49kNJM9iy/NBlg0HvUYPSivJ3XcfXLFI6ovGd KOB0BS0PqsViHqn5UzH5Ou2OZ0crP9LGKgXee8PD55Y3NGKLROetunzvANlgIXERC6J6 OZ/EqXe8pwRl/5tgkg5ZwQSrq4mbok8ti7kbnwRAGCfIU3hUDiJpqefKnagKNE7G15FO efQEOj0/ssKTeJMM0hihFfW7dpmd/xbkNaemHRm2FWx+2XgEiUc9JCsv2DfUYBW9A8Z0 C1uw== X-Gm-Message-State: AOJu0YyBwiGk+j9D+dgV19j/xiWBbp3zBejhwWWYLP3NwQuTZZLEx4r2 /1ih9EfNvpD8/4atBrbeqg/3T3/nCEDcvsxoY1ngb6eHmkCAtkkBviJlPQ== X-Gm-Gg: ASbGncsyirgOTZxd8yhXvcOjd4BL4wHiINRX23slxC4fT/006zCfoizZ/z2u7l10OgM XFVPm84ZghC8mhc8MAnuXrZNRZRosGVhjTOolejSPE3YHcfMfpO/beckF2/GpIjrxs1/iiRMmtG uAxIB4XXRJKl/KvfHkcr8HPH23+4PGVBTKXKwKmSJWvx9tf6UBaRyM/wv7fC+exG3idDV6GnwIK 9hHuUUBwPNhwEzXHpBUWv+NlSlRj9143dehY2v17vzqKm/EwdveL6ueNR9TU2lVVboZ X-Google-Smtp-Source: AGHT+IFoZQpnaP1lpgMirtWeS3UShtKhd9SBCO6ULw+6JPPkfnJCebKQiayuIsnRaG64y/sXbEOuIQ== X-Received: by 2002:a05:600c:34c3:b0:431:46fe:4cad with SMTP id 5b1f17b1804b1-433ce41c7acmr54698665e9.9.1732352757803; Sat, 23 Nov 2024 01:05:57 -0800 (PST) Received: from localhost.localdomain ([95.43.220.235]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3825fad658esm4782814f8f.8.2024.11.23.01.05.57 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 23 Nov 2024 01:05:57 -0800 (PST) From: Ivaylo Dimitrov To: ofono@lists.linux.dev Cc: denkenz@gmail.com, absicsz@gmail.com, merlijn@wizzup.org, Ivaylo Dimitrov Subject: [PATCH 3/4] qmi: sim: implement lock(LockPin method) Date: Sat, 23 Nov 2024 11:05:34 +0200 Message-Id: <1732352735-31944-4-git-send-email-ivo.g.dimitrov.75@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1732352735-31944-1-git-send-email-ivo.g.dimitrov.75@gmail.com> References: <1732352735-31944-1-git-send-email-ivo.g.dimitrov.75@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: --- drivers/qmimodem/sim.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++ drivers/qmimodem/uim.h | 1 + 2 files changed, 64 insertions(+) diff --git a/drivers/qmimodem/sim.c b/drivers/qmimodem/sim.c index 724a3d3..c980203 100644 --- a/drivers/qmimodem/sim.c +++ b/drivers/qmimodem/sim.c @@ -821,6 +821,68 @@ static void qmi_query_locked(struct ofono_sim *sim, l_free(cbd); } +static void qmi_lock(struct ofono_sim *sim, + enum ofono_sim_password_type passwd_type, + int enable, const char *passwd, + ofono_sim_lock_unlock_cb_t cb, void *user_data) +{ + struct sim_data *data = ofono_sim_get_data(sim); + struct cb_data *cbd = cb_data_new(cb, user_data); + int passwd_len; + uint16_t info_len; + uint8_t pin_id; + struct qmi_param *param; + struct qmi_uim_param_session_info session; + struct { + uint8_t id; + uint8_t enabled; + uint8_t length; + uint8_t pin[0]; + } __attribute__((__packed__)) *info; + + DBG(""); + + switch (passwd_type) { + case OFONO_SIM_PASSWORD_SIM_PIN: + pin_id = 0x01; + break; + case OFONO_SIM_PASSWORD_SIM_PIN2: + pin_id = 0x02; + break; + default: + CALLBACK_WITH_CME_ERROR(cb, 4, cbd->data); + return; + } + + passwd_len = strlen(passwd); + param = qmi_param_new(); + + /* info */ + info_len = sizeof(*info) + passwd_len; + info = alloca(info_len); + info->id = pin_id; + info->enabled = enable ? 0x01 : 0x00; + info->length = (uint8_t) passwd_len; + memcpy(info->pin, passwd, passwd_len); + + qmi_param_append(param, QMI_UIM_PARAM_MESSAGE_INFO, info_len, info); + + /* session */ + session.type = QMI_UIM_SESSION_TYPE_CS1; + session.aid_length = 0; + qmi_param_append(param, QMI_UIM_PARAM_MESSAGE_SESSION_INFO, + sizeof(session), &session); + + if (qmi_service_send(data->uim, QMI_UIM_ENABLE_PIN, param, + pin_send_cb, cbd, cb_data_unref) > 0) + return; + + qmi_param_free(param); + + CALLBACK_WITH_FAILURE(cb, cbd->data); + l_free(cbd); +} + static void get_card_status_cb(struct qmi_result *result, void *user_data) { struct ofono_sim *sim = user_data; @@ -964,6 +1026,7 @@ static const struct ofono_sim_driver driver = { .query_pin_retries = qmi_query_pin_retries, .send_passwd = qmi_pin_send, .query_facility_lock = qmi_query_locked, + .lock = qmi_lock, }; OFONO_ATOM_DRIVER_BUILTIN(sim, qmimodem, &driver) diff --git a/drivers/qmimodem/uim.h b/drivers/qmimodem/uim.h index 92cd963..95ba053 100644 --- a/drivers/qmimodem/uim.h +++ b/drivers/qmimodem/uim.h @@ -11,6 +11,7 @@ #define QMI_UIM_WRITE_RECORD 35 /* Write a record */ #define QMI_UIM_GET_FILE_ATTRIBUTES 36 /* Get file attributes */ +#define QMI_UIM_ENABLE_PIN 37 /* Set PIN protection */ #define QMI_UIM_VERIFY_PIN 38 /* Verify PIN */ #define QMI_UIM_EVENT_REGISTRATION 46 /* Register for indications */ From patchwork Sat Nov 23 09:05:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivaylo Dimitrov X-Patchwork-Id: 13883811 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (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 8AFBD183CB0 for ; Sat, 23 Nov 2024 09:06:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732352763; cv=none; b=OSjfpMoPB3H2gYKmWr8BHqC6kuDks3gpPk1IPdE73h8B6P06dLWePW+Z5eW7a/wu+G0u+CE7izgPIzDlznadnmdXT/8ptOIJNU3qRzWg+gsHD8ttKRIgGFxNZbEOVfWTaQblYLNEM9srypbPaGtfMRlBCiZzXKK8R4TIzezs4AE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732352763; c=relaxed/simple; bh=xeGRmOMMy4z8xw4ZtNWZjRJQSPZjF0cte0MinqiRDuI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=ZDpno+foFHbXnrQgRCYoagrAQme5eRUOEqCCFJn6dKrnwkc+B00mSkoO4eqks7UKkuM86fO4ybAeFgaEPyY6gs3htJjVh8W80MVCzDOA9oaARL/CSi73QMR33GVUjX0a1TfDmfXW9RtlGwqOtMeapGViND/BDPdsuDDS5cEHxls= 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=fxV7Bt6t; arc=none smtp.client-ip=209.85.221.47 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="fxV7Bt6t" Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-38246333e12so2755328f8f.1 for ; Sat, 23 Nov 2024 01:06:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732352760; x=1732957560; darn=lists.linux.dev; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=Pb4ZpXTmW3NcM7fGSsrkOz0WHJYbGoSkraQXA+E+CpI=; b=fxV7Bt6tqFG3NgNiJ3/Nr3hGE+mTEW16qB/8A+n1+CVsUopShOksVLtYvFWTOPBz9A pTMsRXNmfSM+2xovwMjux7B2q/GZx6EEy29+uHhHCiYa76ctHeOG6drwb3gucazgcM5S 6VHFrgNEqy5TSDVRZEyEuNiOWdQRxCxJimpsgJCXtGFAqhutfX1OCH7hHUtUAzAEZ0QR Ypq+0P8ZGOJeEr+4HDwkNkjlKCxQzLS37TKB3rI9CLa5pzqS4D3/6n3Qt7IbawvmYA/u LQJva5GRcU5pg7617DUAt9UWxJ7t9/+js4jxxiEYI9W25Zo7nlicYQOpFuuhNzQ1y4bO o4pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732352760; x=1732957560; h=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=Pb4ZpXTmW3NcM7fGSsrkOz0WHJYbGoSkraQXA+E+CpI=; b=usAz26fQuJyxYPWhuMdnr8iRU8W69MlnslYDoF/O9tAQjRsWpjda6uD7mH2cJT14ZO UKon4+WtozZuxG4uANl02LLbeKNJxQiJbnZRCdZPJR1kDh0qjRPeYIG1ru8DElaStPW8 65VS1R4jqQG/0EY95Ca3F2bnxD/G8zJRxrD4kEpirTZCALRy9iBaeCgGe66LXTPgFBeq MrT4/qpUWJwnPa4ALiF12sz0L+qFBRdl7rYaJq/KDm5VCLw2PiMqRpwZnxRtcgkhoq3v DD33oe9I3eg39r6Ttf0EfEtMP3NqNjKmMQecx0DagGRGA3gVwpRQtgSA1782z2+cLdZe lS/Q== X-Gm-Message-State: AOJu0Yw+OsOndW+3aiXShL9r2pizrwtPGG3hJeO4z4WK3F5AeH7WNhIn 2UZ7w5Q1VMVejeWqtnvTZk6osEgONBfdTpW79E21+rPJOvFdFLGY/WMBHg== X-Gm-Gg: ASbGncsP4c7feiULA0rNhcBK3L3iGjtx2/kS1IdP5M5I1OPMtLV7yjB0/aVs1uWxCda 43AXYXzF151nbEtn6w3UBygZ/KUiOQq/OERW2jXYeqndz+oqCR6a+kYW1LnIt9gtW0XqssK2ZEk MiISt/XNm/BCp7WbYKYmb6IVaa0DleTHIr5xHv9HabQQFgFfVqkc0Nax2k5q/TrLeyhb4Y/CwRk DL2yoBx0NwJ1sOYRzORxmfEgNUVT3UXLljtdwHlHCx7Tc20svIhniZkGda0Eg9mSWZZ X-Google-Smtp-Source: AGHT+IG1z+/N9mSEXDeDDYUr0MEJFrfPhtJXNnC710azwwgk6I41zYvlnsSZ2JMSULLF3H79/xgIHQ== X-Received: by 2002:a05:6000:186c:b0:382:4849:d5c8 with SMTP id ffacd0b85a97d-38260b81082mr6162516f8f.31.1732352759765; Sat, 23 Nov 2024 01:05:59 -0800 (PST) Received: from localhost.localdomain ([95.43.220.235]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3825fad658esm4782814f8f.8.2024.11.23.01.05.59 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 23 Nov 2024 01:05:59 -0800 (PST) From: Ivaylo Dimitrov To: ofono@lists.linux.dev Cc: denkenz@gmail.com, absicsz@gmail.com, merlijn@wizzup.org, Ivaylo Dimitrov Subject: [PATCH 4/4] qmi: sim: implement change_passwd(ChangePin method) Date: Sat, 23 Nov 2024 11:05:35 +0200 Message-Id: <1732352735-31944-5-git-send-email-ivo.g.dimitrov.75@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1732352735-31944-1-git-send-email-ivo.g.dimitrov.75@gmail.com> References: <1732352735-31944-1-git-send-email-ivo.g.dimitrov.75@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: --- drivers/qmimodem/sim.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++ drivers/qmimodem/uim.h | 1 + 2 files changed, 77 insertions(+) diff --git a/drivers/qmimodem/sim.c b/drivers/qmimodem/sim.c index c980203..06ff86d 100644 --- a/drivers/qmimodem/sim.c +++ b/drivers/qmimodem/sim.c @@ -883,6 +883,81 @@ static void qmi_lock(struct ofono_sim *sim, l_free(cbd); } +static void qmi_change_passwd(struct ofono_sim *sim, + enum ofono_sim_password_type passwd_type, + const char *old_pwd, const char *new_pwd, + ofono_sim_lock_unlock_cb_t cb, void *user_data) +{ + struct sim_data *data = ofono_sim_get_data(sim); + struct cb_data *cbd = cb_data_new(cb, user_data); + int old_pwd_len; + int new_pwd_len; + uint16_t info_len; + uint16_t info1_len; + uint16_t info2_len; + uint8_t pin_id; + struct qmi_param *param; + struct qmi_uim_param_session_info session; + struct { + uint8_t id; + uint8_t length; + uint8_t pin[0]; + } __attribute__((__packed__)) *info1; + struct { + uint8_t length; + uint8_t pin[0]; + } __attribute__((__packed__)) *info2; + + DBG(""); + + switch (passwd_type) { + case OFONO_SIM_PASSWORD_SIM_PIN: + pin_id = 0x01; + break; + case OFONO_SIM_PASSWORD_SIM_PIN2: + pin_id = 0x02; + break; + default: + CALLBACK_WITH_CME_ERROR(cb, 4, cbd->data); + return; + } + + old_pwd_len = strlen(old_pwd); + new_pwd_len = strlen(new_pwd); + + /* info */ + info1_len = sizeof(*info1) + old_pwd_len; + info2_len = sizeof(*info2) + new_pwd_len; + info_len = info1_len + info2_len; + + info1 = alloca(info_len); + info1->id = pin_id; + info1->length = (uint8_t) old_pwd_len; + memcpy(info1->pin, old_pwd, old_pwd_len); + + info2 = (void *)&info1->pin[old_pwd_len]; + info2->length = (uint8_t) new_pwd_len; + memcpy(info2->pin, new_pwd, new_pwd_len); + + param = qmi_param_new(); + qmi_param_append(param, QMI_UIM_PARAM_MESSAGE_INFO, info_len, info1); + + /* session */ + session.type = QMI_UIM_SESSION_TYPE_CS1; + session.aid_length = 0; + qmi_param_append(param, QMI_UIM_PARAM_MESSAGE_SESSION_INFO, + sizeof(session), &session); + + if (qmi_service_send(data->uim, QMI_UIM_CHANGE_PIN, param, + pin_send_cb, cbd, cb_data_unref) > 0) + return; + + qmi_param_free(param); + + CALLBACK_WITH_FAILURE(cb, cbd->data); + l_free(cbd); +} + static void get_card_status_cb(struct qmi_result *result, void *user_data) { struct ofono_sim *sim = user_data; @@ -1027,6 +1102,7 @@ static const struct ofono_sim_driver driver = { .send_passwd = qmi_pin_send, .query_facility_lock = qmi_query_locked, .lock = qmi_lock, + .change_passwd = qmi_change_passwd, }; OFONO_ATOM_DRIVER_BUILTIN(sim, qmimodem, &driver) diff --git a/drivers/qmimodem/uim.h b/drivers/qmimodem/uim.h index 95ba053..f3c4fb0 100644 --- a/drivers/qmimodem/uim.h +++ b/drivers/qmimodem/uim.h @@ -13,6 +13,7 @@ #define QMI_UIM_ENABLE_PIN 37 /* Set PIN protection */ #define QMI_UIM_VERIFY_PIN 38 /* Verify PIN */ +#define QMI_UIM_CHANGE_PIN 40 /* Change PIN */ #define QMI_UIM_EVENT_REGISTRATION 46 /* Register for indications */ #define QMI_UIM_GET_CARD_STATUS 47 /* Get card status */