Skip to content

Commit 0b81e8a

Browse files
authored
euicc: added support for custom AIDs (#181)
- Added env variable "LPAC_CUSTOM_ISD_R_AID" for user defined AIDs - Added documentation for new env var
1 parent 62eb766 commit 0b81e8a

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

docs/ENVVARS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## General
44

5+
* `LPAC_CUSTOM_ISD_R_AID`: specify which AID will be used to open the logic channel. (hex string, 32 chars)
56
* `LPAC_APDU`: specify which APDU backend will be used. Values:
67
- `at`: use AT commands interface used by LTE module
78
- `pcsc`: use PC/SC Smart Card API

src/main.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <time.h>
77

88
#include <euicc/interface.h>
9+
#include <euicc/hexutil.h>
910
#include <euicc/euicc.h>
1011
#include <driver.h>
1112

@@ -23,6 +24,8 @@
2324
#include <processenv.h>
2425
#endif
2526

27+
#define ISD_R_AID_STR_LENGTH 16
28+
2629
static int driver_applet_main(int argc, char **argv)
2730
{
2831
const struct applet_entry *applets[] = {
@@ -58,6 +61,21 @@ struct euicc_ctx euicc_ctx = {0};
5861

5962
void main_init_euicc()
6063
{
64+
const char *custom_aid_str = getenv("LPAC_CUSTOM_ISD_R_AID");
65+
if (custom_aid_str)
66+
{
67+
unsigned char custom_aid[ISD_R_AID_STR_LENGTH];
68+
const int custom_aid_len = euicc_hexutil_hex2bin(custom_aid, ISD_R_AID_STR_LENGTH, custom_aid_str);
69+
if (custom_aid_len != ISD_R_AID_STR_LENGTH)
70+
{
71+
jprint_error("euicc_init", "invalid custom AID given");
72+
exit(-1);
73+
}
74+
75+
euicc_ctx.aid = custom_aid;
76+
euicc_ctx.aid_len = custom_aid_len;
77+
}
78+
6179
if (euicc_init(&euicc_ctx))
6280
{
6381
jprint_error("euicc_init", NULL);

0 commit comments

Comments
 (0)