chovy-3012 commented on issue #13377: URL: https://github.com/apache/seatunnel/issues/13377#issuecomment-7183073875
Thanks @SEZ9, @DanielLeens — replying to your two latest comments together, since the asks have converged. Summarized, they are: keep `AES_ENCRYPT` / `AES_DECRYPT` unchanged; and, before any implementation PR, close three gaps — (1) pin the one exact `bcprov-jdk18on` version with its ASF LICENSE/NOTICE and distribution changes, (2) prove the cases execute against the shaded, relocated artifact in the packaged runtime, (3) make the binary-contract proof concrete, with secret handling confirmed. Answers below — the three gap quotes are @SEZ9's phrasing, and @DanielLeens' latest comment lists the same three items. ## AES stays unchanged > @DanielLeens: "Please keep `AES_ENCRYPT` and `AES_DECRYPT` unchanged in the SM4 proposal." > > @SEZ9: "For now, please take the second option you offered: AES keeps its envelope, and the SM4 documentation states the intentional AES/SM4 difference explicitly." Understood — the SM4 proposal leaves `AES_ENCRYPT` / `AES_DECRYPT` untouched. AES keeps its Base64 `STRING` envelope; the SM4 documentation (EN and ZH) will state the intentional AES/SM4 envelope difference explicitly. A future AES migration would be its own proposal, with the incompatible-changes note, migration guidance, and independent cross-engine compatibility evidence. ## Gap 1 — version and licensing > "name the one exact `bcprov-jdk18on` version to pin (you validated 1.80, 1.85, and 1.87), and list the ASF LICENSE/NOTICE and distribution changes needed for the relocated classes." **Pinned: `bcprov-jdk18on` 1.87** — the current release and the smallest of the three I validated (7,337,657 bytes; 1.80 is 8.7 MB). Outputs were byte-identical across 1.80 / 1.85 / 1.87 on all probe vectors, so nothing relies on an older version. It is declared once in `seatunnel-transforms-v2` and relocated into the transform jar by the module's existing shade build. License / notice changes: the distribution already covers BouncyCastle through the existing kubernetes / SMB use, so the only edit is the `bcprov-jdk18on` entry in `release-docs/LICENSE` moving from 1.75 to 1.87 (one line). `release-docs/NOTICE` needs no edit — it already carries an unversioned "This product includes Bouncy Castle Provider (JDK18ON Distribution)" attribution. `release-docs/licenses/LICENSE-bcprov-jdk18on.txt` needs no edit — the 1.87 jar ships the same MIT-style Bouncy Castle Licence text. No other LICENSE/NOTICE edits; BC enters one more relocated artifact, it is not a new third-party product in the distribution. ## Gap 2 — packaged-runtime proof > "show that the published-vector, Zeta, and Calcite cases execute against the shaded and relocated artifact in the packaged runtime, not an unshaded test classpath." Confirmed by the harness itself: `TestSQLIT` / `TestCalciteIT` are Testcontainers job-level suites, and `ContainerUtil.copySeaTunnelStarterToContainer` copies `seatunnel-transforms-v2/target/seatunnel-transforms-v2.jar` — the shade-plugin output, with BC relocated under the SeaTunnel shade package — into the container's `lib/` before real jobs execute against it. Those cases therefore run the shipped, shaded, relocated artifact, not an unshaded test classpath; the SM4 cases will go through the same path, and the published known-answer vector I reproduced locally (key/plaintext `0123456789ABCDEFFEDCBA9876543210` → ciphertext `681EDF34D206965E86B3E94F536E4246`) will be one of those SQL cases. ## Gap 3 — binary contract proof > "show the same raw bytes and the same observable binary type through the Zeta dispatcher and the Calcite `byte[]` bridge, and confirm that no secrets or derived key material appear in logs, exceptions, or diagnostics." Reposting the decision here so it is visible in one place: - **The choice:** option (b) — a true `BINARY` result, not a Base64 `STRING` envelope. - **The envelope:** `SM4_ENCRYPT` returns `BYTES`; 3-arg (explicit IV) = bare ciphertext, 2-arg (no IV) = `IV ‖ ciphertext` (16-byte random IV prepended). `SM4_DECRYPT` accepts BINARY only (a Base64 STRING is an error) and returns `STRING`. - **The proof:** one `Sm4Util` registered on both engines, mirroring the existing `DES_ENCRYPT` dual registration. **Zeta:** a `ZetaUDF`; `ZetaSQLType` honors `udf.resultType(argsType)`, so the result is typed `PrimitiveByteArrayType` (`byte[]` / `BYTES`), not STRING like the AES table; `TO_BASE64(byte[])` encodes it byte-exactly for display. **Calcite:** a `CalciteUdf` with `public static byte[] eval(...)`; `BuiltinFunctions` auto-selects `BinaryAwareScalarFunction` for `byte[]` signatures, bridging `byte[]` ↔ `ByteString`, and `CalciteTypeConverter` maps `BYTES` ↔ `VARBINARY` — the bridge already running in production for the eight vector UDFs. **Parity, precisely:** same key/IV/plaintext → either engine outputs a field typed `BYTES` holding the same `byte[]`; the tests assert type and bytes on both engines, not Zeta alone. - **Secrets:** key, derived key material, plaintext, ciphertext, and IV never appear in logs, exception messages, or persisted diagnostics — errors carry metadata only. ## Test plan Published vectors plus fixed key/IV triples asserted on raw bytes; the same SQL executed through both engines, asserting the result type is `BYTES` and the raw bytes are identical; all previously listed cases retained (key forms, IV handling, NULL, malformed/tampered input, wrong key, EN/ZH docs). If these close the remaining details, I'll open the focused implementation proposal against them for review. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
