Amadis

CL Kernel Integration

 

This section is meant to help technical teams to integrate Agnos CL kernels onto their own framework using a third part entry point. The complexity of this task lies on the lake of standardization when time comes to certify a CL kernel. Today, CL L2 TA are executed in a fully integrated fashion so that CL kernels are submitted along with the same entry point that was used for their development and qualification. So, the level of coupling between these nodes may be important.

Consequently, porting an Agnos CL kernel on a new framework may be difficult if the software contract between with the entry point is not normalized. Since all platforms and frameworks are different, that kind of porting will always be a unique task (imposing a reference entry point to certify any CL kernels would have been much more structuring).

As such this section does not intend to cover all aspects of an integration process but instead should be considered as a tool to start with. Further discussions should take place to understand all the specifics of the project.

Requirements

The coupling between any entry point and an Agnos CL kernel will require some glue code to act as a communication channel between those two elements. Not only this code will be responsible for conveying the information from one point to another but also for converting those data from one format to another. In the following sections, let's call this glue code the “wrapper”. The following sections describe the mandatory elements for a successful transaction:

  • A proper Architecture

  • The Data Structures that need to be instantiated and the structure elements that must be filled

  • The Functions that need to be called

Architecture

The view below is a logical model presenting how an Agnos CL kernel is integrated onto an EMV Framework running a Contactless Entry Point.

 

Strategy

In order to leverage as much as possible on Agnos Framework and existing code, the strategy is to port the minimum software parts required to run a kernel in a standalone mode. Along with the kernels, there are three components that are mandatory:

  1. Agnos (see Agnos) which is a library encapsulating EMV processing that doesn’t need to be modified

  2. AgnosMW (see Agnos MW) which is a library encapsulating EMV data management that doesn’t need to be modified

  3. GPI (see GPI) which is a HAL that needs to be adapted to the targeted platform API

And there will two levels of integration for that task:

  1. High Level implementing the contactless entry point API in order to integrate an Agnos kernel (the wrapper)

  2. Low Level integrating the hardware API to access to platform's services

High Level interface (entry point integration)

Agnos kernels are pretty much simple by design. Their API (a.k.a AFS services) is:

  • afsInitialize(tInterface* interface)

  • afsWhatIsYourKernelId: not used in that context of integration

  • afsWhatIsYourVersion: not used in that context of integration

  • afsPreprocessing(tEntryPointConfigurationData *entryPointData, tEntryPointIndicators *riskParameters, tPaymentContext *payment): used only if a kernel supports preprocesing stage (C3 alike specification)

  • afsPerformTransaction(tPaymentContext* payment, tOutComeParameter* outcome)

  • afsRelease()

At Agnos Framework runtime, a kernel is registered onto the framework thanks to the AFS services listed above. Then, a kernel is activated once a corresponding card has been detected by the entry point. n activation, a kernel runs its logic (specifications implementation) using:

  • Internal mechanisms like limit controls, torn management, track calculations, …

  • EMV services supported by Agnos, the EMV library implementing EMV core features for contact an contactless

  • Platform services supported by GPI (CAD/SPED/HSM parts), the HAL that is adapted to the device running Agnos

Switching to a new framework, the High Level porting consists in:

1.Developing an “empty” kernel implementing only the infrastructure → The first task is to understand the software mechanisms not related to functional aspects

2. Adapting the framework's kernel activation to afsPerformTransaction → The second task is to validate that all the pre-conditions required to run an Agnos kernel will be fulfilled at activation time

3.Developing a first version of a kernel → The third task is to prototype rapidly an Agnos kernel instantiation into the framework.

Low Level (platform integration)

This part of the project is close to what Agnos projects usually consist in (see Agnos Framework Porting). There is an exception: the GPI will be partially ported because the porting scope is on the kernels only. Basically, Agnos CL kernels requires:

  • gpiRemovalProcedure

  • gpiBeep

  • gpiAdvancedDisplay

  • gpiGetPrivateScratchPAD (if torn supported)

Below the kernels (see logical architecture), Agnos requires:

  • gpiExchangeAPDU

  • gpiGetEMVCertificate

  • gpiGetEMVCRL

  • gpiSHAInit

  • gpiSHAUpdate

  • gpiSHAFinal

  • gpiRsaComputation

  • gpiGetRandomNumber

  • gpiGetRAMForTags

  • gpiGetRAMForUnknownTags

Data Structures

4 structures need to be instantiated:

  1. tOutComeParameter (see paymentMW.h)

  2. tDataExchangeList (see paymentMW.h and dataxchng.h)

  3. tPaymentContext (see paymentMW.h)

  4. tTransactionalContext (see agnos.h)

