<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.openssl.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'zh',
  ),
  'this' => 
  array (
    0 => 'function.openssl-pkey-get-details.php',
    1 => 'openssl_pkey_get_details',
    2 => '返回包含密钥详情的数组',
  ),
  'up' => 
  array (
    0 => 'ref.openssl.php',
    1 => 'OpenSSL 函数',
  ),
  'prev' => 
  array (
    0 => 'function.openssl-pkey-free.php',
    1 => 'openssl_pkey_free',
  ),
  'next' => 
  array (
    0 => 'function.openssl-pkey-get-private.php',
    1 => 'openssl_pkey_get_private',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'zh',
    'path' => 'reference/openssl/functions/openssl-pkey-get-details.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.openssl-pkey-get-details" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">openssl_pkey_get_details</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.2.0, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">openssl_pkey_get_details</span> &mdash; <span class="dc-title">返回包含密钥详情的数组</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.openssl-pkey-get-details-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>openssl_pkey_get_details</strong></span>(<span class="methodparam"><span class="type"><a href="class.opensslasymmetrickey.php" class="type OpenSSLAsymmetricKey">OpenSSLAsymmetricKey</a></span> <code class="parameter">$key</code></span>): <span class="type"><span class="type"><a href="language.types.array.php" class="type array">array</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></span></div>

  <p class="para rdfs-comment">
   该函数返回密钥详情（位长度，密钥，类型）。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.openssl-pkey-get-details-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">key</code></dt>
     <dd>
      <p class="para">
      持有密钥的资源。
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.openssl-pkey-get-details-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回包含密钥详情的数组，失败时返回 <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>。
   返回的数组中包含了如下索引： <code class="literal">bits</code> (位数)、
   <code class="literal">key</code>（表示公钥的字符串）和
   <code class="literal">type</code>（如下密钥类型之一：
   <strong><code><a href="openssl.key-types.php#constant.openssl-keytype-rsa">OPENSSL_KEYTYPE_RSA</a></code></strong>、<strong><code><a href="openssl.key-types.php#constant.openssl-keytype-dsa">OPENSSL_KEYTYPE_DSA</a></code></strong>、<strong><code><a href="openssl.key-types.php#constant.openssl-keytype-dh">OPENSSL_KEYTYPE_DH</a></code></strong>、<strong><code><a href="openssl.key-types.php#constant.openssl-keytype-ec">OPENSSL_KEYTYPE_EC</a></code></strong>、<strong><code><a href="openssl.key-types.php#constant.openssl-keytype-x25519">OPENSSL_KEYTYPE_X25519</a></code></strong>、<strong><code><a href="openssl.key-types.php#constant.openssl-keytype-ed25519">OPENSSL_KEYTYPE_ED25519</a></code></strong>、<strong><code><a href="openssl.key-types.php#constant.openssl-keytype-x448">OPENSSL_KEYTYPE_X448</a></code></strong>、<strong><code><a href="openssl.key-types.php#constant.openssl-keytype-ed448">OPENSSL_KEYTYPE_ED448</a></code></strong>
   或者是 <code class="literal">-1</code>，代表未知类型）。
  </p>
  <p class="para">
   根据使用的密钥类型，可能会返回不同的额外信息。请注意，有些元素可能并不总是可用的。
  </p>
  <ul class="itemizedlist">
   <li class="listitem">
    <span class="simpara">
     <strong><code><a href="openssl.key-types.php#constant.openssl-keytype-rsa">OPENSSL_KEYTYPE_RSA</a></code></strong>，一个额外的键名为 <code class="literal">&quot;rsa&quot;</code> 的数组，包含了以下密钥数据：
    </span>
     <table class="doctable informaltable">
      
       <thead>
        <tr>
         <th>Key</th>
         <th>说明</th>
        </tr>

       </thead>

       <tbody class="tbody">
        <tr>
         <td><code class="literal">&quot;n&quot;</code></td>
         <td>modulus</td>
        </tr>

        <tr>
         <td><code class="literal">&quot;e&quot;</code></td>
         <td>public exponent</td>
        </tr>

        <tr>
         <td><code class="literal">&quot;d&quot;</code></td>
         <td>private exponent</td>
        </tr>

        <tr>
         <td><code class="literal">&quot;p&quot;</code></td>
         <td>prime 1</td>
        </tr>

        <tr>
         <td><code class="literal">&quot;q&quot;</code></td>
         <td>prime 2</td>
        </tr>

        <tr>
         <td><code class="literal">&quot;dmp1&quot;</code></td>
         <td>exponent1, d mod (p-1)</td>
        </tr>

        <tr>
         <td><code class="literal">&quot;dmq1&quot;</code></td>
         <td>exponent2, d mod (q-1)</td>
        </tr>

        <tr>
         <td><code class="literal">&quot;iqmp&quot;</code></td>
         <td>coefficient, (inverse of q) mod p</td>
        </tr>

       </tbody>
      
     </table>

   </li>
   <li class="listitem">
    <span class="simpara">
     <strong><code><a href="openssl.key-types.php#constant.openssl-keytype-dsa">OPENSSL_KEYTYPE_DSA</a></code></strong>, 一个额外的键为 <code class="literal">&quot;dsa&quot;</code> 的数组， 
     包含如下的密钥数据。
    </span>
     <table class="doctable informaltable">
      
       <thead>
        <tr>
         <th>Key</th>
         <th>说明</th>
        </tr>

       </thead>

       <tbody class="tbody">
        <tr>
         <td><code class="literal">&quot;p&quot;</code></td>
         <td>prime number (public)</td>
        </tr>

        <tr>
         <td><code class="literal">&quot;q&quot;</code></td>
         <td>160-bit subprime, q | p-1 (public)</td>
        </tr>

        <tr>
         <td><code class="literal">&quot;g&quot;</code></td>
         <td>generator of subgroup (public)</td>
        </tr>

        <tr>
         <td><code class="literal">&quot;priv_key&quot;</code></td>
         <td>private key x</td>
        </tr>

        <tr>
         <td><code class="literal">&quot;pub_key&quot;</code></td>
         <td>public key y = g^x</td>
        </tr>

       </tbody>
      
     </table>

   </li>
   <li class="listitem">
    <span class="simpara">
     <strong><code><a href="openssl.key-types.php#constant.openssl-keytype-dh">OPENSSL_KEYTYPE_DH</a></code></strong>, 一个额外的键为 <code class="literal">&quot;dh&quot;</code> 的数组，包含如下的密钥数据。
    </span>
     <table class="doctable informaltable">
      
       <thead>
        <tr>
         <th>Key</th>
         <th>说明</th>
        </tr>

       </thead>

       <tbody class="tbody">
        <tr>
         <td><code class="literal">&quot;p&quot;</code></td>
         <td>prime number (shared)</td>
        </tr>

        <tr>
         <td><code class="literal">&quot;g&quot;</code></td>
         <td>generator of Z_p (shared)</td>
        </tr>

        <tr>
         <td><code class="literal">&quot;priv_key&quot;</code></td>
         <td>private DH value x</td>
        </tr>

        <tr>
         <td><code class="literal">&quot;pub_key&quot;</code></td>
         <td>public DH value g^x</td>
        </tr>

       </tbody>
      
     </table>

   </li>
   <li class="listitem">
    <span class="simpara">
     <strong><code><a href="openssl.key-types.php#constant.openssl-keytype-x25519">OPENSSL_KEYTYPE_X25519</a></code></strong>、<strong><code><a href="openssl.key-types.php#constant.openssl-keytype-ed25519">OPENSSL_KEYTYPE_ED25519</a></code></strong>、<strong><code><a href="openssl.key-types.php#constant.openssl-keytype-x448">OPENSSL_KEYTYPE_X448</a></code></strong>,
     或 <strong><code><a href="openssl.key-types.php#constant.openssl-keytype-ed448">OPENSSL_KEYTYPE_ED448</a></code></strong>，分别返回名为 <code class="literal">&quot;x25519&quot;</code>、<code class="literal">&quot;ed25519&quot;</code>、<code class="literal">&quot;x448&quot;</code>
     或 <code class="literal">&quot;ed448&quot;</code> 的附加数组 key，其中包含密钥数据。
    </span>
     <table class="doctable informaltable">
      
       <thead>
        <tr>
         <th>Key</th>
         <th>说明</th>
        </tr>

       </thead>

       <tbody class="tbody">
        <tr>
         <td><code class="literal">&quot;priv_key&quot;</code></td>
         <td>私钥</td>
        </tr>

        <tr>
         <td><code class="literal">&quot;pub_key&quot;</code></td>
         <td>公钥</td>
        </tr>

       </tbody>
      
     </table>

   </li>
  </ul>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.openssl-pkey-get-details-changelog">
  <h3 class="title">更新日志</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>版本</th>
      <th>说明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.4.0</td>
      <td>
       新增对基于 Curve25519 和 Curve448 的密钥支持。特别是引入了
       <code class="literal">x25519</code>、<code class="literal">ed25519</code>、<code class="literal">x448</code>
       和 <code class="literal">ed448</code> 字段。
      </td>
     </tr>

     <tr>
      <td>8.0.0</td>
      <td>
       现在参数 <code class="parameter">key</code> 接受 <span class="classname"><a href="class.opensslasymmetrickey.php" class="classname">OpenSSLAsymmetricKey</a></span>；
       在此之前，接受 <code class="literal">OpenSSL key</code> 类型的 <span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span>。
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


</div><?php manual_footer($setup); ?>