1--TEST--
2openssl_spki_new() test for creating SPKI string
3--EXTENSIONS--
4openssl
5--FILE--
6<?php
7
8/* array of private key sizes to test */
9$key_sizes = array(1024, 2048, 4096);
10$pkeys = array();
11foreach ($key_sizes as $key_size) {
12    $key_file = "file://" . __DIR__ . "/private_rsa_" . $key_size . ".key";
13    $pkeys[] = openssl_pkey_get_private($key_file);
14}
15
16
17/* array of available hashings to test */
18$algo = array(
19    OPENSSL_ALGO_SHA224,
20    OPENSSL_ALGO_SHA256,
21    OPENSSL_ALGO_SHA384,
22    OPENSSL_ALGO_SHA512,
23);
24
25/* loop over key sizes for test */
26foreach ($pkeys as $pkey) {
27
28    /* loop to create and verify results */
29    foreach ($algo as $value) {
30        var_dump(openssl_spki_new($pkey, _uuid(), $value));
31    }
32}
33
34/* generate a random challenge */
35function _uuid() {
36    return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', mt_rand(0, 0xffff),
37        mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0x0fff) | 0x4000,
38        mt_rand(0, 0x3fff) | 0x8000, mt_rand(0, 0xffff),
39        mt_rand(0, 0xffff), mt_rand(0, 0xffff));
40}
41
42?>
43--EXPECTF--
44string(478) "%s"
45string(478) "%s"
46string(478) "%s"
47string(478) "%s"
48string(830) "%s"
49string(830) "%s"
50string(830) "%s"
51string(830) "%s"
52string(1510) "%s"
53string(1510) "%s"
54string(1510) "%s"
55string(1510) "%s"
56