Encryption
Preface
This section contains information about how to use this document.
Conventions Used in This Document
The following conventions are used in this document to identify the specified types of information
Type of Information
Convention
Example
Elements of the API, such as resources
Boldface
/authorization
Variables
Italics within curly brackets
{ID}
Glossary terms
Italics on first occurrence; defined in Glossary
The purpose of the API is to enable interoperable financial transactions between a Payer (a payer of electronic funds in a payment transaction) located in one FSP (an entity that provides a digital financial service to an end user) and a Payee (a recipient of electronic funds in a payment transaction) located in another FSP.
Library documents
Italics
User information should, in general, not be used by API deployments; the security measures detailed in API Signature and API Encryption should be used instead.
Document Version Information
Version
Date
Change Description
1.1
2020-05-19
1.0
2018-03-13
Initial version
Introduction
This document details security methods to be implemented for Open API (Application Programming Interface) for FSP (Financial Service Provider) Interoperability (hereafter cited as "the API") to ensure confidentiality of API messages between an API client and the API server.
In information security, confidentiality means that information is not made available or disclosed to unauthorized individuals, entities, or processes (excerpt from ISO27000The ISO 27000 Directory). For the API, confidentiality means that some sensitive fields in the payload of an API message cannot be accessed or identified in an unauthorized or undetected manner by the intermediaries involved in the API communication. That is, if some fields of an API message are encrypted by the API client, then only the expected API recipient can decrypt those fields.
JSON Web Encryption (JWE, defined in RFC 7516JSON Web Encryption (JWE)) must be applied to the API to provide end to end message confidentiality. When an API client sends an HTTP request (such as an API request or callback message) to a counterparty, the API client can determine whether there are sensitive fields in the API message to be protected according to the regulation or local schema. If there is a field to be protected, then the API client uses JWE to encrypt the value of that field. Subsequently, the cipher text of that field will be transmitted to the counterparty.
To support encryption for multiple fields of an API message, JWE is extended in this document to adapt to the requirements of the API.
Open API for FSP Interoperability Specification
The Open API for FSP Interoperability Specification includes the following documents.
Logical Documents
Asynchronous REST Binding Documents
Data Integrity, Confidentiality, and Non-Repudiation
General Documents
API Encryption Definition
This section introduces the technology used by API encryption, including:
Data exchange format for the encrypted fields of an API message.
Mechanism for encrypting and decrypting fields.
Encryption Data Model
The API uses the customized HTTP header parameter FSPIOP-Encryption to represent the encrypted fields of an API message; its value is a JSON object serialization. The data model of this parameter is described in Table 1, Table 2 and Table 3.
Note: If FSPIOP-Encryption is present in an API message, then it must also be protected by the API signature. That means FSPIOP-Encryption must be included in the JWS Protected Header of the signature.
Table 1
Name
Cardinality
Type
Description
encryptedFields
1
EncryptedFields
Information about the encrypted fields of an API message
Table 1 -- Data model of HTTP Header Field FSPIOP-Encryption
Table 2
Name
Cardinality
Type
Description
encryptedField
1..*
EncryptedField
Information about the encrypted field of an API message
Table 2 -- Data model of complex type EncryptedFields
Table 3
Name
Cardinality
Type
Description
fieldName
1
String(1..512)
This element identifies the field to be encrypted in the payload of an API message. Because the API payload is a JSON Object serialization string, the field name must be able to identify the exact element path in the JSON Object. A single period ('.') character is used to separate the elements in an element path. For example, payer.personalInfo.dateOfBirth is a valid value for this element for the API request POST /quotes.
encryptedKey
1
String(1..512)
Encrypted Content Encryption Key (CEK) value. Its value is encoded by BASE64URL(JWE Encrypted Key). If there are multiple fields of the API message to be encrypted, we recommend that the same JWE Encrypted Key be used to simplify the implementation; however, this is a decision to be made by each FSP internally based on their implementation.
protectedHeader
1
String(1..1024)
This element identifies the Header Parameters that are applied to JWE to encrypt the specified field. Its value is encoded by BASE64URL(UTF8(JWE Protected Header)).
For example, if the JWE Protected Header applied to the encryption is {"alg":"RSA-OAEP- 256","enc":"A256GCM"}
, then the value is eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkEyNTZHQ00ifQ
.
initializationVector
1
String(1..128)
Initialization Vector value used when encrypting the plaintext. Its value is encoded by BASE64URL(JWE Initialization Vector).
authenticationTag
1
String(1..128)
Authentication Tag value resulting from authenticated encryption of the plaintext with Additional Authenticated Data. Its value is encoded by BASE64URL(JWE Authentication Tag)
Table 3 -- Data model of complex type EncryptedField
Encrypt Fields of API Message
This section describes the encryption process for message fields. The order of the steps is not significant in cases where there are no dependencies between the inputs and outputs of the steps.
Determine the algorithm used to determine the CEK value (this is the algorithm recorded in the alg (algorithm) Header Parameter of the resulting JWE). Because the CEK should be encrypted with the public key of the API recipient, in the API the available algorithms to protect the CEK can only be RSA-OAEP-256.
If there are multiple fields to be encrypted in the API message, then perform Steps 3-15 for each field.
Generate a random CEK. The FSP can generate the value using either its own application or using the JWE implementation employed.
Encrypt the CEK with the algorithm determined by the JWE header parameter alg.
Compute the encoded key value BASE64URL(JWE Encrypted Key).
Generate a random JWE Initialization Vector of the correct size for the content encryption algorithm (if required for the algorithm); otherwise, let the JWE Initialization Vector be the empty octet sequence.
Compute the encoded Initialization Vector value BASE64URL(JWE Initialization Vector).
If a zip parameter was included, compress the plaintext using the specified compression algorithm and let M be the octet sequence representing the compressed plain text; otherwise, let M be the octet sequence representing the plain text.
Create the JSON object or objects containing the desired set of header parameters, which together comprise the JWE Protected Header. Besides the parameter alg, the parameter enc must be included in the JWE Protected Header. The available values for the parameter enc in the API can only be: A128GCM, A192GCM, A256GCM. A256GCM is recommended.
Compute the Encoded Protected Header value BASE64URL(UTF8(JWE Protected Header)).
Let the Additional Authenticated Data encryption parameter be ASCII(Encoded Protected Header).
Encrypt M using the CEK, the JWE Initialization Vector, and the Additional Authenticated Data value using the specified content encryption algorithm to create the JWE Cipher text value and the JWE Authentication Tag (which is the Authentication Tag output from the encryption operation).
Compute the encoded cipher text value BASE64URL(JWE Cipher Text).
Compute the encoded Authentication Tag value BASE64URL(JWE Authentication Tag).
Compute the encryptedField element (see Table 3) for the HTTP header parameter FSPIOP-Encryption.
Compute the value for the HTTP Header parameter FSPIOP-Encryption as described in FSPIOP API documentation. The value for this FSPIOP-Encryption is JSON Object Serialization string.
Note: If JWE is used to encrypt some fields of the payload, then the API client should:
Encrypt the desired fields.
Replace those fields' value with the encoded cipher text in the payload.
Sign the payload.
Decrypt Fields of API Message
If the HTTP Header parameter FSPIOP-Encryption (which is also protected by the API signature) is present, then the API message recipient should decrypt the encrypted fields of the API message after the API signature is validated successfully. The message decryption process is the reverse of the encryption process. The order of the steps is not significant in cases where there are no dependencies between the inputs and outputs of the steps. If there are multiple fields being encrypted, then all fields must be decrypted successfully; otherwise it indicates the API message is invalid.
Parse the HTTP Header parameter FSPIOP-Encryption to get encrypted fields' information, including field name, JWE Protected Header, JWE Encrypted Key, JWE Initialization Vector, and JWE Authentication Tag for each field. If there are multiple fields being encrypted, then perform Steps 2-9 for each encrypted field.
Get the cipher text of the encrypted field by parsing the payload with the specified field path. The value of the specified field is already encoded with BASE64URL.
Verify that the octet sequence resulting from decoding the encoded JWE Protected Header is a UTF-8-encoded representation of a valid JSON object conforming to JSON Data Interchange Format (defined in RFC 7159The JavaScript Object Notation (JSON) Data Interchange Format); let the JWE Protected Header be this JSON object.
Verify that the parameters in the JWE Protected Header understand and can process all fields that are required to support the JWE specification; for example, the algorithm being used.
Determine that the algorithm specified by the alg (algorithm) Header Parameter matches the algorithm of the public / private key of the API recipient.
Decrypt the JWE Encrypted Key with the private key of the API recipient to get the JWE CEK.
Let the Additional Authenticated Data encryption parameter be ASCII(Encoded Protected Header).
Decrypt the JWE Cipher Text using the CEK, the JWE Initialization Vector, the Additional Authenticated Data value, and the JWE Authentication Tag (which is the Authentication Tag input to the calculation) using the specified content encryption algorithm, returning the decrypted plaintext and validating the JWE Authentication Tag in the manner specified for the algorithm. If the JWE Authentication Tag is incorrect, then reject the input without any decryption.
If a zip parameter was included, then the API recipient should decompress the decrypted plaintext using the specified compression algorithm.
API Encryption/Decryption Examples
This section uses a typical quote process to explain how the API encryption and decryption are implemented using JWE. As the algorithm of public / private key of the API recipient can only be RSA, the RSA key used for this example is represented in JSON Web Key (JWK, defined in RFC 7517JSON Web Key(JWK)) format below (with line breaks and indentation within values for display purposes only):
Encryption Example
The following message text is an example of POST /quotes without encryption sent by Payer FSP to a Payee FSP.
In this case, the Payer FSP would like to encrypt two fields of the API message: payer and payee.partyIdInfo.partyIdentifier.
Encrypt the Required Fields
Because there are two fields to be encrypted, the Payer FSP needs to encrypt the two fields one-by-one.
Encrypt "payer"
The Payer FSP performs the following steps to encrypt the field payer in the POST /quotes API message.
Determine the algorithm used to determine the CEK value. In this case, assuming it is RSA-OAEP-256.
Generate a 256-bit random CEK. In this case, its value is (using JSON Array notation):
Encrypt the CEK with the Payee FSP's public key shown in JSON Web Key format in API Encryption/Decryption Examples. In this case, the encrypted value is (using JSON Array notation):
Compute the encoded key value BASE64URL(JWE Encrypted Key). In this case, its value is:
Generate a random JWE Initialization Vector of the correct size for the content encryption algorithm. In this case, its value is (using JSON Array notation):
Compute the encoded Initialization Vector value BASE64URL(JWE Initialization Vector). In this case, its value is:
Get the plaintext of the field payer of the API message as the payload to be encrypted. In this case, its value is:
Create the JSON object or objects containing the desired set of header parameters, which together comprise the JWE Protected Header. In this case, its value is:
Compute the Encoded Protected Header value BASE64URL(UTF8(JWE Protected Header)). In this case, its value is:
Let the Additional Authenticated Data encryption parameter be ASCII(Base64URL(JWE Protected Header)).
Encrypt the plain text using the CEK, the JWE Initialization Vector, and the Additional Authenticated Data value using the specified content encryption algorithm to create the JWE Cipher text value and the JWE Authentication Tag (which is the Authentication Tag output from the encryption operation).
Compute the encoded cipher text value BASE64URL(JWE Cipher Text). In this case its value is:
Compute the encoded Authentication Tag value BASE64URL(JWE Authentication Tag). In this case its value is:
Encrypt payee.partyIdInfo.partyIdentifier
Determine the algorithm used to determine the CEK value. In this case, assuming it is RSA-OAEP-256.
Generate a 256-bit random CEK. In this case, the same CEK defined in Encryption Data Model is used., Its value is (using JSON Array notation):
Encrypt the CEK with the Payee FSP's public key represented in JSON Web Key format in API Encryption/Decryption Examples. In this case, its value is (using JSON Array notation):
Note: Although the same CEK is used for the two fields payer and payee.partyIdInfo.partyIdentifier, the encrypted CEK values may be different from each other because of the use of a random number when encrypting the CEK by JWE implementations (for example, jose4j, nimbus-jose-jwt, and so on). This depends on how the JWE is implemented in each FSP system. 4. Compute the encoded key value BASE64URL(JWE Encrypted Key). In this case, its value is:
Generate a random JWE Initialization Vector of the correct size for the content encryption algorithm. In this case, its value is (using JSON Array notation):
Compute the encoded Initialization Vector value BASE64URL(JWE Initialization Vector). In this case, its value is:
Get the plain text of the field payee.partyIdInfo.partyIdentifier of the API message as the payload to be encrypted. In this case, its value is
Create the JSON object or objects containing the desired set of Header Parameters, which together comprise the JWE Protected Header. In this case, its value is:
Compute the Encoded Protected Header value BASE64URL(UTF8(JWE Protected Header)). In this case, its value is:
Let the Additional Authenticated Data encryption parameter be ASCII(Encoded Protected Header).
Encrypt the plain text using the CEK, the JWE Initialization Vector, and the Additional Authenticated Data value using the specified content encryption algorithm to create the JWE Cipher text value and the JWE Authentication Tag (which is the Authentication Tag output from the encryption operation).
Compute the encoded cipher text value BASE64URL(JWE Cipher Text). In this case its value is:
Compute the encoded Authentication Tag value BASE64URL(JWE Authentication Tag). In this case its value is:
Producing FSPIOP-Encryption
Using the given data model of the header FSPIOP-Encryption, get the header's value as shown below (line break and indentation are only for display purpose):
Re-produce API message with encryption
Using the cipher text of the encrypted field to replace the plain text of the corresponding field of the API message (the string with, light grey background in the message text below), add parameter FSPIOP-Encryption (the string with light grey background in the message text below) into the HTTP header of the API message.
Note: The FSPIOP-Encryption parameter should be included in the JWS Protected Header for the signature of the API message, and the HTTP body of the API message below should be the JWS Payload for the signature. The signature process is out-of- scope for this document.
Decryption Example
In this example, the Payee FSP receives the POST /quotes API message from Payer FSP. The message is described in Encryption Data Model. If the Payee FSP detects that the HTTP header parameter FSPIOP-Encryption is present in the message, then the Payee FSP knows that some fields were encrypted by the Payer FSP. The Payee FSP then performs the following steps to decrypt the encrypted fields.]
Parse FSPIOP-Encryption
The Payee FSP verifies that the value of FSPIOP-Encryption is a UTF-8-encoded representation of a valid JSON object conforming to RFC 7159. The FSP then parses the HTTP Header parameter FSPIOP-Encryption to get encrypted fields information, including field name, JWE Protected Header, JWE Encrypted Key, JWE Initialization Vector, and JWE Authentication Tag for each field.
Decrypt the Encrypted Fields
In this case, the Payee FSP gets two fields payer and payee.partyIdInfo.partyIdentifier from the HTTP header FSPIOP- Encryption. Then the Payee FSP decrypts the two fields one-by-one.
Decrypt payer
The Payer FSP performs the following steps to decrypt the field payer in the POST /quotes API message.
Get the encoded BASE64RUL(JWE Protected Header) from the parsed FSPIOP-Encryption for the field payer. In this case its value is:
Decode the encoded JWE Protected Header. In this case its value is:
Check that the decoded value of JWE Protected Header is a UTF-8-encoded representation of a completely valid JSON object conforming to JSON Data Interchange Format (RFC 7159), and that the parameters in the JWE Protected Header can process all fields that are required to support the JWE specification.
Get the encoded BASE64URL(JWE Encrypted Key). In this case its value is:
Decode the encoded JWE Encrypted Key. In this case its value is as follows (using JSON Array notation):
Decrypt the JWE Encrypted Key using the specified algorithm RSA-OAEP-256 with the Payee FSP's private key to get the CEK. In this case the decrypted CEK is (using JSON Array notat ion):
Get the encoded BASE64URL(JWE Initialization Vector). Its value is:
Decode the encoded JWE Initialization Vector. In this case, its value is (using JSON Array notation):
Get the value of the field payer from the API message as the encoded BASE64URL(JWE Cipher Text) to be decrypted. In this case, its value is
Get the encoded Authentication Tag value BASE64URL(JWE Authentication Tag). In this case its value is:
Decrypt the cipher text using the CEK, the JWE Initialization Vector, and the Additional Authenticated Data value using the specified content encryption algorithm to decrypt the JWE Cipher text. In this case, the plain text is
Verify that the plaintext is a UTF-8-encoded representation of a completely valid JSON object conforming to RFC 7159, and the content matches the data mode definition for the payer.
Decrypt payee.partyIdInfo.partyIdentifier
The Payer FSP performs the following steps to decrypt the field payee.partyIdInfo.partyIdentifier in the POST /quotes API message.
Get the encoded BASE64RUL(JWE Protected Header) from the parsed FSPIOP-Encryption for the field payee.partyIdInfo.partyIdentifier. In this case its value is:
Decode the encoded JWE Protected Header. In this case its value is:
Verify that the decoded value of JWE Protected Header is a UTF-8-encoded representation of a completely valid JSON object conforming to RFC 7159, and that the parameters in the JWE Protected Header understand and can process all fields that are required to support the JWE specification.
Get the encoded BASE64URL(JWE Encrypted Key). In this case its value is:
Decode the encoded JWE Encrypted Key. In this case its value is (using JSON Array notation):
Decrypt the JWE Encrypted Key using the specified algorithm RSA-OAEP-256 with the Payee FSP's private key to get the CEK. In this case the decrypted CEK is (using JSON Array notation):
Get the encoded BASE64URL(JWE Initialization Vector). Its value is:
Decode the encoded JWE Initialization Vector. In this case, its value is (using JSON Array notation):
Get the value of the field payee.partyIdInfo.partyIdentifier from the API message as the encoded BASE64URL(JWE Cipher Text) to be decrypted. In this case, its value is:
Get the encoded Authentication Tag value BASE64URL(JWE Authentication Tag). In this case its value is:
Decrypt the cipher text using the CEK, the JWE Initialization Vector, and the Additional Authenticated Data value using the specified content encryption algorithm to decrypt the JWE Cipher text. In this case, the plain text is
Verify that the plain text is a valid partyIdentifier value.
Table of Tables
Last updated