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
This commit is contained in:
Root-Core 2025-01-05 02:36:44 +01:00 committed by GitHub
parent 62eb766d14
commit 0b81e8ab14
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 0 deletions

View file

@ -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

View file

@ -6,6 +6,7 @@
#include <time.h>
#include <euicc/interface.h>
#include <euicc/hexutil.h>
#include <euicc/euicc.h>
#include <driver.h>
@ -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[] = {
@ -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);