cancel
Showing results for 
Search instead for 
Did you mean: 

Set the password for the write action on the ST25DV04K

FwDevelop
Associate

Hi,

I have a ST25DV04K and I read/write it with the NFC Reader NFC06A1 connected to a NUCLEO L476RG electronic card.

To read and write I use the "X-CUBE-NFC6" library (Ver 1.1.0)

I would like to know if it is possible to set a password to protect the NFC device ST25DV04K for writing.

In the library found on the web link I have not found a function that allows me to set it.

Could you give me some examples?

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Brian TIDAL
ST Employee

Hi,

rfalST25xVPollerPresentPassword API from rfal_st25xv.c can be used for password management (i.e. B3h Present Password command). Unfortunately the rfalST25xVPollerWritePassword API is missing (B1h Write Password command)

In order to have the latest version of this library, I would recommend to use the ST25 Embedded NFC library: you will find the demos from the X-CUBE-NFC6 package plus some new demos, all based on the latest ST25 reader library (aka RFAL). See st25r_st25dv-i2c_ftm.c in FTM demo in the ST25 Embedded NFC lib for code example with rfalST25xVPollerPresentPassword.

For the rfalST25xVPollerWritePassword, I would propose to add the following code in rfal_st25xv.c (and related prototype in rfal_st25xv.h)

/*******************************************************************************/
ReturnCode rfalST25xVPollerWritePassword( uint8_t flags, const uint8_t* uid, uint8_t pwdNum, const uint8_t *pwd,  uint8_t pwdLen)
{
    uint8_t            data[RFAL_ST25xV_PWDNUM_LEN + RFAL_ST25xV_PWD_LEN];
    uint8_t            dataLen;
    uint16_t           rcvLen;
    rfalNfcvGenericRes res;
    
    if( (pwdLen > RFAL_ST25xV_PWD_LEN) || (pwd == NULL) )
    {
        return ERR_PARAM;
    }
    
    dataLen = 0U;
    data[dataLen++] = pwdNum;
    if( pwdLen > 0U )
    {
        ST_MEMCPY(&data[dataLen], pwd, pwdLen);
    }
    dataLen += pwdLen;
    
    return rfalNfcvPollerTransceiveReq( RFAL_NFCV_CMD_WRITE_PASSWORD, flags, RFAL_NFCV_ST_IC_MFG_CODE, uid, data, dataLen, (uint8_t*)&res, sizeof(rfalNfcvGenericRes), &rcvLen );
    
}

Let me know whether this is working properly on your side.

Thanks

Rgds

BT

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

1 REPLY 1
Brian TIDAL
ST Employee

Hi,

rfalST25xVPollerPresentPassword API from rfal_st25xv.c can be used for password management (i.e. B3h Present Password command). Unfortunately the rfalST25xVPollerWritePassword API is missing (B1h Write Password command)

In order to have the latest version of this library, I would recommend to use the ST25 Embedded NFC library: you will find the demos from the X-CUBE-NFC6 package plus some new demos, all based on the latest ST25 reader library (aka RFAL). See st25r_st25dv-i2c_ftm.c in FTM demo in the ST25 Embedded NFC lib for code example with rfalST25xVPollerPresentPassword.

For the rfalST25xVPollerWritePassword, I would propose to add the following code in rfal_st25xv.c (and related prototype in rfal_st25xv.h)

/*******************************************************************************/
ReturnCode rfalST25xVPollerWritePassword( uint8_t flags, const uint8_t* uid, uint8_t pwdNum, const uint8_t *pwd,  uint8_t pwdLen)
{
    uint8_t            data[RFAL_ST25xV_PWDNUM_LEN + RFAL_ST25xV_PWD_LEN];
    uint8_t            dataLen;
    uint16_t           rcvLen;
    rfalNfcvGenericRes res;
    
    if( (pwdLen > RFAL_ST25xV_PWD_LEN) || (pwd == NULL) )
    {
        return ERR_PARAM;
    }
    
    dataLen = 0U;
    data[dataLen++] = pwdNum;
    if( pwdLen > 0U )
    {
        ST_MEMCPY(&data[dataLen], pwd, pwdLen);
    }
    dataLen += pwdLen;
    
    return rfalNfcvPollerTransceiveReq( RFAL_NFCV_CMD_WRITE_PASSWORD, flags, RFAL_NFCV_ST_IC_MFG_CODE, uid, data, dataLen, (uint8_t*)&res, sizeof(rfalNfcvGenericRes), &rcvLen );
    
}

Let me know whether this is working properly on your side.

Thanks

Rgds

BT

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.