SYSCAT.DM.MASK
. Data masking
rules consist of individual rule types that define the specific masking
action or algorithm to apply to the data. Data masking rules are as
follows:
SYSCAT.DM.MASK
function accepts defaults configured as package options in addition to the various
arguments associated with each rule type. For example, the KEY argument for the ENCRYPT rule defaults to the value configured
as the ENCRYPT_KEY
package option if a key
is not specified in the argument. To configure default masking parameters
as package options, use the ALTER SERVER DDL command. The following example sets a default, or pre-configured, encryption key used by the ENCRYPT and HASH rule types:ALTER SERVER {options PACKAGE(name 'DM', ENCRYPT_KEY ’212e8ba6b7f84796a87a985d54277f2f’)}
DECRYPT
rule
type. If encrypted data will require decryption, you should set a
unique encryption key within the data masking argument.
SYSCAT.DM.MASK
function with the specified rule types and arguments to mask a value containing PII.
The rule type argument must be a string constant. Argument names are not case sensitive.
Here is
the syntax:SYSCAT.DM.MASK( 'rule-type', value [, rule-arguments])Here is the syntax for the rule arguments:
[, 'rule-arg-name1', 'rule-arg-value1', [, 'rule-arg-name2', 'rule-arg-value2', ...]] )
Here is an example of
data masking that uses the
HASH rule-type. This rule masks the ‘LastName’ column in the HR.EMPLOYEES table using
an HMAC-MD5
hash and aliases the result as LN: select SYSCAT.DM.MASK('HASH', "LastName", 'alg', 'MD5', 'key', 'abc123!' ) as "LN" from HR.EMPLOYEES |
Argument
|
Description
|
---|---|
rule-type
|
Name of the rule type, for example, ENCRYPT, DECRYPT, or HASH.
|
value
|
Specifies the data value to mask, for example, a column reference or other value expression.
Value is always the first position following a rule-type in a data masking statement.
|
rule-arg-name1
|
Name of the first masking
rule argument.
|
rule-arg-value1
|
Value of the first masking
rule argument.
|
rule-arg-name2,
...
|
Name of the second and
subsequent masking rule arguments.
|
rule-arg-value2
|
Value of the second
and subsequent masking rule arguments.
|
ENCRYPT_KEY
pre-configured
in SYSCAT.DM.MASK
.
SYSCAT.DM.MASK
.
The DECRYPT rule returns NULL for the AES algorithm if the KEY argument
is omitted.
SYSCAT.DM.MASK( 'ENCRYPT', value [, rule-arguments ] ), SYSCAT.DM.MASK( 'DECRYPT', value [, rule-arguments ] )
Unique | Results are unique if the input values are unique. |
Deterministic | Results are deterministic if DETERMINISTIC YES is specified. |
Reversible | Reversal is possible if key is poor quality or divulged. |
Specifies the data value to mask. Value can be a column or other value expression, and always follows the ENCRYPT or DECRYPT rule-type in a masking statement. Here is an example where the social security number column (“SSN”) is masked with encryption:
select SYSCAT.DM.MASK('ENCRYPT', "SSN",...
Argument type: Algorithm required. Case-insensitive string constant.
AES/FIPS | FIPS 140-2 compliant AES encryption (FIPS 197). Symmetric key block encryption cipher using the AES (Advanced Encryption Standard) algorithm for 128 bit blocks using a 256 bit key and a 64 bit salt value. An encryption key must be specified in order for the algorithm to produce truly encrypted results. Requires installation of DataFlux Secure. |
AES | FIPS 140-2 compliant AES encryption (FIPS 197). Symmetric key block encryption cipher using the AES (Advanced Encryption Standard) algorithm for 128 bit blocks using a 256 bit key and a 16 bit salt value. An encryption key must be specified in order for the algorithm to produce truly encrypted results. Requires installation of DataFlux Secure. |
BASE64 | Base 64 encoding. Not FIPS 140-2 compliant. |
SAS001 | Alias for BASE64 encoding. |
SAS002 | SAS Proprietary encoding. Not FIPS 140-2 compliant. |
SAS003 | Alias for AES. |
SAS004 | Alias for AES/FIPS. |
Argument type: Case-insensitive string constant. Valid only with AES encrypted data. Required for DECRYPT. Not valid for the SAS002 algorithm.
ENCRYPT_KEY
option
in SYSCAT.DM.MASK, or, for ENCRYPT
only,
the static default when none is configured. You can set a pre-configured
encryption key using the ENCRYPT_KEY option in the ALTER SERVER DDL
statement.
Argument type: Case-insensitive Boolean string constant or 1 or 0.
ENCRYPT
only.
Argument type: Case-insensitive Boolean string constant or 1 or 0.
ENCRYPT
only.
EXPAND_PREC
is
active by default. If the encrypted value does not fit in the column,
this option returns an empty string for VARCHAR
or NVARCHAR
,
or all-blank for CHAR
or NCHAR
.
VARCHAR
or NVARCHAR
.
CHAR
or NCHAR
.
Argument type: Case-insensitive string constant.
ENCRYPT
only.
U[PPER] | Use uppercase hexits A-F. |
L[OWER] | Use lowercase hexits a-f. |
Argument type: Case-insensitive string constant.
ENCRYPT
only.
SYSCAT.DM.MASK( 'HASH', value [, rule-arguments ] )
Unique | Results might be unique if the input values are unique. |
Deterministic | Yes |
Reversible | No |
Algorithm
|
Value Type
|
Return Type
|
---|---|---|
MD5
|
CHAR or VARCHAR
|
CHAR(32)
|
WCHAR or WVARCHAR
|
WCHAR(32)
|
|
other
|
BINARY(16)
|
|
SHA256
|
CHAR or VARCHAR
|
CHAR(64)
|
WCHAR or WVARCHAR
|
WCHAR(64)
|
|
other
|
BINARY(32)
|
Specifies the data value to mask. Value can be a column or other value expression, and always follows the HASH rule-type in a masking statement. Here is an example where “LastName” is the masked value.
select SYSCAT.DM.MASK('HASH', "LastName",...
Argument type: Case-insensitive string constant.
MD5 | Robert Rivest’s 128–bit algorithm (1991). |
SHA256* | NSA’S 256–bit algorithm (2001). SHA256 is the default. |
Argument type: Case-insensitive string constant.
U[PPER] | Use uppercase hexits A-F. |
L[OWER] | Use lowercase hexits a-f. |
Argument type: Case-insensitive string constant.
SYSCAT.DM.MASK ('TRANC', "value" , 'FROM', 'lower-case string, 'TO', 'lower-case string' )
Unique | Data dependent. |
Deterministic | YES |
Reversible | Reversal is possible depending on the character mapping provided. Reversal is appropriate when mapping multiple input characters to a single output character. |
SELECT SYSCAT.DM.MASK('TRANC', TABLE.COLUMN."FIELD", 'FROM', 'characters_to_convert', 'TO', 'converted_characters', 'START', 1, 'LENGTH ', 11) ) 'TRANC', '123', 'FROM', '0123456789','TO', 'XXXXXXXXXX', 'START', 1, 'LENGTH', 3
Specifies the data value to mask. Value can be a column or other value expression, and always follows the TRANC rule-type in a masking statement.
Argument type: String
Argument type: String
TO
string must not have
more characters than the FROM
string. Additional FROM
string
characters are mapped to blanks.
Argument type: String
Argument type: Integer
Unique | Not guaranteed and dependent on the value range. |
Deterministic | YES unless NULL constant is specified as the value. |
Reversible | Not applicable. |
SELECT SYSCAT.DM.MASK('RANDOM', '123', 'MIN', 1239, 'MAX', 10000, 'VARY', 10.5, 'KEY', '5c39b18d77d5f297ff92e4942e5522b5')
Specifies the data value to mask. Value can be a column or other value expression, and always follows the RANDOM rule-type in a masking statement.
Argument type: 64-bit signed integer
RANDOM_SEED
package
configuration parameter. You can set a RANDOM_SEED using the ALTER SERVER .Argument type: Numeric
Argument type: Numeric
Argument type: Numeric
+/-
variance of the amount. VARY requires
a NOT NULL value. Mutually exclusive of MIN and MAX parameters. Therefore,
VARY is required if MIN or MAX is not used.
Argument type: String
Unique | Not guaranteed and dependent on the date range. |
Deterministic | YES unless NULL constant is specified as the value. |
Reversible | No. |
Specifies the data value to mask. Value can be a column or other value expression, and always follows the RANDATE rule-type in a masking statement.
Argument type: 64-bit signed integer
RANDOM_SEED
package
configuration parameter. You can set a RANDOM_SEED using the ALTER SERVER .Argument type: Numeric
+/-
variance of the amount. Mutually exclusive
of MIN and MAX parameters.
Argument type: String
DAY, D WEEK, WK, W MONTH, MO YEAR, YR, Y HOUR, HR, H MINUTE, MIN, M SECOND, SEC, S
Argument type: String
Type | WCHAR(MAXPREC) if padding is off. WVARCHAR(MAXPREC) if padding is on. |
Unique | Not guaranteed but more so as MINPREC is increased. |
Deterministic | YES unless NULL constant is specified as the value. |
Reversible | Not applicable. |
SELECT SYSCAT.DM.MASK('RANSTR', NULL, 'MINPREC', 10, 'SOURCE', 'Hello World')
Specifies the data value to mask. Value can be a column or other value expression. Value always follows the RANSTR rule-type in a masking statement.
Argument type: 64-bit signed integer
Argument type: Integer
Argument type: Integer
MAXPREC=MINPREC
.
Argument type: String
Argument type: String
' '
as the default character
if a character is not specified.
Argument type: Boolean
Argument type: String
‘0’
for
bases other than 64, and ’’
for
base 64.
SELECT SYSCAT.DM.MASK ('RANDIG', NULL, 'SEED', 100, 'BASE', 2)
Specifies the data value to mask. Value can be a column or other value expression, and always follows the RANDIG rule-type in a masking statement.
Argument type: 64-bit signed integer
Argument type: Integer
Argument type: Integer
MAXPREC=MINPREC
.
Argument type: Integer
2 | Binary |
8 | Octal |
10 | Decimal (default) |
16 | Hexadecimal |
64 | Base 64 |
Argument type: String
U[PPER] | Use uppercase hexits A-F (default). |
L[OWER] | Use lowercase hexits a-f. |
Argument type: String