mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 01:51:03 +09:00
LibCrypto: Adjust DER length encoding to follow the spec
It says to always use the smallest possible length representation
This commit is contained in:
parent
2e142105c9
commit
1be411cc73
Notes:
sideshowbarker
2024-07-17 09:56:35 +09:00
Author: https://github.com/stelar7
Commit: 1be411cc73
Pull-request: https://github.com/SerenityOS/serenity/pull/23674
Issue: https://github.com/SerenityOS/serenity/issues/23657
Reviewed-by: https://github.com/ADKaster ✅
1 changed files with 2 additions and 1 deletions
|
@ -262,7 +262,8 @@ ErrorOr<void> Encoder::write_length(size_t value)
|
|||
if (value < 0x80)
|
||||
return write_byte(value);
|
||||
|
||||
size_t size = ceil_div(AK::ceil_log2(value), 3ul);
|
||||
size_t size_in_bits = AK::ceil_log2(value);
|
||||
size_t size = ceil_div(size_in_bits, 8ul);
|
||||
TRY(write_byte(0x80 | size));
|
||||
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue