reference/openssl/functions/openssl-pkey-new.xml
2e02eeb87167732c245530d970b79061b8aaa24a
...
...
@@ -1,6 +1,6 @@
1
1
<?xml version="1.0" encoding="utf-8"?>
2
2
<!-- $Revision$ -->
3
-
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.openssl-pkey-new">
3
+
<refentry xml:id="function.openssl-pkey-new" xmlns="http://docbook.org/ns/docbook">
4
4
<refnamediv>
5
5
<refname>openssl_pkey_new</refname>
6
6
<refpurpose>Generates a new private key </refpurpose>
...
...
@@ -9,13 +9,13 @@
9
9
<refsect1 role="description">
10
10
&reftitle.description;
11
11
<methodsynopsis>
12
-
<type>resource</type><methodname>openssl_pkey_new</methodname>
13
-
<methodparam choice="opt"><type>array</type><parameter>configargs</parameter></methodparam>
12
+
<type class="union"><type>OpenSSLAsymmetricKey</type><type>false</type></type><methodname>openssl_pkey_new</methodname>
13
+
<methodparam choice="opt"><type class="union"><type>array</type><type>null</type></type><parameter>options</parameter><initializer>&null;</initializer></methodparam>
14
14
</methodsynopsis>
15
15
<para>
16
-
<function>openssl_pkey_new</function> generates a new private and public
17
-
key pair. The public component of the key can be obtained using
18
-
<function>openssl_pkey_get_public</function>.
16
+
<function>openssl_pkey_new</function> generates a new private
17
+
key.
18
+
How to obtain the public component of the key is shown in an example below.
19
19
</para>
20
20
&note.openssl.cnf;
21
21
</refsect1>
...
...
@@ -25,13 +25,13 @@
25
25
<para>
26
26
<variablelist>
27
27
<varlistentry>
28
-
<term><parameter>configargs</parameter></term>
28
+
<term><parameter>options</parameter></term>
29
29
<listitem>
30
30
<para>
31
31
You can finetune the key generation (such as specifying the number of
32
-
bits) using <parameter>configargs</parameter>. See
32
+
bits) using <parameter>options</parameter>. See
33
33
<function>openssl_csr_new</function> for more information about
34
-
<parameter>configargs</parameter>.
34
+
<parameter>options</parameter>.
35
35
</para>
36
36
</listitem>
37
37
</varlistentry>
...
...
@@ -42,13 +42,72 @@
42
42
<refsect1 role="returnvalues">
43
43
&reftitle.returnvalues;
44
44
<para>
45
-
Returns a resource identifier for the pkey on success, or &false; on
45
+
Returns an <classname>OpenSSLAsymmetricKey</classname> instance for the pkey on success, or &false; on
46
46
error.
47
47
</para>
48
48
</refsect1>
49
49

50
-
</refentry>
50
+
<refsect1 role="changelog">
51
+
&reftitle.changelog;
52
+
<informaltable>
53
+
<tgroup cols="2">
54
+
<thead>
55
+
<row>
56
+
<entry>&Version;</entry>
57
+
<entry>&Description;</entry>
58
+
</row>
59
+
</thead>
60
+
<tbody>
61
+
<row>
62
+
<entry>8.0.0</entry>
63
+
<entry>
64
+
On success, this function returns an <classname>OpenSSLAsymmetricKey</classname> instance now;
65
+
previously, a &resource; of type <literal>OpenSSL key</literal> was returned.
66
+
</entry>
67
+
</row>
68
+
<row>
69
+
<entry>7.1.0</entry>
70
+
<entry>The <parameter>curve_name</parameter> option was added to make it possible to create EC keys.</entry>
71
+
</row>
72
+
</tbody>
73
+
</tgroup>
74
+
</informaltable>
75
+
</refsect1>
51
76

77
+
<refsect1 role="examples">
78
+
&reftitle.examples;
79
+
<example xml:id="function.openssl-pkey-new.example.public-key">
80
+
<title>Obtain the public key from a private key</title>
81
+
<programlisting role="php">
82
+
<![CDATA[
83
+
<?php
84
+
$private_key = openssl_pkey_new();
85
+
$public_key_pem = openssl_pkey_get_details($private_key)['key'];
86
+
echo $public_key_pem;
87
+
$public_key = openssl_pkey_get_public($public_key_pem);
88
+
var_dump($public_key);
89
+
?>
90
+
]]>
91
+
</programlisting>
92
+
&example.outputs.similar;
93
+
<screen>
94
+
<![CDATA[
95
+
-----BEGIN PUBLIC KEY-----
96
+
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArZFsmN2P6rx1Xt7YV95o
97
+
gcdlal0k3ryiIhFNzjwtRNNTXfEfBr6lUuaIJYQ8/XqEBX0hpcfuuF6tTRlonA3t
98
+
WLME0QFD93YVsAaXcy76YqjjqcRRodIBphAbYyyMI/lXkQAdn7kbAmr7neSOsMYJ
99
+
El9Wo4Hl4oG6e52ZnYHyqW9dxh4hX93eupR2TmcCdVf+r9xoHewP0KJYSHt7vDUX
100
+
AQlWYcQiWHIadFsmL0orr6mutlXFReoHbesgKY9/3YLOu0JfxflSjIZ2JeL1NTl1
101
+
MsmODsUwgAUrwnWKKx+eQUP5g3GnSB3dPkRh9zRVRiLNWbCugyjrf3e6DgQWrW7j
102
+
pwIDAQAB
103
+
-----END PUBLIC KEY-----
104
+
resource(5) of type (OpenSSL key)
105
+
]]>
106
+
</screen>
107
+
</example>
108
+
</refsect1>
109
+

110
+
</refentry>
52
111
<!-- Keep this comment at the end of the file
53
112
Local variables:
54
113
mode: sgml
55
114