C library to encode and decode brand protection NDEF record and messages
The NFC data exchange format (NDEF) specification by NFC Forum defines a common data format to exchange information between NFC Forum devices.
This C library provides support to build and parse the NDEF brand protection messages, with support for common NDEF record type definitions.
Features
- Build and parse the NDEF brand protection messages
- Build and parse the NDEF brand protection records
Usage
Include the following headers
NDEF message encoding/decoding utility.
Model interface to create record types and set/get record fields.
Model for the brand protection record.
Provides utility functions and macros.
Register the brand protection record into the NDEF C library
ifx_status_t ifx_record_bp_register(void)
Registers the brand protection record with the NDEF library. Only the registered records are encoded ...
Create a new brand protection record
ifx_status_t ifx_record_bp_new(ifx_record_handle_t *handle)
Creates a new brand protection record and the respective handle for the record. This handle can be us...
Defines the handle for specific record type.
Provide custom implementations to encode and decode the certificates
Example: Certificate encoder custom implementation
{
}
#define IFX_SUCCESS
Default status code for successful calls to any function.
uint32_t ifx_status_t
Custom return code type used by all Infineon host software libraries.
Data storage for data and data length where both are required as parameters.
Example: Certificate decoder custom implementation
Set the custom certificate encoder and decoder handles
ifx_status_t ifx_record_bp_set_certificate_handlers(ifx_record_handle_t *handle, ifx_record_bp_cert_encoder_t encoder, ifx_record_bp_cert_decoder_t decoder)
Sets the certificate encoder and decoder callback functions for parsing certificates.
Example for defining the certificate data type
typedef struct
{
char *issuer;
char *subject;
char *fingerprint;
char *authority;
} ifx_x509_certificate_example_t;
Assign a certificate to the created brand protection record
ifx_x509_certificate_example_t certificate;
ifx_status_t ifx_record_bp_set_certificate(ifx_record_handle_t *handle, const void *certificate)
Sets certificate in the brand protection record for a given record handle.
Use the NDEF C library to encode the brand protection record into an NDEF message
uint32_t record_count = 0x01;
ifx_status_t ifx_ndef_message_encode(const ifx_record_handle_t *record_handles, uint32_t number_of_records, ifx_blob_t *ndef_message)
Encodes the array of the NDEF record handles into the NDEF message.
This NDEF message can be written into the NDEF file in the tag.
Use the NDEF C library to decode the brand protection record from an NDEF message
uint32_t get_number_of_records = 0x00;
ifx_status_t ifx_ndef_message_decode(const ifx_blob_t *ndef_message, uint32_t *number_of_records, ifx_record_handle_t *record_handles)
Decodes the NDEF message buffer to the NDEF records array.
Get the certificate from the record handle
ifx_status_t ifx_record_bp_get_certificate(const ifx_record_handle_t *handle, void *certificate)
Gets the certificate from the brand protection record handle.
Release the memory allocated by the library
ifx_status_t ifx_ndef_record_release_resource(void)
This method will free-up the internally allocated memory for ndef registered records.
Architecture
Below image described the software architecture of the library.

Components
- Brand protection record models This component contains the record models that are in-built supported by the library. These record models provide the structure for the record, which can be used to build the record.
- Brand protection record payload encoders and decoders This component contains the payload encoders and decoders which can be used to encode and decode the payload details into a byte array.
Interaction
Below UML diagram describes the interaction between the components.

Directory structure
The library directory is structured according to the Pitchfork Layout.
hsw-ndef-bp
|-- .cmake/ # Includes sources for dependency management
|-- LICENSES/ # Includes list of licenses used for the library
|-- data/ # Includes Doxygen, cppcheck configuration files
|-- docs/ # Includes documentation source files, images, and the generated API reference
|-- include/ # Public Headers(.h) of the library
|-- src/ # Sources(.c) and Private headers(.h) of the library
|-- .clang-format # clang-format configuration file
|-- .gitignore # Library specific gitignore file
|-- CMakeLists.txt # CMake build configurations for the library
`-- README.md # Overview of the hsw-ndef-bp library
Dependencies
- hsw-error This dependent library is used for creating and parsing an error information.
- hsw-ndef This dependent library is used for creating the DEF RTDs and parsing the NDEF record information.
- hsw-utils This dependent library is used for utility functions such as string parsers.
References
- Infineon Technologies AG: OPTIGA™; Authenticate NBT, Extended Datasheet
- NFC Data Exchange Format (NDEF), Technical Specification, NFC Forum™, NDEF 1.0
- NFC Record Type Definition (RTD), Technical Specification, NFC Forum™, RTD 1.0