note 129166 added to function.openssl-verify

From: Date: Tue, 16 Jan 2024 14:14:35 +0000
Subject: note 129166 added to function.openssl-verify
Groups: php.notes 
Request: Send a blank email to php-notes+get-221120@lists.php.net to get a copy of this message
The RSA-PSS and ECDSA key pairs generated through the JavaScript Web Crypto API can successfully implement data signature and verification, but if the public keys are exported and sent to PHP, PHP cannot be successfully verified through openssl_verify(), does PHP still not support RSA-PSS and ECDSA signature verification? In addition, openssl does not support padding other than PKCS V1.5, why does it still not support these secure encryption, decryption, signing, and verification schemes? ----- JavaScript ----- var data = new TextEncoder().encode('test string'); Sign the data with var key = await crypto.subtle.generateKey({ name: 'ECDSA', namedCurve: 'P-256' }, false, ['sign', 'verify']); var signature = await crypto.subtle.sign({ name: 'ECDSA', hash: 'SHA-256' }, key.privateKey, data); OR var key = await crypto.subtle.generateKey({ name: 'RSA-PSS', modulusLength: 2048, publicExponent: new Uint8Array([1, 0, 1]), hash: 'SHA-256' }, true, ['sign', 'verify']); var signature = await crypto.subtle.sign({ name: 'RSA-PSS', saltLength: 32 }, key.privateKey, data); ----- PHP ----- $public = '-----BEGIN PUBLIC KEY-----' . PHP_EOL . chunk_split( base64_encode( $_POST['public'], 64, PHP_EOL ) . '-----END PUBLIC KEY-----'; $public = openssl_pkey_get_public( $public ); $verify = openssl_verify( $_POST['data'], $_POST['signature'], $public, OPENSSL_ALGO_SHA256 ); // always -1 or 0 or false ---- Server IP: 45.112.84.4 Probable Submitter: 45.91.157.134 (proxied: 171.213.50.226) ---- Manual Page -- https://php.net/manual/en/function.openssl-verify.php Edit -- https://main.php.net/note/edit/129166 Del: integrated -- https://main.php.net/note/delete/129166/integrated Del: useless -- https://main.php.net/note/delete/129166/useless Del: bad code -- https://main.php.net/note/delete/129166/bad+code Del: spam -- https://main.php.net/note/delete/129166/spam Del: non-english -- https://main.php.net/note/delete/129166/non-english Del: in docs -- https://main.php.net/note/delete/129166/in+docs Del: other reasons-- https://main.php.net/note/delete/129166 Reject -- https://main.php.net/note/reject/129166 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#221120) next »