WPC Provisioning API#

WPC provisioning consists of two major parts:

  • Service adapter

  • Target adapter

Service adapter’s responsibility is to provide WPC Certificate chain. Target adapter is then responsible to injecting said chain into the target.

Out-of-the-box SPSDK provides one Service adapter using EL2GO and one Target adapter using MBoot/BLhost.

WPC Service adapter using EL2GO#

class spsdk.wpc.service_el2go.WPCCertificateServiceEL2GO(family, url, qi_id, api_key, timeout=60)#

Bases: WPCCertificateService

WPC Certificate Service adapter for EdgeLock2GO platform.

This class provides integration with NXP’s EdgeLock2GO cloud service to obtain WPC (Wireless Power Consortium) certificate chains for device authentication. It handles REST API communication, authentication, and certificate retrieval operations.

Variables:

identifier – Service identifier used for configuration and registration.

Initialize the EL2GO adapter.

Parameters:
  • family (FamilyRevision) – Target MCU family and revision.

  • url (str) – URL to EL2GO WPC service.

  • qi_id (int) – Customer’s Qi ID.

  • api_key (str) – Customer’s EL2GO REST API access token.

  • timeout (int) – REST API request timeout in seconds, defaults to 60.

classmethod get_validation_schemas(family)#

Get JSON schema for validating EL2GO configuration data.

Parameters:

family (FamilyRevision) – Target MCU family and revision information.

Return type:

list[dict[str, Any]]

Returns:

List containing EL2GO validation schema dictionary.

get_wpc_cert(wpc_id_data)#

Obtain the WPC Certificate Chain from EL2GO service.

Retrieves a WPC (Wireless Power Consortium) certificate chain by making a request to the EL2GO service. Supports both CSR (Certificate Signing Request) and RSID (Root Secure ID) request types. Handles certificate re-download if certificate already exists for RSID type.

Parameters:

wpc_id_data (bytes) – WPC identification data - either CSR bytes for COMPUTED_CSR type or TP-Data-Container v2 bytes for RSID type

Raises:
  • SPSDKWPCError – When unsupported WPC ID type is used, response format is invalid, or unable to parse PUC ID from error description

  • EL2GoWPCError – When EL2GO service request fails (except for handled 422 status code with RSID type)

Return type:

WPCCertChain

Returns:

WPC certificate chain containing root CA hash, manufacturer certificate, and product unit certificate

identifier: str = 'el2go'#
classmethod load_from_config(config)#

Create instance of this class based on configuration data.

The method loads configuration parameters including API key, URL, QI ID, family revision, and timeout to initialize a new instance. Uses cls.CONFIG_PARAMS to scope configuration data.

Parameters:

config (Config) – Configuration data containing service parameters

Return type:

Self

Returns:

Instance of this class initialized with configuration values

WPC Target adapter using MBoot#

class spsdk.wpc.target_mboot.WPCTargetMBoot(family, mboot_interface)#

Bases: WPCTarget

WPC Target adapter using MBoot interface.

This class provides WPC (Wireless Power Consortium) target operations through the MBoot communication protocol. It handles device communication, certificate management, and WPC ID operations for NXP MCUs that support MBoot interface.

Variables:

identifier – Interface type identifier for MBoot protocol.

Initialize WPC Target adapter.

The adapter configures the mboot interface and loads family-specific database settings for WPC operations including buffer address, ID length, and various operational flags.

Parameters:
  • family (FamilyRevision) – Target family name and revision information.

  • mboot_interface (dict[str, str]) – Dictionary containing interface definition with keys like “port”: “com4”, “usb”: “0x1fc9:0x014f”, or “plugin”: “identifier=…”

get_low_level_wpc_id()#

Get the lower-level WPC ID from the target.

Retrieves WPC ID data from the target device using McuBoot interface. The method handles two types of WPC IDs: COMPUTED_CSR (reads pre-computed CSR data) and RSID (generates and reads WPC ID using dedicated command).

Raises:

SPSDKWPCError – When unable to read WPC ID, WPC ID generation fails, unexpected WPC ID length is returned, or unsupported WPC ID type.

Return type:

bytes

Returns:

Raw WPC ID data as bytes.

classmethod get_validation_schemas(family)#

Get JSON schema for validating configuration data.

Retrieves the JSON schema specifically for mboot configuration validation from the WPC database schema file.

Parameters:

family (FamilyRevision) – Family and revision information for the target device.

Return type:

list[dict[str, Any]]

Returns:

List containing the mboot validation schema dictionary.

identifier: str = 'mboot'#
classmethod load_from_config(config)#

Create instance of this class based on configuration data.

The method initializes the class using configuration parameters. It extracts family revision information and mboot interface settings from the provided configuration to create a new instance.

