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

crypto/cipher: ExampleNewGCM_encrypt should use NonceSize to generate nonce. #48372

Open
najeira opened this issue Sep 14, 2021 · 1 comment · May be fixed by #48373
Open

crypto/cipher: ExampleNewGCM_encrypt should use NonceSize to generate nonce. #48372

najeira opened this issue Sep 14, 2021 · 1 comment · May be fixed by #48373
Labels
Documentation NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@najeira
Copy link

najeira commented Sep 14, 2021

ExampleNewGCM_encrypt should use AEAD.NonceSize to generate nonce.

Current:

nonce := make([]byte, 12)

12 is hard-coded to make nonce buffer.

Better:

nonce := make([]byte, aesgcm.NonceSize())

Use AEAD.NonceSize. AEAD has NonceSize that returns the size of the nonce.

najeira added a commit to najeira/go that referenced this issue Sep 14, 2021
…he example

The existing example uses hard-coded constant to make nonce buffer.
Using AEAD.NonceSize makes it a more portable and appropriate example.

Fixes: golang#48372
@gopherbot
Copy link
Contributor

Change https://golang.org/cl/349603 mentions this issue: crypto/cipher: use AEAD.NonceSize to make nonce in the example

@seankhliao seankhliao added the NeedsFix The path to resolution is known, but the work has not been done. label Sep 15, 2021
@seankhliao seankhliao added this to the Unplanned milestone Aug 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants