<?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 => 'de',
  ),
  '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">Beschreibung</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="simpara">
   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">Parameter-Liste</h3>
  <dl>
   
    <dt><code class="parameter">kmsProvider</code></dt>
    <dd>
     <span class="simpara">
      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.
     </span>
    </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>
           <span class="simpara">
            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>.
           </span>
           
  <p class="para">
   <table class="doctable table">
    <caption><strong><code class="literal">&quot;aws&quot;</code>-Provider-Optionen</strong></caption>
    
     <thead>
      <tr>
       <th>Option</th>
       <th>Typ</th>
       <th>Beschreibung</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>region</td>
       <td>string</td>
       <td>Erforderlich</td>
      </tr>

      <tr>
       <td>key</td>
       <td>string</td>
       <td>Erforderlich; der Amazon-Ressourcenname (ARN) für den AWS-Kundenhauptschlüssel (CMK).</td>
      </tr>

      <tr>
       <td>endpoint</td>
       <td>string</td>
       <td>Optional; ein alternativer Host-Bezeichner, an den KMS-Anfragen gesendet werden; kann die Portnummer enthalten.</td>
      </tr>

     </tbody>
    
   </table>

  </p>
  <p class="para">
   <table class="doctable table">
    <caption><strong><code class="literal">&quot;azure&quot;</code>-Provider-Optionen</strong></caption>
    
     <thead>
      <tr>
       <th>Option</th>
       <th>Typ</th>
       <th>Beschreibung</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>keyVaultEndpoint</td>
       <td>string</td>
       <td>Erforderlich; der Host mit optionalem Port (z. B. &quot;example.vault.azure.net&quot;).</td>
      </tr>

      <tr>
       <td>keyName</td>
       <td>string</td>
       <td>Erforderlich</td>
      </tr>

      <tr>
       <td>keyVersion</td>
       <td>string</td>
       <td>Optional; eine bestimmte Version des genannten Schlüssels. Standardmäßig wird die primäre Version des Schlüssels verwendet.</td>
      </tr>

     </tbody>
    
   </table>

  </p>
  <p class="para">
   <table class="doctable table">
    <caption><strong><code class="literal">&quot;gcp&quot;</code>-Provider-Optionen</strong></caption>
    
     <thead>
      <tr>
       <th>Option</th>
       <th>Typ</th>
       <th>Beschreibung</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>projectId</td>
       <td>string</td>
       <td>Erforderlich</td>
      </tr>

      <tr>
       <td>location</td>
       <td>string</td>
       <td>Erforderlich</td>
      </tr>

      <tr>
       <td>keyRing</td>
       <td>string</td>
       <td>Erforderlich</td>
      </tr>

      <tr>
       <td>keyName</td>
       <td>string</td>
       <td>Erforderlich</td>
      </tr>

      <tr>
       <td>keyVersion</td>
       <td>string</td>
       <td>Optional; eine bestimmte Version des genannten Schlüssels. Standardmäßig wird die primäre Version des Schlüssels verwendet.</td>
      </tr>

      <tr>
       <td>endpoint</td>
       <td>string</td>
       <td>Optional; der Host mit optionalem Port. Der Standardwert ist &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>-Provider-Optionen</strong></caption>
    
     <thead>
      <tr>
       <th>Option</th>
       <th>Typ</th>
       <th>Beschreibung</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>keyId</td>
       <td>string</td>
       <td>Optional; der eindeutige Bezeichner für ein 96 Byte großes, verwaltetes geheimes KMIP-Datenobjekt. Wenn nicht angegeben, erstellt der Treiber ein zufälliges geheimes KMIP-Datenobjekt mit 96 Byte.</td>
      </tr>

      <tr>
       <td>endpoint</td>
       <td>string</td>
       <td>Optional; der Host mit optionalem Port.</td>
      </tr>

      <tr>
       <td>delegated</td>
       <td>bool</td>
       <td>Optional; wenn true, soll dieser Schlüssel vom KMIP-Server entschlüsselt werden.</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>
           <span class="simpara">
            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>.
           </span>
          </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>
           <span class="simpara">
            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.
           </span>
          </td>
         </tr>

        </tbody>
       
      </table>

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


 <div class="refsect1 returnvalues" id="refsect1-mongodb-driver-clientencryption.createdatakey-returnvalues">
  <h3 class="title">Rückgabewerte</h3>
  <p class="simpara">
   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">Fehler/Exceptions</h3>
  <ul class="simplelist">
   <li>Wirft eine <span class="classname"><a href="class.mongodb-driver-exception-invalidargumentexception.php" class="classname">MongoDB\Driver\Exception\InvalidArgumentException</a></span>, wenn beim Analysieren von Argumenten ein Fehler auftritt.</li><li>Wirft eine <span class="classname"><a href="class.mongodb-driver-exception-connectionexception.php" class="classname">MongoDB\Driver\Exception\ConnectionException</a></span>, wenn der Aufbau einer Verbindung zum Server fehlschlägt (aus einem anderen Grund als der Authentifizierung).</li><li>Wirft eine <span class="classname"><a href="class.mongodb-driver-exception-authenticationexception.php" class="classname">MongoDB\Driver\Exception\AuthenticationException</a></span>, wenn eine Authentifizierung erforderlich ist und fehlschlägt.</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">Changelog</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Version</th>
      <th>Beschreibung</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>

 </div>


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