Parameters:

config (Config) – Configuration data containing family and mboot interface parameters.

Return type:

Self

Returns:

Instance of this class initialized with configuration data.

sign(data)#

Sign data by the target using WPC (Wireless Power Consortium) signing functionality.

This method writes the provided data to the target’s memory buffer, executes the WPC CSR signing command through McuBoot interface, and retrieves the generated signature.

Parameters:

data (bytes) – The data bytes to be signed (typically CSR-TBS data).

Return type:

bytes

Returns:

The 64-byte signature generated by the target.

Raises:
  • SPSDKWPCError – If memory write operation fails.

  • SPSDKWPCError – If CSR signing operation fails.

  • SPSDKWPCError – If signature reading operation fails.

wpc_insert_cert(cert_chain, reset=True)#

Insert the WPC Certificate Chain into the target.

The method writes the certificate chain to device memory and executes the WPC certificate insertion command. It handles lifecycle checking, device reset, and memory alignment as needed.

Parameters:
  • cert_chain (WPCCertChain) – Certificate chain to insert into the target

  • reset (bool) – Perform reset if the target requires it. With this option you may disable required reset (for testing purposes)

Raises:

SPSDKWPCError – Error during certificate chain insertion

Return type:

bool

Returns:

True if operation finishes successfully

Creating your own WPC Service/Target adapters#

To create your own Service adapter, create new class derived from WPCCertificateService. To create your own Target adapter, create new class derived from WPCTarget.

Service is responsible to provide WPC Certificate Chain as WPCCertChain via get_wpc_cert(). Target adapters then injects said certificate chain into the target using wpc_insert_cert().

Both WPCCertificateService and WPCTarget base-classes are using common approach regarding regarding instantiation via configuration data defined in BaseWPCClass. Each derived class should implement s(). This method should return a JSON validation schema which is used for both configuration template creation and validating configuration data specific for each class. Derived class can be then instantiated via load_from_config() Method validates configuration data and passes the data into the __init__ method

To see a practical example on how to create your own Service, please see Creating a custom WPC Service adapter

class spsdk.wpc.wpc.WPCCertificateService(family)#

Bases: BaseWPCClass

WPC Certificate Service base class.

This abstract base class defines the interface for service adapters that provide WPC (Wireless Power Consortium) Certificate Chains. Implementations of this class handle the retrieval and management of WPC certificates required for wireless power transfer authentication.

Variables:

CONFIG_PARAMS – Configuration parameter key for service settings.

Initialize WPC target.

Parameters:

family (FamilyRevision) – Target family name and revision information

Raises:

SPSDKWPCError – Family is not supported as WPC target

CONFIG_PARAMS: str = 'service_parameters'#
abstract get_wpc_cert(wpc_id_data)#

Obtain the WPC Certificate Chain.

Parameters:

wpc_id_data (bytes) – WPC ID provided by the target device.

Return type:

WPCCertChain

Returns:

WPC Certificate Chain containing the device certificates.

class spsdk.wpc.wpc.WPCTarget(family)#

Bases: BaseWPCClass

WPC Target adapter base class.

This abstract base class provides the foundation for implementing adapters that establish connections to target devices for Wireless Power Consortium (WPC) operations. It defines the interface for WPC ID retrieval, certificate chain insertion, and cryptographic signing operations on target hardware.

Variables:

CONFIG_PARAMS – Configuration parameter key for target-specific settings.

Initialize WPC target.

Parameters:

family (FamilyRevision) – Target family name and revision information

Raises:

SPSDKWPCError – Family is not supported as WPC target

CONFIG_PARAMS: str = 'target_parameters'#
abstract get_low_level_wpc_id()#

Get the lower-level WPC ID from the target.

Return type:

bytes

Returns:

The lower-level WPC ID as bytes.

get_wpc_id()#

Get the WPC ID from the target.

Retrieves and processes the WPC (Wireless Power Consortium) ID based on the configured ID type. For COMPUTED_CSR type, generates a certificate signing request with the target’s public key and signature. For RSID type, returns the raw ID data.

Raises:
  • SPSDKWPCError – When WPC ID contains all zeros.

  • NotImplementedError – When WPC ID type is not supported.

Return type:

bytes

Returns:

WPC ID as PEM-encoded CSR bytes for COMPUTED_CSR type or raw bytes for RSID type.

sign(data)#

Sign data by the target.

Parameters:

data (bytes) – Data to be signed.

Raises:

NotImplementedError – Method must be implemented by subclass.

Return type:

bytes

Returns:

Signed data.

abstract wpc_insert_cert(cert_chain)#

Insert the WPC Certificate Chain into the target.

This method handles the insertion of a complete WPC certificate chain into the target device, ensuring proper validation and secure provisioning.

