Format Preserving Encryption
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 any outside cardinality characters are present in the input data then the user must calculate effective input data length and provide IV accordingly.
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 requires minimum two bytes/characters to perform encryption.
Duplicate characters are not allowed in FPE Unicode file.
The unicode file cannot be updated at the run time; that is, the file cannot be dynamic in nature. For example, if a user has encrypted some data using a particular file then at the time of decryption same file should be used with no addition or modification of data.
For Hebrew or Arabic, it is recommended that the entire file should be based on one language. Otherwise, decrypted text may not meet plaintext.
No spaces and numbers are allowed in the unicode file, except the following cases:
For FPE/FF1/ASCII, use of numbers are allowed.
For FPE/FF1v2/ASCII, use of numbers are allowed.
For FPE/FF3/ASCII, use of numbers are allowed.
For Windows, the unicode file should be saved in the ANSI format and not in the UTF-8 format.
While using CLI commands for encrypting using FPE/FF1, FPE/FF1v2, and FPE/FF3 algorithms, the value of RADIX specified by user is equal to the character count in the provided Charset.
For 8.12.1 and older releases, if the data is encrypted using CARD62, use any of the following configuration to decrypt them:
Set Environment Variable "FPE_CARD62_Charset_Order" to 0 (False).
For example: FPE_CARD62_Charset_Order = 0.Set charset order to 0 in userSpec structure using ENUM "I_T_USPEC_CARD62_CHARSET_ORDER".
For example:I_C_SetUserSpec(I_T_USPEC_CARD62_CHARSET_ORDER, "0" , 1 , &Userspec)
The Userspec
setting has the precedence over Environment Variable.
FPE Algorithms
FPE/AES
The algorithm supports different cardinalities for different kind of data.
CARD10 for digits in range (0 - 9).
CARD26 for lower case alphabets (a-z).
CARD62 for digits (0 - 9), lower case alphabets (a - z), and upper case alphabets (A - Z).
UNICODE for various languages. The characters to be encrypted/decrypted can be specified in File or through API.
The location of this file is passed in the NAE session when performing encryption for the data derived from such character set. The number of characters provided in the character set file will be treated as cardinality for the input data. If the input data to be encrypted contains characters other than the ones available in the character set than it is retained as it is after encryption/decryption.
FPE is supported both in local and remote mode; however, in remote mode, only cardinality 10 is supported.
On performing Crypto operations with FPE, characters other than the supported cardinality set characters (if any) in the input data remains preserved and does not get encrypted.
Supported Functions
The following functions are supported by the FPE feature:
I_C_Crypt_Enhanced
I_C_CryptBulk_Enhanced
I_C_Crypt_Enhanced_FpeFormat
How it Works
To use FPE feature, the user needs to call the Crypto API with the following arguments:
Algorithm
Input data based on cardinality
IV as per input data cardinality and input data length.
Userspec (that is, tweakalgo, tweakdata and other user-defined parameters set via setUserSpec)
User provides algorithm with configured cardinality set name.
For example:
I_C_Crypt_Enhanced(session,cipherspec,operation,iv,ivlen,indata,indatalen,outdata,outdatalen,userspec)
While using FPE in Local mode the sequence of operations performed internally is as follows:
Based on the algoname, cardinality is retrieved.
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 FPE in Remote mode (only CARD10 supported) the sequence of operations performed internally is as follows:
Based on algoname, the cardinality is retrieved
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.
• Special characters preservation is not supported in the remote mode.
FPE/FF1 and FPE/FF1v2
Before using the FPE/FF1 or FPE/FF1v2 feature, the user must be aware of the following:
FPE/FF1 and FPE/FF1v2 require minimum two characters to perform encryption.
IV is not supported in FF1 and FF1v2.
These algorithms support FPE formats. For more information, refer to FPE Formats.
In the case of CARD10, 26, and 62 the user-provided Charset and Radix will be ignored.
If both Charset and UNICODE file are provided, then Charset is prioritized.
Tweak Algorithm | Tweak Data |
---|---|
NONE/Null | Less than or equal to 256 bytes |
SHA1 | Greater than 1, Less than or Equal to 256 bytes |
SHA256 | Greater than 1, Less than or Equal to 256 bytes |
Note
FPE/FF1v2 is an upgraded version of FPE/FF1. This algorithm additionally supports ACVP vectors.
This algorithm supports different cardinalities for different types of data.
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)
ASCII characters
UNICODE for various languages. The characters to be encrypted/decrypted can be specified in File or through API.
Note
• FPE/FF1 and FPE/FF1v2 algorithms are supported only in the local mode.
• Supported UTF modes are:
• UTF8
• UTF16
• UTF32
FPE/FF3
Before using FPE/FF3 feature, the user must be aware of the following:
FPE/FF3 requires minimum two characters to perform encryption.
IV is not supported in FF3.
FPE/FF3 algorithms support FPE formats. For more information, refer to FPE Formats.
Tweak data is mandatory. If tweak algorithm is NONE, the tweak data must be of 8 bytes.
For tweak algorithms SHA1 and SHA256, the tweak data length should be ≤ 256 characters.
Tweak Algorithm | Tweak Data |
---|---|
NONE/Null | Equal to 8 bytes |
SHA1 | Greater than 1, Less than or Equal to 256 bytes |
SHA256 | Greater than 1, Less than or Equal to 256 bytes |
This algorithm supports different cardinalities for different types of data.
CARD10 for digits in range 0 - 9
CARD26 for lower case alphabets (a-z)
CARD62 for digits (0 - 9), lower case alphabets (a - z), and upper case alphabets (A - Z)
ASCII characters
UNICODE for various languages. The characters to be encrypted/decrypted can be specified in File or through API.
Note
• FPE/FF3 algorithms are supported only in the local mode.
• Supported UTF modes are:
• UTF8
• UTF16
• UTF32
Modes of FPE Version Key
You can pass any of the following key version header modes in the FPE samples:
0 (NONE) - no header. This is the default value.
1 (External)- key version header is saved in the
userspec
structure. User can get version header usinggetUserSpec
after encryption.Example
CryptoSinglePart_FPE CADP_CAPI.properties j_aes_v FPE/AES/CARD10 12345 null null Username Password null null null null null 1 Plain Text (Hex):31 32 33 34 35 Encrypted Text:0 7 0 3 9 Encrypted Text (Hex):30 37 30 33 39 Version Header (Hex):10 00 20 Decrypted PlainText:1 2 3 4 5 Decrypted Text (Hex):31 32 33 34 35
2 (Internal) - key version header is in HEX format. It is saved in the first six bytes of the ciphertext.
Example
CryptoSinglePart_FPE CADP_CAPI.properties j_aes_v FPE/AES/CARD10 12345 null null Username Password null null null null null 2 Plain Text (Hex):31 32 33 34 35 Encrypted Text:1 0 0 0 2 0 0 7 0 3 9 Encrypted Text (Hex):31 30 30 30 32 30 30 37 30 33 39 Decrypted PlainText:1 2 3 4 5 Decrypted Text (Hex):31 32 33 34 35
FPE Formats
Note
For FPE AES, selection of Format Type is allowed in local and remote mode for CARD10. It determines the structure of the output.
Supported FPE Formats
Format | Description |
---|---|
LAST_FOUR | This format allows the user to keep intact the last four digits of the plaintext input even after encryption. So, after encryption the last four digits of the output ciphertext will remain same as input plaintext and rest digits will be encrypted using FPE. |
FIRST_SIX | This format allows the user to keep intact the first six digits of the plaintext input. So, after encryption the first six digits of the output ciphertext will remain same as input plaintext and rest digits will be encrypted using FPE. |
FIRST_SIX_LAST_FOUR | This format allows the user to keep intact the first six and last four digits of the plaintext input. So, after encryption the first six and last four digits of the output ciphertext will remain same as input plaintext and rest digits will be encrypted using FPE. |
FIRST_TWO_LAST_FOUR | This format allows the user to keep intact the first two and last four digits of the plaintext input. So, after encryption the first two and last four digits of the output ciphertext will remain same as input plaintext and rest digits will be encrypted using FPE. |
NONE | No format is applied with FPE. |
Note
• For FPE/FF1, FPE/FF1v2, and FPE/FF3, only CARD10, CARD26, and CARD62 is supported. ASCII and UNICODE are not supported.
• While using Format functionality in FPE, the effective input data length must be less than or equal to 56 bytes.
• In case of I_C_Crypt_Enhanced_FpeFormat
, special characters preservation is supported in both the local and remote modes.
• For versioned keys, only external header mode is supported.
Charset
The Character set (Charset) for UNICODE and ASCII can be provided using:
API (using
I_C_SetUserSpec
)UNICODE file (using
CADP_CAPI.properties
)
Charset using API (Charset and Radix)
The Charset can be provided in the two ways:
Complete Charset with Radix
Example:
Charset: abcdefghijklmnopqrstuvwxyz
Radix: 26 (total count of characters)
Charset range
Example:
Charset: 61-7A
Radix: Not required for Charset range
You can also provide multiple Charset ranges and they must be separated by comma.
Example
0030-0039,0041-005A
Note
The plaintext must be in the HEX format if the charset range uses UTF32 mode.
Charset using UNICODE File
The number of characters provided in the character set file will be treated as cardinality for the input data.
If Charset is provided through the UNICODE file, then Radix is calculated automatically.
Note
The characters out of the charset in the plaintext will be preserved.
FPE Unicode
FPE Unicode enables you to support various languages such as German, Spanish, and Arabic.
A parameter, FPE_Unicode_File
, is added in the CADP_CAPI.properties
file. This parameter contains path including file name of the FPE unicode file. This FPE unicode file contains all the characters supported in this cardinality. Cardinality is calculated on the basis of number of characters present in the FPE unicode file. It differs for FPE/AES, and FPE/FF1, FPE/FF1v2, and FPE/FF3.
For FPE/AES, the FPE unicode file contains only UTF8 characters, and the number of characters in this file should be greater than 10 and less than 256.
For FPE/FF1, FPE/FF1v2, and FPE/FF3, the FPE unicode file can contain either UTF8, or UTF16, or UTF32 character types. The number of characters in this file should be greater than 10.
Note
For all FPE algorithms, all characters other than the ones mentioned in the FPE unicode file are considered as special characters and hence they will be preserved.
IV should be as per input data cardinality and input data length.
Sample FPE Unicode File
The content of the sample FPE unicode file shown below includes all the supported Spanish characters. So all characters other than these will be considered as special characters and will be preserved.
á
é
í
ó
ú
ñ
Ñ
ü
Ü
¿
¡
Á
É
Í
Ó
Ú)
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: FPE/AES/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: FPE/AES/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: FPE/AES/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)
Algorithm: FPE/AES/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. |