I'm trying to use DeleteAll() but just cannot make it work. I'm using NXPPlugNTrust nano-package API. Steps I'm taking:
- In a separate session, write UserID to RESERVED_ID_FACTORY_RESET
- Create session with that key
- Send DeleteAll
I have checked that every step except DeleteAll returns 0x9000 and the user ID does exist (CheckObjectExists). I have compared my code against se05x_mandate_scp03 example and it is basically identical except that RESERVED_ID_FACTORY_RESET is written and used instead.
Writing user ID (relevant part):
uint8_t userId[] = DELETE_ALL_USERID_VALUE;
status = Se05x_API_WriteUserID(
&session,
&policy,
0,
kSE05x_AppletResID_FACTORY_RESET,
userId, sizeof(userId),
kSE05x_AttestationType_AUTH
);
Using DeleteAll:
smStatus_t status;
Se05xSession_t session = { 0 };
size_t sessionIdLen = sizeof(se05x_applet_session_value);
set_keys(
&session,
scp03_key_enc, sizeof(scp03_key_enc),
scp03_key_mac, sizeof(scp03_key_mac)
);
status = Se05x_API_SessionOpen(&session);
if (status != SM_OK) {
SMLOG_E("Se05x_API_SessionOpen %x\n", status);
return status;
}
uint8_t userId[] = DELETE_ALL_USERID_VALUE;
SE05x_Result_t exists = kSE05x_Result_FAILURE;
size_t sessionIdLen = sizeof(se05x_applet_session_value);
status = Se05x_API_CheckObjectExists(
&session,
kSE05x_AppletResID_FACTORY_RESET,
&exists
);
if (status != SM_OK) {
SMLOG_E("Se05x_API_CheckObjectExists %x\n", status);
return status;
}
status = Se05x_API_CreateSession(
&session,
kSE05x_AppletResID_FACTORY_RESET,
&se05x_applet_session_value[0],
&sessionIdLen
);
if (status != SM_OK) {
SMLOG_E("Se05x_API_CreateSession %x\n", status);
return status;
}
status = Se05x_API_VerifySessionUserID(&session, userId, sizeof(userId));
if (status != SM_OK) {
SMLOG_E("Se05x_API_VerifySessionUserID %x\n", status);
return status;
}
status = Se05x_API_DeleteAll(&session);
if (status != SM_OK) {
SMLOG_E("Se05x_API_DeleteAll: %x", status);
return status;
}
return status;
I have attached a debug console output that included both setting the userID and using it.