From e17409a3e39baf7c8ed9635c04130802463b117b Mon Sep 17 00:00:00 2001 From: terrafrost Date: Sat, 24 Feb 2024 08:42:27 -0600 Subject: [PATCH] Tests: add unit test for EC pub key with excessively large integer --- tests/Unit/File/X509/X509Test.php | 12 ++++++++++++ tests/Unit/File/X509/mal-cert-01.der | Bin 0 -> 3249 bytes 2 files changed, 12 insertions(+) create mode 100644 tests/Unit/File/X509/mal-cert-01.der diff --git a/tests/Unit/File/X509/X509Test.php b/tests/Unit/File/X509/X509Test.php index df46f277..05c3be28 100644 --- a/tests/Unit/File/X509/X509Test.php +++ b/tests/Unit/File/X509/X509Test.php @@ -1392,4 +1392,16 @@ JYhGgW6KsKViE0hzQB8dSAcNcfwQPSKzOd02crXdJ7uYvZZK9prN83Oe1iDaizeA $this->assertFalse($x509->validateURL('https://aa')); } + + public function testLargeInteger() + { + // cert has an elliptic curve public key with a specified curve (vs a named curve) with + // an excessively large integer value + $cert = file_get_contents(__DIR__ . '/mal-cert-01.der'); + + $x509 = new X509(); + $x509->loadX509($cert); + $this->expectException(\RuntimeException::class); + $x509->getPublicKey(); + } } diff --git a/tests/Unit/File/X509/mal-cert-01.der b/tests/Unit/File/X509/mal-cert-01.der new file mode 100644 index 0000000000000000000000000000000000000000..3219ccd49feeeb0d7b70b7a68bc72c1945fa07d3 GIT binary patch literal 3249 zcmXqL;#q6Z#1p)LnTe5!Nmza7@#|Lt6HD}dJbK2}a`#ShmYV?=8;4e#$2nUTW+np> zLm>kJHs(+kW*$yoM;|x;AYWG(137VCBV$8DBTEAdQ)3g$C?MAa$Tfy?ap-E|?l5TL zPGDmPo6f`tIm_g%w2FtqbJeyt&aa!mqR3RaFRkw9o!x6f7bHzR z*Urt(H2cqO-E$f@BR@4pi~SIv!KBE577G7%t-JGVy~hIU{g>i;E|@tw0^8HfN({_g zZpS9QnV5Ir#!eH3h7~+5&y~Yn@0v>Zt8n~H`4DL7xH#A#&_EX0u9xLw5n~ZaGZ+4| zLv&KZ|5v}yKI9g^zwt*CyMa7NTA4+{K&%0~0)CJJVMfOPEUX61Knl6z!0f?b;L4;R z_~%G~iQWDhkB?<``rhTj%*>kuk2FVna8_?kTq`tp63|C8Cft77k`Qt8{kd-?)lUxQ Wb9}sUs`%o@#-m1uo^ZE4-vj`MX*|yW literal 0 HcmV?d00001