Skip to content

Commit

Permalink
euicc: added support for custom AIDs (#181)
Browse files Browse the repository at this point in the history
- Added env variable "LPAC_CUSTOM_ISD_R_AID" for user defined AIDs
- Added documentation for new env var
  • Loading branch information
Root-Core authored Jan 5, 2025
1 parent 62eb766 commit 0b81e8a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
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);
}

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

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

0 comments on commit 0b81e8a

Please sign in to comment.