@@ -50,13 +50,16 @@ public function setUp(): void
5050 public function testSign (): void
5151 {
5252 // test RSA-SHA1
53- $ rsa = $ this ->factory ->getAlgorithm (C::SIG_RSA_SHA1 , $ this ->privateKey );
54- $ this ->assertEquals (
55- '75780000a403f4280d361c246a1c23e650d59c8cabbe4064e1848bace35ba8931a7c397caacf8af36c10ead3bed5252109a3c12 ' .
56- 'a54b3f867950ae75ea29864babef465eabdda826d81c367583725012dfa68a1b51119425e3e6e9490c778db81b5be937ae35f4b ' .
57- '1393944b7260d4ebd3c100bf59ae42d4506c82cae6550d68b8 ' ,
58- bin2hex ($ rsa ->sign ($ this ->plaintext )),
59- );
53+ if (boolval (OPENSSL_VERSION_NUMBER >= hexdec ('0x30000000 ' )) === false ) {
54+ // OpenSSL 3.0 disabled SHA1 support
55+ $ rsa = $ this ->factory ->getAlgorithm (C::SIG_RSA_SHA1 , $ this ->privateKey );
56+ $ this ->assertEquals (
57+ '75780000a403f4280d361c246a1c23e650d59c8cabbe4064e1848bace35ba8931a7c397caacf8af36c10ead3bed5252109a3c12 ' .
58+ 'a54b3f867950ae75ea29864babef465eabdda826d81c367583725012dfa68a1b51119425e3e6e9490c778db81b5be937ae35f4b ' .
59+ '1393944b7260d4ebd3c100bf59ae42d4506c82cae6550d68b8 ' ,
60+ bin2hex ($ rsa ->sign ($ this ->plaintext )),
61+ );
62+ }
6063
6164 // test RSA-SHA224
6265 $ rsa = $ this ->factory ->getAlgorithm (C::SIG_RSA_SHA224 , $ this ->privateKey );
@@ -114,15 +117,18 @@ public function testSign(): void
114117 public function testVerify (): void
115118 {
116119 // test RSA-SHA1
117- $ rsa = $ this ->factory ->getAlgorithm (C::SIG_RSA_SHA1 , $ this ->publicKey );
118- $ this ->assertTrue ($ rsa ->verify (
119- $ this ->plaintext ,
120- hex2bin (
121- '75780000a403f4280d361c246a1c23e650d59c8cabbe4064e1848bace35ba8931a7c397caacf8af36c10ead3bed5252109a ' .
122- '3c12a54b3f867950ae75ea29864babef465eabdda826d81c367583725012dfa68a1b51119425e3e6e9490c778db81b5be93 ' .
123- '7ae35f4b1393944b7260d4ebd3c100bf59ae42d4506c82cae6550d68b8 ' ,
124- ),
125- ));
120+ if (boolval (OPENSSL_VERSION_NUMBER >= hexdec ('0x30000000 ' )) === false ) {
121+ // OpenSSL 3.0 disabled SHA1 support
122+ $ rsa = $ this ->factory ->getAlgorithm (C::SIG_RSA_SHA1 , $ this ->publicKey );
123+ $ this ->assertTrue ($ rsa ->verify (
124+ $ this ->plaintext ,
125+ hex2bin (
126+ '75780000a403f4280d361c246a1c23e650d59c8cabbe4064e1848bace35ba8931a7c397caacf8af36c10ead3bed5252109a ' .
127+ '3c12a54b3f867950ae75ea29864babef465eabdda826d81c367583725012dfa68a1b51119425e3e6e9490c778db81b5be93 ' .
128+ '7ae35f4b1393944b7260d4ebd3c100bf59ae42d4506c82cae6550d68b8 ' ,
129+ ),
130+ ));
131+ }
126132
127133 // test RSA-SHA224
128134 $ rsa = $ this ->factory ->getAlgorithm (C::SIG_RSA_SHA224 , $ this ->publicKey );
0 commit comments