Add callback path from wpa_supplicant core to
AidlManager::getCertificate.
Order of calls is:
1. eapol_sm_get_certificate (eapol_supp_sm.c)
2. wpa_supplicant_get_certificate_cb (wpas_glue.c)
3. wpas_get_certificate (notify.c)
4. wpas_aidl_get_certificate (aidl.cpp)
5. getCertificate (aidl_manager.cpp)
Bug: 205764502
Test: Manual test - store a key-value pair to
legacy Keystore. Check that we can retrieve
the value in supplicant using the new callbacks.
Change-Id: Ibe1fc5a2c50b818101c194bf739632d4c2a302a4
diff --git a/src/eap_peer/eap.h b/src/eap_peer/eap.h
index 8f83d0b..b98e878 100644
--- a/src/eap_peer/eap.h
+++ b/src/eap_peer/eap.h
@@ -304,6 +304,16 @@
* @reason_string: Information to log about the event
*/
void (*notify_open_ssl_failure)(void *ctx, const char* reason_string);
+
+ /**
+ * get_certificate - Retrieve a certificate from the certificate store
+ * @ctx: eapol_ctx from eap_peer_sm_init() call
+ * @alias: key into the certificate key-value store
+ * @value: pointer reference - pointer to the retrieved certificate will
+ * be stored here on success
+ * Returns: size of the retrieved certificate or -1 on error
+ */
+ ssize_t (*get_certificate)(void* ctx, const char* alias, uint8_t** value);
};
/**
diff --git a/src/eapol_supp/eapol_supp_sm.c b/src/eapol_supp/eapol_supp_sm.c
index a0bc6ab..a8ac6fd 100644
--- a/src/eapol_supp/eapol_supp_sm.c
+++ b/src/eapol_supp/eapol_supp_sm.c
@@ -2112,6 +2112,17 @@
sm->ctx->open_ssl_failure_cb(sm->ctx->ctx, reason_string);
}
+static ssize_t
+eapol_sm_get_certificate(void *ctx, const char* alias, uint8_t** value)
+{
+ struct eapol_sm *sm = ctx;
+
+ if (sm->ctx->get_certificate_cb) {
+ return sm->ctx->get_certificate_cb(alias, value);
+ }
+ return -1;
+}
+
static const struct eapol_callbacks eapol_cb =
{
eapol_sm_get_config,
@@ -2135,7 +2146,8 @@
#endif /* CONFIG_EAP_PROXY */
eapol_sm_set_anon_id,
eapol_sm_notify_eap_method_selected,
- eapol_sm_notify_open_ssl_failure
+ eapol_sm_notify_open_ssl_failure,
+ eapol_sm_get_certificate
};
diff --git a/src/eapol_supp/eapol_supp_sm.h b/src/eapol_supp/eapol_supp_sm.h
index ad94cf5..fe34ec9 100644
--- a/src/eapol_supp/eapol_supp_sm.h
+++ b/src/eapol_supp/eapol_supp_sm.h
@@ -336,6 +336,15 @@
* Returns: Whether the current session requires encryption
*/
bool (*encryption_required)(void *ctx);
+
+ /**
+ * get_certificate_cb - Retrieve a certificate from the certificate store
+ * @alias: key into the certificate key-value store
+ * @value: pointer reference - pointer to the retrieved certificate will
+ * be stored here on success
+ * Returns: size of the retrieved certificate or -1 on error
+ */
+ ssize_t (*get_certificate_cb)(const char* alias, uint8_t** value);
};