The tOutcomeParameter structure will mainly be used as an output structure to feed the Entry Point back with the transaction outcome. Only one field need to be filled in before the transaction starts:

  • tOutcomeParameter.mFieldOffReq = 0

Note: the zeroisation of the mFieldOffReq element must be done after the pmwInitializeOutComeParameter function has been called.

The tDataExchangeList structure will be used to store data elements (TLVs mostly) when Data Exchange feature is required. It doesn’t need to be filled before the transaction starts but needs to be attached to a payment context (tPaymentContext structure).

The tPaymentContext structure is the most important one. It holds all the transaction related information (e.g. the pieces of information that may vary upon each transaction). Below is the list of the structure fields that need to be filled before the transaction can start:

  • tPaymentContext.mDataExchange.mDEList (a tDataExchangeList structure needs to be attached)

  • tPaymentContext.mCashBack (pointer to a cashback value, even if 0)

  • tPaymentContext.mAmount (pointer to an amount value, even if 0)

  • tPaymentContext.mDataExchange.mError.mSW1SW2 (value of the FINAL SELECT response status word)

  • tPaymentContext.mTransactionCurrencyCode

  • tPaymentContext.mTransactionCurrencyExponent

  • tPaymentContext.mTransactionType

  • tPaymentContext.mEMVContactless

  • tPaymentContext.mTransactionDate

  • tPaymentContext.mTransactionTime

  • tPaymentContext.mRID

The tTransactionalContext structure is mostly filled by the kernel itself but still a few fields need to be prepare by the wrapper:

  • tTransactionalContext .mTransactionDate (same information as the tPaymentContext structure)

  • tTransactionalContext .mTransactionTime (same information as the tPaymentContext structure)

  • tTransactionalContext .mPinTimeOut (in seconds)

Functions

To complete the selection process (if a kernel's specification supports the preprocessing as per EMVCo books A/B) the wrapper must call the following function (APIs):

void afPreprocessing(tEntryPointConfigurationData *entryPointData, tEntryPointIndicators *riskParameters, tPaymentContext *payment)

This function will calculate the risk parameters required by the entry point to complete the selection process.

To prepare the transaction context and start the transaction the wrapper must call a certain number of functions (APIs):

void pmwInitializePaymentContext(tPaymentContext *ctx) void pmwInitializeOutComeParameter(tOutComeParameter *outcome)

These two functions will prepare and initialize the tPaymentContext and tOutcomeContext structures that must be declared in the wrapper.

tGPIError gpiInitialize(const char* transactionLogName) tGPIError gpiInitializeHSM(const char* CertificateFilesName, const char* CertificatesRevocationListFileName,const char* ExceptionFileName)

These functions will initialize the GPI library with the different file paths it requires for processing.

This function should be called to provide the kernel with all the tags corresponding to the combination's configuration that has been selected by the Entry Point before kernel's activation.

This function can be called with its parameters set to NULL and NULL.

 

Important: Depending on the contactless framework implementation, the entry point might or might not performed the Final Select. If the Final Select has been performed right after PPSE selection, then agnSetExitState must be called with NO_SELECT_FINAL as the second argument.

At this point the transaction can be started with:

Once the transaction has ended and all data has been transferred to the Entry Point, the wrapper can call the following functions:

Note: in case the wrapper is a volatile entity (e.g. a library) then all the above functions must be called each time. In case the wrapper is a non-volatile entity (e.g. binary / daemon running continuously) then some of the functions must be called only once at start-up to avoid unnecessary workload:

  • gpiInitialize

  • gpiInitializeHSM

Same applies to a function that need to be called only before the wrapper fully stops:

  • gpiRelease

Pseudo-code Sequence (preprocessing a transaction)

If the preprocessing is supported by a specification, the entry point integrating the corresponding Agnos CL kernel will be calling afsPreprocessing several times.

Pseudo-code Sequence (performing a transaction)

The following sequence is a generic example that may be used to encapsulate any Agnos kernel from a specific entry point framework.

Tags

See Configuration Model page to match potential specific framework's tags to Agnos Tags.

Technical Notes

  • For that kind of integration, Agnos' data model is not used. It's the framework's responsibility to guaranty that pre-processing, card discovery, combination selection and kernel activation will see to the appropriate tags set provided to the Agnos CL kernel

  • GPI porting is light. Focus on GPI/CAD and GPI/HSM to start. Refer to this wiki to get a good overview of the layer of the architecture

  • If ODA, EFL, and CRL are supported then refer to Physical Model to learn keys related file formats

  • For any Agnos CL kernel to be integrated onto a framework, it is important to comment the call to agnResetSessionContext performed in xxxPrepareSessionData (xxx is a prefix depending on the kernel)

  • Don't forget to implement GPI/Platform/sharedram.c allowing kernels to access to RAM