Parameters:

cert_chain (WPCCertChain) – Certificate chain to insert into the target

Raises:

SPSDKWPCError – Error during certificate chain insertion

Return type:

bool

Returns:

True if operation finishes successfully

class spsdk.wpc.wpc.BaseWPCClass(family)#

Bases: FeatureBaseClassComm

Base abstract class for WPC (Wireless Power Consortium) Service and Target implementations.

This class provides the foundation for WPC operations across NXP MCU portfolio, handling device identification, family-specific configurations, and database management for wireless power charging functionality.

Variables:
  • FEATURE – Feature identifier for WPC operations.

  • legacy_identifier_name – Legacy attribute name for backward compatibility.

Initialize WPC target.

Parameters:

family (FamilyRevision) – Target family name and revision information

Raises:

SPSDKWPCError – Family is not supported as WPC target

CONFIG_PARAMS: str#
FEATURE: str = 'wpc'#
get_config(data_path='./')#

Create configuration of the Feature.

Parameters:

data_path (str) – Path to directory containing configuration data files.

Raises:

SPSDKNotImplementedError – Method not implemented in base class.

Return type:

Config

classmethod get_providers()#

Get available WPC Service/Target Providers.

This method dynamically loads and registers WPC (Wireless Power Consortium) service and target providers from both built-in modules and entry points. It ensures that all available providers are properly registered with the plugin manager.

Return type:

dict[str, Type[Self]]

Returns:

Dictionary mapping provider identifiers to their corresponding class types.

identifier: str#
legacy_identifier_name = 'NAME'#
class spsdk.wpc.wpc.WPCCertChain(root_ca_hash, manufacturer_cert, product_unit_cert)#

Bases: object

WPC Certificate Chain for Qi wireless charging authentication.

This class represents a complete WPC (Wireless Power Consortium) certificate chain used in Qi wireless charging authentication, containing the root CA hash, manufacturer certificate, and product unit certificate with their respective WPC-specific extensions.

root_ca_hash: bytes#
manufacturer_cert: Certificate#
product_unit_cert: Certificate#
get_puk_offset(pu_cert_only=False)#

Get offset to the Product Unit Certificate public key.

Parameters:

pu_cert_only (bool) – Get the offset relative to start of the Product Unit Certificate, defaults to False.

Return type:

int

Returns:

Offset to the Product Unit Certificate public key.

get_rsid_offset(pu_cert_only=False)#

Get offset to the Revocation Sequential Identifier.

Parameters:

pu_cert_only (bool) – Get the offset relative to Product Unit Certificate, defaults to False

Return type:

int

Returns:

Offset to the Revocation ID.

get_rsid()#

Get the Revocation Sequential Identifier.

Extracts the RSID from the product unit certificate extension and validates its length. The RSID is used for certificate revocation tracking in WPC authentication.

Raises:

SPSDKWPCError – Invalid RSID length (expected 9 bytes).

Return type:

bytes

Returns:

The 9-byte RSID extracted from the certificate extension.

export()#

Export WPC Certificate Chain into bytes.

The method concatenates the root CA hash with manufacturer and product unit certificates in DER encoding format, then prepends the total length as a 2-byte big-endian value.

Return type:

bytes

Returns:

Byte representation of the WPC certificate chain with length prefix.

classmethod parse(data)#

Parse binary data into WPC Certificate Chain object.

The method parses the binary representation of a WPC certificate chain, extracting the root CA hash, manufacturer certificate, and product unit certificate.

Parameters:

data (bytes) – Binary data containing the WPC certificate chain.

Raises:

SPSDKWPCError – When the data length doesn’t match expected length.

Return type:

Self

Returns:

Parsed WPC Certificate Chain object.

classmethod load(path)#

Load WPC Certificate Chain from a file.

Parameters:

path (str) – Path to the file containing WPC Certificate Chain data.

Raises:

SPSDKError – If the file cannot be loaded or parsed.

Return type:

Self

Returns:

WPC Certificate Chain object.

save(chain_path=None, root_hash_path=None, manufacturer_path=None, product_unit_path=None)#

Save WPC Certificate Chain into file(s).

The method allows saving the complete certificate chain or individual components (root hash, manufacturer certificate, product unit certificate) to separate files. At least one path parameter must be provided to perform any save operation.

Parameters:
  • chain_path (Optional[str]) – Path where to store the whole certificate chain in binary format.

  • root_hash_path (Optional[str]) – Path where to store only the WPC Root Certificate hash as hex string.

  • manufacturer_path (Optional[str]) – Path where to store only the Manufacturer Certificate in DER format.

  • product_unit_path (Optional[str]) – Path where to store only the Product Unit Certificate in DER format.

Return type:

None