mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-09 09:34:57 +09:00
LibCrypto: Accept correct IV sizes for AES-GCM
AES-GCM should accept 96-bits keys as is. Any other key should be preprocessed with GHASH.
This commit is contained in:
parent
3167d4f06b
commit
1ae28324bd
Notes:
github-actions[bot]
2024-12-16 12:28:59 +00:00
Author: https://github.com/devgianlu
Commit: 1ae28324bd
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2935
Reviewed-by: https://github.com/alimpfard
Reviewed-by: https://github.com/gmta ✅
3 changed files with 51 additions and 37 deletions
|
@ -154,13 +154,10 @@ void TLSv12::update_packet(ByteBuffer& packet)
|
|||
// AEAD IV (12)
|
||||
// IV (4)
|
||||
// (Nonce) (8)
|
||||
// -- Our GCM impl takes 16 bytes
|
||||
// zero (4)
|
||||
u8 iv[16];
|
||||
Bytes iv_bytes { iv, 16 };
|
||||
u8 iv[12];
|
||||
Bytes iv_bytes { iv, 12 };
|
||||
Bytes { m_context.crypto.local_aead_iv, 4 }.copy_to(iv_bytes);
|
||||
fill_with_random(iv_bytes.slice(4, 8));
|
||||
memset(iv_bytes.offset(12), 0, 4);
|
||||
|
||||
// write the random part of the iv out
|
||||
iv_bytes.slice(4, 8).copy_to(ct.bytes().slice(header_size));
|
||||
|
@ -400,13 +397,10 @@ ssize_t TLSv12::handle_message(ReadonlyBytes buffer)
|
|||
// AEAD IV (12)
|
||||
// IV (4)
|
||||
// (Nonce) (8)
|
||||
// -- Our GCM impl takes 16 bytes
|
||||
// zero (4)
|
||||
u8 iv[16];
|
||||
Bytes iv_bytes { iv, 16 };
|
||||
u8 iv[12];
|
||||
Bytes iv_bytes { iv, 12 };
|
||||
Bytes { m_context.crypto.remote_aead_iv, 4 }.copy_to(iv_bytes);
|
||||
nonce.copy_to(iv_bytes.slice(4));
|
||||
memset(iv_bytes.offset(12), 0, 4);
|
||||
|
||||
auto ciphertext = payload.slice(0, payload.size() - 16);
|
||||
auto tag = payload.slice(ciphertext.size());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue