<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Generating custom messages and records for NFC communication</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/41213/generating-custom-messages-and-records-for-nfc-communication</link><description>Hi, 
 I am implementing an application where I need to transfer a 32 byte array via NFC. The only issue is that existing modules in nrf52 sdk have support for UTF-8 encoding, URI encoding etc. 
 I understand that I&amp;#39;ll have to write custom records and</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 10 Dec 2018 14:58:02 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/41213/generating-custom-messages-and-records-for-nfc-communication" /><item><title>RE: Generating custom messages and records for NFC communication</title><link>https://devzone.nordicsemi.com/thread/161039?ContentTypeID=1</link><pubDate>Mon, 10 Dec 2018 14:58:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:03db274e-1570-4d2b-bd7a-fc212d3c511e</guid><dc:creator>Martin Lesund</dc:creator><description>&lt;p&gt;&lt;em&gt;from the duplicate:&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;quot;You should be able to get the data from data pointer in&amp;nbsp;nfc_callback in main.c when you receive a NFC_T4T_EVENT_NDEF_UPDATED event.&amp;quot;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Generating custom messages and records for NFC communication</title><link>https://devzone.nordicsemi.com/thread/160268?ContentTypeID=1</link><pubDate>Tue, 04 Dec 2018 18:22:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fc66d12f-0e99-4546-8951-8f286e66f521</guid><dc:creator>Varun</dc:creator><description>&lt;p&gt;Hi Martin,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks. There are few more roadblocks that I&amp;#39;m facing. Let me explain the flow of my application first.&lt;/p&gt;
&lt;p&gt;I am using an android phone to write a 32 byte array to the nrf52 device which is running the Type 4 Tag (Read/Write) NFC example. Now, once the 32 byte array is written to the device, I need to use the same to create an ecdsa signature which is then written back to the FDS and loaded to the NDEF message buffer so that the android phone can read the signature from the device.&lt;/p&gt;
&lt;p&gt;Now, the problem that I am facing is, where should I pick the 32 byte array in the application to use it for further processing.&lt;/p&gt;
&lt;p&gt;I tried fetching the value from the ndef_message_buff variable, which stores the updated ndef message and generating the signature here, but I&amp;#39;m guessing this interrupts the write process to the fds and hence I receive an error.&lt;/p&gt;
&lt;p&gt;I also tried fetching the value from the FDS once the FDS Update Success event is called, and generating the signature from here, but this results in a recursive loop, since I&amp;#39;m performing an update to the fds right after generating the signature.&lt;/p&gt;
&lt;p&gt;For clarification, here is my generate_signature function.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;ret_code_t generate_signature(uint8_t m_hash[])
{
    static nrf_crypto_ecc_private_key_t alice_private_key;
    ret_code_t                          err_code = NRF_SUCCESS;

    NRF_LOG_INFO(&amp;quot;Transaction Signature Generation&amp;quot;);


    err_code = nrf_crypto_ecc_private_key_from_raw(&amp;amp;g_nrf_crypto_ecc_secp256k1_curve_info,
                                                   &amp;amp;alice_private_key,
                                                   m_alice_raw_private_key,
                                                   sizeof(m_alice_raw_private_key));

    // Generate signature of the RLP Encoded Hash using ECDSA
    m_signature_size = sizeof(m_signature);
    err_code = nrf_crypto_ecdsa_sign(NULL,
                                     &amp;amp;alice_private_key,
                                     m_hash,
                                     sizeof(m_hash),
                                     m_signature,
                                     &amp;amp;m_signature_size);


    // Alice can now send the message and its signature to Bob
    print_hex(&amp;quot;RLP Encoded hash: &amp;quot;, m_hash, sizeof(m_hash));
    print_hex(&amp;quot;Signed Transaction: &amp;quot;, m_signature, m_signature_size);

    // Key deallocation
    err_code = nrf_crypto_ecc_private_key_free(&amp;amp;alice_private_key);


    // Write signature to flash storage

    uint32_t size = sizeof(m_ndef_msg_buf);
    err_code = ndef_file_signature_encode(m_ndef_msg_buf, &amp;amp;size);
    APP_ERROR_CHECK(err_code);

    err_code = ndef_file_update(m_ndef_msg_buf, NDEF_FILE_SIZE);
    APP_ERROR_CHECK(err_code);
    NRF_LOG_DEBUG(&amp;quot;Signature written to flash storage&amp;quot;);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;In this case, the variable m_hash is the 32 byte array that I will feed to the generate_signature function.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Generating custom messages and records for NFC communication</title><link>https://devzone.nordicsemi.com/thread/160261?ContentTypeID=1</link><pubDate>Tue, 04 Dec 2018 14:07:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c8ec8ded-a784-4fd5-9d03-a88412fa2fad</guid><dc:creator>Martin Lesund</dc:creator><description>&lt;p&gt;Hi Varun,&lt;/p&gt;
&lt;p&gt;I suggest that you try to modify the&lt;a href="https://www.nordicsemi.com/DocLib/Content/SDK_Doc/nRF5_SDK/v15-0-0/nfc_record_text"&gt; NFC text record example from the SDK&lt;/a&gt;&amp;nbsp;and just put the 32 bytes in the payload.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;It is up to the receiver on how this should get decoded.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>