<div class="content"><p>The R_KeyExchangePhase1 method receives a pair of encrypted
client keys and returns server <a href="1243ba70-74ca-44f9-be0b-dfd6697010b4#gt_8312d817-fdc5-4a49-8894-729b7b9e0ce5" data-linktype="relative-path">encryption</a> and <a href="1243ba70-74ca-44f9-be0b-dfd6697010b4#gt_4f67a585-fb00-4166-93e8-cf4abca8226d" data-linktype="relative-path">session keys</a>.</p><dl>
<dd>
<div><pre> HRESULT R_KeyExchangePhase1(
   [unique, in] IIS_CRYPTO_BLOB* pClientKeyExchangeKeyBlob,
   [unique, in] IIS_CRYPTO_BLOB* pClientSignatureKeyBlob,
   [out] IIS_CRYPTO_BLOB** ppServerKeyExchangeKeyBlob,
   [out] IIS_CRYPTO_BLOB** ppServerSignatureKeyBlob,
   [out] IIS_CRYPTO_BLOB** ppServerSessionKeyBlob
 );
</pre></div>
</dd></dl><p><b>pClientKeyExchangeKeyBlob: </b>A pointer to an <a href="bbe15a83-a32d-48a3-9564-8dacea965e83" data-linktype="relative-path">IIS_CRYPTO_BLOB</a> structure
containing the encrypted client key used to decrypt client data.</p><p><b>pClientSignatureKeyBlob: </b>A pointer to an
IIS_CRYPTO_BLOB structure containing the encrypted client signature key used
for data verification.</p><p><b>ppServerKeyExchangeKeyBlob: </b>A pointer to a set
of IIS_CRYPTO_BLOB structures containing encrypted server keys used by the
client to decrypt server data.</p><p><b>ppServerSignatureKeyBlob: </b>A pointer to a set
of IIS_CRYPTO_BLOB structures containing encrypted server signature keys used
for data verification.</p><p><b>ppServerSessionKeyBlob: </b>A pointer to a set of
IIS_CRYPTO_BLOB structures containing encrypted server session keys.</p><p><b>Return Values: </b>A signed 32-bit value that
indicates return status. If the method returns a negative value, it failed. If
the 12-bit facility code (bits 16–27) is set to 0x007, the value contains a
Win32 error code in the lower 16 bits. Zero or positive values indicate
success, with the lower 16 bits in positive nonzero values containing warnings
or flags defined in the method implementation. For more information about Win32
error codes and <a href="../ms-dtyp/a9046ed2-bfb2-4d56-a719-2824afce59ac" data-linktype="relative-path">HRESULT</a>
values, see <a href="../ms-erref/1bc92ddf-b79e-413c-bbaa-99a5281a6c90" data-linktype="relative-path">[MS-ERREF]</a>.</p><dl>
<dd>
<table><thead>
  <tr>
   <th>
   <p>Return value/code</p>
   </th>
   <th>
   <p>Description</p>
   </th>
  </tr>
 </thead><tbody><tr>
  <td>
  <p>0x00000000</p>
  <p>S_OK</p>
  </td>
  <td>
  <p>The call was successful.</p>
  </td>
 </tr></tbody></table>
</dd></dl><p>The <a href="1243ba70-74ca-44f9-be0b-dfd6697010b4#gt_e127848e-c66d-427d-b3aa-9f904fa4ada7" data-linktype="relative-path">opnum</a>
field value for this method is 26. </p><p>When the server receives the R_KeyExchangePhase1 method, it
SHOULD check the state of the <a href="1243ba70-74ca-44f9-be0b-dfd6697010b4#gt_e58c72cc-2506-4e51-b33d-fbefe4bd6138" data-linktype="relative-path">secure
session</a>. If the session was already negotiated, the server SHOULD return
the E_INVALIDARG error code.</p><p>If the session was not negotiated yet, the server MUST
perform the following steps:</p><ol><li><p><span>    </span>Store the
client&#39;s <a href="1243ba70-74ca-44f9-be0b-dfd6697010b4#gt_3ac30f9e-dfc0-4d06-a450-49ed662b4328" data-linktype="relative-path">key exchange public
key</a> that was received in the message.</p>
</li><li><p><span>    </span>Store the
client&#39;s <a href="1243ba70-74ca-44f9-be0b-dfd6697010b4#gt_3fb3f762-0e54-4380-8af0-f2549101ff61" data-linktype="relative-path">signature public
key</a> that was received in the message.</p>
</li><li><p><span>    </span>Generate or
locate the server&#39;s key exchange private key.</p>
</li><li><p><span>    </span>Generate or
locate the server&#39;s signature private key.</p>
</li><li><p><span>    </span>Generate the
server&#39;s session key.</p>
</li><li><p><span>    </span>Encrypt the
server&#39;s session key using the client&#39;s key exchange public key that was just
received.</p>
</li><li><p><span>    </span>Calculate the <a href="1243ba70-74ca-44f9-be0b-dfd6697010b4#gt_08dd8645-e19c-410c-8081-63a12d3c3a2c" data-linktype="relative-path">signed hash</a> of the
encrypted server&#39;s session key, as described in section <a href="40f4d444-ef92-43cb-8fe2-4e017d4cbdd0" data-linktype="relative-path">3.1.4.1.4</a>. Use the
server&#39;s <a href="1243ba70-74ca-44f9-be0b-dfd6697010b4#gt_651b4855-9100-4a98-82a1-24bbf934e23a" data-linktype="relative-path">signature private
key</a> for signing.</p>
</li><li><p><span>    </span>Build an
IIS_CRYPTO_BLOB structure with the <b>BlobSignature</b> field set to SESSION_KEY_BLOB_SIGNATURE
to store the server&#39;s encrypted session key and signed hash as calculated in
the previous steps.</p>
</li><li><p><span>    </span>Build an
IIS_CRYPTO_BLOB structure with the <b>BlobSignature</b> field set to
PUBLIC_KEY_BLOB_SIGNATURE to store the server&#39;s key exchange public key.</p>
</li><li><p><span>  </span>Build an IIS_CRYPTO_BLOB
structure with the <b>BlobSignature</b> field set to PUBLIC_KEY_BLOB_SIGNATURE
to store the server&#39;s signature public key.</p>
</li><li><p><span>  </span>Send an IIS_CRYPTO_BLOB
structure that was built in the previous three steps to the client in response
to the R_KeyExchangePhase1 method.</p>
</li></ol></div>