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

Add byte[] overloads for all String ctors #13

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

altr-benjamin
Copy link

Add constructors that accept byte[] values for key and tweak. In the event a user is working with byte[] cryptographic primitives, this allows them to avoid the unnecessary overhead of converting to/from Strings to initialize the cipher.

This does not contain any breaking changes w.r.t. the FF3Cipher class interface.

Add constructors that accept byte[] values for key and tweak. In the event a user is working with byte[] cryptographic primitives, this allows them to avoid the unnecessary overhead of converting to/from Strings to initialize the cipher.

This does not contain any breaking changes w.r.t. the FF3Cipher class interface.
@bschoening
Copy link
Member

@altr-benjamin this looks terrific, thanks. Could you add a simple unit test testFF3_2() for it exercise the new constructors.

@bschoening bschoening self-requested a review November 7, 2024 02:45
@bschoening bschoening self-assigned this Nov 7, 2024
@altr-benjamin
Copy link
Author

@altr-benjamin this looks terrific, thanks. Could you add a simple unit test testFF3_2() for it exercise the new constructors.

Hi @bschoening, I extended the testCreate test method to include all 6 constructors with the same assertion (not null after create). Is that what you're looking for?

@bschoening
Copy link
Member

bschoening commented Nov 7, 2024

@altr-benjamin it's a good idea to have those constructors called, but I'd also like to add an encrypt/decrypt test with the bytes[] constructor and asserts for expected ciphertext and decrypted plaintext.

So, adding another new test similar to testFF3_1, but let's call it testFF3_1_bytes or something

@Test
public void testFF3_1() throws Exception {
    // Test with 56 bit tweak
    String[] testVector = TestVectors[0];
    FF3Cipher c = new FF3Cipher(testVector[Tkey], "D8E7920AFA330A", Integer.parseInt(testVector[Tradix]));
    String pt = testVector[Tplaintext], ct = "477064185124354662";
    String ciphertext = c.encrypt(pt);
    String plaintext = c.decrypt(ciphertext);
    assertEquals(ct, ciphertext);
    assertEquals(pt, plaintext);
}

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