<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.rnp.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'en',
  ),
  'this' => 
  array (
    0 => 'function.rnp-op-generate-key.php',
    1 => 'rnp_op_generate_key',
    2 => 'Generate key',
  ),
  'up' => 
  array (
    0 => 'ref.rnp.php',
    1 => 'Rnp Functions',
  ),
  'prev' => 
  array (
    0 => 'function.rnp-op-encrypt.php',
    1 => 'rnp_op_encrypt',
  ),
  'next' => 
  array (
    0 => 'function.rnp-op-sign.php',
    1 => 'rnp_op_sign',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/rnp/functions/rnp-op-generate-key.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.rnp-op-generate-key" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">rnp_op_generate_key</h1>
  <p class="verinfo">(PECL rnp &gt;= 0.1.1)</p><p class="refpurpose"><span class="refname">rnp_op_generate_key</span> &mdash; <span class="dc-title">Generate key</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.rnp-op-generate-key-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>rnp_op_generate_key</strong></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="class.rnpffi.php" class="type RnpFFI">RnpFFI</a></span> <code class="parameter">$ffi</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$userid</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$key_alg</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$sub_alg</code><span class="initializer"> = ?</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.array.php" class="type array">array</a></span> <code class="parameter">$options</code><span class="initializer"> = ?</span></span><br>): <span class="type"><span class="type"><a href="language.types.string.php" class="type string">string</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></span></div>

  <p class="simpara">

  </p>


 </div>


 <div class="refsect1 parameters" id="refsect1-function.rnp-op-generate-key-parameters">
  <h3 class="title">Parameters</h3>
  <dl>
   
    <dt><code class="parameter">ffi</code></dt>
    <dd>
     <span class="simpara">
      The FFI object returned by <span class="function"><a href="function.rnp-ffi-create.php" class="function">rnp_ffi_create()</a></span>.
     </span>
    </dd>
   
   
    <dt><code class="parameter">userid</code></dt>
    <dd>
     <span class="simpara">
      PGP User ID - text that is intended to represent
      the name and email address of the key holder.
     </span>
    </dd>
   
   
    <dt><code class="parameter">key_alg</code></dt>
    <dd>
     <span class="simpara">
      Primary key algorithm (i.e. &#039;RSA&#039;, &#039;DSA&#039;, etc).
     </span>
    </dd>
   
   
    <dt><code class="parameter">sub_alg</code></dt>
    <dd>
     <span class="simpara">
      Subkey algorithm. If not set, subkey will not be generated.
     </span>
    </dd>
   
   
    <dt><code class="parameter">options</code></dt>
    <dd>
     <span class="simpara">
      An associative array with options.
     </span>
     <table class="doctable informaltable">
      
       <thead>
        <tr>
         <th>Key</th>
         <th>Data type</th>
         <th>Description</th>
        </tr>

       </thead>

       <tbody class="tbody">
        <tr>
         <td><code class="literal">&quot;bits&quot;</code></td>
         <td>integer</td>
         <td>Primary key size in bits. Applicable only to RSA, DSA and El-Gamal keys.</td>
        </tr>

        <tr>
         <td><code class="literal">&quot;hash&quot;</code></td>
         <td>string</td>
         <td>Hash algorithm used in self signature or subkey binding signature.</td>
        </tr>

        <tr>
         <td><code class="literal">&quot;dsa_qbits&quot;</code></td>
         <td>integer</td>
         <td>Set size of a <code class="literal">q</code> parameter for DSA key.
          Note: appropriate default value will be set, depending on key bits. However you may
          override it if needed.</td>
        </tr>

        <tr>
         <td><code class="literal">&quot;curve&quot;</code></td>
         <td>string</td>
         <td>Set the curve used for ECC key. Note: this is only applicable for ECDSA, ECDH and SM2 keys.</td>
        </tr>

        <tr>
         <td><code class="literal">&quot;request_password&quot;</code></td>
         <td>boolean</td>
         <td>Enable requesting password via password provider. This password
          will be used for key encryption. Password provider callback function should be set in
	  advance by calling <span class="function"><a href="function.rnp-ffi-set-pass-provider.php" class="function">rnp_ffi_set_pass_provider()</a></span>.
          Note: this setting will be ignored if password was set via<code class="literal">&quot;password&quot;</code></td>
        </tr>

        <tr>
         <td><code class="literal">&quot;password&quot;</code></td>
         <td>string</td>
         <td>Set the password used to encrypt the secret key data.</td>
        </tr>

        <tr>
         <td><code class="literal">&quot;expiration&quot;</code></td>
         <td>integer</td>
         <td>Set the key and subkey expiration time in seconds.</td>
        </tr>

        <tr>
         <td><code class="literal">&quot;sub_bits&quot;</code></td>
         <td>integer</td>
         <td>Subkey size in bits. Applicable only to RSA, DSA and El-Gamal keys.</td>
        </tr>

        <tr>
         <td><code class="literal">&quot;sub_hash&quot;</code></td>
         <td>string</td>
         <td>Hash algorithm used in subkey self signature or subkey binding signature.</td>
        </tr>

        <tr>
         <td><code class="literal">&quot;sub_curve&quot;</code></td>
         <td>string</td>
         <td>Set the curve used for ECC subkey. Note: this is only applicable for ECDSA, ECDH and SM2 keys.</td>
        </tr>

       </tbody>
      
     </table>

    </dd>
   
  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.rnp-op-generate-key-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="simpara">
   Fingerprint of the generated primary key or <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> on failure. This fingerprint can be used
   later to reference the key in sign and encrypt operations. The key data is stored in FFI
   memory context and can be saved using
   <span class="function"><a href="function.rnp-save-keys.php" class="function">rnp_save_keys()</a></span> or <span class="function"><a href="function.rnp-save-keys-to-path.php" class="function">rnp_save_keys_to_path()</a></span>.
  </p>
 </div>



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