-
Notifications
You must be signed in to change notification settings - Fork 207
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
How do i get AAD and IV in AES 128 GCM? #26
Comments
here is my AES 128 GCM decrypt
i dont know why this is doesnt working. |
Hi Kevin! The use of GCM in TLS is explained much better on my TLS 1.3 site, https://tls13.xargs.org. That site goes into detail on what is used for IV and AAD, though the exact AAD will probably be different for TLS 1.2 since the record wrappers are different. My memory is that the IV will be incremented by (xor'd with) with the record sequence number (starting at zero) to create a new IV for each record. The AAD will generally be all the un-encrypted bytes in the record, though I'd have to check for TLS 1.2 specifically. If you are using a GCM cipher, changing the IV and providing AAD must be performed for each packet encryption/decryption, it is fundamental to the security of GCM. The security guarantees of GCM can disappear if an IV is used twice (therefore it is always modified, for every encryption/decryption), and AAD is also a required input to the GCM algorithm. I've just checked the TLS 1.2 RFC, here is the spec for AAD:
where
Since you are most likely not using a compression method I can't be sure of the correctness of other data in your sample code, but try calling Good luck! |
(I've made a few edits to the above, not sure if they are sent to you, be sure to refresh the page just in case) |
Can you give an example of how to get the IV? I'm still dont understand... 😅 |
Pre-Master key: 5c05e8e6a6ca22fa3afcd832a0cda61afde780b3b26929e07c825ea1a500d16a105af67228db9c091405c41b2c782c77 Client MAC key: d966c90c69eadfeae377667c305e61c2873f7443 So, i must take the first byte of Client write IV, and sequence number IV: Sorry if my grammar is bad 🙏 |
My understanding is that the IV is 4 bytes generated as
|
That sounds right, you'll also need to supply the matching AAD or the encrypt/decrypt operations will fail. The design of an AEAD cipher mode like GCM is that it takes constant time whether successful or failing, and that it can give no indication of which input is incorrect (be it the IV, the key, or the AAD). |
(still reading your questions):
actually, since you are using a cipher that only wants 4 bytes of IV from this source, it would be a mistake to use this many bytes for each. I believe in this case the client write IV would be This would be combined with an additional 8 bytes of IV that are sent in the record. Hmm, since GCM requires that an IV is never repeated with the same encryption key, I wonder if this means the same 8 bytes of IV data will be sent each time? That sounds right. Then the record number will keep incrementing the IV by 1 each time. EDIT: I just re-read the spec and I think you'll see the the explicit IV, given in each record, already has the number incremented. So you'll probably see something like this: record 0:
record 1:
record 2:
... etc. I haven't looked deeply at TLS1.2+GCM so haven't seen this yet. |
Hmmmmm... This GCM Encryption Makes my head hurt, hahahaha 😂 |
so, |
It doesn't have to be, the spec just says it can't be repeated in two different records. I think the easiest method to do this, and probably what most implementations do, is to just put the sequence number in the IV, yes. |
ohhh... btw do you have Discord? so that we can chat about TLS on discord? if you dont want to chat on the Discord, its okay. |
and btw, im sorry if i disturb your time 🙏 |
okay, after i read https://www.rfc-editor.org/rfc/rfc5246#section-6.2.3.3 (section-6.2.3.3) and https://www.rfc-editor.org/rfc/rfc5288.html the nonce (IV) it generated from Client/Server write IV (4 bytes) and Sequence Number (8 bytes) how do i get authentication tag (auth tag)? is the auth tag is from the last 16 bytes from encrypted data? example:
so the, auth tag is sorry if my grammar is bad 🙏 |
hmmmm... already try like same in the RFC
its still doesnt work |
Oops, wrong button 🤦 |
Hello, how do i get AAD and IV in AES 128 GCM?
Cipher: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (0xc02f)
in AES 128 CBC (TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA (0xc013)), the IV is on the Client handshake finished
Example like in your website
the IV is:
40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f
and no need to use AAD
but how about AES 128 GCM?
Sorry if my grammar is bad, Thanks.
The text was updated successfully, but these errors were encountered: