-
Notifications
You must be signed in to change notification settings - Fork 2
Add aes-gcm mode to contain the message authentication in network module #7
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
Conversation
sgkim126
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't matter if you add a new mode but replacing the current mode to another does.
|
@sgkim126 AES-GCM-SIV has been designed to preserve both privacy and integrity, even if nonces are repeated. You can confirm this content here: aes-gcm-siv@0.3.0 and AES-GCM-SIV:Informational. And I 'added' the aes-gcm mode, not replace. : ) With @HoOngEe, Could you review this PR? |
The network module is using the block cipher mode `aes-256-cbc`. However, it does not contain message authentication. Then, I added `aes-gcm-siv` mode, which is an authenticated message encryption method. I used the aes-gcm-siv crate to implement the aes-gcm-siv mode. AES-GCM-SIV has been designed to preserve both privacy and integrity, even if nonces are repeated.
| let aead = Aes256GcmSiv::new(generic_key); | ||
|
|
||
| let temp_nonce = &nonce.to_be_bytes(); | ||
| let nonce = GenericArray::from_slice(&temp_nonce[0..12]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you explain why do you take only 12 bytes from the nonce?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you will use only 12 bytes, IMHO, you should change the type of a nonce parameter as [u8: 12]. Discarding information inside a function may make the user misuse.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, nonce reuse is not recommended in AES-GCM-SIV so we should not use a fixed nonce anymore.
|
CodeChain is using I proposed to apply I investigated examples related to the network or p2p protocol using Therefore, since there is no immediate way to add new modes or change protocols, I close this PR. Getting rid of the attack possibility and using AEAD is meaningful, so if a new way to apply AEAD is devised, then it will continue from there. |
The network module is using the block cipher mode
aes-256-cbc.However, it does not contain message authentication.
Then, I added
aes-gcmmode, which is an authenticated message encryption method.I used the aes-gcm-siv crate to implement the aes-gcm mode. AES-GCM-SIV has been designed
to preserve both privacy and integrity, even if nonces are repeated.
And I added directory
/targetto.gitignore.Fixed #5