OTP encryption tool
-
Does not result in any data loss even if you have old devices that are using an old format (plain text).
-
The backward compatibility support with an old NetScaler Gateway version, helps to integrate and support the existing devices, along with the new device.
-
The OTP encryption tool helps admins migrate all the OTP secret data of all users at once.
Uses of OTP encryption tool
-
Encryption. Store the OTP secret in encrypted format. The tool extracts the OTP data of the devices registered with NetScaler, and then converts the OTP data in plain text format to encrypted format.
-
Decryption. Revert the OTP secret to the plain text format.
-
Update certificates. Administrators can update the certificate to a new certificate at any time. Admins can use the tool to enter the new certificate and update all the entries with the new certificate data. The certificate path must either be an absolute path or a relative path.
-
You must enable the encryption parameter in the NetScaler appliance to use the OTP encryption tool.
-
For devices registered with NetScaler before build 41.20, you must perform the following:
-
Upgrade the 13.0 NetScaler appliance to 13.0 build 41.20.
-
Enable the encryption parameter on the appliance.
-
Use the OTP Secret migration tool to migrate OTP secret data from plain text format to encrypted format.
-
-
The OTP encryption tool supports only single-valued user attributes. It does not support multi-valued user attributes.
OTP secret data in plain text format
#@devicename=<16 or more bytes>&tag=<64bytes>&,
OTP secret data in encrypted format
{
"otpdata”: {
“devices”: {
“device1”: “value1”,
“device2”: “value2”, …
}
}
}
{
secret:<16-byte secret>,
tag : <64-byte tag value>
alg: <algorithm used> (not mandatory, default is sha1, specify the algorithm only if it is not default)
}
-
In “devices”, you have value against each name. The value is base64encode(KID).base64encode(IV).base64encode(cipherdata).
-
KID is the key ID value that is used to identify the certificate used for OTP secret data encryption. The key ID is useful especially when multiple certificates are used for the OTP secret data encryption.
-
In standard AES algorithms, IV is always sent as first 16 or 32 bytes of cipher data. You can follow the same model.
-
IV differs for each device though key remains the same.
OTP encryption tool setup
\var\netscaler\otptool. You must download the code from the NetScaler source and run the tool with the required AD credentials.
-
Prerequisites for using the OTP encryption tool:
-
Install python 3.5 or higher version in the environment where this tool is run.
-
Install pip3 or later versions.
-
-
Run the following commands:
-
pip install -r requirements.txt. Automatically installs the requirements.
-
python main.py. Invokes the OTP encryption tool. You must provide the required arguments as per your need for the migration of OTP secret data.
-
-
The tool can be located at
\var\netscaler\otptoolfrom a shell prompt. -
Run the tool with the required AD credentials.
OTP encryption tool interface
OPERATION argument
| Scenario | Operation argument value and other arguments |
|---|---|
| Convert plaintext OTP secret to encrypted format in the same attribute | Enter the OPERATION argument value as 0 and provide the same value for the source and target attribute. Example: python3 main.py -Host 192.0.2.1 –Port 636 -username ldapbind_user@aaa.local -search_base cn=users,dc=aaa,dc=local -source_attribute unixhomedirectory -target_attribute unixhomedirectory -operation 0 -cert_path aaatm_wild_all.cert |
| Convert plaintext OTP secret to encrypted format in a different attribute | Enter the OPERATION argument value as 0 and provide the corresponding values for the source and target attribute. Example: python3 main.py -Host 192.0.2.1 –Port 636 -username ldapbind_user@aaa.local -search_base cn=users,dc=aaa,dc=local -source_attribute unixhomedirectory -target_attribute userparameters -operation 0 -cert_path aaatm_wild_all.cert |
| Convert the encrypted entries back to plaintext | Enter the OPERATION argument value as 1 and provide the corresponding values for the source and target attribute. Example: python3 main.py -Host 192.0.2.1 –Port 636 -username ldapbind_user@aaa.local -search_base cn=users,dc=aaa,dc=local -source_attribute unixhomedirectory -target_attribute userparameters -operation 1 -cert_path aaatm_wild_all.cert |
| Update the certificate to a new certificate | Enter the OPERATION argument value as 2 and provide all the previous certificate and the new certificate details in the corresponding arguments. Example: python3 main.py -Host 192.0.2.1 –Port 636 -username ldapbind_user@aaa.local -search_base cn=users,dc=aaa,dc=local -source_attribute unixhomedirectory -operation 2 -cert_path aaatm_wild_all.cert –new_cert_path aaatm_wild_all_new.cert |
CERT_PATH argument
certkey.merged that can be used as the value for the cert_path flag.
$ cat certificate.cert certificate.key > certkey.merged
$
-
The user must provide the same certificate which is bound globally in the NetScaler appliance for user data encryption.
-
The certificate must contain the Base64 encoded public certificate and its corresponding RSA private key in the same file.
-
The format of the certificate has to be either PEM or CERT. The certificate must adhere to X509 format.
-
Password protected certificate format and .pfx file are not accepted by this tool. The user must convert the PFX certificates to .cert before providing the certificates to the tool.
SEARCH_FILTER argument
-
-search_filter "(sAMAccountName=OTP*)": Filters users whose samAccountNames (user logon names) start with "OTP". -
-search_filter "(objectCategory=person)": Filters the object category of type person. -
-search_file "(objectclass=*)": Filters all the objects.
Enabling encryption option in the NetScaler appliance
set aaa otpparameter [-encryption ( ON | OFF )]
set aaa otpparameter -encryption ON
OTP encryption tool use cases
Register new devices with NetScaler appliance version 13.0 build 41.20
Migrate OTP data for the devices registered previous to 13.0 build 41.20
-
Use the conversion tool to migrate OTP data from plain text format to encrypted format.
-
Enable the "Encryption" parameter on the NetScaler appliance.
-
To enable the encryption option by using the CLI:
-
set aaa otpparameter -encryption ON
-
-
To enable encryption options by using the GUI:
-
Navigate to Security > AAA – Application Traffic and click Change authentication AAA OTP Parameter under Authentication Settings section.
-
On the Configure AAA OTP Parameter page, select OTP Secret encryption, and click OK.
-
-
Log in with the valid AD credentials.
-
If it is required, register more devices (optional).
-
Migrate encrypted data from old certificate to new certificate
python3 main.py -Host 192.0.2.1 –Port 636 -username ldapbind_user@aaa.local -search_base cn=users,dc=aaa,dc=local -source_attribute unixhomedirectory -target_attribute userparameters -operation 2 -cert_path aaatm_wild_all.cert –new_cert_path aaatm_wild_all_new.cert
-
The certificates must have both private and public keys.
-
Currently, the functionality is provided only for OTP.
Re-encrypt or migrate to new certificate for devices registered after the appliance is upgraded to 13.0 build 41.20 with encryption
Convert encrypted data back to plain text format
python3 main.py -Host 192.0.2.1 –Port 636 -username ldapbind_user@aaa.local -search_base cn=users,dc=aaa,dc=local -source_attribute unixhomedirectory -target_attribute userparameters -operation 1
Troubleshooting
-
app.log: Logs all the major steps of execution and information about errors, warnings, and failures.
-
unmodified_users.txt: Contains a list of User DNs that was not upgraded from plain text to encrypted format. These logs are generated to an error in format or might be due to some other reason.
OTP_encryption_tool directory within the folder where the OTP encryption tool is placed in the end-user device.