Format Preserving Encryption for PKCS#11
The Format Preserving Encryption (FPE) algorithm allows the user to perform crypto operations on data while preserving the format of the input data.
Important Notes
Before using FPE feature, the user must be aware of the following:
If user has mixed cardinality in any particular data, then user must tokenize the data for each cardinality, and provide respective data chunk for each cardinality separately.
FPE algorithm requires minimum two bytes/characters to perform encryption.
While using CLI commands for encrypting using FPE, FF1 and FF3-1 algorithms, the value of RADIX specified by user is equal to the character count in the provided Charset.
Version keys with internal header are supported for symmetric encryption algorithms in local mode only.
Supported Functions
The following functions are supported by the FPE feature:
C_EncryptInit
C_Encrypt
C_DecryptInit
C_Decrypt
How it Works
To use FPE feature, the user needs to call the Crypto API C_EncryptInit/ C_DecryptInit to set the following:
Algorithm
Tweak algorithm
Tweak data
Charset
Cardinality
Unicode
For example:
Then call the Crypto API C_Encrypt/ C_Decrypt with data to be encrypted/decrypted respectively.
For example:
While using in Local mode, the sequence of operations performed internally is as follows:
Outside cardinality characters are trimmed and preserved as they remain as is.
The input data (without outside cardinality characters) is translated into s-integers.
FPE Crypto operation is performed in s-integers.
The s-integers ciphertext is translated to cardinality set.
Outside cardinality characters are placed at their original position.
While using FF3-1 in Remote mode, the sequence of operations performed internally is as follows:
XML request is sent for Crypto
For XML request, the CipherTrust Manager:
Translates the input data into s-integers
Performs FPE Crypto operation in s-integers
Translates s-integers ciphertext to cardinality set
Note
The characters out of charset in the plaintext will be preserved.
Supported Algorithms
FPE
Before using the FPE algorithm, the user must be aware of the following:
Two charsets ASCII and UNICODE (UTF 8, UTF 16, and UTF 32) are supported in local mode only.
On performing Crypto operations with FPE, characters other than the supported charsets (if any) in the input data remains preserved and does not get encrypted.
Tweak data is optional but highly recommended.
Supported UTF modes are:
UTF8
UTF16
UTF32
FPE algorithm supports Tweak data with 8 bytes of maximum length.
FF1
Before using the FF1 algorithm, the user must be aware of the following:
IV is not supported in FF1.
Two cardinalities ASCII and UNICODE are supported in local mode only.
Tweak data is optional but highly recommended.
Supported UTF modes are:
UTF8
UTF16
UTF32
(optional) FF1 algorithm supports Tweak data with 8 bytes of maximum length.
FF3-1
Before using FF3-1 feature, the user must be aware of the following:
IV is not supported in FF3-1.
Cardinality CARD10 is supported in both modes remote and local mode.
Cardinality CARD26, 62, ASCII and UNICODE supported in local mode only.
Supported UTF modes are:
UTF8
UTF16
UTF32
For cardinalities (CARD10, 26, and 62), you can skip providing the charset, charset length, and radix.
For ASCII, the charset length must be between 2 to 255, and radix is calculated based on the charset length.
Tweak data is mandatory. If tweak algorithm is NONE, the tweak data must be of 7 bytes for FF3-1.
For tweak algorithms SHA1 and SHA256, the tweak data length should be ≤ 256 characters.
Tweak Algorithm | Tweak Data |
---|---|
NONE/Null | Equal to 7 bytes |
SHA1 | Greater than 1, Less than or Equal to 256 bytes |
SHA256 | Greater than 1, Less than or Equal to 256 bytes |
Cardinalities
CARD10 - for digits in range 0 - 9
CARD26 - for lower case alphabets (a-z)
CARD62 - for digits (0 - 9), upper case alphabets (A - Z), and lower case alphabets (a - z)
Note
CARD10, 26 and 62 are only supported with FF3-1.
Charset
ASCII - for ascii characters
UNICODE - for various languages
The Character set (Charset) for UNICODE and ASCII can be provided with Radix as below example:
Charset: abcdefghijklmnopqrstuvwxyz
Radix: 26 (total count of characters)
Note
The plaintext must be in the HEX format if the charset range uses UTF32 mode.
Use Cases
Below are a few use cases to explain the usage of FPE/AES/UNICODE.
**Case 1**
Data element: **Name**
Cardinality set: **a to z**
Algorithm: **FF3-1**
Cardinality: **CARD26**
Maxb = **40**
Actual Input Data | Input Data to Crypto API | IV Required | Output | Remarks |
---|---|---|---|---|
“John Smith” | “john smith” | no | "kesv wqfkn" | User performs uppercase to all lower case conversion. CADP for C is preserving (space) as special character. CADP for C is performing CARD26 encryption as single data(lowercase) with space removed (datasize = 9 characters). |
"Mrs. ANNA TERESA" | "mrs. Anna teresa" | no | "pth. whts bgftds" | User performs uppercase to all lower case conversion. CADP for C is preserving (space and '.') as outside cardinality character. CADP for C is performing CARD26 encryption as single data(lowercase) with space removed (datasize = 13 characters). |
"Mrs. ANNA BERTHA CECILIA DIANA EMILY FANNY QUINCEREBECCA SARAH TERESA" | "mrs. anna bertha cecilia diana emily fanny quincerebecca sarah teresa" | yes | "gkh. stet fnrsps lspjqka amgtq ftnso liseq eudnze-skypeqv ewqlg ybdnlh" | User performs uppercase to all lower case conversion. CADP for C is preserving (space, '.' and '-’) as outside cardinality characters. CADP for C is performing CARD26 encryption as single data (lowercase) with space removed (datasize = 59 characters). IV of 40 bytes required. |
"Hary" | "hary" | no | "wybs" | User performs uppercase to all lower case conversion. CADP for C is performing CARD26 encryption as single data (lowercase) (datasize = 4 characters). |
**Case 2**
Data element: **Identification Numbers and Sensitive Authentication Data**
Cardinality set: **[0 to 9]**
Algorithm: **FF3-1**
Cardinality: **CARD10**
Maxb = **56**
Actual Input Data | Input Data to Crypto API | IV Required | Output | Remarks |
---|---|---|---|---|
"2323-3434-5656-3434" | "2323-3434-5656-3434" | no | "4527-8628-7902-7942" | CADP for C is preserving ('-') as special characters. CADP for C is performing CARD10 encryption as single data with '-' removed. (datasize =16 characters). |
"555-50-1234" | "555-50-1234" | no | "687-23-6272" | CADP for C is preserving ('-') as special characters. CADP for C is performing CARD10 encryption as single data with '-' removed (datasize =9 characters). |
"1122" | "1122" | no | "7394" | CADP for C is performing CARD10 encryption as single data (datasize =4 characters). |
**Case 3**
Data element: **Sensitive Authentication Data and Address Information**
Cardinality set: **(0 to 9, a to z, A to Z)**
Algorithm: **FF3-1**
Cardinality: **CARD62**
Maxb = **32**
Actual Input Data | Input Data to Crypto API | IV Required | Output | Remarks |
---|---|---|---|---|
"3412 25D9 dAB5 394D" | "3412 25D9 dAB5 394D" | no | "A3n4 25fD 8DEl leDF" | CADP for C is preserving CADP for C is performing FPE encryption as single data with |
"John Alexander Diaz HQ USAREUR & 7A CMR 420 Box 676 APO AE 09063" | "John Alexander Diaz HQ USAREUR & 7A CMR 420 Box 676 APO AE 09063" | yes | "12dF 376lAr3fE9sS2k3 73DW0FT & vQ90s 1mK6cC 2JRAq3 23 1lR0RT" | CADP for C is preserving all special characters. CADP for C is performing FPE encryption as single data with special characters removed datasize>maxb(32) IV required. |
"oasis_tan_1941 @gmail.com" | "oasis_tan_1941 @gmail.com" | no | "A2dr_er4_LSK4 @a35dS.29k" | CADP for C is preserving all special characters. CADP for C is performing FPE encryption as single data with special characters removed output may fail as email validation. |
"oasis_tan_1941@gmail.com" | oasis_tan_1941 | no | 23Ar_wrf_LSK4 | User performs tokenizing input and taking only username of email-id as data input for encrypt. CADP for C is preserving all special characters. CADP for C is performing FPE encryption as single data with special characters removed user can put this encrypted username and use it for email validation provided the username card62 encryption does not fail any username validation. |
";123456789012 3445=99011211 XXXXXXX00**?" | ";123456789012 3445=99011211 XXXXXXX00**?" | no | ";SAa562345dfH EE53=S9532NJE Q12446555**?" | CADP for C is preserving all special characters. CADP for C is performing FPE encryption as single data with special characters removed. |
**Case 4**
Data element: **Spanish characters**
Cardinality set: **Spanish special characters (as mentioned in [Sample FPE Unicode File](#sample-fpe-unicode-file))**
Algorithm: **FF3-1**
Cardinality: ** UNICODE **
Maxb = **48**
Actual Input Data | Input Data to Crypto API | IV Required | Output | Remarks |
---|---|---|---|---|
ÉÜÜ¿ | ÉÜÜ¿ | No | ¡ÓÁñ | CADP for C is performing FPE encryption as single data. All the characters are encrypted as there are no special characters. |
AÉÜVßÜ¿C | AÉÜVßÜ¿C | No | A¡ÓVßÁñC | CADP for C is preserving special characters (A, V, ß & C). CADP for C is performing FPE encryption as single data with special characters removed. |
ÉÜÜ¿ñññÉÜÜ¿ñ¿ñ ¿ñÉÜÉÜÉÜÉÜÉÜÉ ÜÉÜ¿ñ¿ñ¿¿ñ¿ñ¿¿ ñ¿ñ¿ÉÜ¿ÉÜ¿ | ÉÜÜ¿ñññÉÜÜ¿ñ¿ñ¿ ñÉÜÉÜÉÜÉÜÉÜÉÜÉ Ü¿ñ¿ñ¿¿ñ¿ñ¿¿ñ¿ñ¿ ÉÜ¿ÉÜ¿ | Yes(SinceMaxb =48) | ÍÍññéÚÉññüñé ÉÍ¡ÜÁéñÍúóÁ¿ áÚúÍÜúííÜóñÉ ÓÚ¿éÉáÑÓÁÑ ñóÑÉÁ | CADP for C is performing FPE encryption as single data. |