kelvinmo / simplejwt

A simple JSON web token library written in PHP.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ECDH error in PHP 8.1

kelvinmo opened this issue · comments

Description

ECDH does not work in PHP 8.1

Steps to reproduce

Run phpunit under PHP 8.1

Backtrace

1) ECDH_AESKeyWrapTest::testECDHES_A128KW
Undefined array key "crv"

/home/runner/work/simplejwt/simplejwt/src/SimpleJWT/Keys/Key.php:287
/home/runner/work/simplejwt/simplejwt/src/SimpleJWT/Keys/Key.php:91
/home/runner/work/simplejwt/simplejwt/src/SimpleJWT/Keys/ECKey.php:189
/home/runner/work/simplejwt/simplejwt/src/SimpleJWT/Crypt/ECDH.php:190
/home/runner/work/simplejwt/simplejwt/src/SimpleJWT/Crypt/ECDH.php:149
/home/runner/work/simplejwt/simplejwt/src/SimpleJWT/Crypt/ECDH_AESKeyWrap.php:75
/home/runner/work/simplejwt/simplejwt/tests/ECDH_AESKeyWrapTest.php:58

2) ECDH_AESKeyWrapTest::testECDHES_A192KW
Undefined array key "crv"

/home/runner/work/simplejwt/simplejwt/src/SimpleJWT/Keys/Key.php:287
/home/runner/work/simplejwt/simplejwt/src/SimpleJWT/Keys/Key.php:91
/home/runner/work/simplejwt/simplejwt/src/SimpleJWT/Keys/ECKey.php:189
/home/runner/work/simplejwt/simplejwt/src/SimpleJWT/Crypt/ECDH.php:190
/home/runner/work/simplejwt/simplejwt/src/SimpleJWT/Crypt/ECDH.php:149
/home/runner/work/simplejwt/simplejwt/src/SimpleJWT/Crypt/ECDH_AESKeyWrap.php:75
/home/runner/work/simplejwt/simplejwt/tests/ECDH_AESKeyWrapTest.php:77

3) ECDH_AESKeyWrapTest::testECDHES_A256KW
Undefined array key "crv"

/home/runner/work/simplejwt/simplejwt/src/SimpleJWT/Keys/Key.php:287
/home/runner/work/simplejwt/simplejwt/src/SimpleJWT/Keys/Key.php:91
/home/runner/work/simplejwt/simplejwt/src/SimpleJWT/Keys/ECKey.php:189
/home/runner/work/simplejwt/simplejwt/src/SimpleJWT/Crypt/ECDH.php:190
/home/runner/work/simplejwt/simplejwt/src/SimpleJWT/Crypt/ECDH.php:149
/home/runner/work/simplejwt/simplejwt/src/SimpleJWT/Crypt/ECDH_AESKeyWrap.php:75
/home/runner/work/simplejwt/simplejwt/tests/ECDH_AESKeyWrapTest.php:95

Additional information

This is occurring because in PHP 8.1, openssl exports EC keys in PKCS#8 format instead of RFC 5915 format, and ECKey does not recognise the new format