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

[QUESTION] ZeroBytePadding with Zero-Ending Input? #1871

Closed
onacit opened this issue Oct 19, 2024 · 1 comment
Closed

[QUESTION] ZeroBytePadding with Zero-Ending Input? #1871

onacit opened this issue Oct 19, 2024 · 1 comment
Labels
question Further information is requested

Comments

@onacit
Copy link

onacit commented Oct 19, 2024

It seems that the ZeroBytePadding detects the end with 0.

    @MethodSource({"getArgumentsStream"})
    @ParameterizedTest
    void __one(final BufferedBlockCipher cipher, final CipherParameters params) throws Exception {
        // ------------------------------------------------------------------------------------------------------- plain
//        final var plain = _RandomTestUtils.newRandomBytes(1);
        final var plain = new byte[]{0};
        // ----------------------------------------------------------------------------------------------------- encrypt
        cipher.init(true, params);
        final var encrypted = JinahyaBufferedBlockCipherUtils.processBytesAndDoFinal(cipher, plain);
        // ----------------------------------------------------------------------------------------------------- decrypt
        cipher.init(false, params);
        final var decrypted = JinahyaBufferedBlockCipherUtils.processBytesAndDoFinal(cipher, encrypted);
        // -------------------------------------------------------------------------------------------------------------
        _LogUtils.log(plain, encrypted, decrypted);
        assertThat(decrypted).isEqualTo(plain);
}
    plain:          1, AA==
encrypted:         16, PQFUtQ/fA78CrDl95CTWdQ==
decrypted:          0, 

Is the padding is a general-purpose one?

@dghgit
Copy link
Contributor

dghgit commented Oct 19, 2024

Nope, only added under duress, for backwards compatibility. Don't use it in anything new. Ever.

@onacit onacit closed this as completed Oct 21, 2024
@winfriedgerlach winfriedgerlach added the question Further information is requested label Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants