Skip to content

Conversation

@dev-koan
Copy link
Collaborator

This update adds support for PBES1, PBEKeyFactory, and PBEParameters for PBES1 algorithms using native acceleration for OpenJCEPlus provider. PBE cipher tests have also been updated for better test coverage.

Signed-off-by: Dev Agarwal [email protected]

Cipher | PBEWithSHA1AndRC2_128 | |X | |
Cipher | PBEWithSHA1AndRC4_40 | |X | |
Cipher | PBEWithSHA1AndRC4_128 | |X | |
Cipher | PBEWithHmacSHA1AndAES_128 | |X | |
Copy link
Member

Choose a reason for hiding this comment

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

Any reason we are unable to support PBEWithMD5AndTripleDES which is a S1 PBE algorithm?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

PBEWithMD5AndTripleDES is a sun proprietary algorithm and doesn't have an OID available for it which we can use.


public static final class SHA1AndRC2_40 extends PBEParameters {
public SHA1AndRC2_40() throws NoSuchAlgorithmException {
super("PBEWithSHA1RC2_40");
Copy link
Member

Choose a reason for hiding this comment

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

Do these names need to match the algorithm name? If so seems like this should be PBEWithSHA1AndRC2_40 ?

Copy link
Member

Choose a reason for hiding this comment

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

Similar problem below for PBEWithSHA1RC2_128

Copy link
Member

Choose a reason for hiding this comment

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

Perhaps a simple test to validate the algorithm name used on a getInstance matches the name of within the parameters created could be added?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated the subclass names.
We do have a test to compare the algorithms (

assertEquals(algorithm, testParams.getAlgorithm());
)

this.iterationCount = pbespec.getIterationCount();

if (keySalt != null && (!Arrays.equals(pbespec.getSalt(), keySalt))) {
throw new InvalidAlgorithmParameterException("Different iteration count between key and params");
Copy link
Member

Choose a reason for hiding this comment

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

Should the error message here state salt not iteration count?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated.

}

// Get the NID.
id = ICC_OBJ_txt2nid(ockCtx, text);
Copy link
Member

Choose a reason for hiding this comment

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

Is this the method that is intermittantly failing at the moment on non aarch platforms?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes

Copy link
Member

Choose a reason for hiding this comment

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

I kind of remember this kind of issue when doing the ML-KEM work. It had to do with over writing memory. Once, I found where I was not allocating the right amounts this seemed to go away. This maybe something similar.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thank you for your suggestion there John.
We were able to fix this by using GetStringUTFChars instead of GetPrimitiveArrayCritical and accordingly passing a jstring instead of jbyteArray.

passwordLength = (*env)->GetArrayLength(env, password);

/*
* Get the input data. Check for null is not required becuase that is
Copy link
Member

Choose a reason for hiding this comment

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

Spelling of because instead of becuase

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated.

saltNative = NULL;
}
if (NULL != passwordNative) {
(*env)->ReleasePrimitiveArrayCritical(env, password,
Copy link
Member

Choose a reason for hiding this comment

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

I wasnt sure in this spot if we have a copy of the password or not allocated above with GetPrimitiveArrayCritical. From what i can tell this API may or may not be a copy so not sure we can zero out sensitive data ( password ) here.

@dev-koan dev-koan force-pushed the implement_pbe1 branch 5 times, most recently from 0007042 to c9002b2 Compare December 5, 2025 14:10
This update adds support for PBES1, PBEKeyFactory, and
PBEParameters for PBES1 algorithms using native acceleration
for OpenJCEPlus provider. PBE cipher tests have also been
updated for better test coverage.

Signed-off-by: Dev Agarwal <[email protected]>
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.

3 participants