This document describes the cryptographic constructs used in
FIDO Web Pay (FWP) Assertions.
To make the descriptions more accessible,
the samples in the core document are used for illustrating the different processing steps.
The samples depend on the keys provided in the Sample Keys section.
2. Relationship to Existing Standards
Since the user authorization component of FWP Assertions is based on CBOR
[RFC8949],
one might assume that the cryptography would be based on
COSE [RFC8152].
However, this is only partially true because FIDO signatures (Web Authentication) are
incompatible with COSE. In addition, FWP authorization signatures build on
deterministic CBOR as outlined in RFC8949, section 4.2.1.
3. Terminology
Throughout this document CBOR primitives are expressed in
CDDL [RFC8610]
notation.
Items in red refer to attributes associated with the selected Payment Credential.
4. User Authorization
Unlike Web Authentication, FWP builds on an authorization concept derived
from EMV®. That is, user authorizations are created entirely locally in the FWP client.
Compatible FIDO authenticators MUST therefore be "client side" only.
The following subsections describe the steps required
for creating the user authorization component of FWP Assertions.
4.1. Create Authorization Data (AD)
Before requesting the user to authorize ("sign"),
the FWP client creates data to related to the
payment request (aka "dynamic linking") like in the sample from the
main document:
Since this section is about cryptographic constructs, only the data in the
signaturemap (label -1) is
elaborated on here.
Definition:
Name
Label
Type
Description
signatureAlgorithm
1
int
FIDO signatureAlgorithm associated with the selected Payment Credential.
The value to use is the "Identifier" specified in the Signature Algorithms table.
publicKey
2
map
FIDO publicKey descriptor associated with the selected Payment Credential.
The key descriptor MUST only contain the core public key data.
This item MUST be COSE compliant as well as be compatible with the
signatureAlgorithm.
As can be seen in the listing, the signatureAlgorithm and
publicKey attributes are already featured in the signaturemap.
This is because they are static and can thus be included in the data
to be signed, potentially making the signature scheme more resistant to tampering.
The sample AD should read as follows
when expressed in hexadecimal encoding:
Using the result of the previous step (but
using binary encoding), as the sole data input to the
FIDO signature process,
the user should at this stage be asked to authorize a payment request
using the key (authenticator)
pointed out by the credentialId of the selected Payment Credential.
For a detailed description of how FIDO signatures are created,
turn to Web Authentication. Note that AD is signed after hashing, making
clientDataHash the actual data to be signed:
The SHA256 hash of the sample AD should read as follows if encoded in hexadecimal:
To identify the ESAD object profile, as well as the encrypted SAD object,
a common
COTX tag with the value
"https://fido-web-pay.github.io/ns/p1"
is wrapping the encryption attributes.
ESAD objects are packaged as follows:
Numbers in parentheses represent the CBOR map key
(label) associated with the symbolic name.
The attributes in the dashed boxes are optional, depending on
key encryption algorithm and encryption key reference method.
Main map definition:
Name
Label
Type
Description
algorithm
1
int
Symmetric key algorithm used for encrypting the actual content.
The value to use is the "Identifier" specified in the
Content Encryption Algorithms table.
Key encryption algorithm.
The value to use is the "Identifier" specified in the
Key Encryption Algorithms table.
keyId
3
"Any"
Optional: To facilitate a streamlined decryption process,
the encryption object MUST include a reference to the
encryption key. This reference is either provided through a keyId
or through the publicKey itself. That is, both attributes MUST NOT
be present in an FWP compliant encryption object.
Note that the this specification does not define any specific keyId syntax.
The sample uses a tstr but it could equally well be
a hash of the publicKey featured in a bstr.
publicKey
4
map
Optional: Public key in COSE format. See keyId.
Note that a publicKey attribute MUST only contain the
core public key data.
ephemeralKey
7
map
Ephemeral public key in COSE format.
Note that a publicKey attribute MUST only contain the
core public key data.
cipherText
10
bstr
Optional: Encrypted key for key-wrapping ECDH algorithms.
5.2. Encryption Process
To encrypt a SAD object, the following steps MUST be performed:
Retrieve the keyEncryptionAlgorithm,
contentEncryptionAlgorithm,
and encryptionKey attributes of the selected Payment Credential.
The compatibility of these attributes with respect to this specification,
as well as with the client implementation, is assumed
to have been verified during credential enrollment.
Copy the keyEncryptionAlgorithm to the algorithm label.
If the encryptionKeyId of the selected Payment Credential
is defined, copy the value to the keyId label,
else copy the encryptionKey to the publicKey label.
Creating a key for encrypting the content (SAD) requires the following steps:
Generate a key pair compatible with the encryptionKey.
Copy the public key of the generated key pair to the ephemeralKey label.
Perform the core ECDH operation (key agreement) including the KDF,
using the private key of the generated key pair and
the encryptionKey.
Note that the requested length of the shared secret generated by the KDF,
is defined by the keyEncryptionAlgorithm. See Key Encryption Algorithms.
For the ECDH-ES (direct mode) keyEncryptionAlgorithm,
set a varible contentEncryptionKey equal
to the result of the ECDH operation. For the other (key wrapping)
ECDH variants, perform the following steps:
Define a contentEncryptionKey variable.
Assign a random number to the contentEncryptionKey.
Encrypt the contentEncryptionKey with the key wrapping method
associated with the ECDH algorithm using
the previously generated shared secret as encryption key.
Copy the result of the previous operation to the cipherText label.
Note that the length of the contentEncryptionKey is defined by the
contentEncryptionAlgorithm. See Content Encryption Algorithms.
The length of the "Derived Key" attribute is in bytes.
5.6. Key Derivation Function
Note that the ECDH algorithms MUST use a Key Derivation Function (KDF) according to HKDF
[RFC5869],
profiled as follows:
hmac: The HKDF implementation MUST use HMAC with SHA256
salt: N/A. The default extract mode handling MUST be implemented.
info: This parameter MUST consist of the actual COSE key
encryption algorithm, expressed as a 32-bit (4 byte) signed big-endian integer.
6. User Authorization Decoding and Verification
The following sections describe the steps needed for decoding
the user authorization part (ESAD) of FWP Assertions, as well as
verifying that it is technically correct from a cryptographic point of view.
As outlined in the core document, several other checks MUST also be performed
before an associated payment request can be considered as trusted.
Missing, erroneous, or extraneous data MUST cause the verification
process to terminate with an appropriate error indication.
6.1. Decrypt Authorization (ESAD)
Decode the ESAD binary using a suitable CBOR parser.
Perform the following steps to decrypt the ESAD object:
Retrieve the private encryption key associated with the encryptionKeyId or
the publicKey in the Sub map, depending on
which of the attributes that are defined (which in most cases is known in advance
since the issuer and relying party usually is the same entity).
Fetch the ECDH algorithm to use from the algorithm attribute in the Sub map.
Perform an ECDH key agreement operation including KDF with the retrieved private key
and the ephemeralKey attribute in the Sub map.
For key wrapping ECDH algorithms, use the result of the ECDH operation
to unwrap a contentEncryptionKey (specified by
the cipherText attribute in the Sub map), while ECDH-ES
returns the contentEncryptionKey directly. See Key Encryption Algorithms.
Note that ES256 signatures usually depend on a random factor as well, making
each signature unique. Verification should still work
as long as the signature key and data to be signed remain constant.
7.2. Encryption Key
The following key (here expressed as a JWK [RFC7517]),
was used for the encryption part of the ESAD sample: