This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2640R2F: cc2640r2f

Part Number: CC2640R2F


Where can we find the long term key(LTK) value if we are implementing passcode in simple peripheral code that is used for passcode purpose ?

  • M Spim,

    Please review documentation on the GAPBondMgr and SNV here: software-dl.ti.com/.../gapbondmngr.html
  • ya i have gone through it but i am unable to spot the exact value of LTK(long term key) in simple peripheral ,whether its value is present or how its value is determined.
  • M SPIM,

    Sorry for getting back to you a bit later. First, I'd be curious as to why you want to do this, just for my education. Can you provide some insight there?

    Second, you can find information on how the LTK is calculated in the Bluetooth LE Specification: https://www.bluetooth.com/specifications/bluetooth-core-specification

    For BLE4.2, you can find more information on the BLE Security Manager Spec in Vol3, Part H.

    Third, reading the LTK is a bit more complicated as the keys are stored in Secure Non-Volatile memory (SNV). The SNV is not easy to decode, but if you have the ID, you can use the osal_snv_read() to read the LTK. But this is generally abstracted by the GAPBondMgr.

    In the gapbondmgr.c, you will find the following macro:

    #define localLTKNvID(bondIdx)

    This takes the bondIdx as an argument and returns the NVID. From there you can use osal_snv_read(), then get the IDX from GAPBondMgr_ResolveAddr.

    For the arguments for the GAPBondMgr_ResolveAddr(), you can use linkDB_GetInfo() to retrieve what you need to pass into the Resolve Addr API. 

    As a best practice, it may also be good to reference the GAPBondMgr and LE Secure Connections Documentation to see how the pairing callbacks work. 

    software-dl.ti.com/.../gapbondmngr.html

  • Thankyou for the reply but actually i want to know what is the name of the API that saves secret key generated from passkey(example 123456 default passcode in case of simple_peripheral.c) and random number

  • M SPIM,

    For clarity for anyone else using this thread as a reference, the answer I gave above is the answer to your first question.

    For your inquiry into which API that handles saving the LTK, this is in gapBondMgrAddBond() in the gapbondmgr.c file. Please inspect this function and read the comments.
  • Hi

    Actually we know that simple_peripheral can be connected to nRF connect in phone by entering the passcode but if i want to connect simple_peripheral to mobile where pairing should take place successfully without asking for passcode then what should be the implementation? Can you please suggest me.

    Thanks and regards
    M.SILPA
  • MSPIM,

    What you want sounds like a "just works" pairing. You can find more information on this in the users guide I linked in previous posts as well as the BLE specification Volume 3, Part H. Section 2. 

  • Then in simple peripheral application what type of pairing are we going on with, i think its just work pairing. Please correct me if i am wrong.
  • Simple Peripheral is actually passcode pairing.

    You can observe why it is by examining the simple_peripheral.c file, particularly the following section:

      // Setup the GAP Bond Manager. For more information see the section in the
      // User's Guide:
      // software-dl.ti.com/.../
      {
        // Don't send a pairing request after connecting; the peer device must
        // initiate pairing
        uint8_t pairMode = GAPBOND_PAIRING_MODE_WAIT_FOR_REQ;
        // Use authenticated pairing: require passcode.
        uint8_t mitm = TRUE;
        // This device only has display capabilities. Therefore, it will display the
        // passcode during pairing. However, since the default passcode is being
        // used, there is no need to display anything.
        uint8_t ioCap = GAPBOND_IO_CAP_DISPLAY_ONLY;
        // Request bonding (storing long-term keys for re-encryption upon subsequent
        // connections without repairing)
        uint8_t bonding = TRUE;
    
        GAPBondMgr_SetParameter(GAPBOND_PAIRING_MODE, sizeof(uint8_t), &pairMode);
        GAPBondMgr_SetParameter(GAPBOND_MITM_PROTECTION, sizeof(uint8_t), &mitm);
        GAPBondMgr_SetParameter(GAPBOND_IO_CAPABILITIES, sizeof(uint8_t), &ioCap);
        GAPBondMgr_SetParameter(GAPBOND_BONDING_ENABLED, sizeof(uint8_t), &bonding);
      }

    You can reference the following portion of the software users guide for more information and see what just works vs pairing vs other secure connection methods. http://software-dl.ti.com/lprf/simplelink_cc2640r2_latest/docs/blestack/ble_user_guide/html/ble-stack-3.x/gapbondmngr.html?highlight=just%20works#gapbondmgr-examples-for-different-pairing-modes

  • MSPIM,

    Just wanted to ask that you please let me know if i've resolved your original questions if possible. If you have any new questions unrelated to your original questions, please create a new thread so we can keep each topic/conversation focused around one issue.
  • Ya i will let you know as soon as it will work out. Thank you for the information and help being provided. 

  • Hi

    As i have gone through the above link provided by you i have noticed that in order to implement just works pairing mitm is set to false,but still it asks for passcode during first pairing . So can you please suggest me how to implement just works pairing apart from only setting mitm=false.

    Thanks
    Silpa
  • MSPIM,

    When you made those changes to the project, did you clean and rebuild the stack project and then clean and rebuild the application project?