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

Fix off-by-one in P_MAX and A_MAX #46

Merged
merged 3 commits into from
Sep 3, 2024
Merged

Fix off-by-one in P_MAX and A_MAX #46

merged 3 commits into from
Sep 3, 2024

Conversation

jedisct1
Copy link
Collaborator

@jedisct1 jedisct1 commented Sep 1, 2024

Spotted by @Yawning, thanks!

Fixes #45

@Yawning
Copy link

Yawning commented Sep 2, 2024

No problem.

The AEGIS-256 description also has the issue, so one more place to update.

- `P_MAX` (maximum length of the plaintext) is 2<sup>61</sup> bytes (2<sup>64</sup> bits).
- `A_MAX` (maximum length of the associated data) is 2<sup>61</sup> bytes (2<sup>64</sup> bits).
- `N_MIN` (minimum nonce length) = `N_MAX` (maximum nonce length) = 32 bytes (256 bits).
- `C_MAX` (maximum ciphertext length) = `P_MAX` + tag length = 2<sup>61</sup> + 16 or 32 bytes (2<sup>64</sup> + 128 or 256 bits).

Also avoid the double parenthesis.
@jedisct1
Copy link
Collaborator Author

jedisct1 commented Sep 2, 2024

/cc @samuel-lucas6

Copy link
Collaborator

@samuel-lucas6 samuel-lucas6 left a comment

Choose a reason for hiding this comment

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

Shouldn't length MUST be less than P_MAX and length MUST be less than A_MAX (in Section 3.1 and 4.1) still be changed? Otherwise, the maximum is technically 261 - 2 bytes.

If I'm right about that, length MUST be less than C_MAX and length MUST be less than A_MAX should also be changed in Section 3.2 and 4.2.

Besides that, it looks ok. I'm not super keen on the brackets inside brackets, but there's not really anything you can do.

@Yawning
Copy link

Yawning commented Sep 2, 2024

Shouldn't length MUST be less than P_MAX and length MUST be less than A_MAX (in Section 3.1 and 4.1) still be changed? Otherwise, the maximum is technically 261 - 2 bytes.

If I'm right about that, length MUST be less than C_MAX and length MUST be less than A_MAX should also be changed in Section 3.2 and 4.2.

Ah, yes. That's right.

Unrelated, thanks for the nice spec, I've been working on implementing 128L and 256, and it's been easy to do.

@jedisct1
Copy link
Collaborator Author

jedisct1 commented Sep 2, 2024

Good catch, @samuel-lucas6 !

Copy link
Collaborator

@samuel-lucas6 samuel-lucas6 left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks @Yawning!

@jedisct1 jedisct1 merged commit 55b9132 into main Sep 3, 2024
2 checks passed
@jedisct1 jedisct1 deleted the adjust_pmax_amax branch September 3, 2024 18:01
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.

spec: Off-by-one error in the definition of RFC 5116 constants
3 participants