Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support native PBKDF2 #961

Open
wants to merge 1 commit into
base: openj9
Choose a base branch
from

Conversation

JinhangZhang
Copy link
Contributor

@JinhangZhang JinhangZhang commented Mar 6, 2025

A native implementation of the following PBKDF2 related crypto sevices are supported to optimze the PBKDF2 key derivations performance.

  • PBKDF2WithHmacSHA1
  • PBKDF2WithHmacSHA224
  • PBKDF2WithHmacSHA256
  • PBKDF2WithHmacSHA384
  • PBKDF2WithHmacSHA512
  • PBKDF2WithHmacSHA512/224
  • PBKDF2WithHmacSHA512/256

A new JVM option (jdk.nativePBKDF2) is provided to enable the use of the native PBKDF2 implementation, which is disabled by default.

@JinhangZhang
Copy link
Contributor Author

@jasonkatonica FYI

@JinhangZhang JinhangZhang force-pushed the supportNativePBKDF2 branch 2 times, most recently from 8cfeb4b to a744174 Compare March 6, 2025 16:10
@pshipton pshipton requested a review from keithc-ca March 6, 2025 16:18
@JinhangZhang JinhangZhang force-pushed the supportNativePBKDF2 branch 3 times, most recently from abc7b61 to 6522dc8 Compare March 7, 2025 04:15
@JinhangZhang JinhangZhang force-pushed the supportNativePBKDF2 branch from 6522dc8 to cf418d1 Compare March 7, 2025 15:58
@JinhangZhang JinhangZhang requested a review from keithc-ca March 7, 2025 15:58
@JinhangZhang JinhangZhang force-pushed the supportNativePBKDF2 branch 2 times, most recently from ec2a129 to e93838f Compare March 7, 2025 17:03
A native implementation of the following PBKDF2
related crypto sevices are supported to optimze
the PBKDF2 key derivations performance.

- PBKDF2WithHmacSHA1
- PBKDF2WithHmacSHA224
- PBKDF2WithHmacSHA256
- PBKDF2WithHmacSHA384
- PBKDF2WithHmacSHA512
- PBKDF2WithHmacSHA512/224
- PBKDF2WithHmacSHA512/256

A new JVM option (jdk.nativePBKDF2) is provided to
enable the use of the native PBKDF2 implementation,
which is disabled by default.

Signed-off-by: Jinhang Zhang <[email protected]>
@JinhangZhang JinhangZhang force-pushed the supportNativePBKDF2 branch from e93838f to 87098db Compare March 7, 2025 17:32
@@ -3845,3 +3857,89 @@ Java_jdk_crypto_jniprovider_NativeCrypto_XDHGenerateSecret
}
return ret;
}

/* Password based key derivation functions
Copy link
Member

Choose a reason for hiding this comment

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

Typo, missing period:

/* Password based key derivation function.

*/
JNIEXPORT jbyteArray JNICALL
Java_jdk_crypto_jniprovider_NativeCrypto_PBKDF2Derive
(JNIEnv *env, jclass clazz, jbyteArray password, jbyteArray salt, jint iterations, jint keyLength, jint hashAlgorithm)
Copy link
Member

Choose a reason for hiding this comment

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

The second parameter is not a class as this function implements a non-static method. Please ensure all signatures are correct and consistently use jclass clazz for static methods and jobject thisObj for non-static methods.

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