jpos / jPOS

jPOS Project
http://jpos.org
GNU Affero General Public License v3.0
599 stars 458 forks source link

feat: Add Application Cryptogram Spec to jPOS 3 #500

Closed rainer010 closed 1 year ago

rainer010 commented 1 year ago

Quick summary

In an online authorization scenario, an ARQC (Authorization ReQuest Cryptogram ) is generated on the card chip, forwarded to the card scheme, and later validated by the Issuer. To perform an adequate validation, the issuer needs to consider:

This PR aims to create a set of components that could simplify the process of validating an ARQC and generating the adequate ARPC (Application Response Cryptogram) in a version-agnostic approach.

Implementation details

We are proposing a set of java components that could be able to:

These requirements could be better appreciated in this sample code:

ISOMsg request = ...;
ISOMsg response = ...;
TLVList tlv = parse(request.get(55));
IssuerApplicationData iad = new IssuerApplicationData(tlv.getString(0x9f10));
CryptogramSpec spc = iad.getCryptogramSpec();
CryptogramDataBuilder dataBuilder = spc.getDataBuilder();

boolean isValid = hsm.validateARQC(spc.getMKDMethod(), spc.getSKDMethod(), f55.getString(0x9f26), ..., dataBuilder.buildARQCRequest(tlv, iad)); 
if (isValid) {
   String arpcRequest = spc.getDefaultARPCRequestData(true);
   String arpc = hsm.generateARPC(spc.getMKDMethod(), spc.getSKDMethod(), f55.getString(0x9f26), ..., arpcRequest);

   TLVList responseTLV = new TLVList();
   responseTLV.put(0x9f10, arpc + arpcRequest);
   response.set(55, serialize(responseTLV));
} else { 
   response.unset(55);
   response.set(39, INVALID_ARQC);
}

To cover these requirements, the following changes are added: