<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.mongodb-driver-clientencryption.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'uk',
  ),
  'this' => 
  array (
    0 => 'mongodb-driver-clientencryption.createdatakey.php',
    1 => 'MongoDB\\Driver\\ClientEncryption::createDataKey',
    2 => 'Creates a key document',
  ),
  'up' => 
  array (
    0 => 'class.mongodb-driver-clientencryption.php',
    1 => 'MongoDB\\Driver\\ClientEncryption',
  ),
  'prev' => 
  array (
    0 => 'mongodb-driver-clientencryption.construct.php',
    1 => 'MongoDB\\Driver\\ClientEncryption::__construct',
  ),
  'next' => 
  array (
    0 => 'mongodb-driver-clientencryption.decrypt.php',
    1 => 'MongoDB\\Driver\\ClientEncryption::decrypt',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/mongodb/mongodb/driver/clientencryption/createdatakey.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="mongodb-driver-clientencryption.createdatakey" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">MongoDB\Driver\ClientEncryption::createDataKey</h1>
  <p class="verinfo">(mongodb &gt;=1.7.0)</p><p class="refpurpose"><span class="refname">MongoDB\Driver\ClientEncryption::createDataKey</span> &mdash; <span class="dc-title">Creates a key document</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-mongodb-driver-clientencryption.createdatakey-description">
  <h3 class="title">Опис</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">final</span> <span class="modifier">public</span> <span class="methodname"><strong>MongoDB\Driver\ClientEncryption::createDataKey</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$kmsProvider</code></span>, <span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.array.php" class="type array">array</a></span></span> <code class="parameter">$options</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>): <span class="type"><a href="class.mongodb-bson-binary.php" class="type MongoDB\BSON\Binary">MongoDB\BSON\Binary</a></span></div>

  <p class="para rdfs-comment">
   Creates a new key document and inserts it into the key vault collection.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-mongodb-driver-clientencryption.createdatakey-parameters">
  <h3 class="title">Параметри</h3>
  <dl>
   
    <dt><code class="parameter">kmsProvider</code></dt>
    <dd>
     <p class="para">
      The KMS provider (e.g. <code class="literal">&quot;local&quot;</code>,
      <code class="literal">&quot;aws&quot;</code>) that will be used to encrypt the new data key.
     </p>
    </dd>
   

   
    <dt><code class="parameter">options</code></dt>
    <dd>
     <p class="para">
      <table class="doctable table">
       <caption><strong>Data key options</strong></caption>
       
        <thead>
         <tr>
          <th>Option</th>
          <th>Type</th>
          <th>Description</th>
         </tr>

        </thead>

        <tbody class="tbody">
         <tr>
          <td>masterKey</td>
          <td><span class="type"><a href="language.types.array.php" class="type array">array</a></span></td>
          <td>
           <p class="para">
            The masterKey document identifies a KMS-specific key used to encrypt
            the new data key. This option is required unless
            <code class="parameter">kmsProvider</code> is <code class="literal">&quot;local&quot;</code>.
           </p>
           
  <p class="para">
   <table class="doctable table">
    <caption><strong>Налаштування провейдера <code class="literal">&quot;aws&quot;</code></strong></caption>
    
     <thead>
      <tr>
       <th>Назва</th>
       <th>Тип</th>
       <th>Опис</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>region</td>
       <td>string</td>
       <td>Обов&#039;язковий.</td>
      </tr>

      <tr>
       <td>key</td>
       <td>string</td>
       <td>Обов&#039;язковий. Amazon Resource Name (ARN) для AWS customer
       master key (CMK).</td>
      </tr>

      <tr>
       <td>endpoint</td>
       <td>string</td>
       <td>Необов&#039;язковий. Додатковий ідентифікатор хоста для надсилання
       запитів KMS. Може містити номер порту.</td>
      </tr>

     </tbody>
    
   </table>

  </p>
  <p class="para">
   <table class="doctable table">
    <caption><strong>Налаштування провейдера <code class="literal">&quot;azure&quot;</code></strong></caption>
    
     <thead>
      <tr>
       <th>Назва</th>
       <th>Тип</th>
       <th>Опис</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>keyVaultEndpoint</td>
       <td>string</td>
       <td>Обов&#039;язковий. Хост (може бути з портом) (напр.
       &quot;example.vault.azure.net&quot;).</td>
      </tr>

      <tr>
       <td>keyName</td>
       <td>string</td>
       <td>Обов&#039;язковий.</td>
      </tr>

      <tr>
       <td>keyVersion</td>
       <td>string</td>
       <td>Необов&#039;язковий. Певна версія названого ключа. Стандартно
       вказується версія головного ключа.</td>
      </tr>

     </tbody>
    
   </table>

  </p>
  <p class="para">
   <table class="doctable table">
    <caption><strong>Налаштування провейдера <code class="literal">&quot;gcp&quot;</code></strong></caption>
    
     <thead>
      <tr>
       <th>Назва</th>
       <th>Тип</th>
       <th>Опис</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>projectId</td>
       <td>string</td>
       <td>Обов&#039;язковий.</td>
      </tr>

      <tr>
       <td>location</td>
       <td>string</td>
       <td>Обов&#039;язковий.</td>
      </tr>

      <tr>
       <td>keyRing</td>
       <td>string</td>
       <td>Обов&#039;язковий.</td>
      </tr>

      <tr>
       <td>keyName</td>
       <td>string</td>
       <td>Обов&#039;язковий.</td>
      </tr>

      <tr>
       <td>keyVersion</td>
       <td>string</td>
       <td>Необов&#039;язковий. Певна версія названого ключа. Стандартно
       вказується версія головного ключа.</td>
      </tr>

      <tr>
       <td>endpoint</td>
       <td>string</td>
       <td>Необов&#039;язковий. Хост (може бути з портом) (напр.
       &quot;cloudkms.googleapis.com&quot;).</td>
      </tr>

     </tbody>
    
   </table>

  </p>
  <p class="para">
   <table class="doctable table">
    <caption><strong>Налаштування провейдера <code class="literal">&quot;kmip&quot;</code></strong></caption>
    
     <thead>
      <tr>
       <th>Назва</th>
       <th>Тип</th>
       <th>Опис</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>keyId</td>
       <td>string</td>
       <td>Необов&#039;язковий. Унікальний ідентифікатор для 96-байтного
       об&#039;єкта керування секретними даними KMIP. Якщо не вказано,
       об&#039;єкт генерується випадковим чином.</td>
      </tr>

      <tr>
       <td>endpoint</td>
       <td>string</td>
       <td>Необов&#039;язковий. Хост (може бути з портом).</td>
      </tr>

     </tbody>
    
   </table>

  </p>

          </td>
         </tr>

         <tr>
          <td>keyAltNames</td>
          <td><span class="type"><a href="language.types.array.php" class="type array">array</a></span></td>
          <td>
           <p class="para">
            An optional list of string alternate names used to reference a key.
            If a key is created with alternate names, then encryption may refer
            to the key by the unique alternate name instead of by
            <code class="literal">_id</code>.
           </p>
          </td>
         </tr>

         <tr>
          <td>keyMaterial</td>
          <td><span class="classname"><a href="class.mongodb-bson-binary.php" class="classname">MongoDB\BSON\Binary</a></span></td>
          <td>
           <p class="para">
            An optional 96-byte value to use as custom key material for the data
            key being created. If keyMaterial is given, the custom key material
            is used for encrypting and decrypting data. Otherwise, the key
            material for the new data key is generated from a cryptographically
            secure random device.
           </p>
          </td>
         </tr>

        </tbody>
       
      </table>

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


 <div class="refsect1 returnvalues" id="refsect1-mongodb-driver-clientencryption.createdatakey-returnvalues">
  <h3 class="title">Значення, що повертаються</h3>
  <p class="para">
   Returns the identifier of the new key as a
   <span class="classname"><a href="class.mongodb-bson-binary.php" class="classname">MongoDB\BSON\Binary</a></span> object with subtype 4 (UUID).
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-mongodb-driver-clientencryption.createdatakey-errors">
  <h3 class="title">Помилки/виключення</h3>
  <ul class="simplelist">
   <li>У разі помилки обробки параметрів
