Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

euicc: added support for multiple AIDs #181

Merged
merged 1 commit into from
Jan 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/ENVVARS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## General

* `LPAC_CUSTOM_ISD_R_AID`: specify which AID will be used to open the logic channel. (hex string, 32 chars)
* `LPAC_APDU`: specify which APDU backend will be used. Values:
- `at`: use AT commands interface used by LTE module
- `pcsc`: use PC/SC Smart Card API
Expand Down
18 changes: 18 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <time.h>

#include <euicc/interface.h>
#include <euicc/hexutil.h>
#include <euicc/euicc.h>
#include <driver.h>

Expand All @@ -23,6 +24,8 @@
#include <processenv.h>
#endif

#define ISD_R_AID_STR_LENGTH 16

static int driver_applet_main(int argc, char **argv)
{
const struct applet_entry *applets[] = {
Expand Down Expand Up @@ -58,6 +61,21 @@ struct euicc_ctx euicc_ctx = {0};

void main_init_euicc()
{
const char *custom_aid_str = getenv("LPAC_CUSTOM_ISD_R_AID");
if (custom_aid_str)
{
unsigned char custom_aid[ISD_R_AID_STR_LENGTH];
const int custom_aid_len = euicc_hexutil_hex2bin(custom_aid, ISD_R_AID_STR_LENGTH, custom_aid_str);
if (custom_aid_len != ISD_R_AID_STR_LENGTH)
{
jprint_error("euicc_init", "invalid custom AID given");
exit(-1);
}
CoelacanthusHex marked this conversation as resolved.
Show resolved Hide resolved

euicc_ctx.aid = custom_aid;
euicc_ctx.aid_len = custom_aid_len;
}

if (euicc_init(&euicc_ctx))
{
jprint_error("euicc_init", NULL);
Expand Down