From 45b98d8cb39230019612ddcca3abbdc574152834 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Fri, 2 Aug 2024 09:04:47 -0500 Subject: [PATCH] fix IEEE length calculations secp521r1 has length of 521 so we want 66 to cover that last extra bit - not 65 --- phpseclib/Crypt/EC/Formats/Signature/IEEE.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpseclib/Crypt/EC/Formats/Signature/IEEE.php b/phpseclib/Crypt/EC/Formats/Signature/IEEE.php index 26ff7404..6bfd9311 100644 --- a/phpseclib/Crypt/EC/Formats/Signature/IEEE.php +++ b/phpseclib/Crypt/EC/Formats/Signature/IEEE.php @@ -62,7 +62,7 @@ abstract class IEEE { $r = $r->toBytes(); $s = $s->toBytes(); - $length >>= 3; + $length = (int) ceil($length / 8); return str_pad($r, $length, "\0", STR_PAD_LEFT) . str_pad($s, $length, "\0", STR_PAD_LEFT); } }