reference/openssl/functions/openssl-verify.xml
497c40ac164d5873fd87f622dfdeb5206392b446
...
...
@@ -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-verify">
3
+
<refentry xml:id="function.openssl-verify" xmlns="http://docbook.org/ns/docbook">
4
4
<refnamediv>
5
5
<refname>openssl_verify</refname>
6
6
<refpurpose>Verify signature</refpurpose>
...
...
@@ -9,17 +9,17 @@
9
9
<refsect1 role="description">
10
10
&reftitle.description;
11
11
<methodsynopsis>
12
-
<type>int</type><methodname>openssl_verify</methodname>
12
+
<type class="union"><type>int</type><type>false</type></type><methodname>openssl_verify</methodname>
13
13
<methodparam><type>string</type><parameter>data</parameter></methodparam>
14
14
<methodparam><type>string</type><parameter>signature</parameter></methodparam>
15
-
<methodparam><type>mixed</type><parameter>pub_key_id</parameter></methodparam>
16
-
<methodparam choice="opt"><type>mixed</type><parameter>signature_alg</parameter><initializer>OPENSSL_ALGO_SHA1</initializer></methodparam>
15
+
<methodparam><type class="union"><type>OpenSSLAsymmetricKey</type><type>OpenSSLCertificate</type><type>array</type><type>string</type></type><parameter>public_key</parameter></methodparam>
16
+
<methodparam choice="opt"><type class="union"><type>string</type><type>int</type></type><parameter>algorithm</parameter><initializer><constant>OPENSSL_ALGO_SHA1</constant></initializer></methodparam>
17
17
</methodsynopsis>
18
18
<para>
19
19
<function>openssl_verify</function> verifies that the
20
20
<parameter>signature</parameter> is correct for the specified
21
21
<parameter>data</parameter> using the public key associated with
22
-
<parameter>pub_key_id</parameter>. This must be the public key
22
+
<parameter>public_key</parameter>. This must be the public key
23
23
corresponding to the private key used for signing.
24
24
</para>
25
25
</refsect1>
...
...
@@ -45,19 +45,19 @@
45
45
</listitem>
46
46
</varlistentry>
47
47
<varlistentry>
48
-
<term><parameter>pub_key_id</parameter></term>
48
+
<term><parameter>public_key</parameter></term>
49
49
<listitem>
50
50
<para>
51
-
<type>resource</type> - a key, returned by <function>openssl_get_publickey</function>
51
+
<classname>OpenSSLAsymmetricKey</classname> - a key, returned by <function>openssl_get_publickey</function>
52
52
</para>
53
53
<para>
54
-
<type>string</type> - a PEM formatted key, example, "-----BEGIN PUBLIC KEY-----
55
-
MIIBCgK..."
54
+
<type>string</type> - a <acronym>PEM</acronym> formatted key (e.g. <literal>-----BEGIN PUBLIC KEY-----
55
+
MIIBCgK...</literal>)
56
56
</para>
57
57
</listitem>
58
58
</varlistentry>
59
59
<varlistentry>
60
-
<term><parameter>signature_alg</parameter></term>
60
+
<term><parameter>algorithm</parameter></term>
61
61
<listitem>
62
62
<para>
63
63
<type>int</type> - one of these <link linkend="openssl.signature-algos">Signature Algorithms</link>.
...
...
@@ -75,32 +75,33 @@ MIIBCgK..."
75
75
&reftitle.returnvalues;
76
76
<para>
77
77
Returns 1 if the signature is correct, 0 if it is incorrect, and
78
-
-1 on error.
78
+
-1 or &false; on error.
79
79
</para>
80
80
</refsect1>
81
81

82
82
<refsect1 role="changelog">
83
83
&reftitle.changelog;
84
-
<para>
85
-
<informaltable>
86
-
<tgroup cols="2">
87
-
<thead>
88
-
<row>
89
-
<entry>&Version;</entry>
90
-
<entry>&Description;</entry>
91
-
</row>
92
-
</thead>
93
-
<tbody>
94
-
<row>
95
-
<entry>5.2.0</entry>
96
-
<entry>
97
-
The <parameter>signature_alg</parameter> parameter was added.
98
-
</entry>
99
-
</row>
100
-
</tbody>
101
-
</tgroup>
102
-
</informaltable>
103
-
</para>
84
+
<informaltable>
85
+
<tgroup cols="2">
86
+
<thead>
87
+
<row>
88
+
<entry>&Version;</entry>
89
+
<entry>&Description;</entry>
90
+
</row>
91
+
</thead>
92
+
<tbody>
93
+
<row>
94
+
<entry>8.0.0</entry>
95
+
<entry>
96
+
<parameter>public_key</parameter> accepts an <classname>OpenSSLAsymmetricKey</classname>
97
+
or <classname>OpenSSLCertificate</classname> instance now;
98
+
previously, a &resource; of type <literal>OpenSSL key</literal> or <literal>OpenSSL X.509</literal>
99
+
was accepted.
100
+
</entry>
101
+
</row>
102
+
</tbody>
103
+
</tgroup>
104
+
</informaltable>
104
105
</refsect1>
105
106

106
107
<refsect1 role="examples">
...
...
@@ -148,10 +149,10 @@ $details = openssl_pkey_get_details($private_key_res);
148
149
$public_key_res = openssl_pkey_get_public($details['key']);
149
150

150
151
//create signature
151
-
openssl_sign($data, $signature, $private_key_res, "sha1WithRSAEncryption");
152
+
openssl_sign($data, $signature, $private_key_res, "sha256WithRSAEncryption");
152
153

153
154
//verify signature
154
-
$ok = openssl_verify($data, $signature, $public_key_res, OPENSSL_ALGO_SHA1);
155
+
$ok = openssl_verify($data, $signature, $public_key_res, OPENSSL_ALGO_SHA256);
155
156
if ($ok == 1) {
156
157
echo "valid";
157
158
} elseif ($ok == 0) {
...
...
@@ -176,7 +177,6 @@ if ($ok == 1) {
176
177
</refsect1>
177
178

178
179
</refentry>
179
-

180
180
<!-- Keep this comment at the end of the file
181
181
Local variables:
182
182
mode: sgml
183
183