You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gravitino.apache.org by mc...@apache.org on 2026/06/22 12:47:10 UTC

(gravitino) branch main updated: [#11756] fix(authn): Switch built-in IdP password hashing to JDK SHA3-512 (#11761)

This is an automated email from the ASF dual-hosted git repository.

mchades pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/gravitino.git


The following commit(s) were added to refs/heads/main by this push:
     new 084dd39eb0 [#11756] fix(authn): Switch built-in IdP password hashing to JDK SHA3-512 (#11761)
084dd39eb0 is described below

commit 084dd39eb0bbe28457853932adfca3bdfac27edd
Author: MaSai <30...@users.noreply.github.com>
AuthorDate: Mon Jun 22 20:47:06 2026 +0800

    [#11756] fix(authn): Switch built-in IdP password hashing to JDK SHA3-512 (#11761)
    
    ### What changes were proposed in this pull request?
    
    - Replace Argon2id + Bouncy Castle with JDK `MessageDigest` SHA3-512
    password hashing for the built-in IdP
    - Add `Sha3512PasswordHasher` with PHC-style stored hashes:
    `$sha3-512$i=100000$<salt>$<hash>`
    - Remove `bcprov-jdk18on` from `plugins:idp-basic` dependencies and from
    distribution `libs/`
    - Remove Bouncy Castle entries from `LICENSE.bin`, `NOTICE.bin`, and
    `licenses/bouncycastle.txt`
    - Update `design-docs/gravitino-local-authentication.md`
    
    Fixes #11756
    
    ### Why are the changes needed?
    
    Gravitino 1.3 bundled Bouncy Castle for Argon2id IdP password hashing,
    which introduced third-party cryptographic components in the server
    distribution and ASF export-control overhead. This change uses the JDK
    built-in SHA3-512 digest API instead, removing the Bouncy Castle
    dependency from the distribution.
    
    ### Does this PR introduce _any_ user-facing change?
    
    Yes.
    
    1. New IdP password hashes use SHA3-512 (`$sha3-512$...`) instead of
    Argon2id (`$argon2id$...`).
    
    ### How was this patch tested?
    
    - `./gradlew :plugins:idp-basic:spotlessApply`
    - `./gradlew :plugins:idp-basic:test --tests TestSha3512PasswordHasher
    -PskipITs`
    
    ---------
    
    Co-authored-by: Cursor <cu...@cursor.com>
---
 LICENSE.bin                                        |   1 -
 NOTICE.bin                                         |   3 -
 design-docs/gravitino-local-authentication.md      |  31 +--
 gradle/libs.versions.toml                          |   2 -
 licenses/bouncycastle.txt                          |  16 --
 plugins/idp-basic/build.gradle.kts                 |   5 -
 .../idp/basic/password/Argon2idPasswordHasher.java | 234 ---------------------
 .../idp/basic/password/PasswordHasherFactory.java  |   2 +-
 ...{Argon2idDefaults.java => Sha3512Defaults.java} |  25 ++-
 .../idp/basic/password/Sha3512PasswordHasher.java  | 176 ++++++++++++++++
 ...dHasher.java => TestSha3512PasswordHasher.java} |  75 +++----
 11 files changed, 232 insertions(+), 338 deletions(-)

diff --git a/LICENSE.bin b/LICENSE.bin
index 507d315d30..a4006db315 100644
--- a/LICENSE.bin
+++ b/LICENSE.bin
@@ -437,7 +437,6 @@
    Kyligence/kylinpy
    elarivie/pyReaderWriterLock
    tkem/cachetools
-   Bouncy Castle
 
    This product bundles various third-party components also under the
    Common Development and Distribution License 1.0
diff --git a/NOTICE.bin b/NOTICE.bin
index 03bade0d58..a7c6b4c5ff 100644
--- a/NOTICE.bin
+++ b/NOTICE.bin
@@ -267,9 +267,6 @@ Joda.org (https://www.joda.org/).
 Apache log4j
 Copyright 2010 The Apache Software Foundation
 
-Bouncy Castle
-Copyright (c) 2000 - 2026 The Legion of the Bouncy Castle Inc.
-
 Byte Buddy
 Copyright 2014 - Present Rafael Winterhalter
 
diff --git a/design-docs/gravitino-local-authentication.md b/design-docs/gravitino-local-authentication.md
index b8ba682d84..77e64c6010 100644
--- a/design-docs/gravitino-local-authentication.md
+++ b/design-docs/gravitino-local-authentication.md
@@ -124,31 +124,32 @@ The `plugins:idp-basic` module provides:
 User credentials must never be stored in plaintext. Passwords are stored as password hashes in the
 database.
 
-Among the common password hashing algorithms, **Argon2id** is the recommended choice for
-Gravitino.
+Among the common password hashing algorithms, **SHA3-512** (via JDK `MessageDigest`) is the
+recommended choice for Gravitino.
 
-| Algorithm | Status |
-|---|---|
-| Argon2id | Recommended default |
+| Algorithm          | Status              |
+|--------------------|---------------------|
+| SHA3-512           | Recommended default |
 
-The initial design uses **Argon2id** as the only supported algorithm, which keeps the
-implementation simple while aligning with modern password storage recommendations.
+The initial design uses **SHA3-512** as the only supported algorithm, which keeps the
+implementation simple while relying on the JDK built-in digest API and avoiding additional
+third-party cryptographic dependencies in the server distribution.
 
 To make this implementable, the password hashing design should also define the storage and
 dependency model explicitly:
 
-- introduce one dedicated server-side password-hashing dependency that supports Argon2id
-- store the full Argon2id hash string in `password_hash`, including algorithm marker, parameters,
+- use the JDK JCA `MessageDigest` implementation for `SHA3-512`
+- store the full SHA3-512 hash string in `password_hash`, including algorithm marker, parameters,
   salt, and hash output
 - use a self-describing format so future parameter tuning does not require schema changes
 
 For example, `password_hash` should store a PHC-style string such as:
 
 ```text
-$argon2id$v=19$m=65536,t=3,p=1$<salt>$<hash>
+$sha3-512$i=100000$<salt>$<hash>
 ```
 
-This keeps verification logic simple and allows future upgrades of Argon2id cost parameters without
+This keeps verification logic simple and allows future upgrades of SHA3-512 cost parameters without
 introducing additional columns.
 
 ---
@@ -297,7 +298,7 @@ The initialization process should be:
 5. If the service admin already has a password in `idp_user_meta`, continue startup without
    modifying the stored password.
 6. If `GRAVITINO_INITIAL_ADMIN_PASSWORD` is configured and the service admin does not yet have a
-   password stored in `idp_user_meta`, hash the supplied password with Argon2id and create that
+   password stored in `idp_user_meta`, hash the supplied password with SHA3-512 and create that
    service admin account in `idp_user_meta`.
 7. If `GRAVITINO_INITIAL_ADMIN_PASSWORD` is not configured and any configured service admin does not
    yet have a password stored in `idp_user_meta`, fail startup immediately and prompt the user to
@@ -413,7 +414,7 @@ in `gravitino.authorization.serviceAdmins` and a password stored in `idp_user_me
 
 ### 8.2 Password Algorithm
 
-The initial implementation uses Argon2id as the fixed password hashing algorithm.
+The initial implementation uses SHA3-512 as the fixed password hashing algorithm.
 
 ---
 
@@ -525,7 +526,7 @@ curl -X PUT -H "Accept: application/vnd.gravitino.v1+json" \
 | Phase | Work Item | Module / Files | Notes |
 |---|---|---|---|
 | 1 | Built-in IDP module wiring | `settings.gradle.kts`, `server/build.gradle.kts`, `plugins:idp-basic` | Add the new module and register `IdpRESTFeature` through `gravitino.server.rest.extensionPackages`. |
-| 2 | Password hashing support | `PasswordHasher`, `Argon2idPasswordHasher`, related tests | Use Argon2id as the only supported password hashing algorithm and store PHC-style hash strings. |
+| 2 | Password hashing support | `PasswordHasher`, `Sha3512PasswordHasher`, related tests | Use SHA3-512 as the only supported password hashing algorithm and store PHC-style hash strings. |
 | 3 | IdP metadata schema | JDBC schema files, mapper definitions, store layer | Create `idp_user_meta`, `idp_group_meta`, and `idp_user_group_rel` with soft-delete support. |
 | 4 | Service admin initialization | startup initialization logic, validation logic | Validate `GRAVITINO_INITIAL_ADMIN_PASSWORD`, initialize missing configured service admins during startup, and fail startup when required credentials are absent. |
 | 5 | Basic authentication flow | `BasicAuthenticator`, auth manager, filter integration | Verify Basic credentials against `idp_user_meta` and resolve the authenticated principal. |
@@ -569,7 +570,7 @@ either unavailable or unnecessarily heavy. The key design choices are:
 - **Basic authentication**
 - **username/password credentials**
 - **database-backed storage**
-- **Argon2id password hashing**
+- **SHA3-512 password hashing**
 - **startup-time service admin initialization**
 
 The result is a self-contained authentication path that is easy to deploy, fast to evaluate, and
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index a08c53425f..6c93c5af40 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -107,7 +107,6 @@ kafka = "3.4.0"
 curator = "2.12.0"
 awaitility = "4.2.1"
 servlet = "3.1.0"
-bouncycastle = "1.84"
 jodd = "3.5.2"
 flink = "1.18.0"
 flink18 = "1.18.0"
@@ -222,7 +221,6 @@ jersey-test-framework-provider-jetty = { group = "org.glassfish.jersey.test-fram
 jodd-core = { group = "org.jodd", name = "jodd-core", version.ref = "jodd" }
 mockito-core = { group = "org.mockito", name = "mockito-core", version.ref = "mockito" }
 mockito-inline = { group = "org.mockito", name = "mockito-inline", version.ref = "mockito" }
-bcprov-jdk18on = { group = "org.bouncycastle", name = "bcprov-jdk18on", version.ref = "bouncycastle" }
 hive2-metastore = { group = "org.apache.hive", name = "hive-metastore", version.ref = "hive2"}
 hive2-exec = { group = "org.apache.hive", name = "hive-exec", version.ref = "hive2"}
 hive2-common = { group = "org.apache.hive", name = "hive-common", version.ref = "hive2"}
diff --git a/licenses/bouncycastle.txt b/licenses/bouncycastle.txt
deleted file mode 100644
index 0e9ebe8af7..0000000000
--- a/licenses/bouncycastle.txt
+++ /dev/null
@@ -1,16 +0,0 @@
-Copyright (c) 2000 - 2026 The Legion of the Bouncy Castle Inc. (https://www.bouncycastle.org)
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software
-and associated documentation files (the "Software"), to deal in the Software without restriction,
-including without limitation the rights to use, copy, modify, merge, publish, distribute,
-sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all copies or
-substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
-NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
-OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/plugins/idp-basic/build.gradle.kts b/plugins/idp-basic/build.gradle.kts
index 1a91a0ec33..626a78d809 100644
--- a/plugins/idp-basic/build.gradle.kts
+++ b/plugins/idp-basic/build.gradle.kts
@@ -31,7 +31,6 @@ dependencies {
   implementation(project(":common"))
   implementation(project(":core"))
 
-  implementation(libs.bcprov.jdk18on)
   implementation(libs.bundles.jersey)
   implementation(libs.commons.lang3)
   implementation(libs.guava)
@@ -76,10 +75,6 @@ tasks {
       include("gravitino-idp-basic-*.jar")
       exclude("*-javadoc.jar", "*-sources.jar")
     }
-    // Argon2id password hashing; not bundled in the server distribution today.
-    from(configurations.runtimeClasspath) {
-      include("bcprov-jdk18on-*.jar")
-    }
     into("$rootDir/distribution/package/libs")
     duplicatesStrategy = DuplicatesStrategy.EXCLUDE
   }
diff --git a/plugins/idp-basic/src/main/java/org/apache/gravitino/idp/basic/password/Argon2idPasswordHasher.java b/plugins/idp-basic/src/main/java/org/apache/gravitino/idp/basic/password/Argon2idPasswordHasher.java
deleted file mode 100644
index 98e895e07c..0000000000
--- a/plugins/idp-basic/src/main/java/org/apache/gravitino/idp/basic/password/Argon2idPasswordHasher.java
+++ /dev/null
@@ -1,234 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.gravitino.idp.basic.password;
-
-import com.google.common.base.Preconditions;
-import java.nio.charset.StandardCharsets;
-import java.security.MessageDigest;
-import java.security.SecureRandom;
-import java.util.Base64;
-import org.apache.commons.lang3.StringUtils;
-import org.bouncycastle.crypto.generators.Argon2BytesGenerator;
-import org.bouncycastle.crypto.params.Argon2Parameters;
-import org.bouncycastle.util.Arrays;
-
-/** Argon2id-based password hasher. */
-public class Argon2idPasswordHasher implements PasswordHasher {
-
-  private static final String PHC_PREFIX = "$argon2id$";
-  private static final SecureRandom SECURE_RANDOM = new SecureRandom();
-
-  @Override
-  public String hash(String plainPassword) {
-    Preconditions.checkArgument(
-        StringUtils.isNotBlank(plainPassword), "Plain password must not be blank");
-
-    byte[] salt = new byte[Argon2idDefaults.DEFAULT_SALT_LENGTH];
-    SECURE_RANDOM.nextBytes(salt);
-    byte[] passwordBytes = plainPassword.getBytes(StandardCharsets.UTF_8);
-    byte[] hash = new byte[Argon2idDefaults.DEFAULT_HASH_LENGTH];
-    try {
-      generateHash(
-          passwordBytes,
-          salt,
-          Argon2idDefaults.DEFAULT_ITERATIONS,
-          Argon2idDefaults.DEFAULT_MEMORY_KB,
-          Argon2idDefaults.DEFAULT_PARALLELISM,
-          Argon2idDefaults.DEFAULT_VERSION,
-          hash);
-      return toPhcString(
-          salt,
-          hash,
-          Argon2idDefaults.DEFAULT_ITERATIONS,
-          Argon2idDefaults.DEFAULT_MEMORY_KB,
-          Argon2idDefaults.DEFAULT_PARALLELISM,
-          Argon2idDefaults.DEFAULT_VERSION);
-    } finally {
-      Arrays.clear(passwordBytes);
-      Arrays.clear(salt);
-      Arrays.clear(hash);
-    }
-  }
-
-  @Override
-  public boolean verify(String plainPassword, String hashedPassword) {
-    Preconditions.checkArgument(
-        StringUtils.isNotBlank(plainPassword), "Plain password must not be blank");
-    Preconditions.checkArgument(
-        StringUtils.isNotBlank(hashedPassword), "Hashed password must not be blank");
-
-    ParsedHash parsedHash = parse(hashedPassword);
-    byte[] passwordBytes = plainPassword.getBytes(StandardCharsets.UTF_8);
-    byte[] actualHash = new byte[parsedHash.hash.length];
-    try {
-      generateHash(
-          passwordBytes,
-          parsedHash.salt,
-          parsedHash.iterations,
-          parsedHash.memoryKb,
-          parsedHash.parallelism,
-          parsedHash.version,
-          actualHash);
-      return MessageDigest.isEqual(actualHash, parsedHash.hash);
-    } finally {
-      Arrays.clear(passwordBytes);
-      Arrays.clear(actualHash);
-      Arrays.clear(parsedHash.salt);
-      Arrays.clear(parsedHash.hash);
-    }
-  }
-
-  private static void generateHash(
-      byte[] passwordBytes,
-      byte[] salt,
-      int iterations,
-      int memoryKb,
-      int parallelism,
-      int version,
-      byte[] output) {
-    Argon2Parameters parameters =
-        new Argon2Parameters.Builder(Argon2idDefaults.DEFAULT_TYPE)
-            .withVersion(version)
-            .withIterations(iterations)
-            .withMemoryAsKB(memoryKb)
-            .withParallelism(parallelism)
-            .withSalt(salt)
-            .build();
-    Argon2BytesGenerator generator = new Argon2BytesGenerator();
-    generator.init(parameters);
-    generator.generateBytes(passwordBytes, output);
-  }
-
-  private static String toPhcString(
-      byte[] salt, byte[] hash, int iterations, int memoryKb, int parallelism, int version) {
-    Base64.Encoder encoder = Base64.getEncoder().withoutPadding();
-    return PHC_PREFIX
-        + "v="
-        + version
-        + "$m="
-        + memoryKb
-        + ",t="
-        + iterations
-        + ",p="
-        + parallelism
-        + "$"
-        + encoder.encodeToString(salt)
-        + "$"
-        + encoder.encodeToString(hash);
-  }
-
-  private static ParsedHash parse(String hashedPassword) {
-    Preconditions.checkArgument(hashedPassword.startsWith(PHC_PREFIX), invalidHashFormatMessage());
-    String[] parts = hashedPassword.split("\\$");
-    Preconditions.checkArgument(parts.length == 6, invalidHashFormatMessage());
-    Preconditions.checkArgument("argon2id".equals(parts[1]), invalidHashFormatMessage());
-    Preconditions.checkArgument(parts[2].startsWith("v="), invalidHashFormatMessage());
-    Preconditions.checkArgument(parts[3].startsWith("m="), invalidHashFormatMessage());
-
-    String[] parameterParts = parts[3].split(",");
-    Preconditions.checkArgument(parameterParts.length == 3, invalidHashFormatMessage());
-    Preconditions.checkArgument(parameterParts[1].startsWith("t="), invalidHashFormatMessage());
-    Preconditions.checkArgument(parameterParts[2].startsWith("p="), invalidHashFormatMessage());
-
-    ParsedHash parsedHash =
-        new ParsedHash(
-            parseInteger(parts[2].substring(2)),
-            parseInteger(parameterParts[0].substring(2)),
-            parseInteger(parameterParts[1].substring(2)),
-            parseInteger(parameterParts[2].substring(2)),
-            decodeBase64(parts[4], Argon2idDefaults.DEFAULT_SALT_LENGTH),
-            decodeBase64(parts[5], Argon2idDefaults.DEFAULT_HASH_LENGTH));
-    validateSupportedParameters(parsedHash);
-    return parsedHash;
-  }
-
-  private static byte[] decodeBase64(String value, int maxDecodedLength) {
-    Preconditions.checkArgument(
-        value.length() <= maxEncodedLength(maxDecodedLength), invalidHashFormatMessage());
-    int remainder = value.length() % 4;
-    Preconditions.checkArgument(remainder != 1, invalidHashFormatMessage());
-    String paddedValue = remainder == 0 ? value : value + "====".substring(0, 4 - remainder);
-    try {
-      return Base64.getDecoder().decode(paddedValue);
-    } catch (IllegalArgumentException e) {
-      throw invalidHashFormat();
-    }
-  }
-
-  private static int maxEncodedLength(int decodedLength) {
-    int fullGroups = decodedLength / 3;
-    int remainder = decodedLength % 3;
-    return fullGroups * 4 + (remainder == 0 ? 0 : remainder + 1);
-  }
-
-  private static int parseInteger(String value) {
-    try {
-      return Integer.parseInt(value);
-    } catch (NumberFormatException e) {
-      throw invalidHashFormat();
-    }
-  }
-
-  private static void validateSupportedParameters(ParsedHash parsedHash) {
-    Preconditions.checkArgument(
-        parsedHash.version == Argon2idDefaults.DEFAULT_VERSION,
-        "Unsupported Argon2id hash parameters");
-    Preconditions.checkArgument(
-        parsedHash.memoryKb == Argon2idDefaults.DEFAULT_MEMORY_KB,
-        "Unsupported Argon2id hash parameters");
-    Preconditions.checkArgument(
-        parsedHash.iterations == Argon2idDefaults.DEFAULT_ITERATIONS,
-        "Unsupported Argon2id hash parameters");
-    Preconditions.checkArgument(
-        parsedHash.parallelism == Argon2idDefaults.DEFAULT_PARALLELISM,
-        "Unsupported Argon2id hash parameters");
-    Preconditions.checkArgument(
-        parsedHash.salt.length == Argon2idDefaults.DEFAULT_SALT_LENGTH, invalidHashFormatMessage());
-    Preconditions.checkArgument(
-        parsedHash.hash.length == Argon2idDefaults.DEFAULT_HASH_LENGTH, invalidHashFormatMessage());
-  }
-
-  private static IllegalArgumentException invalidHashFormat() {
-    return new IllegalArgumentException(invalidHashFormatMessage());
-  }
-
-  private static String invalidHashFormatMessage() {
-    return "Invalid Argon2id hash format";
-  }
-
-  private static class ParsedHash {
-    private final int version;
-    private final int memoryKb;
-    private final int iterations;
-    private final int parallelism;
-    private final byte[] salt;
-    private final byte[] hash;
-
-    private ParsedHash(
-        int version, int memoryKb, int iterations, int parallelism, byte[] salt, byte[] hash) {
-      this.version = version;
-      this.memoryKb = memoryKb;
-      this.iterations = iterations;
-      this.parallelism = parallelism;
-      this.salt = salt;
-      this.hash = hash;
-    }
-  }
-}
diff --git a/plugins/idp-basic/src/main/java/org/apache/gravitino/idp/basic/password/PasswordHasherFactory.java b/plugins/idp-basic/src/main/java/org/apache/gravitino/idp/basic/password/PasswordHasherFactory.java
index 25c67e9bd6..41c74c28a4 100644
--- a/plugins/idp-basic/src/main/java/org/apache/gravitino/idp/basic/password/PasswordHasherFactory.java
+++ b/plugins/idp-basic/src/main/java/org/apache/gravitino/idp/basic/password/PasswordHasherFactory.java
@@ -26,6 +26,6 @@ public final class PasswordHasherFactory {
 
   /** Create the built-in password hasher. */
   public static PasswordHasher create() {
-    return new Argon2idPasswordHasher();
+    return new Sha3512PasswordHasher();
   }
 }
diff --git a/plugins/idp-basic/src/main/java/org/apache/gravitino/idp/basic/password/Argon2idDefaults.java b/plugins/idp-basic/src/main/java/org/apache/gravitino/idp/basic/password/Sha3512Defaults.java
similarity index 58%
rename from plugins/idp-basic/src/main/java/org/apache/gravitino/idp/basic/password/Argon2idDefaults.java
rename to plugins/idp-basic/src/main/java/org/apache/gravitino/idp/basic/password/Sha3512Defaults.java
index 1ccb61bd96..0880644217 100644
--- a/plugins/idp-basic/src/main/java/org/apache/gravitino/idp/basic/password/Argon2idDefaults.java
+++ b/plugins/idp-basic/src/main/java/org/apache/gravitino/idp/basic/password/Sha3512Defaults.java
@@ -19,18 +19,23 @@
 
 package org.apache.gravitino.idp.basic.password;
 
-import org.bouncycastle.crypto.params.Argon2Parameters;
+/** Default parameters for the built-in SHA3-512 password hasher. */
+public final class Sha3512Defaults {
 
-/** Default parameters for the built-in Argon2id password hasher. */
-public final class Argon2idDefaults {
+  /** JCA {@link java.security.MessageDigest} algorithm name for SHA3-512. */
+  public static final String DIGEST_ALGORITHM = "SHA3-512";
 
-  public static final int DEFAULT_VERSION = Argon2Parameters.ARGON2_VERSION_13;
-  public static final int DEFAULT_TYPE = Argon2Parameters.ARGON2_id;
-  public static final int DEFAULT_HASH_LENGTH = 32;
-  public static final int DEFAULT_MEMORY_KB = 1 << 16;
-  public static final int DEFAULT_ITERATIONS = 3;
-  public static final int DEFAULT_PARALLELISM = 1;
+  /** Default iteration count for salted SHA3-512 password stretching. */
+  public static final int DEFAULT_ITERATIONS = 100_000;
+
+  /** PHC-style prefix for stored password hashes. */
+  public static final String PHC_PREFIX = "$sha3-512$";
+
+  /** Default salt length in bytes. */
   public static final int DEFAULT_SALT_LENGTH = 16;
 
-  private Argon2idDefaults() {}
+  /** SHA3-512 digest output length in bytes. */
+  public static final int DEFAULT_HASH_LENGTH = 64;
+
+  private Sha3512Defaults() {}
 }
diff --git a/plugins/idp-basic/src/main/java/org/apache/gravitino/idp/basic/password/Sha3512PasswordHasher.java b/plugins/idp-basic/src/main/java/org/apache/gravitino/idp/basic/password/Sha3512PasswordHasher.java
new file mode 100644
index 0000000000..58573758a9
--- /dev/null
+++ b/plugins/idp-basic/src/main/java/org/apache/gravitino/idp/basic/password/Sha3512PasswordHasher.java
@@ -0,0 +1,176 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.gravitino.idp.basic.password;
+
+import com.google.common.base.Preconditions;
+import java.nio.charset.StandardCharsets;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.security.SecureRandom;
+import java.util.Arrays;
+import java.util.Base64;
+import org.apache.commons.lang3.StringUtils;
+
+/**
+ * SHA3-512 password hasher backed by the JDK {@link MessageDigest} API.
+ *
+ * <p>Built-in IdP password hashing is limited to the JDK JCA provider to reduce EAR Category 5D002
+ * export-control scope for ASF binary releases.
+ */
+public class Sha3512PasswordHasher implements PasswordHasher {
+
+  private static final String PHC_PREFIX = Sha3512Defaults.PHC_PREFIX;
+  private static final String INVALID_HASH_FORMAT = "Invalid SHA3-512 hash format";
+  private static final String UNSUPPORTED_HASH_PARAMETERS = "Unsupported SHA3-512 hash parameters";
+  private static final SecureRandom SECURE_RANDOM = new SecureRandom();
+
+  @Override
+  public String hash(String plainPassword) {
+    Preconditions.checkArgument(
+        StringUtils.isNotBlank(plainPassword), "Plain password must not be blank");
+
+    byte[] salt = new byte[Sha3512Defaults.DEFAULT_SALT_LENGTH];
+    SECURE_RANDOM.nextBytes(salt);
+    byte[] passwordBytes = plainPassword.getBytes(StandardCharsets.UTF_8);
+    try {
+      byte[] hash =
+          digestPassword(
+              passwordBytes,
+              salt,
+              Sha3512Defaults.DEFAULT_ITERATIONS,
+              Sha3512Defaults.DEFAULT_HASH_LENGTH);
+      return toPhcString(salt, hash);
+    } finally {
+      Arrays.fill(passwordBytes, (byte) 0);
+      Arrays.fill(salt, (byte) 0);
+    }
+  }
+
+  @Override
+  public boolean verify(String plainPassword, String hashedPassword) {
+    Preconditions.checkArgument(
+        StringUtils.isNotBlank(plainPassword), "Plain password must not be blank");
+    Preconditions.checkArgument(
+        StringUtils.isNotBlank(hashedPassword), "Hashed password must not be blank");
+
+    ParsedHash parsedHash = parse(hashedPassword);
+    byte[] passwordBytes = plainPassword.getBytes(StandardCharsets.UTF_8);
+    byte[] actualHash = null;
+    try {
+      actualHash =
+          digestPassword(
+              passwordBytes, parsedHash.salt, parsedHash.iterations, parsedHash.hash.length);
+      return MessageDigest.isEqual(actualHash, parsedHash.hash);
+    } finally {
+      Arrays.fill(passwordBytes, (byte) 0);
+      if (actualHash != null) {
+        Arrays.fill(actualHash, (byte) 0);
+      }
+      Arrays.fill(parsedHash.salt, (byte) 0);
+      Arrays.fill(parsedHash.hash, (byte) 0);
+    }
+  }
+
+  private static byte[] digestPassword(
+      byte[] passwordBytes, byte[] salt, int iterations, int hashLength) {
+    MessageDigest digest = newDigest();
+    digest.update(salt);
+    digest.update(passwordBytes);
+    byte[] hash = digest.digest();
+    for (int i = 1; i < iterations; i++) {
+      hash = digest.digest(hash);
+    }
+    if (hash.length == hashLength) {
+      return hash;
+    }
+    return Arrays.copyOf(hash, hashLength);
+  }
+
+  private static MessageDigest newDigest() {
+    try {
+      return MessageDigest.getInstance(Sha3512Defaults.DIGEST_ALGORITHM);
+    } catch (NoSuchAlgorithmException e) {
+      throw new IllegalStateException("SHA3-512 is not supported by the JCA provider", e);
+    }
+  }
+
+  private static String toPhcString(byte[] salt, byte[] hash) {
+    Base64.Encoder encoder = Base64.getEncoder().withoutPadding();
+    return PHC_PREFIX
+        + "i="
+        + Sha3512Defaults.DEFAULT_ITERATIONS
+        + "$"
+        + encoder.encodeToString(salt)
+        + "$"
+        + encoder.encodeToString(hash);
+  }
+
+  private static ParsedHash parse(String hashedPassword) {
+    Preconditions.checkArgument(hashedPassword.startsWith(PHC_PREFIX), INVALID_HASH_FORMAT);
+    String[] parts = hashedPassword.split("\\$");
+    Preconditions.checkArgument(parts.length == 5, INVALID_HASH_FORMAT);
+    Preconditions.checkArgument("sha3-512".equals(parts[1]), INVALID_HASH_FORMAT);
+    Preconditions.checkArgument(parts[2].startsWith("i="), INVALID_HASH_FORMAT);
+
+    int iterations;
+    try {
+      iterations = Integer.parseInt(parts[2].substring(2));
+    } catch (NumberFormatException e) {
+      throw new IllegalArgumentException(INVALID_HASH_FORMAT);
+    }
+
+    byte[] salt = decodeBase64(parts[3], Sha3512Defaults.DEFAULT_SALT_LENGTH);
+    byte[] hash = decodeBase64(parts[4], Sha3512Defaults.DEFAULT_HASH_LENGTH);
+    Preconditions.checkArgument(
+        iterations == Sha3512Defaults.DEFAULT_ITERATIONS, UNSUPPORTED_HASH_PARAMETERS);
+    Preconditions.checkArgument(
+        salt.length == Sha3512Defaults.DEFAULT_SALT_LENGTH, INVALID_HASH_FORMAT);
+    Preconditions.checkArgument(
+        hash.length == Sha3512Defaults.DEFAULT_HASH_LENGTH, INVALID_HASH_FORMAT);
+    return new ParsedHash(iterations, salt, hash);
+  }
+
+  private static byte[] decodeBase64(String value, int maxDecodedLength) {
+    int fullGroups = maxDecodedLength / 3;
+    int decodedRemainder = maxDecodedLength % 3;
+    int maxEncodedLength = fullGroups * 4 + (decodedRemainder == 0 ? 0 : decodedRemainder + 1);
+    Preconditions.checkArgument(value.length() <= maxEncodedLength, INVALID_HASH_FORMAT);
+    int remainder = value.length() % 4;
+    Preconditions.checkArgument(remainder != 1, INVALID_HASH_FORMAT);
+    String paddedValue = remainder == 0 ? value : value + "====".substring(0, 4 - remainder);
+    try {
+      return Base64.getDecoder().decode(paddedValue);
+    } catch (IllegalArgumentException e) {
+      throw new IllegalArgumentException(INVALID_HASH_FORMAT);
+    }
+  }
+
+  private static class ParsedHash {
+    private final int iterations;
+    private final byte[] salt;
+    private final byte[] hash;
+
+    private ParsedHash(int iterations, byte[] salt, byte[] hash) {
+      this.iterations = iterations;
+      this.salt = salt;
+      this.hash = hash;
+    }
+  }
+}
diff --git a/plugins/idp-basic/src/test/java/org/apache/gravitino/idp/basic/password/TestArgon2idPasswordHasher.java b/plugins/idp-basic/src/test/java/org/apache/gravitino/idp/basic/password/TestSha3512PasswordHasher.java
similarity index 61%
rename from plugins/idp-basic/src/test/java/org/apache/gravitino/idp/basic/password/TestArgon2idPasswordHasher.java
rename to plugins/idp-basic/src/test/java/org/apache/gravitino/idp/basic/password/TestSha3512PasswordHasher.java
index f5643139bd..1475d9e677 100644
--- a/plugins/idp-basic/src/test/java/org/apache/gravitino/idp/basic/password/TestArgon2idPasswordHasher.java
+++ b/plugins/idp-basic/src/test/java/org/apache/gravitino/idp/basic/password/TestSha3512PasswordHasher.java
@@ -23,37 +23,29 @@ import java.util.Base64;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
 
-public class TestArgon2idPasswordHasher {
+public class TestSha3512PasswordHasher {
 
-  private final PasswordHasher passwordHasher = new Argon2idPasswordHasher();
+  private final PasswordHasher passwordHasher = new Sha3512PasswordHasher();
 
   @Test
-  public void testHashProducesArgon2idPhcString() {
+  public void testHashFormat() {
     String hashedPassword = passwordHasher.hash("test-password");
 
     String[] parts = hashedPassword.split("\\$");
 
-    Assertions.assertEquals(6, parts.length);
+    Assertions.assertEquals(5, parts.length);
     Assertions.assertEquals("", parts[0]);
-    Assertions.assertEquals("argon2id", parts[1]);
-    Assertions.assertEquals("v=" + Argon2idDefaults.DEFAULT_VERSION, parts[2]);
-    Assertions.assertEquals(
-        "m="
-            + Argon2idDefaults.DEFAULT_MEMORY_KB
-            + ",t="
-            + Argon2idDefaults.DEFAULT_ITERATIONS
-            + ",p="
-            + Argon2idDefaults.DEFAULT_PARALLELISM,
-        parts[3]);
-
-    byte[] salt = decodeBase64(parts[4]);
-    byte[] hash = decodeBase64(parts[5]);
-    Assertions.assertEquals(Argon2idDefaults.DEFAULT_SALT_LENGTH, salt.length);
-    Assertions.assertEquals(Argon2idDefaults.DEFAULT_HASH_LENGTH, hash.length);
+    Assertions.assertEquals("sha3-512", parts[1]);
+    Assertions.assertEquals("i=" + Sha3512Defaults.DEFAULT_ITERATIONS, parts[2]);
+
+    byte[] salt = decodeBase64(parts[3]);
+    byte[] hash = decodeBase64(parts[4]);
+    Assertions.assertEquals(Sha3512Defaults.DEFAULT_SALT_LENGTH, salt.length);
+    Assertions.assertEquals(Sha3512Defaults.DEFAULT_HASH_LENGTH, hash.length);
   }
 
   @Test
-  public void testVerifyMatchesExpectedPassword() {
+  public void testVerifyMatch() {
     String hashedPassword = passwordHasher.hash("test-password");
 
     Assertions.assertTrue(passwordHasher.verify("test-password", hashedPassword));
@@ -61,8 +53,8 @@ public class TestArgon2idPasswordHasher {
   }
 
   @Test
-  public void testFactoryCreatesArgon2idHasher() {
-    Assertions.assertTrue(PasswordHasherFactory.create() instanceof Argon2idPasswordHasher);
+  public void testFactoryCreatesHasher() {
+    Assertions.assertTrue(PasswordHasherFactory.create() instanceof Sha3512PasswordHasher);
   }
 
   @Test
@@ -97,9 +89,9 @@ public class TestArgon2idPasswordHasher {
     IllegalArgumentException exception =
         Assertions.assertThrows(
             IllegalArgumentException.class,
-            () -> passwordHasher.verify("test-password", "$argon2id$v=19$m=65536,x=3,p=1$abc$abc"));
+            () -> passwordHasher.verify("test-password", "$sha3-512$i=100000$abc"));
 
-    Assertions.assertEquals("Invalid Argon2id hash format", exception.getMessage());
+    Assertions.assertEquals("Invalid SHA3-512 hash format", exception.getMessage());
   }
 
   @Test
@@ -111,9 +103,9 @@ public class TestArgon2idPasswordHasher {
             () ->
                 passwordHasher.verify(
                     "test-password",
-                    "$argon2id$v=19$m=65536,t=3,p=1$" + oversizedBase64 + "$" + oversizedBase64));
+                    "$sha3-512$i=100000$" + oversizedBase64 + "$" + oversizedBase64));
 
-    Assertions.assertEquals("Invalid Argon2id hash format", exception.getMessage());
+    Assertions.assertEquals("Invalid SHA3-512 hash format", exception.getMessage());
   }
 
   @Test
@@ -121,44 +113,25 @@ public class TestArgon2idPasswordHasher {
     IllegalArgumentException exception =
         Assertions.assertThrows(
             IllegalArgumentException.class,
-            () -> passwordHasher.verify("test-password", "$argon2id$v=19$m=65536,t=3,p=1$a$abc"));
+            () -> passwordHasher.verify("test-password", "$sha3-512$i=100000$a$abc"));
 
-    Assertions.assertEquals("Invalid Argon2id hash format", exception.getMessage());
+    Assertions.assertEquals("Invalid SHA3-512 hash format", exception.getMessage());
   }
 
   @Test
-  public void testVerifyRejectsUnexpectedArgon2CostParameters() {
+  public void testVerifyRejectsUnexpectedIterations() {
     String hashedPassword = passwordHasher.hash("test-password");
     String unsupportedHash =
         hashedPassword.replace(
-            "m="
-                + Argon2idDefaults.DEFAULT_MEMORY_KB
-                + ",t="
-                + Argon2idDefaults.DEFAULT_ITERATIONS
-                + ",p="
-                + Argon2idDefaults.DEFAULT_PARALLELISM,
-            "m=131072,t=3,p=1");
-
-    IllegalArgumentException exception =
-        Assertions.assertThrows(
-            IllegalArgumentException.class,
-            () -> passwordHasher.verify("test-password", unsupportedHash));
-
-    Assertions.assertEquals("Unsupported Argon2id hash parameters", exception.getMessage());
-  }
-
-  @Test
-  public void testVerifyRejectsUnexpectedArgon2Version() {
-    String hashedPassword = passwordHasher.hash("test-password");
-    String unsupportedHash =
-        hashedPassword.replace("v=" + Argon2idDefaults.DEFAULT_VERSION, "v=16");
+            "i=" + Sha3512Defaults.DEFAULT_ITERATIONS,
+            "i=" + (Sha3512Defaults.DEFAULT_ITERATIONS + 1));
 
     IllegalArgumentException exception =
         Assertions.assertThrows(
             IllegalArgumentException.class,
             () -> passwordHasher.verify("test-password", unsupportedHash));
 
-    Assertions.assertEquals("Unsupported Argon2id hash parameters", exception.getMessage());
+    Assertions.assertEquals("Unsupported SHA3-512 hash parameters", exception.getMessage());
   }
 
   private static byte[] decodeBase64(String value) {