2025-11-23 8:25 PM
Hello ST Community,
I am using a STEVAL-25R200A to do tests with the ST25TV02KC.
I am trying to rfalST25xVPollerPresentPassword, with a pwdNumber of 0x00 to enter Configuration Session (As described in the nfc tag datasheet), But keep getting error 5, even though I am passing the default 32-bit password.
I am using this function:
ReturnCode ST25TAGS_TVC_OpenSecuritySession(const uint8_t * uid, ST25TAG_TVC_SecuritySession_t sessionType,
const uint8_t * pPassword)
{
uint8_t pwdNumber;
uint8_t pwdLengthInBytes = 4;
ReturnCode errCode;
uint8_t rxBuf[ 1 + 2 + 2 ]; /* Flags + Random Number Data + CRC */;
uint16_t rcvLen;
uint8_t updatedPassword[8];
switch (sessionType)
{
case CONFIGURATION_SECURITY_SESSION:
pwdNumber = 0;
break;
case USER_AREA1_SECURITY_SESSION:
pwdNumber = 1;
break;
case USER_AREA2_SECURITY_SESSION:
pwdNumber = 2;
break;
case SINGLE_USER_AREA_SECURITY_SESSION:
pwdLengthInBytes = 8;
pwdNumber = 1;
break;
case UNTRACEABLE_SECURITY_SESSION:
pwdNumber = 3;
break;
default:
return RFAL_ERR_PARAM;
}
// Encrypt password
// 1. Get Random Number
errCode = rfalST25xVPollerGetRandomNumber( ST25TAGS_TVC_REQ_FLAG, uid, rxBuf, sizeof(rxBuf), &rcvLen );
if ( errCode == RFAL_ERR_NONE )
{
// 2. XOR random number with given password located in rxBuf[1] and rxBuf[2]
for (uint8_t i = 0; i < (pwdLengthInBytes * 2); i++)
{
updatedPassword[i] = pPassword[i] ^ rxBuf[2 - (i + 1) % 2];
}
// Present password
errCode = rfalST25xVPollerPresentPassword( ST25TAGS_TVC_REQ_FLAG, uid,
pwdNumber, updatedPassword, pwdLengthInBytes);
}
// Same ReturnCode definitions used in st_errno.h of RFAL
return errCode;
}And calling it like this:
uint8_t plainPwd[4] = {0x0, 0x0, 0x0 ,0x0};
err = ST25TAGS_TVC_OpenSecuritySession(uid, CONFIGURATION_SECURITY_SESSION, plainPwd);
platformLog(" Present password: %s Error Code: %d \r\n", (err != RFAL_ERR_NONE) ? "Fail" : "OK", (err != RFAL_ERR_NONE) ? err : 0);But i get this error code:
Present password: Fail Error Code: 5
I would appreciate your help,
Thank you