викидається
<span class="classname"><a href="class.mongodb-driver-exception-invalidargumentexception.php" class="classname">MongoDB\Driver\Exception\InvalidArgumentException</a></span>.</li><li>Якщо не вдається з’єднатися з
сервером (з інших причин, ніж автентифікація), то викидається
<span class="classname"><a href="class.mongodb-driver-exception-connectionexception.php" class="classname">MongoDB\Driver\Exception\ConnectionException</a></span>.</li><li>Якщо обов'язкова
автентифікація провалена, то викидається
<span class="classname"><a href="class.mongodb-driver-exception-authenticationexception.php" class="classname">MongoDB\Driver\Exception\AuthenticationException</a></span>.</li>
   <li>Throws <span class="classname"><a href="class.mongodb-driver-exception-runtimeexception.php" class="classname">MongoDB\Driver\Exception\RuntimeException</a></span> on other errors.</li>
  </ul>
 </div>


 <div class="refsect1 changelog" id="refsect1-mongodb-driver-clientencryption.createdatakey-changelog">
  <h3 class="title">Журнал змін</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Версія</th>
       <th>Опис</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>PECL mongodb 1.20.0</td>
       <td>
        Added <code class="literal">&quot;delegated&quot;</code> to the KMIP provider masterKey options.
       </td>
      </tr>

      <tr>
       <td>PECL mongodb 1.15.0</td>
       <td>
        Added the <code class="literal">&quot;keyMaterial&quot;</code> option.
       </td>
      </tr>

      <tr>
       <td>PECL mongodb 1.10.0</td>
       <td>
        Azure and GCP are now supported as KMS providers for client-side
        encryption.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


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