Skip to content

Conversation

@vikaskr22
Copy link
Contributor

@vikaskr22 vikaskr22 commented Oct 31, 2025

What changes were proposed in this pull request?

Support for PBKDF2WithHmacSHA256 encryption algorithm to encrypt/decrypt the service password. This PR is only for fresh Ranger installation and requires compliant SecurityProvider in the java.security and required jars in the JRE path.

How was this patch tested?

  • mvn clean install

  • Manual Testing in Docker env:
    Non-Fips: Here I created a new docker image with new code and verified the non-fips env. Service passwords were being encrypted/decrypted using older PBEWithHmacSHA512AndAES_128 algorithm

    For FIPS:
    Updated the ranger-admin-site.xml with following prop:

    <property>
             <name>ranger.password.iteration.count</name>
             <value>5000</value>
     </property>
     <property>
             <name>ranger.password.encryption.algorithm</name>
             <value>PBKDF2WithHmacSHA256</value>
     </property>
    

Then, created a new docker image and started the container.
By default, Admin container starts but service creation will fail due to missing SecurityProvider and related configurations.

To make it work, following steps are required:

Copied SecurityProvider jar to JRE path:

docker cp bc-fips-2.0.0.jar b8b631895054:/opt/java/openjdk/jre/lib/ext/

Next, Updated java.security with following content:

security.provider.1=org.bouncycastle.jcajce.provider.BouncyCastleFipsProvider
org.bouncycastle.fips.approved_only=true

Once above explained configuration are completed and container is restarted, new Provider will come into effect.

Then, I executed following command to create all the failed services:
ranger@ranger:~/scripts$ python3 create-ranger-services.py

After than all services got created with latest algorithm. It can be verified by looking into DB also.

x_service_config_map with latest also

Request to review the PR. Upgrade scenario will be implemented as part of separate JIRA where re-encryption of existing passwords will happen.

public class PasswordUtils {
private static final Logger LOG = LoggerFactory.getLogger(PasswordUtils.class);

public static final String PBE_SHA512_AES_128 = "PBEWITHHMACSHA512ANDAES_128";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need this? Aren't we now going to use PBEWithHmacSHA512AndAES_128 from RangerSupportedCryptoAlgo

return false;
}

return PBE_SHA512_AES_128.equalsIgnoreCase(cryptoAlgo)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above. Do we need to replace this check with the one from RangerSupportedCryptoAlgo?

int index = 0;

cryptAlgo = cryptAlgoArray[index++]; // 0
cryptAlgo = RangerSupportedCryptoAlgo.valueOf(cryptAlgoArray[index++]); // 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to handle the case for crypto algorithm that is not in the list of enums supported in RangerSupportedCryptoAlgo. Can you please check?

@Test
public void testEncryptWithSHA512AndAES128() throws IOException, NoSuchAlgorithmException {
String freeTextPasswordMetaData = join("PBEWITHHMACSHA512ANDAES_128", "ENCRYPT_KEY", "SALTSALT", "4", PasswordUtils.generateIvIfNeeded("PBEWITHHMACSHA512ANDAES_128"));
String freeTextPasswordMetaData = join("PBEWithHmacSHA512AndAES_128", "ENCRYPT_KEY", "SALTSALT", "4", PasswordUtils.generateIvIfNeeded("PBEWithHmacSHA512AndAES_128"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case of upgrades, would this case difference in the algorithm name has any affect?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants