Object signing and encryption conforms to the IETF JSON Object Signing and Encryption (JOSE) standard, which provides a general approach for encrypting and signing any content. It includes the use of JSON Web Encryption (JWE) for encryption and JSON Web Signature (JWS) for signing. Visa uses it to protect sensitive information, such as personal information about cardholders and their accounts, e.g. account numbers (PANs).
Clients use Field-Level Encryption (FLE) or Message-Level Encryption (MLE) to encrypt sensitive data when making API request to Visa. Field-level encryption encrypts specific API data fields (values), while Message-Level encryption encrypts entire request message. API responses may also contain Visa- encrypted data, which a client must decrypt.
Note: In many cases, the use of Field-level encryption is indicated by the enc prefix on the API field name, e.g. encPaymentInstrument.
The JWE specification standardizes the way to represent encrypted content in a JSON-based data structure.
See https://tools.ietf.org/html/draft-ietf-jose-json-web-encryption-40 for more details and complete specifications for JWE.
Visa supports both symmetric (JWE using API Key and Shared Secret) and asymmetric algorithms (JWE using RSA PKI).
For symmetric keys, the corresponding Key ID or API Key and shared secret are assigned to the client during onboarding. The shared secret will be generated and provided by Visa.
For asymmetric keys, during onboarding both Visa and the client would share their public keys. Client will encrypt all necessary fields in the request payload using Visa's public key and Visa will decrypt these fields using its corresponding private key. Similarly, Visa will encrypt all necessary fields in the response payload using the client's public key and client will decrypt these fields using their private key.
Refer to the product-specific API specification document or the implementation guide for more information on which type of encryption is required for the Visa product you are integrating with.
Visa uses the Compact serialization scheme for JWE. The JWE composition is defined as follows:
Base64URL (UTF8 (JWE Header)) || ‘.’ || Base64URL (JWE Encrypted Key) || ‘.’ || Base64URL (JWE Initialization Vector) || ‘.’ || Base64URL (JWE Ciphertext) || ‘.’ || Base64URL (JWE Authentication Tag)
Base64 encoding & conventions that Visa follows:
Visa has chosen to suffix “..” to the Base64URL encoded values, instead of the more popular == convention.
The JSON Web Signature (JWS) is a compact signature format intended for space constrained environments such as HTTP Authorization headers and URI query parameters. The JWS signature mechanisms are independent of the type of content being signed, allowing arbitrary content to be signed. A related encryption capability is described in a separate JSON Web Encryption (JWE) [JWE] specification.
Please refer to https://tools.ietf.org/html/rfc7515 for more details.
JWS represents signed content using JSON data structures and base64url encoding. The representation consists of three parts:
JWS Header
JWS Payload
JWS Signature
The three parts are base64url-encoded for transmission, and typically represented as the concatenation of the encoded strings in that order, with the three strings being separated by period ('.') characters.
The JWS Header describes the signature method and parameters employed. The JWS Payload is the message content to be secured. The JWS Signature ensures the integrity of both the JWS Header and the JWS Payload.
Base64URL (UTF-8 (JWS Header)) || ‘.’ || Base64URL (JWS Payload) || ‘.’ || Base64URL (JWS Signature)
Base64 encoding & conventions that Visa follows:
Visa has chosen to suffix “..” to the Base-64 encode values, instead of the more popular == convention.
The encryption key provided during onboarding is used to encrypt and decrypt payloads. JSON Web Encryption (JWE) content should be signed or encrypted using the shared secret that was provided to client at the time of onboarding.
Below are the symmetric encryption parameters:
Note:
The JWE Protected Header is input as the AAD (Additional Authenticated Data) parameter of the authenticated encryption (AES-GCM) of the “text to encrypt”. The general approach for JWE Encryption using API Key / Shared Secret are as follows:
To create a signature by applying JWS on JWE:
ASCII (Base64URL (UTF8 (JWS Header)) || ‘.’ || Base64URL(JWS Payload))
Base64URL (UTF8 (JWS Header)) || ‘.’ || Base64URL (JWE) || ‘.’ || Base64URL (JWS Signature)
Visa provides sample code in various languages, such as C#, Go Lang, Node JS, and Java, for handling JSON Web Encryption (JWE) for encryption and JSON Web Signatures (JWS) for object signing. To access these code samples, create an account on the Visa Developer Portal, log in, and scroll past My Projects on your dashboard to the General Assets, which include code samples for download.