xref: /PHP-8.1/ext/openssl/tests/bug66501.phpt (revision 03a4ccd9)
1--TEST--
2Bug #66501: EC private key support in openssl_sign
3--EXTENSIONS--
4openssl
5--SKIPIF--
6<?php
7if (!defined('OPENSSL_KEYTYPE_EC')) die("skip no EC available");
8?>
9--FILE--
10<?php
11$pkey = 'ASN1 OID: prime256v1
12-----BEGIN EC PARAMETERS-----
13BggqhkjOPQMBBw==
14-----END EC PARAMETERS-----
15-----BEGIN EC PRIVATE KEY-----
16MHcCAQEEILPkqoeyM7XgwYkuSj3077lrsrfWJK5LqMolv+m2oOjZoAoGCCqGSM49
17AwEHoUQDQgAEPq4hbIWHvB51rdWr8ejrjWo4qVNWVugYFtPg/xLQw0mHkIPZ4DvK
18sqOTOnMoezkbSmVVMuwz9flvnqHGmQvmug==
19-----END EC PRIVATE KEY-----';
20$key = openssl_pkey_get_private($pkey);
21$res = openssl_sign($data ='alpha', $sign, $key, 'SHA256');
22var_dump($res);
23?>
24--EXPECT--
25bool(true)
26