Table of Contents |
---|
This section is meant to help technical teams to integrate Agnos CL kernels onto their own framework using a CL 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 (or a similar software component) that was used to qualify themfor 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 (using 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 the 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:
...
And there will two levels of integration for that task:
High Level implementing the contactless entry point API in order to integrate an Agnos kernel (the wrapper)
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:
...
gpiExchangeAPDU
gpiGetEMVCertificate
gpiGetEMVCRL
gpiSHAInit
gpiSHAUpdate
gpiSHAFinal
gpiRsaComputation
gpiGetRandomNumber
gpiGetRAMForTags
gpiGetRAMForUnknownTags
Data Structures
4 structures need to be instantiated:
...
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):
Code Block | ||
---|---|---|
| ||
void afPreprocessing(tEntryPointConfigurationData *entryPointData, tEntryPointIndicators *riskParameters, tPaymentContext *payment) |
...
To prepare the transaction context and start the transaction the wrapper must call a certain number of functions (APIs):
Code Block | ||
---|---|---|
| ||
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.
Code Block | ||
---|---|---|
| ||
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.
Code Block | ||
---|---|---|
| ||
tAgnosError agnSetAgnosDatabase(tSessionId session, const tByte *TLV, const tWord TLVLen) |
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.
Code Block | ||
---|---|---|
| ||
void afsInitialize(tInterface *interface, void *parameters) |
This function can be called with its parameters set to NULL and NULL.
Code Block | ||
---|---|---|
| ||
tAgnosError agnOpenSessionCL ( const tString smartcardReaderName, const tString pinPadName, const tString applicationId, const tTransactionalContext *txnContext, tBoolean setEMVTag, tSessionId *session, tBoolean clipping, tBoolean sred ) tAgnosError agnSetAID ( tSessionId session, const tByte *AID, const tWord AIDLen ) tAgnosError agnSetExitState ( tSessionId session, tAgnosState exitState ) |
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:
Code Block | ||
---|---|---|
| ||
void afsPerformTransaction(tPaymentContext *payment, tOutComeParameter *outcome) |
Once the transaction has ended and all data has been transferred to the Entry Point, the wrapper can call the following functions:
Code Block | ||
---|---|---|
| ||
tPaymentError pmwCloseEMVSession(tSessionId session) tGPIError gpiRelease(void) |
...
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.
Code Block | ||
---|---|---|
| ||
static tEntryPointIndicators riskParameters[numberOfMaxSession]; // Store TTQ copy (among other flags) so that it can be fetched during actual card processing // NumberOfMaxSession reflects the maximum number of times the entry point will be calling the preprocessing for a given transaction type tPaymentContext payment; tByte i; // session identifier corresponding to a CL combination // // At EACH ENTRY POINT CALL triggering, start preprocessing (i.e. once per eligible [kernel Identifier,AID Identifier] for a given transaction type) // // BEGIN ------------------------ // Reset payment context pmwInitializePaymentContext(&payment); // // Prepare payment context // Set tPaymentContext data members like // 9F02, 9F03, 9C, 9A, 9F21, 5F2A, 5F36, 9F7C (see paymentMW.h, tPaymentContext structure/Information provide by Level3 section) // // Open session afsWhatIsYourVersion(version); agnOpenSessionCL((char*)"smartcardReaderName",(char*)"pinPadName",version,&txnContext,setEMVTag,&i,clipping,sred); // Where i is in [1..numberOfMaxSession] // Depending of the kernel, some proprietary tags need to be converted // Prepare session data agnSetAgnosDataBaseStrategy(payment->mSession,STRATEGY); // STRATEGY value depends on Agnos kernel xxxSetUpdateCondition(); // xxx prefix varies on Agnos kernel adbSetAddTagContactlessCallback(&_xxxAddTag); // xxx prefix varies on Agnos kernel agnSetAgnosDatabase(i,TLV,TLVLengh); // TLV contains selected CL combination for the preprocessing, where i is in [1..numberOfMaxSession] // Card processing afsPreprocessing(NULL,&riskParameters[i],&payment); // where i is in [1..numberOfMaxSession] // Process preprocessing results like // riskParameters->mExtendedSelectionFlagSupported // riskParameters->mTTQCopy // riskParameters->mContactlessApplicationNotAllowed // riskParameters->mStatusCheckRequested // END ------------------------ |
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.
Code Block | ||
---|---|---|
| ||
tPaymentContext payment; tOutComeParameter outcome; tTransactionalContext txnContext; tInterface interface; tBoolean clipping=bFALSE, sred=bFALSE; // Optional. Depends on the platform char version[100]=""; // // At EACH SYSTEM START-UP, system initialization // // BEGIN ------------------------ // gpiInitialize((const char*)"transactionLogName"); // Optional. Depends on the platform gpiInitializeHSM((const char*)"certificateFilesName",(const char*)"certificatesRevocationListFileName",(const char*)"exceptionFileName"); // Optional. Depends on the platform // // END ------------------------ // // At EACH NEW TRANSACTION triggering, transaction initialization // // BEGIN ------------------------ // // Reset payment context pmwInitializePaymentContext(&payment); // // Prepare payment context // Set tPaymentContext data members like // 9F02, 9F03, 9C, 9A, 9F21, 5F2A, 5F36, 9F7C (see paymentMW.h, tPaymentContext structure/Information provide by Level3 section) // If PayPass, set an instance of tDataExchangeList // // Initialize Agnos kernel afsInitialize(&interface,NULL); // // END ------------------------ // // At EACH ENTRY POINT CALL triggerring, start initialization (i.e. always) // // BEGIN ------------------------ // // Reset outcome context pmwInitializeOutComeParameter(&outcome); // IF no preprocessing performed earlier THEN // Open session afsWhatIsYourVersion(version); agnOpenSessionCL((char*)"smartcardReaderName",(char*)"pinPadName",version,&txnContext,setEMVTag,&payment->mSession,clipping,sred); // ELSE payment->mSession = i; // IMPORTANT: where i corresponds to the selected CL combination that is used to perform the transaction // END IF // Depending of the kernel, some proprietary tags need to be converted // Prepare session data agnSetAgnosDataBaseStrategy(payment->mSession,STRATEGY); // STRATEGY value depends on Agnos kernel xxxSetUpdateCondition(); // xxx prefix varies on Agnos kernel adbSetAddTagContactlessCallback(&_xxxAddTag); // xxx prefix varies on Agnos kernel agnSetAgnosDatabase(payment->mSession,TLV,TLVLengh); // TLV contains selected CL combination // Miscellaneous settings memcpy(payment->mRID,AID,5); // AID is provided by the entry point agnSetAID(session,AID,AID_LENGTH); // AID and AID_LENGTH are provided by the entry point agnSetExitState(payment->mSession,NO_SELECT_FINAL); // Optional. Depends on entry point implementation (i.e if the entry point performs the Final Select) // If 9F37 is provided by entry point then call agnOverwriteEMVTag with 9F37 value // If NO_SELECT_FINAL then set 9F02 and 9F03 using agnSetEMVTag // Card processing afsPerformTransaction(&payment,&outcome); // Process card processing results like // Tag reading // Outcome conversion // payment->mDataExchange conversion // etc... // Close Agnos session pmwCloseEMVSession(payment->mSession); // // END ------------------------ // // At EACH SYSTEM SHUT DOWN, system release // // BEGIN ------------------------ // gpiRelease(); // Optional. Depends on the platform // // END ------------------------ |
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 Deployment 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