Skip to content

Conversation

@juergw
Copy link
Collaborator

@juergw juergw commented Nov 26, 2024

Each of the three subclasses needs a slightly different implementation of these methods. So it's better to have the implementation here.

@prbprbprb
Copy link
Contributor

Awesome, thanks!

LGTM but I'll take another look with fresh eyes in the morning.

Copy link
Contributor

@prbprbprb prbprbprb left a comment

Choose a reason for hiding this comment

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

I think we're lacking some tests around zero length inputs but overall LGTM apart from one untested branch noted below.


final int bytesWritten;
if (inputLen > 0) {
bytesWritten = updateInternal(input, inputOffset, inputLen, output, outputOffset,
Copy link
Contributor

Choose a reason for hiding this comment

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

No tests seem to hit this branch, could you add one, please.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done. The Cipher interface has many similar methods, and depending on how exactly it is called, a different method of the implementation is executed. I've now changed the tests of Cipher so that it tries a range of different call patterns. I think this should give a better coverage.

}

/** Concatenates the given arrays into a single array.*/
byte[] concatArrays(byte[]... arrays) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: We already have ArrayUtils.concat for the two array case. Maybe move this method into ArrayUtils for the other cases (it's fairly small).

byte[] concatArrays(byte[]... arrays) {
int length = 0;
for (byte[] array : arrays) {
if (array == null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe throw on null? But you can certainly skip zero length arrays.

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually don't worry about fixing the nits :)

@prbprbprb prbprbprb merged commit 842feb0 into google:master Dec 9, 2024
37 checks passed
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