setContactCAPKs

abstract fun setContactCAPKs(tContactCAPKData: TypePublicKeyModal): NexusRet

Loads one CAPK (Certificate Authority Public Key) into the contact EMV kernel CAPK Buffer.

This method adds a single Certificate Authority Public Key to the internal buffer for contact EMV transactions. CAPKs are essential for EMV offline data authentication, enabling the terminal to verify the authenticity of card data without requiring online authorization. Each CAPK is associated with a specific payment scheme (identified by RID) and has a unique index.

Prerequisites:

CAPK data structure: The TypePublicKeyModal typically contains the following EMV tags:

  • 9F06 (AID/RID): Application/Registered Identifier specifying the payment scheme

  • 9F22 (CA Public Key Index): Unique identifier for this CAPK within the RID

  • DF02 (Modulus): RSA public key modulus for cryptographic operations

  • DF04 (Exponent): RSA public key exponent (typically 3 or 65537)

  • DF05 (Hash Value): Hash of the modulus and exponent for integrity verification

Usage sequence: This method is part of a multi-step contact CAPK loading process:

  1. Call this method multiple times to load all required contact CAPKs

  2. Call endContactCAPKLoad to finalize and commit all loaded CAPKs to the kernel

Thread safety: This method should be called from a single thread during the CAPK loading sequence to ensure data consistency and prevent buffer corruption.

Exceptions: This function MUST NOT throw any exception. Any error must be indicated through NexusRet Any unexpected error must be mapped as NexusRet.INTERR

Return

NexusRet indicating the CAPK loading result:

  • NexusRet.OK: CAPK data loaded successfully into the buffer

  • NexusRet.INTERR: Internal error during CAPK loading

  • Other values: Specific TLV parsing errors, data validation errors, or kernel failures

Example usage:

val visaContactCAPK = TypePublicKeyModal(
ridValue = "A000000003",
capkIndex = "01",
modulus = "...", // RSA modulus
exponent = "03", // RSA exponent
// ... other CAPK parameters
)

val result = emvPort.setContactCAPKs(visaContactCAPK)
if (result == NexusRet.OK) {
println("VISA contact CAPK loaded successfully")
}

Timber log suggestion: Log RID, CAPK index, and loading status for audit purposes.

Parameters

tContactCAPKData

A TypePublicKeyModal object containing the complete CAPK data for contact transactions. This includes the RID, CAPK index, RSA modulus, exponent, hash algorithm, and other cryptographic parameters required for contact EMV offline data authentication.